Freeciv-3.3
Loading...
Searching...
No Matches
citydlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
25/* utility */
26#include "bitvector.h"
27#include "fcintl.h"
28#include "log.h"
29#include "mem.h"
30#include "shared.h"
31#include "support.h"
32
33/* common */
34#include "city.h"
35#include "game.h"
36#include "map.h"
37#include "movement.h"
38#include "packets.h"
39#include "player.h"
40#include "unitlist.h"
41
42/* client */
43#include "chatline_common.h"
44#include "client_main.h"
45#include "colors.h"
46#include "control.h"
47#include "climap.h"
48#include "options.h"
49#include "text.h"
50#include "tilespec.h"
51
52/* client/agents */
53#include "cma_fec.h"
54
55/* client/gui-gtk-4.0 */
56#include "choice_dialog.h"
57#include "citizensinfo.h"
58#include "cityrep.h"
59#include "cma_fe.h"
60#include "dialogs.h"
61#include "graphics.h"
62#include "gui_main.h"
63#include "gui_stuff.h"
64#include "happiness.h"
65#include "helpdlg.h"
66#include "inputdlg.h"
67#include "mapview.h"
68#include "update_queue.h"
69#include "wldlg.h"
70
71#include "citydlg.h"
72
73#define CITYMAP_WIDTH MIN(512, canvas_width)
74#define CITYMAP_HEIGHT (CITYMAP_WIDTH * canvas_height / canvas_width)
75#define CITYMAP_SCALE ((double)CITYMAP_WIDTH / (double)canvas_width)
76
77#define TINYSCREEN_MAX_HEIGHT (500 - 1)
78
79/* Only CDLGR_UNITS button currently uses these, others have
80 * direct callback. */
82
83struct city_dialog;
84
85/* Get 'struct dialog_list' and related function */
86#define SPECLIST_TAG dialog
87#define SPECLIST_TYPE struct city_dialog
88#include "speclist.h"
89
90#define dialog_list_iterate(dialoglist, pdialog) \
91 TYPED_LIST_ITERATE(struct city_dialog, dialoglist, pdialog)
92#define dialog_list_iterate_end LIST_ITERATE_END
93
94struct unit_node {
97 int height;
101};
102
103/* Get 'struct unit_node' and related function */
104#define SPECVEC_TAG unit_node
105#define SPECVEC_TYPE struct unit_node
106#include "specvec.h"
107
108#define unit_node_vector_iterate(list, elt) \
109 TYPED_VECTOR_ITERATE(struct unit_node, list, elt)
110#define unit_node_vector_iterate_end VECTOR_ITERATE_END
111
112#define NUM_CITIZENS_SHOWN 30
113
116 NUM_PAGES /* The number of pages in city dialog notebook
117 * must match the entries in misc_whichtab_label[] */
119
120enum {
125 NUM_INFO_FIELDS /* Number of fields in city_info panel
126 * must match entries in output_label[] */
128
129/* Minimal size for the city map scrolling windows */
130#define CITY_MAP_MIN_SIZE_X 200
131#define CITY_MAP_MIN_SIZE_Y 150
132
133struct city_map_canvas {
134 GtkWidget *sw;
136};
137
138struct city_dialog {
139 struct city *pcity;
140
145
149
150 struct {
152
153 GtkWidget *production_bar;
154 GtkWidget *production_combo;
155 GtkWidget *buy_command;
156 GtkWidget *improvement_list;
157
158 GtkWidget *supported_units_frame;
159 GtkWidget *supported_unit_table;
160
161 GtkWidget *present_units_frame;
162 GtkWidget *present_unit_table;
163
164 struct unit_node_vector supported_units;
165 struct unit_node_vector present_units;
166
168
169 GtkListStore *change_production_store;
171
172 struct {
173 GtkWidget *production_label;
174 GtkWidget *production_bar;
175 GtkWidget *buy_command;
178
179 struct {
181
186
187 struct cma_dialog *cma_editor;
188
189 struct {
190 GtkWidget *rename_command;
191 GtkWidget *new_citizens_radio[3];
192 GtkWidget *disband_on_settler;
193 GtkWidget *whichtab_radio[NUM_PAGES];
194 short block_signal;
196
200
204
206
207 int cwidth;
208};
209
215
217
218static struct
219{
220 struct city *owner;
221 struct tile *loc;
223
224static bool low_citydlg;
225
226/****************************************/
227
228static void initialize_city_dialogs(void);
229static void city_dialog_map_create(struct city_dialog *pdialog,
232
233static struct city_dialog *get_city_dialog(struct city *pcity);
237 GdkModifierType state,
238 gpointer data);
239
240static GtkWidget *create_city_info_table(struct city_dialog *pdialog,
242static void create_and_append_overview_page(struct city_dialog *pdialog);
243static void create_and_append_map_page(struct city_dialog *pdialog);
244static void create_and_append_buildings_page(struct city_dialog *pdialog);
245static void create_and_append_worklist_page(struct city_dialog *pdialog);
246static void create_and_append_happiness_page(struct city_dialog *pdialog);
247static void create_and_append_cma_page(struct city_dialog *pdialog);
248static void create_and_append_settings_page(struct city_dialog *pdialog);
249
250static struct city_dialog *create_city_dialog(struct city *pcity);
251
252static void city_dialog_update_title(struct city_dialog *pdialog);
253static void city_dialog_update_citizens(struct city_dialog *pdialog);
255 struct city_dialog *pdialog);
256static void city_dialog_update_map(struct city_dialog *pdialog);
257static void city_dialog_update_building(struct city_dialog *pdialog);
259 *pdialog);
261 *pdialog);
262static void city_dialog_update_present_units(struct city_dialog *pdialog);
263static void city_dialog_update_prev_next(void);
264
265static void show_units_response(void *data);
266
268 double x, double y, gpointer data);
270 double x, double y, gpointer data);
272 double x, double y, gpointer data);
274 double x, double y, gpointer data);
276 double x, double y, gpointer data);
277
278static void close_citydlg_unit_popover(struct city_dialog *pdialog);
279
280static void unit_center_callback(GSimpleAction *action, GVariant *parameter,
281 gpointer data);
282static void unit_activate_callback(GSimpleAction *action, GVariant *parameter,
283 gpointer data);
285 GVariant *parameter,
286 gpointer data);
288 GVariant *parameter,
289 gpointer data);
290static void unit_load_callback(GSimpleAction *action, GVariant *parameter,
291 gpointer data);
292static void unit_unload_callback(GSimpleAction *action, GVariant *parameter,
293 gpointer data);
294static void unit_sentry_callback(GSimpleAction *action, GVariant *parameter,
295 gpointer data);
296static void unit_fortify_callback(GSimpleAction *action, GVariant *parameter,
297 gpointer data);
298static void unit_disband_callback(GSimpleAction *action, GVariant *parameter,
299 gpointer data);
300static void unit_homecity_callback(GSimpleAction *action, GVariant *parameter,
301 gpointer data);
302static void unit_upgrade_callback(GSimpleAction *action, GVariant *parameter,
303 gpointer data);
305 double x, double y, gpointer data);
307 double x, double y, gpointer data);
309 double x, double y, gpointer data);
310static void draw_map_canvas(struct city_dialog *pdialog);
311
312static void buy_callback(GtkWidget * w, gpointer data);
313static void change_production_callback(GtkComboBox *combo,
314 struct city_dialog *pdialog);
315
316static void sell_callback(struct impr_type *pimprove, gpointer data);
317static void sell_callback_response(GtkWidget *w, gint response, gpointer data);
318
319static void impr_callback(GtkTreeView *view, GtkTreePath *path,
321
322static void rename_callback(GtkWidget * w, gpointer data);
323static void rename_popup_callback(gpointer data, gint response,
324 const char *input);
325static void set_cityopt_values(struct city_dialog *pdialog);
326static void cityopt_callback(GtkWidget * w, gpointer data);
327static void misc_whichtab_callback(GtkWidget * w, gpointer data);
328
329static void city_destroy_callback(GtkWidget *w, gpointer data);
330static void close_city_dialog(struct city_dialog *pdialog);
331static void citydlg_response_callback(GtkDialog *dlg, gint response,
332 void *data);
333static void close_callback(GtkWidget *w, gpointer data);
334static void switch_city_callback(GtkWidget *w, gpointer data);
335
336/***********************************************************************/
345
346/***********************************************************************/
349static void initialize_city_dialogs(void)
350{
351 int height;
352
354
358
359 /* Use default layout when height cannot be determined
360 * (when height == 0) */
361 if (height > 0 && height <= TINYSCREEN_MAX_HEIGHT) {
363 } else {
365 }
366
368}
369
370/***********************************************************************/
374{
376 return;
377 }
378
380
382 /* There's no reasonable way to resize a GtkImage, so we don't try.
383 Instead we just redraw the overview within the existing area.
384 The player has to close and reopen the dialog to fix this. */
385 city_dialog_update_map(pdialog);
387
389}
390
391/***********************************************************************/
395static struct city_dialog *get_city_dialog(struct city *pcity)
396{
399 }
400
402 if (pdialog->pcity == pcity) {
403 return pdialog;
404 }
406
407 return NULL;
408}
409
410/***********************************************************************/
414 int width, int height, gpointer data)
415{
416 struct city_dialog *pdialog = data;
417
420 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
421 cairo_paint_with_alpha(cr, 0.5);
422 } else {
423 cairo_paint(cr);
424 }
425}
426
427/***********************************************************************/
430static void city_dialog_map_create(struct city_dialog *pdialog,
432{
433 GtkWidget *sw, *darea;
436
445
446 darea = gtk_drawing_area_new();
449 canvas_draw_cb, pdialog, NULL);
450
452 g_signal_connect(controller, "pressed",
458 g_signal_connect(controller, "pressed",
462
463 /* save all widgets for the city map */
464 cmap_canvas->sw = sw;
465 cmap_canvas->darea = darea;
466}
467
468/***********************************************************************/
492
493/***********************************************************************/
497{
498 struct city_dialog *pdialog = get_city_dialog(pcity);
499
500 log_debug("CITYMAP_WIDTH: %d", CITYMAP_WIDTH);
501 log_debug("CITYMAP_HEIGHT: %d", CITYMAP_HEIGHT);
502 log_debug("CITYMAP_SCALE: %.3f", CITYMAP_SCALE);
503
507 }
508
509 if (!pdialog) {
510 return;
511 }
512
516 city_dialog_update_map(pdialog);
521
524
526
527 if (!low_citydlg) {
529 }
533 }
534
535 if (!client_is_observer()) {
537 }
538
542 } else {
543 /* Set the buttons we do not want live while a Diplomat investigates */
545 }
546}
547
548/***********************************************************************/
553{
554 struct city *pcity_sup, *pcity_pre;
555 struct city_dialog *pdialog;
556
559
560 if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
562 }
563
564 if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
566 }
567}
568
569/***********************************************************************/
573{
574 struct city_dialog *pdialog;
575
576 if (!(pdialog = get_city_dialog(pcity))) {
577 pdialog = create_city_dialog(pcity);
578 }
579
581
582 /* center the city map(s); this must be *after* the city dialog was drawn
583 * else the size information is missing! */
585 if (pdialog->happiness.map_canvas.sw) {
587 }
588}
589
590/***********************************************************************/
594{
595 return get_city_dialog(pcity) != NULL;
596}
597
598/***********************************************************************/
602{
603 struct city_dialog *pdialog = get_city_dialog(pcity);
604
605 if (pdialog) {
606 close_city_dialog(pdialog);
607 }
608}
609
610/***********************************************************************/
626
627/***********************************************************************/
633 GdkModifierType state,
634 gpointer data)
635{
636 struct city_dialog *pdialog = (struct city_dialog *)data;
637
638 if (state & GDK_CONTROL_MASK) {
639 switch (keyval) {
640 case GDK_KEY_Left:
642 return TRUE;
643
644 case GDK_KEY_Right:
646 return TRUE;
647
648 default:
649 break;
650 }
651 }
652
653 return FALSE;
654}
655
656/***********************************************************************/
660 double x, double y, gpointer data)
661{
663 struct city_dialog *pdialog = g_object_get_data(G_OBJECT(w), "pdialog");
664 GtkWidget *p, *label;
665 char buf[1024];
666
667 switch (GPOINTER_TO_UINT(data)) {
668 case INFO_SIZE:
669 fc_snprintf(buf, sizeof(buf), _("Population: %d, Specialists: %d"),
670 pdialog->pcity->size, city_specialists(pdialog->pcity));
671 break;
672 case INFO_FOOD:
673 get_city_dialog_output_text(pdialog->pcity, O_FOOD, buf, sizeof(buf));
674 break;
675 case INFO_SHIELD:
677 buf, sizeof(buf));
678 break;
679 case INFO_TRADE:
680 get_city_dialog_output_text(pdialog->pcity, O_TRADE, buf, sizeof(buf));
681 break;
682 case INFO_GOLD:
683 get_city_dialog_output_text(pdialog->pcity, O_GOLD, buf, sizeof(buf));
684 break;
685 case INFO_SCIENCE:
687 buf, sizeof(buf));
688 break;
689 case INFO_LUXURY:
691 buf, sizeof(buf));
692 break;
693 case INFO_CULTURE:
694 get_city_dialog_culture_text(pdialog->pcity, buf, sizeof(buf));
695 break;
696 case INFO_POLLUTION:
697 get_city_dialog_pollution_text(pdialog->pcity, buf, sizeof(buf));
698 break;
699 case INFO_ILLNESS:
700 get_city_dialog_illness_text(pdialog->pcity, buf, sizeof(buf));
701 break;
702 case INFO_AIRLIFT:
703 get_city_dialog_airlift_text(pdialog->pcity, buf, sizeof(buf));
704 break;
705 default:
706 return TRUE;
707 }
708
709 p = gtk_popover_new();
710
712
713 label = gtk_label_new(buf);
714 gtk_widget_set_name(label, "city_label");
719
721
723
724 return TRUE;
725}
726
727/***********************************************************************/
733{
734 int i;
735 GtkWidget *table, *label;
736
737 static const char *output_label[NUM_INFO_FIELDS] = {
738 N_("Size:"),
739 N_("Food:"),
740 N_("Prod:"),
741 N_("Trade:"),
742 N_("Gold:"),
743 N_("Luxury:"),
744 N_("Science:"),
745 N_("Granary:"),
746 N_("Change in:"),
747 N_("Corruption:"),
748 N_("Waste:"),
749 N_("Culture:"),
750 N_("Pollution:"),
751 N_("Plague risk:"),
752 N_("Tech Stolen:"),
753 N_("Airlift:"),
754 };
755 static bool output_label_done;
757
763
765
766 for (i = 0; i < NUM_INFO_FIELDS; i++) {
767 label = gtk_label_new(output_label[i]);
768 switch (i) {
769 case INFO_SIZE:
770 case INFO_TRADE:
771 case INFO_SCIENCE:
772 case INFO_GROWTH:
774 break;
775
776 case INFO_FOOD:
777 case INFO_GOLD:
778 case INFO_GRANARY:
779 case INFO_CORRUPTION:
781 break;
782 default:
783 break;
784 }
786 gtk_widget_set_name(label, "city_label"); /* For font style? */
789 gtk_grid_attach(GTK_GRID(table), label, 0, i, 1, 1);
790
791 label = gtk_label_new("");
792 switch (i) {
793 case INFO_TRADE:
794 case INFO_SCIENCE:
795 case INFO_GROWTH:
797 break;
798
799 case INFO_GOLD:
800 case INFO_GRANARY:
801 case INFO_CORRUPTION:
803 break;
804 default:
805 break;
806 }
807
808 g_object_set_data(G_OBJECT(label), "pdialog", pdialog);
809
811 g_signal_connect(controller, "pressed",
814
815 info_label[i] = label;
816 gtk_widget_set_name(label, "city_label"); /* Ditto */
819
820 gtk_grid_attach(GTK_GRID(table), label, 1, i, 1, 1);
821 }
822
823 /*
824 * Allow special highlighting of emergencies for granary etc by
825 * city_dialog_update_information().
826 */
827 {
828 /* This will persist, and can be shared between overview and happiness
829 * pages. */
831
832 if (emergency_provider == NULL) {
834
836 ".emergency {\n"
837 " color: rgba(255, 0.0, 0.0, 255);\n"
838 "}",
839 -1);
840
845 }
846 }
847
849
850 return table;
851}
852
853/***********************************************************************/
858static void create_citydlg_main_map(struct city_dialog *pdialog,
859 GtkWidget *grid, int col, int row)
860{
861 GtkWidget *frame;
862
863 frame = gtk_frame_new(_("City map"));
866 gtk_grid_attach(GTK_GRID(grid), frame, col, row, 1, 1);
867
868 city_dialog_map_create(pdialog, &pdialog->overview.map_canvas);
870}
871
872/***********************************************************************/
876{
878 GtkListStore *store;
880
881 /* improvements */
882 /* gtk list store columns: 0 - sell value, 1 - sprite,
883 2 - description, 3 - upkeep, 4 - is redundant, 5 - tooltip */
887
891 g_object_unref(store);
893 gtk_widget_set_name(view, "small_font");
894 pdialog->overview.improvement_list = view;
895
898 rend, "pixbuf", 1, NULL);
901 rend, "text", 2,
902 "strikethrough", 4, NULL);
904 g_object_set(rend, "xalign", 1.0, NULL);
906 rend, "text", 3,
907 "strikethrough", 4, NULL);
908
910
912 pdialog);
913
914 return view;
915}
916
917/***********************************************************************/
934{
936 GtkWidget *right, *frame, *table;
937 GtkWidget *label, *sw, *view, *bar, *production_combo;
940 /* TRANS: Overview tab in city dialog */
941 const char *tab_title = _("_Overview");
943 int page_row = 0;
944
945 /* Main page */
946 page = gtk_grid_new();
955
956 if (!low_citydlg) {
957 GtkWidget *middle;
958 GtkWidget *vbox;
960 int middle_col = 0;
961
962 /* Middle: city map, improvements */
963 middle = gtk_grid_new();
965 gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1);
966
967 /* City map */
968 create_citydlg_main_map(pdialog, middle, middle_col++, 0);
969
970 /* Improvements */
972 gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1);
973
975
976 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
977 "xalign", 0.0, "yalign", 0.5, NULL);
978 gtk_box_append(GTK_BOX(vbox), label);
979
982
986
987 bar = gtk_progress_bar_new();
989 pdialog->overview.production_bar = bar;
991
992 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
993
1002
1007 rend, "pixbuf", 0, NULL);
1008 g_object_set(rend, "xalign", 0.0, NULL);
1009
1013 rend, "text", 1, "strikethrough", 3, NULL);
1014
1015 pdialog->overview.buy_command
1016 = icon_label_button_new("system-run", _("_Buy"));
1018 g_signal_connect(pdialog->overview.buy_command, "clicked",
1019 G_CALLBACK(buy_callback), pdialog);
1020
1021 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1022 "mnemonic-widget", view,
1023 "label", _("I_mprovements:"),
1024 "xalign", 0.0, "yalign", 0.5, NULL);
1025 gtk_box_append(GTK_BOX(vbox), label);
1026
1031 gtk_box_append(GTK_BOX(vbox), sw);
1032
1034 } else {
1035 pdialog->overview.buy_command = NULL;
1036 pdialog->overview.production_bar = NULL;
1037 pdialog->overview.production_combo = NULL;
1039 }
1040
1041 /* Bottom: info, units */
1044
1045 /* Info */
1046 frame = gtk_frame_new(_("Info"));
1047 gtk_box_append(GTK_BOX(bottom), frame);
1048
1049 table = create_city_info_table(pdialog,
1050 pdialog->overview.info_label);
1054
1055 /* Right: present and supported units (overview page) */
1057 gtk_box_append(GTK_BOX(bottom), right);
1058
1063
1064 /* Supported units */
1071 sw);
1072
1073
1077
1080
1081 /* Present units */
1088
1092
1095
1096 /* Show page */
1098}
1099
1100/***********************************************************************/
1103static void create_and_append_map_page(struct city_dialog *pdialog)
1104{
1105 if (low_citydlg) {
1106 GtkWidget *page;
1107 GtkWidget *label;
1108 const char *tab_title = _("Citymap");
1109 int page_row = 0;
1110
1111 page = gtk_grid_new();
1120
1121 create_citydlg_main_map(pdialog, page, 0, page_row++);
1122
1124 }
1125}
1126
1127/***********************************************************************/
1131 const GValue *value,
1132 double x, double y, gpointer data)
1133{
1134 struct city_dialog *pdialog = (struct city_dialog *) data;
1135 cid id;
1136 struct universal univ;
1137
1138 if (NULL != client.conn.playing
1139 && city_owner(pdialog->pcity) != client.conn.playing) {
1140 return FALSE;
1141 }
1142
1143 id = g_value_get_int(value);
1144 univ = cid_production(id);
1145
1146 city_change_production(pdialog->pcity, &univ);
1147
1148 return TRUE;
1149}
1150
1151/***********************************************************************/
1155static int create_production_header(struct city_dialog *pdialog,
1156 GtkWidget *grid, int row)
1157{
1158 GtkWidget *hgrid, *bar;
1159 int grid_col = 0;
1160
1161 hgrid = gtk_grid_new();
1167 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1168
1169 /* The label is set in city_dialog_update_building() */
1170 bar = gtk_progress_bar_new();
1173 pdialog->production.production_bar = bar;
1174 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1175 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1176
1178
1179 pdialog->production.buy_command
1180 = icon_label_button_new("system-run", _("_Buy"));
1182 grid_col++, 0, 1, 1);
1183
1184 g_signal_connect(pdialog->production.buy_command, "clicked",
1185 G_CALLBACK(buy_callback), pdialog);
1186
1187 return row;
1188}
1189
1190/***********************************************************************/
1194{
1195 if (low_citydlg) {
1196 GtkWidget *page;
1197 GtkWidget *label;
1198 GtkWidget *vbox;
1199 GtkWidget *view;
1200 const char *tab_title = _("Buildings");
1201 int page_row = 0;
1202
1203 page = gtk_grid_new();
1211
1212 page_row = create_production_header(pdialog, page, page_row);
1213 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1214
1216 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1217
1219
1220 gtk_box_append(GTK_BOX(vbox), view);
1221
1223 }
1224}
1225
1226/***********************************************************************/
1230{
1231 const char *tab_title = _("P_roduction");
1233 GtkWidget *page, *editor;
1234 int page_row = 0;
1235
1236 page = gtk_grid_new();
1243 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1244
1245 /* Stuff that's being currently built */
1246 if (!low_citydlg) {
1248 "label", _("Production:"),
1249 "xalign", 0.0, "yalign", 0.5, NULL);
1250 pdialog->production.production_label = label;
1251 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1252
1253 page_row = create_production_header(pdialog, page, page_row);
1254 } else {
1255 pdialog->production.production_label = NULL;
1256 }
1257
1263 reset_city_worklist(editor, pdialog->pcity);
1264 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1265 pdialog->production.worklist = editor;
1266
1268}
1269
1270/***********************************************************************/
1281{
1282 GtkWidget *page, *label, *table, *right, *left, *frame;
1283 const char *tab_title = _("Happ_iness");
1284 int page_col = 0;
1285 int left_row = 0;
1286
1287 /* Main page */
1288 page = gtk_grid_new();
1295 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1296
1297 /* Left: info, citizens */
1298 left = gtk_grid_new();
1301 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1302
1303 if (!low_citydlg) {
1304 /* Upper left: info */
1305 frame = gtk_frame_new(_("Info"));
1306 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1307
1308 table = create_city_info_table(pdialog,
1309 pdialog->happiness.info_label);
1312 }
1313
1314 /* Lower left: citizens */
1318 0, left_row++, 1, 1);
1320 citizens_dialog_display(pdialog->pcity));
1321 }
1322
1323 /* Right: city map, happiness */
1325 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1326
1327 if (!low_citydlg) {
1328 /* Upper right: city map */
1329 frame = gtk_frame_new(_("City map"));
1332 gtk_box_append(GTK_BOX(right), frame);
1333
1334 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1336 }
1337
1338 /* Lower right: happiness */
1340 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1343 pdialog->shell));
1344
1345 /* Show page */
1347}
1348
1349/***********************************************************************/
1352static void create_and_append_cma_page(struct city_dialog *pdialog)
1353{
1354 GtkWidget *page, *label;
1355 const char *tab_title = _("_Governor");
1356
1358
1360
1361 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1362
1363 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1364 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1365
1367}
1368
1369/***********************************************************************/
1373{
1374 int i;
1375 GtkWidget *vgrid, *page, *frame, *label, *button;
1377 GtkWidget *group;
1378 const char *tab_title = _("_Settings");
1379 int grid_row = 0;
1380
1381 static const char *new_citizens_output_label[] = {
1382 N_("Luxury"),
1383 N_("Science"),
1384 N_("Gold")
1385 };
1386
1387 static const char *disband_label
1388 = N_("Allow unit production to disband city");
1389
1390 static const char *misc_whichtab_label[NUM_PAGES] = {
1391 N_("Overview page"),
1392 N_("Production page"),
1393 N_("Happiness page"),
1394 N_("Governor page"),
1395 N_("This Settings page"),
1396 N_("Last active page")
1397 };
1398
1399 static bool new_citizens_label_done;
1400 static bool misc_whichtab_label_done;
1401
1402 /* Initialize signal_blocker */
1403 pdialog->misc.block_signal = 0;
1404
1405
1406 page = gtk_grid_new();
1412
1414
1416
1417 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1418
1419 /* new_citizens radio */
1420 frame = gtk_frame_new(_("New citizens produce"));
1421 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1423
1424 vgrid = gtk_grid_new();
1428
1431
1432 group = NULL;
1433 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1436 GTK_CHECK_BUTTON(group));
1437 pdialog->misc.new_citizens_radio[i] = button;
1438 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1439 g_signal_connect(button, "toggled",
1440 G_CALLBACK(cityopt_callback), pdialog);
1441 group = button;
1442 }
1443
1444 /* Next is the next-time-open radio group in the right column */
1445 frame = gtk_frame_new(_("Next time open"));
1446 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1448
1449 vgrid = gtk_grid_new();
1450 grid_row = 0;
1454
1457
1458 group = NULL;
1459 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1462 GTK_CHECK_BUTTON(group));
1463 pdialog->misc.whichtab_radio[i] = button;
1464 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1465 g_signal_connect(button, "toggled",
1467 group = button;
1468 }
1469
1470 /* Now we go back and fill the hbox rename */
1471 frame = gtk_frame_new(_("City"));
1472 gtk_widget_set_margin_top(frame, 12);
1474 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1475
1476 vgrid = gtk_grid_new();
1477 grid_row = 0;
1481
1482 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1483 pdialog->misc.rename_command = button;
1484 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1485 g_signal_connect(button, "clicked",
1486 G_CALLBACK(rename_callback), pdialog);
1487
1489
1490 /* The disband-city-on-unit-production button */
1492 pdialog->misc.disband_on_settler = button;
1493 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1494 g_signal_connect(button, "toggled",
1495 G_CALLBACK(cityopt_callback), pdialog);
1496
1497 /* We choose which page to popup by default */
1499 (pdialog->
1501 TRUE);
1502
1503 set_cityopt_values(pdialog);
1504
1506
1507 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1509 last_page);
1510 } else {
1513 }
1514}
1515
1516/***********************************************************************/
1525{
1526 struct city_dialog *pdialog;
1528 GtkWidget *vbox, *hbox, *cbox;
1531 int ccol = 0;
1533 struct player *owner;
1534
1537 }
1538
1539 pdialog = fc_malloc(sizeof(struct city_dialog));
1540 pdialog->pcity = pcity;
1541 pdialog->sell_shell = NULL;
1542 pdialog->rename_shell = NULL;
1543 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1544 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1545 pdialog->happiness.citizens = NULL; /* Ditto */
1546 pdialog->production.buy_command = NULL;
1547 pdialog->production.production_label = NULL;
1548 pdialog->production.production_bar = NULL;
1549 pdialog->cma_editor = NULL;
1553
1554 pdialog->shell = gtk_dialog_new();
1556 setup_dialog(pdialog->shell, toplevel);
1557
1558 g_signal_connect(pdialog->shell, "destroy",
1560 gtk_widget_set_name(pdialog->shell, "Freeciv");
1561
1562 gtk_widget_realize(pdialog->shell);
1563
1564 /* Keep the icon of the executable on Windows (see PR#36491) */
1565#ifndef FREECIV_MSWINDOWS
1566 {
1567 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1568 }
1569#endif /* FREECIV_MSWINDOWS */
1570
1571 /* Restore size of the city dialog. */
1575
1576 pdialog->popover = NULL;
1577
1581 gtk_box_append(GTK_BOX(vbox), hbox);
1582
1583 /**** Citizens bar here ****/
1584 cbox = gtk_grid_new();
1585 gtk_box_append(GTK_BOX(hbox), cbox);
1586
1589
1593 pdialog->citizen_pics = gtk_picture_new();
1594
1603 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1604
1606 g_signal_connect(controller, "pressed",
1607 G_CALLBACK(citizens_callback), pdialog);
1609
1610 /**** City name label here ****/
1611 pdialog->name_label = gtk_label_new(NULL);
1616
1617 /**** -Start of Notebook- ****/
1618
1619 pdialog->notebook = gtk_notebook_new();
1622 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1623
1627
1628 owner = city_owner(pcity);
1629
1630 /* Only create these tabs if not a spy */
1634 }
1635
1636 if (owner == client_player()
1637 && !client_is_observer()) {
1640 } else {
1643 }
1644
1645 /**** End of Notebook ****/
1646
1647 /* Bottom buttons */
1648
1649 pdialog->show_units_command =
1650 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1651
1652 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1654
1655 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1657 GTK_WIDGET(pdialog->prev_command), 1);
1658
1659 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1661 GTK_WIDGET(pdialog->next_command), 2);
1662
1663 if (owner != client_player()) {
1666 }
1667
1669 _("_Close"), GTK_RESPONSE_CLOSE);
1670
1673
1675 G_CALLBACK(close_callback), pdialog);
1676
1677 g_signal_connect(pdialog->prev_command, "clicked",
1679
1680 g_signal_connect(pdialog->next_command, "clicked",
1682
1683 /* Some other things we gotta do */
1684
1686 g_signal_connect(controller, "key-pressed",
1689
1691
1693
1694 /* Need to do this every time a new dialog is opened. */
1696
1698
1700
1701 return pdialog;
1702}
1703
1704/**************** Functions to update parts of the dialog *****************/
1705
1706/***********************************************************************/
1709static void city_dialog_update_title(struct city_dialog *pdialog)
1710{
1711 gchar *buf;
1712 const gchar *now;
1713
1714 if (city_unhappy(pdialog->pcity)) {
1715 /* TRANS: city dialog title */
1716 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
1717 city_name_get(pdialog->pcity),
1719 } else if (city_celebrating(pdialog->pcity)) {
1720 /* TRANS: city dialog title */
1721 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
1722 city_name_get(pdialog->pcity),
1724 } else if (city_happy(pdialog->pcity)) {
1725 /* TRANS: city dialog title */
1726 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
1727 city_name_get(pdialog->pcity),
1729 } else {
1730 /* TRANS: city dialog title */
1731 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
1732 city_name_get(pdialog->pcity),
1734 }
1735
1737 if (strcmp(now, buf) != 0) {
1740 }
1741
1742 g_free(buf);
1743}
1744
1745/***********************************************************************/
1748static void city_dialog_update_citizens(struct city_dialog *pdialog)
1749{
1750 enum citizen_category categories[MAX_CITY_SIZE];
1753 struct city *pcity = pdialog->pcity;
1754 int num_citizens = get_city_citizen_types(pcity, FEELING_FINAL, categories);
1755 cairo_t *cr;
1756
1757 /* If there is not enough space we stack the icons. We draw from left to */
1758 /* right. width is how far we go to the right for each drawn pixmap. The */
1759 /* last icon is always drawn in full, and so has reserved */
1760 /* tileset_small_sprite_width(tileset) pixels. */
1761
1763 if (num_citizens > 1) {
1765 / (num_citizens - 1));
1766 } else {
1767 width = full_width;
1768 }
1769 pdialog->cwidth = width;
1770
1771 /* overview page */
1772 /* keep these values in sync with create_city_dialog */
1775
1776 cr = cairo_create(pdialog->citizen_surface);
1777
1778 for (i = 0; i < num_citizens; i++) {
1780 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
1781 i * width, 0);
1782 cairo_rectangle(cr, i * width, 0,
1783 /* Always draw last citizen in full */
1784 i + 1 < num_citizens ? width : full_width,
1786 cairo_fill(cr);
1787 }
1788
1789 total_used_width = (i - 1) * width + full_width;
1790
1792 /* Clear the rest of the area.
1793 * Note that this might still be necessary even in cases where
1794 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
1795 * divided perfectly. */
1800 cairo_fill(cr);
1801 }
1802
1803 cairo_destroy(cr);
1804
1806 pdialog->citizen_surface);
1807
1809}
1810
1811/***********************************************************************/
1815 struct city_dialog *pdialog)
1816{
1817 int i, illness = 0;
1818 char buf[NUM_INFO_FIELDS][512];
1819 struct city *pcity = pdialog->pcity;
1820 int granaryturns;
1821 int non_workers = city_specialists(pcity);
1822
1823 /* fill the buffers with the necessary info */
1824 if (non_workers) {
1825 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
1826 pcity->size, non_workers);
1827 } else {
1828 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
1829 }
1830 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
1831 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
1832 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
1833 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
1834 pcity->surplus[O_SHIELD]);
1835 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
1836 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
1837 pcity->surplus[O_TRADE]);
1838 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
1839 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
1840 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
1841 pcity->prod[O_LUXURY]);
1842 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
1843 pcity->prod[O_SCIENCE]);
1844 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
1846
1848 if (granaryturns == 0) {
1849 /* TRANS: city growth is blocked. Keep short. */
1850 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
1851 } else if (granaryturns == FC_INFINITY) {
1852 /* TRANS: city is not growing. Keep short. */
1853 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
1854 } else {
1855 /* A negative value means we'll have famine in that many turns.
1856 But that's handled down below. */
1857 /* TRANS: city growth turns. Keep short. */
1859 PL_("%d turn", "%d turns", abs(granaryturns)),
1860 abs(granaryturns));
1861 }
1863 pcity->waste[O_TRADE]);
1864 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
1865 pcity->waste[O_SHIELD]);
1866 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
1867 pcity->client.culture);
1869 pcity->pollution);
1870 if (!game.info.illness_on) {
1871 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
1872 } else {
1874 /* illness is in tenth of percent */
1875 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
1876 (float)illness / 10.0);
1877 }
1878 if (pcity->steal) {
1879 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
1880 pcity->steal);
1881 } else {
1882 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
1883 }
1884
1886
1887 /* stick 'em in the labels */
1888 for (i = 0; i < NUM_INFO_FIELDS; i++) {
1890 }
1891
1892 /*
1893 * Make use of the emergency-indicating styles set up for certain labels
1894 * in create_city_info_table().
1895 */
1896 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
1897 * of a warning. */
1898 if (granaryturns > -4 && granaryturns < 0) {
1900 } else {
1902 }
1903
1904 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
1906 } else {
1908 }
1909
1910 /* Someone could add the color &orange for better granularity here */
1911 if (pcity->pollution >= 10) {
1913 } else {
1915 }
1916
1917 /* Illness is in tenth of percent, i.e 100 == 10.0% */
1918 if (illness >= 100) {
1920 } else {
1922 }
1923}
1924
1925/***********************************************************************/
1928static void city_dialog_update_map(struct city_dialog *pdialog)
1929{
1930 struct canvas store = FC_STATIC_CANVAS_INIT;
1931
1932 store.surface = pdialog->map_canvas_store_unscaled;
1933
1934 /* The drawing is done in three steps.
1935 * 1. First we render to a pixmap with the appropriate canvas size.
1936 * 2. Then the pixmap is rendered into a pixbuf of equal size.
1937 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
1938 * target pixbuf.
1939 */
1940
1941 city_dialog_redraw_map(pdialog->pcity, &store);
1942
1943 /* draw to real window */
1944 draw_map_canvas(pdialog);
1945}
1946
1947/***********************************************************************/
1950static void city_dialog_update_building(struct city_dialog *pdialog)
1951{
1952 char buf[32], buf2[200];
1953 gdouble pct;
1954 GtkListStore *store;
1956 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
1957 struct item items[MAX_NUM_PRODUCTION_TARGETS];
1958 int targets_used, item;
1959 struct city *pcity = pdialog->pcity;
1961 const char *descr = city_production_name_translation(pcity);
1963
1964 if (pdialog->overview.buy_command != NULL) {
1966 }
1967 if (pdialog->production.buy_command != NULL) {
1969 }
1970
1971 /* Make sure build slots info is up to date */
1972 if (pdialog->production.production_label != NULL) {
1973 int build_slots = city_build_slots(pcity);
1974
1975 /* Only display extra info if more than one slot is available */
1976 if (build_slots > 1) {
1977 fc_snprintf(buf2, sizeof(buf2),
1978 /* TRANS: never actually used with built_slots <= 1 */
1979 PL_("Production (up to %d unit per turn):",
1980 "Production (up to %d units per turn):", build_slots),
1981 build_slots);
1984 } else {
1986 GTK_LABEL(pdialog->production.production_label), _("Production:"));
1987 }
1988 }
1989
1990 /* Update what the city is working on */
1991 get_city_dialog_production(pcity, buf, sizeof(buf));
1992
1993 if (cost > 0) {
1994 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
1995 pct = CLAMP(pct, 0.0, 1.0);
1996 } else {
1997 pct = 1.0;
1998 }
1999
2000 if (pdialog->overview.production_bar != NULL) {
2001 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2002 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2007 }
2008
2009 if (pdialog->production.production_bar != NULL) {
2010 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2011 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2016 }
2017
2018 store = pdialog->overview.change_production_store;
2019 if (store != NULL) {
2020 int cur = -1;
2021 int actcount = 0;
2022
2023 if (pdialog->overview.production_combo != NULL) {
2025 -1);
2026 }
2027
2028 gtk_list_store_clear(store);
2029
2031 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2032 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2033
2034 for (item = 0; item < targets_used; item++) {
2035 if (can_city_build_now(pcity, &items[item].item)) {
2036 const char *name;
2037 struct sprite *sprite;
2038 GdkPixbuf *pix;
2039 struct universal *target = &items[item].item;
2040 bool useless;
2041
2042 if (VUT_UTYPE == target->kind) {
2046 useless = FALSE;
2047 } else {
2051 }
2053 gtk_list_store_append(store, &iter);
2054 gtk_list_store_set(store, &iter, 0, pix,
2055 1, name, 3, useless,
2056 2, (gint)cid_encode(items[item].item), -1);
2058
2059 if (are_universals_equal(target, &pcity->production)) {
2060 cur = actcount;
2061 }
2062
2063 actcount++;
2064 }
2065 }
2066
2067 if (pdialog->overview.production_combo != NULL) {
2069 cur);
2070 }
2071 }
2072}
2073
2074/***********************************************************************/
2078{
2079 int item, targets_used;
2080 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2081 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2082 GtkTreeModel *model;
2083 GtkListStore *store;
2084
2085 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2086 "sell an improvement.");
2087 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2088 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2089
2090 model =
2092 store = GTK_LIST_STORE(model);
2093
2095 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2096
2097 gtk_list_store_clear(store);
2098
2099 for (item = 0; item < targets_used; item++) {
2100 GdkPixbuf *pix;
2101 GtkTreeIter it;
2102 int upkeep;
2103 struct sprite *sprite;
2104 struct universal target = items[item].item;
2105
2106 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2107 /* This takes effects (like Adam Smith's) into account. */
2108 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2110
2112 gtk_list_store_append(store, &it);
2113 gtk_list_store_set(store, &it,
2114 0, target.value.building,
2115 1, pix,
2116 2, items[item].descr,
2117 3, upkeep,
2118 4,
2120 target.value.building),
2121 5,
2124 (is_small_wonder(target.value.building) ?
2126 -1);
2128 }
2129}
2130
2131/***********************************************************************/
2135{
2136 struct unit_list *units;
2137 struct unit_node_vector *nodes;
2138 int n, m, i;
2139 gchar *buf;
2141
2142 if (NULL != client.conn.playing
2143 && city_owner(pdialog->pcity) != client.conn.playing) {
2144 units = pdialog->pcity->client.info_units_supported;
2145 } else {
2146 units = pdialog->pcity->units_supported;
2147 }
2148
2149 nodes = &pdialog->overview.supported_units;
2150
2151 n = unit_list_size(units);
2152 m = unit_node_vector_size(nodes);
2153
2154 if (m > n) {
2155 i = 0;
2157 if (i++ >= n) {
2159 elt->cmd);
2160 }
2162
2164 } else {
2165 for (i = m; i < n; i++) {
2166 GtkWidget *cmd, *pix;
2167 struct unit_node node;
2168
2169 cmd = gtk_button_new();
2170 node.cmd = cmd;
2171
2173
2174 pix = gtk_picture_new();
2175 node.pix = pix;
2177
2179
2181 cmd);
2182
2183 node.left = NULL;
2184 node.middle = NULL;
2185 node.right = NULL;
2186
2187 unit_node_vector_append(nodes, node);
2188 }
2189 }
2190
2191 i = 0;
2192 unit_list_iterate(units, punit) {
2193 struct unit_node *pnode;
2194 int happy_cost = city_unit_unhappiness(punit, &free_unhappy);
2195
2196 pnode = unit_node_vector_get(nodes, i);
2197 if (pnode) {
2198 GtkWidget *cmd, *pix;
2201
2202 cmd = pnode->cmd;
2203 pix = pnode->pix;
2204
2206 punit->upkeep, happy_cost);
2207
2208 if (pnode->left != NULL) {
2212 }
2213
2215
2217 g_signal_connect(controller, "pressed",
2221 pnode->left = controller;
2225 g_signal_connect(controller, "released",
2229 pnode->middle = controller;
2233 g_signal_connect(controller, "released",
2237 pnode->right = controller;
2238
2239 if (city_owner(pdialog->pcity) != client.conn.playing) {
2241 } else {
2243 }
2244
2247 }
2248 i++;
2250
2251 buf = g_strdup_printf(_("Supported units %d"), n);
2253 g_free(buf);
2254}
2255
2256/***********************************************************************/
2260{
2261 struct unit_list *units;
2262 struct unit_node_vector *nodes;
2263 int n, m, i;
2264 gchar *buf;
2265
2266 if (NULL != client.conn.playing
2267 && city_owner(pdialog->pcity) != client.conn.playing) {
2268 units = pdialog->pcity->client.info_units_present;
2269 } else {
2270 units = pdialog->pcity->tile->units;
2271 }
2272
2273 nodes = &pdialog->overview.present_units;
2274
2275 n = unit_list_size(units);
2276 m = unit_node_vector_size(nodes);
2277
2278 if (m > n) {
2279 i = 0;
2281 if (i++ >= n) {
2283 elt->cmd);
2284 }
2286
2288 } else {
2289 for (i = m; i < n; i++) {
2290 GtkWidget *cmd, *pix;
2291 struct unit_node node;
2292
2293 cmd = gtk_button_new();
2294 node.cmd = cmd;
2295
2297
2298 pix = gtk_picture_new();
2299 node.pix = pix;
2301
2303
2305 cmd);
2306
2307 node.left = NULL;
2308 node.middle = NULL;
2309 node.right = NULL;
2310
2311 unit_node_vector_append(nodes, node);
2312 }
2313 }
2314
2315 i = 0;
2316 unit_list_iterate(units, punit) {
2317 struct unit_node *pnode;
2318
2319 pnode = unit_node_vector_get(nodes, i);
2320 if (pnode) {
2321 GtkWidget *cmd, *pix;
2324
2325 cmd = pnode->cmd;
2326 pix = pnode->pix;
2327
2329
2330 if (pnode->left != NULL) {
2334 }
2335
2337
2339 g_signal_connect(controller, "pressed",
2343 pnode->left = controller;
2347 g_signal_connect(controller, "released",
2351 pnode->middle = controller;
2355 g_signal_connect(controller, "released",
2359 pnode->right = controller;
2360
2361 if (city_owner(pdialog->pcity) != client.conn.playing) {
2363 } else {
2365 }
2366
2369 }
2370 i++;
2372
2373 buf = g_strdup_printf(_("Present units %d"), n);
2375 g_free(buf);
2376}
2377
2378/***********************************************************************/
2386{
2387 int count = 0;
2388 int city_number;
2389
2390 if (NULL != client.conn.playing) {
2392 } else {
2393 city_number = FC_INFINITY; /* ? */
2394 }
2395
2396 /* The first time, we see if all the city dialogs are open */
2398 if (city_owner(pdialog->pcity) == client.conn.playing) {
2399 count++;
2400 }
2402
2403 if (count == city_number) { /* All are open, shouldn't prev/next */
2405 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2406 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2408 } else {
2410 if (city_owner(pdialog->pcity) == client.conn.playing) {
2411 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2412 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2413 }
2415 }
2416}
2417
2418/***********************************************************************/
2421static void citydlg_response_callback(GtkDialog *dlg, gint response,
2422 void *data)
2423{
2424 switch (response) {
2425 case CDLGR_UNITS:
2426 show_units_response(data);
2427 break;
2428 }
2429}
2430
2431/***********************************************************************/
2434static void show_units_response(void *data)
2435{
2436 struct city_dialog *pdialog = (struct city_dialog *) data;
2437 struct tile *ptile = pdialog->pcity->tile;
2438
2439 if (unit_list_size(ptile->units)) {
2441 }
2442}
2443
2444/***********************************************************************/
2454static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2455 GtkWidget *wdg, bool supported)
2456{
2457 GMenu *menu;
2458 GActionGroup *group;
2459 GSimpleAction *act;
2460
2461 if (!can_client_issue_orders()) {
2462 return FALSE;
2463 }
2464
2465 if (pdialog->popover != NULL) {
2467 }
2468
2470 menu = g_menu_new();
2471
2472 if (supported) {
2473 act = g_simple_action_new("center", NULL);
2474 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2478 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2479 }
2480
2481 act = g_simple_action_new("activate", NULL);
2482 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2486 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2487 "win.activate"));
2488
2489 act = g_simple_action_new("activate_close", NULL);
2490 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2492
2493 if (supported) {
2494 g_signal_connect(act, "activate",
2497 } else {
2498 g_signal_connect(act, "activate",
2501 }
2502
2504 g_menu_item_new(_("Activate unit, _close dialog"),
2505 "win.activate_close"));
2506
2507 if (!supported) {
2508 act = g_simple_action_new("load", NULL);
2509 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2514 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2515
2516 act = g_simple_action_new("unload", NULL);
2517 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2525 unit_tile(punit)));
2526 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2527 "win.unload"));
2528
2529 act = g_simple_action_new("sentry", NULL);
2530 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2538 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2539 "win.sentry"));
2540
2541 act = g_simple_action_new("fortify", NULL);
2542 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2550 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2551 "win.fortify"));
2552 }
2553
2554 act = g_simple_action_new("disband", NULL);
2555 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2561 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2562 "win.disband"));
2563
2564 if (!supported) {
2565 act = g_simple_action_new("rehome", NULL);
2566 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2572 pdialog->pcity));
2575 "win.rehome"));
2576
2577 act = g_simple_action_new("upgrade", NULL);
2578 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2587 != NULL);
2588 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
2589 "win.upgrade"));
2590 }
2591
2593 g_object_ref(pdialog->popover);
2594 gtk_widget_insert_action_group(pdialog->popover, "win", group);
2596
2597
2599
2600 return TRUE;
2601}
2602
2603/***********************************************************************/
2607 double x, double y, gpointer data)
2608{
2609 struct city_dialog *pdialog;
2610 struct city *pcity;
2611 struct unit *punit =
2612 player_unit_by_number(client_player(), (size_t) data);
2613
2614 if (NULL != punit
2615 && NULL != (pcity = game_city_by_number(punit->homecity))
2616 && NULL != (pdialog = get_city_dialog(pcity))) {
2617
2618 return create_unit_menu(pdialog, punit,
2620 TRUE);
2621 }
2622
2623 return TRUE;
2624}
2625
2626/***********************************************************************/
2630 double x, double y, gpointer data)
2631{
2632 struct city_dialog *pdialog;
2633 struct city *pcity;
2634 struct unit *punit =
2635 player_unit_by_number(client_player(), (size_t) data);
2636
2637 if (NULL != punit
2638 && NULL != (pcity = tile_city(unit_tile(punit)))
2639 && NULL != (pdialog = get_city_dialog(pcity))) {
2640
2641 return create_unit_menu(pdialog, punit,
2643 FALSE);
2644 }
2645
2646 return TRUE;
2647}
2648
2649/***********************************************************************/
2654 int n_press, double x, double y,
2655 gpointer data)
2656{
2657 struct city_dialog *pdialog;
2658 struct city *pcity;
2659 struct unit *punit =
2660 player_unit_by_number(client_player(), (size_t) data);
2661
2662 if (NULL != punit
2663 && NULL != (pcity = tile_city(unit_tile(punit)))
2664 && NULL != (pdialog = get_city_dialog(pcity))
2667 close_city_dialog(pdialog);
2668 }
2669
2670 return TRUE;
2671}
2672
2673/***********************************************************************/
2678 double x, double y, gpointer data)
2679{
2680 struct city_dialog *pdialog;
2681 struct city *pcity;
2682 struct unit *punit =
2683 player_unit_by_number(client_player(), (size_t) data);
2684
2685 if (NULL != punit
2686 && NULL != (pcity = game_city_by_number(punit->homecity))
2687 && NULL != (pdialog = get_city_dialog(pcity))
2690 close_city_dialog(pdialog);
2691 }
2692
2693 return TRUE;
2694}
2695
2696/***********************************************************************/
2700 double x, double y, gpointer data)
2701{
2702 struct unit *punit =
2703 player_unit_by_number(client_player(), (size_t) data);
2704
2705 if (NULL != punit
2708 }
2709
2710 return TRUE;
2711}
2712
2713/***********************************************************************/
2718static void close_citydlg_unit_popover(struct city_dialog *pdialog)
2719{
2720 if (pdialog->popover != NULL) {
2721 gtk_widget_unparent(pdialog->popover);
2722 g_object_unref(pdialog->popover);
2723 pdialog->popover = NULL;
2724 }
2725}
2726
2727/***********************************************************************/
2731 gpointer data)
2732{
2733 struct unit *punit =
2735
2736 if (NULL != punit) {
2738 }
2739
2741}
2742
2743/***********************************************************************/
2747 gpointer data)
2748{
2749 struct unit *punit =
2751
2752 if (NULL != punit) {
2754 }
2755
2757}
2758
2759/***********************************************************************/
2764 GVariant *parameter,
2765 gpointer data)
2766{
2767 struct unit *punit =
2769
2770 if (NULL != punit) {
2771 struct city *pcity =
2773
2775 if (NULL != pcity) {
2776 struct city_dialog *pdialog = get_city_dialog(pcity);
2777
2778 if (NULL != pdialog) {
2779 close_city_dialog(pdialog);
2780 }
2781 }
2782 }
2783
2785}
2786
2787/***********************************************************************/
2792 GVariant *parameter,
2793 gpointer data)
2794{
2795 struct unit *punit =
2797
2798 if (NULL != punit) {
2799 struct city *pcity = tile_city(unit_tile(punit));
2800
2802 if (NULL != pcity) {
2803 struct city_dialog *pdialog = get_city_dialog(pcity);
2804
2805 if (NULL != pdialog) {
2806 close_city_dialog(pdialog);
2807 }
2808 }
2809 }
2810
2812}
2813
2814/***********************************************************************/
2818 gpointer data)
2819{
2820 struct unit *punit =
2822
2823 if (NULL != punit) {
2825 }
2826
2828}
2829
2830/***********************************************************************/
2834 gpointer data)
2835{
2836 struct unit *punit =
2838
2839 if (NULL != punit) {
2841 }
2842
2844}
2845
2846/***********************************************************************/
2850 gpointer data)
2851{
2852 struct unit *punit =
2854
2855 if (NULL != punit) {
2857 }
2858
2860}
2861
2862/***********************************************************************/
2866 gpointer data)
2867{
2868 struct unit *punit =
2870
2871 if (NULL != punit) {
2873 }
2874
2876}
2877
2878/***********************************************************************/
2882 gpointer data)
2883{
2884 struct unit_list *punits;
2885 struct unit *punit =
2887
2888 if (NULL == punit) {
2889 return;
2890 }
2891
2896
2898}
2899
2900/***********************************************************************/
2905 gpointer data)
2906{
2907 struct unit *punit =
2909
2910 if (NULL != punit) {
2912 }
2913
2915}
2916
2917/***********************************************************************/
2921 gpointer data)
2922{
2923 struct unit_list *punits;
2924 struct unit *punit =
2926
2927 if (NULL == punit) {
2928 return;
2929 }
2930
2935
2937}
2938
2939/******** Callbacks for citizen bar, map funcs that are not update ********/
2940
2941/***********************************************************************/
2946 double x, double y, gpointer data)
2947{
2948 struct city_dialog *pdialog = data;
2949 struct city *pcity = pdialog->pcity;
2950 int citnum, tlen, len;
2951
2952 if (!can_client_issue_orders()) {
2953 return FALSE;
2954 }
2955
2957 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
2958
2959 if (x > len) {
2960 /* No citizen that far to the right */
2961 return FALSE;
2962 }
2963 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
2964
2966
2967 return TRUE;
2968}
2969
2970/***********************************************************************/
2974{
2975 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
2976 struct city *pcity = workertask_req.owner;
2977 struct tile *ptile = workertask_req.loc;
2978 struct packet_worker_task task;
2979
2980 task.city_id = pcity->id;
2981
2982 if (act == ACTIVITY_LAST) {
2983 task.tgt = -1;
2984 task.want = 0;
2985 } else {
2986 enum extra_cause cause = activity_to_extra_cause(act);
2988 struct extra_type *tgt;
2989
2990 if (cause != EC_NONE) {
2991 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
2992 } else if (rmcause != ERM_NONE) {
2993 tgt = prev_extra_in_tile(ptile, rmcause, city_owner(pcity), NULL);
2994 } else {
2995 tgt = NULL;
2996 }
2997
2998 if (tgt == NULL) {
2999 struct terrain *pterr = tile_terrain(ptile);
3000
3001 if ((act != ACTIVITY_TRANSFORM
3002 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3003 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3004 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3005 /* No extra to order */
3006 output_window_append(ftc_client, _("There's no suitable extra to order."));
3007
3008 return;
3009 }
3010
3011 task.tgt = -1;
3012 } else {
3013 task.tgt = extra_index(tgt);
3014 }
3015
3016 task.want = 100;
3017 }
3018
3019 task.tile_id = ptile->index;
3020 task.activity = act;
3021
3023}
3024
3025/***********************************************************************/
3032
3033/***********************************************************************/
3036static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3037{
3039 GtkWidget *shl;
3040 struct terrain *pterr = tile_terrain(ptile);
3041 struct universal for_terr = { .kind = VUT_TERRAIN,
3042 .value = { .terrain = pterr }};
3043 struct worker_task *ptask;
3044
3046 workertask_req.owner = pcity;
3047 workertask_req.loc = ptile;
3048
3050 _("What Action to Request"),
3051 _("Select autoworker activity:"));
3052
3054 if (ptask != NULL) {
3055 choice_dialog_add(shl, _("Clear request"),
3058 }
3059
3061 choice_dialog_add(shl, Q_("?act:Mine"),
3064 }
3065 if (pterr->plant_result != NULL
3067 NULL, &for_terr)) {
3068 choice_dialog_add(shl, _("Plant"),
3071 }
3073 choice_dialog_add(shl, _("Irrigate"),
3076 }
3077 if (pterr->cultivate_result != NULL
3079 NULL, &for_terr)) {
3080 choice_dialog_add(shl, _("Cultivate"),
3083 }
3085 choice_dialog_add(shl, _("Road"),
3088 }
3089 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3091 NULL, &for_terr)) {
3092 choice_dialog_add(shl, _("Transform"),
3095 }
3097 city_owner(pcity), NULL) != NULL) {
3098 choice_dialog_add(shl, _("Clean"),
3101 }
3102
3103 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3105
3107 NULL);
3108 }
3109}
3110
3111/***********************************************************************/
3115 double x, double y, gpointer data)
3116{
3117 struct city_dialog *pdialog = data;
3119
3120 if (!can_client_issue_orders()) {
3121 return FALSE;
3122 }
3123
3124 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3125 return FALSE;
3126 }
3127
3130
3132 city_map_radius_sq_get(pdialog->pcity),
3133 canvas_x, canvas_y)) {
3135 }
3136
3137 return TRUE;
3138}
3139
3140/***********************************************************************/
3144 double x, double y, gpointer data)
3145{
3146 struct city_dialog *pdialog = data;
3148
3149 if (!can_client_issue_orders()) {
3150 return FALSE;
3151 }
3152
3155
3157 city_map_radius_sq_get(pdialog->pcity),
3158 canvas_x, canvas_y)) {
3159 struct city *pcity = pdialog->pcity;
3160
3161 popup_workertask_dlg(pdialog->pcity,
3162 city_map_to_tile(&(wld.map), pcity->tile,
3164 city_x, city_y));
3165 }
3166
3167 return TRUE;
3168}
3169
3170/***********************************************************************/
3173static void draw_map_canvas(struct city_dialog *pdialog)
3174{
3176 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3178 }
3179}
3180
3181/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3182
3183/***********************************************************************/
3186static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
3187{
3188 struct city_dialog *pdialog = data;
3189
3190 if (response == GTK_RESPONSE_YES) {
3191 city_buy_production(pdialog->pcity);
3192 }
3193
3195}
3196
3197/***********************************************************************/
3200static void buy_callback(GtkWidget *w, gpointer data)
3201{
3203 struct city_dialog *pdialog = data;
3204 const char *name = city_production_name_translation(pdialog->pcity);
3205 int value = pdialog->pcity->client.buy_cost;
3206 char buf[1024];
3207
3208 if (!can_client_issue_orders()) {
3209 return;
3210 }
3211
3212 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3213 "Treasury contains %d gold.",
3214 client_player()->economic.gold),
3215 client_player()->economic.gold);
3216
3217 if (value <= client_player()->economic.gold) {
3221 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3222 PL_("Buy %s for %d gold?\n%s",
3223 "Buy %s for %d gold?\n%s", value),
3224 name, value, buf);
3225 setup_dialog(shell, pdialog->shell);
3226 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3229 pdialog);
3231 } else {
3235 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3236 PL_("%s costs %d gold.\n%s",
3237 "%s costs %d gold.\n%s", value),
3238 name, value, buf);
3239 setup_dialog(shell, pdialog->shell);
3240 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3242 NULL);
3244 }
3245}
3246
3247/***********************************************************************/
3251 struct city_dialog *pdialog)
3252{
3254
3256 && gtk_combo_box_get_active_iter(combo, &iter)) {
3257 cid id;
3258 struct universal univ;
3259
3260 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 2, &id, -1);
3261 univ = cid_production(id);
3262 city_change_production(pdialog->pcity, &univ);
3263 }
3264}
3265
3266/***********************************************************************/
3269static void sell_callback(struct impr_type *pimprove, gpointer data)
3270{
3271 GtkWidget *shl;
3272 struct city_dialog *pdialog = (struct city_dialog *) data;
3273 pdialog->sell_id = improvement_number(pimprove);
3274 int price;
3275
3276 if (!can_client_issue_orders()) {
3277 return;
3278 }
3279
3281 pimprove) != TR_SUCCESS) {
3282 return;
3283 }
3284
3285 price = impr_sell_gold(pimprove);
3290 PL_("Sell %s for %d gold?",
3291 "Sell %s for %d gold?", price),
3292 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3293 setup_dialog(shl, pdialog->shell);
3294 pdialog->sell_shell = shl;
3295
3296 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3297
3298 g_signal_connect(shl, "response",
3300
3302}
3303
3304/***********************************************************************/
3307static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3308{
3309 struct city_dialog *pdialog = data;
3310
3311 if (response == GTK_RESPONSE_YES) {
3312 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3313 }
3315
3316 pdialog->sell_shell = NULL;
3317}
3318
3319/***********************************************************************/
3324{
3325 GtkTreeModel *model;
3326 GtkTreeIter it;
3327 GdkSeat *seat;
3329 struct impr_type *pimprove;
3330
3332
3333 if (!gtk_tree_model_get_iter(model, &it, path)) {
3334 return;
3335 }
3336
3337 gtk_tree_model_get(model, &it, 0, &pimprove, -1);
3338
3341
3342 if (!(mask & GDK_CONTROL_MASK)) {
3343 sell_callback(pimprove, data);
3344 } else {
3345 if (is_great_wonder(pimprove)) {
3347 } else {
3349 }
3350 }
3351}
3352
3353/************ Callbacks for stuff on the Misc. Settings page **************/
3354
3355/***********************************************************************/
3359{
3360 struct city_dialog *pdialog;
3361
3362 pdialog = (struct city_dialog *) data;
3363
3364 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3365 /* "shellrenamecity" */
3366 _("Rename City"),
3367 _("What should we rename the city to?"),
3368 city_name_get(pdialog->pcity),
3369 rename_popup_callback, pdialog);
3370}
3371
3372/***********************************************************************/
3375static void rename_popup_callback(gpointer data, gint response,
3376 const char *input)
3377{
3378 struct city_dialog *pdialog = data;
3379
3380 if (pdialog) {
3381 if (response == GTK_RESPONSE_OK) {
3382 city_rename(pdialog->pcity, input);
3383 } /* else CANCEL or DELETE_EVENT */
3384
3385 pdialog->rename_shell = NULL;
3386 }
3387}
3388
3389/***********************************************************************/
3393{
3395}
3396
3397/***********************************************************************/
3401{
3402 struct city_dialog *pdialog = (struct city_dialog *) data;
3403
3404 if (!can_client_issue_orders()) {
3405 return;
3406 }
3407
3408 if (!pdialog->misc.block_signal) {
3409 struct city *pcity = pdialog->pcity;
3411
3412 fc_assert(CITYO_LAST == 3);
3413
3417 }
3420 }
3423 }
3424
3426 }
3427}
3428
3429/***********************************************************************/
3433static void set_cityopt_values(struct city_dialog *pdialog)
3434{
3435 struct city *pcity = pdialog->pcity;
3436
3437 pdialog->misc.block_signal = 1;
3438
3441
3444 (pdialog->misc.new_citizens_radio[1]), TRUE);
3445 } else if (is_city_option_set(pcity, CITYO_GOLD_SPECIALISTS)) {
3447 (pdialog->misc.new_citizens_radio[2]), TRUE);
3448 } else {
3450 (pdialog->misc.new_citizens_radio[0]), TRUE);
3451 }
3452 pdialog->misc.block_signal = 0;
3453}
3454
3455/******************** Callbacks for: Close, Prev, Next. *******************/
3456
3457/***********************************************************************/
3460static void close_callback(GtkWidget *w, gpointer data)
3461{
3462 close_city_dialog((struct city_dialog *) data);
3463}
3464
3465/***********************************************************************/
3469{
3470 struct city_dialog *pdialog;
3471
3472 pdialog = (struct city_dialog *) data;
3473
3475
3477 citizens_dialog_close(pdialog->pcity);
3478 }
3479 close_happiness_dialog(pdialog->pcity);
3480 close_cma_dialog(pdialog->pcity);
3481
3482 /* Save size of the city dialog. */
3491
3492 last_page
3494
3497
3500
3501 if (pdialog->sell_shell) {
3503 }
3504 if (pdialog->rename_shell) {
3506 }
3507
3510
3511 free(pdialog);
3512
3513 /* Need to do this every time a new dialog is closed. */
3515}
3516
3517/***********************************************************************/
3520static void close_city_dialog(struct city_dialog *pdialog)
3521{
3523}
3524
3525/***********************************************************************/
3530{
3531 struct city_dialog *pdialog = (struct city_dialog *) data;
3532 int i, j, dir, size;
3533 struct city *new_pcity = NULL;
3534
3536 return;
3537 }
3538
3540
3542 fc_assert_ret(size >= 1);
3544
3545 if (size == 1) {
3546 return;
3547 }
3548
3549 /* dir = 1 will advance to the city, dir = -1 will get previous */
3550 if (w == GTK_WIDGET(pdialog->next_command)) {
3551 dir = 1;
3552 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3553 dir = -1;
3554 } else {
3555 /* Always fails. */
3557 || w == GTK_WIDGET(pdialog->prev_command));
3558 dir = 1;
3559 }
3560
3561 for (i = 0; i < size; i++) {
3562 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3563 break;
3564 }
3565 }
3566
3567 fc_assert_ret(i < size);
3568
3569 for (j = 1; j < size; j++) {
3571 (i + dir * j + size) % size);
3573
3574 fc_assert_ret(other_pdialog != pdialog);
3575 if (!other_pdialog) {
3577 break;
3578 }
3579 }
3580
3581 if (!new_pcity) {
3582 /* Every other city has an open city dialog. */
3583 return;
3584 }
3585
3586 /* cleanup happiness dialog */
3588 citizens_dialog_close(pdialog->pcity);
3589 }
3590 close_happiness_dialog(pdialog->pcity);
3591
3592 pdialog->pcity = new_pcity;
3593
3594 /* reinitialize happiness, and cma dialogs */
3597 citizens_dialog_display(pdialog->pcity));
3598 }
3600 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
3601 if (!client_is_observer()) {
3602 fc_assert(pdialog->cma_editor != NULL);
3603 pdialog->cma_editor->pcity = new_pcity;
3604 }
3605
3606 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
3607
3608 can_slide = FALSE;
3609 center_tile_mapcanvas(pdialog->pcity->tile);
3610 can_slide = TRUE;
3611 if (!client_is_observer()) {
3612 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
3613 }
3614
3616
3617 /* Recenter the city map(s) */
3619 if (pdialog->happiness.map_canvas.sw) {
3621 }
3622}
3623
3624/***********************************************************************/
3628{
3630 refresh_worklist(pdialog->production.worklist);
3632}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1225
bool action_ever_possible(action_id action)
Definition actions.c:7481
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:688
#define n
Definition astring.c:77
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
int city_granary_size(int city_size)
Definition city.c:2129
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:1011
int city_unit_unhappiness(struct unit *punit, int *free_unhappy)
Definition city.c:3046
int city_build_slots(const struct city *pcity)
Definition city.c:2929
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:305
const char * city_name_get(const struct city *pcity)
Definition city.c:1133
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1251
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3384
int city_population(const struct city *pcity)
Definition city.c:1187
bool city_unhappy(const struct city *pcity)
Definition city.c:1622
bool city_celebrating(const struct city *pcity)
Definition city.c:1641
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2867
bool city_happy(const struct city *pcity)
Definition city.c:1610
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
citizens city_specialists(const struct city *pcity)
Definition city.c:3313
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1992
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:700
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
citizen_category
Definition city.h:267
#define city_owner(_pcity_)
Definition city.h:563
#define MAX_CITY_SIZE
Definition city.h:106
@ FEELING_FINAL
Definition city.h:284
void get_city_dialog_output_text(const struct city *pcity, Output_type_id otype, char *buf, size_t bufsz)
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
int city_rename(struct city *pcity, const char *name)
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
int city_buy_production(struct city *pcity)
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
void get_city_dialog_airlift_text(const struct city *pcity, char *buf, size_t bufsz)
int city_change_production(struct city *pcity, struct universal *target)
void city_rotate_specialist(struct city *pcity, int citizen_index)
int get_citydlg_canvas_width(void)
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
void get_city_dialog_airlift_value(const struct city *pcity, char *buf, size_t bufsz)
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
void get_city_dialog_pollution_text(const struct city *pcity, char *buf, size_t bufsz)
void get_city_dialog_culture_text(const struct city *pcity, char *buf, size_t bufsz)
bool city_can_buy(const struct city *pcity)
int get_citydlg_canvas_height(void)
void get_city_dialog_illness_text(const struct city *pcity, char *buf, size_t bufsz)
void city_report_dialog_update_city(struct city *pcity)
bool client_is_global_observer(void)
bool client_is_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:809
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:640
cid cid_encode(struct universal target)
Definition climisc.c:482
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:902
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
#define cid_production
Definition climisc.h:71
int cid
Definition climisc.h:31
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:551
char * incite_cost
Definition comments.c:74
void request_unit_fortify(struct unit *punit)
Definition control.c:2326
void unit_focus_set(struct unit *punit)
Definition control.c:501
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2067
void request_unit_unload(struct unit *pcargo)
Definition control.c:2167
void request_unit_sentry(struct unit *punit)
Definition control.c:2315
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
static struct editor_state * editor
Definition editor.c:100
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:779
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1090
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1111
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:380
#define EC_NONE
Definition fc_types.h:1093
@ TR_SUCCESS
Definition fc_types.h:1226
#define ERM_NONE
Definition fc_types.h:1116
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_LUXURY
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const struct ft_color ftc_client
const char * population_to_text(int thousand_citizen)
Definition game.c:737
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct city * game_city_by_number(int id)
Definition game.c:106
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
void choice_dialog_end(GtkWidget *dshell)
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
GtkWidget * citizens_dialog_display(const struct city *pcity)
void citizens_dialog_refresh(const struct city *pcity)
void citizens_dialog_close(const struct city *pcity)
static void unit_sentry_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2874
citydlg_response
Definition citydlg.c:82
@ CDLGR_UNITS
Definition citydlg.c:82
@ CDLGR_PREV
Definition citydlg.c:82
@ CDLGR_NEXT
Definition citydlg.c:82
static int new_dialog_def_page
Definition citydlg.c:219
static void create_and_append_buildings_page(struct city_dialog *pdialog)
Definition citydlg.c:1238
static void unit_upgrade_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2933
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3044
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1869
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3456
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1830
static int last_page
Definition citydlg.c:220
static void init_citydlg_dimensions(void)
Definition citydlg.c:332
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1272
struct tile * loc
Definition citydlg.c:227
@ WORKLIST_PAGE
Definition citydlg.c:112
@ CMA_PAGE
Definition citydlg.c:112
@ HAPPINESS_PAGE
Definition citydlg.c:112
@ SETTINGS_PAGE
Definition citydlg.c:113
@ STICKY_PAGE
Definition citydlg.c:113
@ NUM_PAGES
Definition citydlg.c:114
@ OVERVIEW_PAGE
Definition citydlg.c:112
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:128
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3381
static bool low_citydlg
Definition citydlg.c:230
static struct @141 workertask_req
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
static void city_dialog_update_building(struct city_dialog *pdialog)
Definition citydlg.c:2069
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2501
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3172
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2773
static struct city_dialog * get_city_dialog(struct city *pcity)
Definition citydlg.c:387
#define CITY_MAP_MIN_SIZE_Y
Definition citydlg.c:129
static void city_dialog_update_information(GtkWidget **info_ebox, GtkWidget **info_label, struct city_dialog *pdialog)
Definition citydlg.c:1932
static GtkWidget * create_citydlg_improvement_list(struct city_dialog *pdialog, GtkWidget *vbox)
Definition citydlg.c:897
static void create_production_header(struct city_dialog *pdialog, GtkContainer *contain)
Definition citydlg.c:1205
static void workertask_dlg_destroy(GtkWidget *w, gpointer data)
Definition citydlg.c:3036
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2355
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2954
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3235
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2848
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3422
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3511
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:661
static void create_and_append_overview_page(struct city_dialog *pdialog)
Definition citydlg.c:956
static void create_and_append_happiness_page(struct city_dialog *pdialog)
Definition citydlg.c:1316
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
static void buy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3185
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3308
static void create_and_append_map_page(struct city_dialog *pdialog)
Definition citydlg.c:1144
static void city_dialog_map_create(struct city_dialog *pdialog, struct city_map_canvas *cmap_canvas)
Definition citydlg.c:423
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
void reset_city_dialogs(void)
Definition citydlg.c:365
static void cityopt_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3389
static void city_dialog_map_recenter(GtkWidget *map_canvas_sw)
Definition citydlg.c:462
static void draw_map_canvas(struct city_dialog *pdialog)
Definition citydlg.c:3160
static bool is_showing_workertask_dialog
Definition citydlg.c:222
#define unit_node_vector_iterate_end
Definition citydlg.c:108
static void sell_callback(struct impr_type *pimprove, gpointer data)
Definition citydlg.c:3254
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2800
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2462
static void create_and_append_settings_page(struct city_dialog *pdialog)
Definition citydlg.c:1500
static bool city_dialogs_have_been_initialised
Definition citydlg.c:217
static void close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3448
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3293
static void create_citydlg_main_map(struct city_dialog *pdialog, GtkWidget *container)
Definition citydlg.c:880
#define NUM_CITIZENS_SHOWN
Definition citydlg.c:110
#define CITYMAP_HEIGHT
Definition citydlg.c:75
static void unit_homecity_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2920
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2887
static gboolean present_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2597
struct city * owner
Definition citydlg.c:226
static GtkWidget * create_city_info_table(struct city_dialog *pdialog, GtkWidget **info_ebox, GtkWidget **info_label)
Definition citydlg.c:745
static struct city_dialog * create_city_dialog(struct city *pcity)
Definition citydlg.c:1642
static void target_drag_data_received(GtkWidget *w, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
Definition citydlg.c:1167
static void unit_disband_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2900
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3347
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3520
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2047
static void unit_unload_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2861
static void show_units_response(void *data)
Definition citydlg.c:2514
static void initialize_city_dialogs(void)
Definition citydlg.c:341
static int canvas_height
Definition citydlg.c:218
static int canvas_width
Definition citydlg.c:218
#define TINYSCREEN_MAX_HEIGHT
Definition citydlg.c:78
static void city_dialog_update_supported_units(struct city_dialog *pdialog)
Definition citydlg.c:2249
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2786
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2825
@ INFO_LUXURY
Definition citydlg.c:120
@ INFO_STEAL
Definition citydlg.c:122
@ INFO_CORRUPTION
Definition citydlg.c:121
@ NUM_INFO_FIELDS
Definition citydlg.c:123
@ INFO_ILLNESS
Definition citydlg.c:122
@ INFO_WASTE
Definition citydlg.c:121
@ INFO_SIZE
Definition citydlg.c:119
@ INFO_GROWTH
Definition citydlg.c:120
@ INFO_SHIELD
Definition citydlg.c:119
@ INFO_CULTURE
Definition citydlg.c:121
@ INFO_GOLD
Definition citydlg.c:119
@ INFO_SCIENCE
Definition citydlg.c:120
@ INFO_POLLUTION
Definition citydlg.c:121
@ INFO_TRADE
Definition citydlg.c:119
@ INFO_AIRLIFT
Definition citydlg.c:122
@ INFO_GRANARY
Definition citydlg.c:120
@ INFO_FOOD
Definition citydlg.c:119
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2981
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3364
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2192
static void create_and_append_cma_page(struct city_dialog *pdialog)
Definition citydlg.c:1480
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:595
static gboolean supported_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2535
void close_cma_dialog(struct city *pcity)
Definition cma_fe.c:104
struct cma_dialog * create_cma_dialog(struct city *pcity, bool tiny)
Definition cma_fe.c:214
void refresh_cma_dialog(struct city *pcity, enum cma_refresh refresh)
Definition cma_fe.c:471
@ REFRESH_ALL
Definition cma_fe.h:26
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
GtkWidget * toplevel
Definition gui_main.c:125
GtkWidget * map_canvas
Definition gui_main.c:107
int screen_height(void)
Definition gui_main.c:2616
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
GtkWidget * icon_label_button_new(const gchar *icon_name, const gchar *label_text)
Definition gui_stuff.c:76
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void intl_slist(int n, const char **s, bool *done)
Definition gui_stuff.c:111
void close_happiness_dialog(struct city *pcity)
Definition happiness.c:330
void refresh_happiness_dialog(struct city *pcity)
Definition happiness.c:317
GtkWidget * get_top_happiness_display(struct city *pcity, bool low_dlg, GtkWidget *win)
Definition happiness.c:356
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
GtkWidget * input_dialog_create(GtkWindow *parent, const char *dialogname, const char *text, const char *postinputtest, input_dialog_callback_t response_callback, gpointer response_cli_data)
Definition inputdlg.c:66
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
bool request_transport(struct unit *cargo, struct tile *ptile)
void refresh_worklist(GtkWidget *editor)
Definition wldlg.c:1327
void add_worklist_dnd_target(GtkWidget *w)
Definition wldlg.c:339
void reset_city_worklist(GtkWidget *editor, struct city *pcity)
Definition wldlg.c:1279
GtkWidget * create_worklist(void)
Definition wldlg.c:1054
void refresh_all_city_worklists(void)
Definition citydlg.c:3627
static void canvas_draw_cb(GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
Definition citydlg.c:413
static gboolean right_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3143
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2653
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2454
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2699
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3114
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2718
static gboolean middle_supported_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2677
static gboolean citydlg_keyboard_handler(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
Definition citydlg.c:630
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
void put_unit_picture_city_overlays(struct unit *punit, GtkPicture *p, int height, int *upkeep_cost, int happy_cost)
Definition mapview.c:519
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:494
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
static SDL_Surface * info_label
Definition widget.c:57
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_WONDER
Definition helpdlg_g.h:21
int impr_sell_gold(const struct impr_type *pimprove)
enum test_result test_player_sell_building_now(struct player *pplayer, struct city *pcity, const struct impr_type *pimprove)
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
void center_tile_mapcanvas(const struct tile *ptile)
bool can_slide
#define fc_malloc(sz)
Definition mem.h:34
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:318
bool unit_can_load(const struct unit *punit)
Definition movement.c:884
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:675
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:674
int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options)
int len
Definition packhand.c:127
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1203
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
#define CLIP(lower, current, upper)
Definition shared.h:57
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
size_t size
Definition specvec.h:72
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
cairo_surface_t * surface
Definition canvas.h:23
GtkWidget * prev_command
Definition citydlg.c:208
struct city_dialog::@144 happiness
GtkWidget * name_label
Definition citydlg.c:141
struct city_dialog::@142 overview
GtkWidget * rename_shell
Definition citydlg.c:205
GtkWidget * rename_command
Definition citydlg.c:196
GtkWidget * production_bar
Definition citydlg.c:152
GtkWidget * supported_units_frame
Definition citydlg.c:157
GtkWidget * sell_shell
Definition citydlg.c:203
GtkWidget * production_label
Definition citydlg.c:173
GtkWidget * widget
Definition citydlg.c:182
GtkWidget * supported_unit_table
Definition citydlg.c:158
GtkWidget * disband_on_settler
Definition citydlg.c:198
struct city_map_canvas map_canvas
Definition citydlg.c:150
GtkWidget * improvement_list
Definition citydlg.c:155
GtkWidget * buy_command
Definition citydlg.c:154
short block_signal
Definition citydlg.c:200
GtkWidget * whichtab_radio[NUM_PAGES]
Definition citydlg.c:199
struct unit_node_vector supported_units
Definition citydlg.c:163
cairo_surface_t * map_canvas_store_unscaled
Definition citydlg.c:142
struct city * pcity
Definition citydlg.c:138
struct unit_node_vector present_units
Definition citydlg.c:164
city_map * view
Definition citydlg.h:450
GtkWidget * popover
Definition citydlg.c:146
GtkWidget * citizen_pics
Definition citydlg.c:147
struct city_dialog::@146 misc
GtkWidget * citizens
Definition citydlg.c:185
GtkWidget * show_units_command
Definition citydlg.c:207
Impr_type_id sell_id
Definition citydlg.c:211
GtkWidget * production_combo
Definition citydlg.c:153
enum city_dialog::@214 page
struct cma_dialog * cma_editor
Definition citydlg.c:193
cairo_surface_t * citizen_surface
Definition citydlg.c:147
GtkWidget * shell
Definition citydlg.c:140
GtkWidget * worklist
Definition citydlg.c:176
struct city_dialog::@143 production
GtkWidget * present_units_frame
Definition citydlg.c:160
GtkWidget * info_label[NUM_INFO_FIELDS]
Definition citydlg.c:167
GtkWidget * new_citizens_radio[3]
Definition citydlg.c:197
GtkListStore * change_production_store
Definition citydlg.c:169
GtkWidget * present_unit_table
Definition citydlg.c:161
GtkWidget * notebook
Definition citydlg.c:143
GtkWidget * next_command
Definition citydlg.c:209
GtkTreeSelection * change_selection
Definition citydlg.c:204
GtkWidget * darea
Definition citydlg.c:134
GtkWidget * sw
Definition citydlg.c:132
Definition city.h:320
struct worker_task_list * task_reqs
Definition city.h:412
int surplus[O_LAST]
Definition city.h:355
int food_stock
Definition city.h:367
int pollution
Definition city.h:369
int id
Definition city.h:326
int waste[O_LAST]
Definition city.h:356
struct unit_list * info_units_present
Definition city.h:474
struct player * owner
Definition city.h:323
struct unit_list * info_units_supported
Definition city.h:473
struct worklist worklist
Definition city.h:401
struct universal production
Definition city.h:396
int steal
Definition city.h:414
citizens size
Definition city.h:332
int illness
Definition city.h:434
int culture
Definition city.h:465
int buy_cost
Definition city.h:466
struct tile * tile
Definition city.h:322
int shield_stock
Definition city.h:368
int prod[O_LAST]
Definition city.h:358
struct unit_list * units_supported
Definition city.h:406
struct city::@17::@20 client
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
GtkWidget * shell
Definition cma_fe.h:33
struct city * pcity
Definition cma_fe.h:32
struct player * playing
Definition connection.h:151
Definition climisc.h:80
struct universal item
Definition climisc.h:81
char descr[MAX_LEN_NAME+40]
Definition climisc.h:82
enum unit_activity activity
struct city_list * cities
Definition player.h:281
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int height
Definition citydlg.c:98
GtkEventController * right
Definition citydlg.c:100
GtkWidget * cmd
Definition citydlg.c:96
GtkWidget * pix
Definition citydlg.c:97
GtkEventController * middle
Definition citydlg.c:99
GtkEventController * left
Definition citydlg.c:98
Definition unit.h:140
int upkeep[O_LAST]
Definition unit.h:150
enum unit_activity activity
Definition unit.h:159
int id
Definition unit.h:147
int homecity
Definition unit.h:148
enum universals_n kind
Definition fc_types.h:880
universals_u value
Definition fc_types.h:879
struct tile * ptile
Definition workertask.h:22
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * unit_description(struct unit *punit)
Definition text.c:488
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:111
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6822
int tileset_small_sprite_width(const struct tileset *t)
Definition tilespec.c:902
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:790
int tileset_small_sprite_height(const struct tileset *t)
Definition tilespec.c:938
int tileset_unit_with_upkeep_height(const struct tileset *t)
Definition tilespec.c:860
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6761
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6844
const struct unit_type * utype
Definition fc_types.h:698
const struct impr_type * building
Definition fc_types.h:691
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:492
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2499
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:386
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
#define unit_tile(_pu)
Definition unit.h:397
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
void economy_report_dialog_update(void)
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66