Freeciv-3.2
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-3.22 */
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 "repodlgs.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
99
100/* get 'struct unit_node' and related function */
101#define SPECVEC_TAG unit_node
102#define SPECVEC_TYPE struct unit_node
103#include "specvec.h"
104
105#define unit_node_vector_iterate(list, elt) \
106 TYPED_VECTOR_ITERATE(struct unit_node, list, elt)
107#define unit_node_vector_iterate_end VECTOR_ITERATE_END
108
109#define NUM_CITIZENS_SHOWN 30
110
113 NUM_PAGES /* the number of pages in city dialog notebook
114 * must match the entries in misc_whichtab_label[] */
116
117enum {
122 NUM_INFO_FIELDS /* number of fields in city_info panel
123 * must match entries in output_label[] */
125
126/* minimal size for the city map scrolling windows*/
127#define CITY_MAP_MIN_SIZE_X 200
128#define CITY_MAP_MIN_SIZE_Y 150
129
135
137 struct city *pcity;
138
143
147
148 struct {
150
155
158
161
162 struct unit_node_vector supported_units;
163 struct unit_node_vector present_units;
164
167
170
171 struct {
173 GtkWidget *production_bar;
174 GtkWidget *buy_command;
177
178 struct {
180
186
188
189 struct {
191 GtkWidget *new_citizens_radio[3];
193 GtkWidget *whichtab_radio[NUM_PAGES];
196
200
204
206
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);
235 struct city_dialog *pdialog);
236
237static GtkWidget *create_city_info_table(struct city_dialog *pdialog,
240static void create_and_append_overview_page(struct city_dialog *pdialog);
241static void create_and_append_map_page(struct city_dialog *pdialog);
242static void create_and_append_buildings_page(struct city_dialog *pdialog);
243static void create_and_append_worklist_page(struct city_dialog *pdialog);
244static void create_and_append_happiness_page(struct city_dialog *pdialog);
245static void create_and_append_cma_page(struct city_dialog *pdialog);
246static void create_and_append_settings_page(struct city_dialog *pdialog);
247
248static struct city_dialog *create_city_dialog(struct city *pcity);
249
250static void city_dialog_update_title(struct city_dialog *pdialog);
251static void city_dialog_update_citizens(struct city_dialog *pdialog);
254 struct city_dialog *pdialog);
255static void city_dialog_update_map(struct city_dialog *pdialog);
256static void city_dialog_update_building(struct city_dialog *pdialog);
258 *pdialog);
260 *pdialog);
261static void city_dialog_update_present_units(struct city_dialog *pdialog);
262static void city_dialog_update_prev_next(void);
263
264static void show_units_response(void *data);
265
267 gpointer data);
269 gpointer data);
272 gpointer data);
275 gpointer data);
276
277static void unit_center_callback(GtkWidget * w, gpointer data);
278static void unit_activate_callback(GtkWidget * w, gpointer data);
280 gpointer data);
282 gpointer data);
283static void unit_load_callback(GtkWidget * w, gpointer data);
284static void unit_unload_callback(GtkWidget * w, gpointer data);
285static void unit_sentry_callback(GtkWidget * w, gpointer data);
286static void unit_fortify_callback(GtkWidget * w, gpointer data);
287static void unit_disband_callback(GtkWidget * w, gpointer data);
288static void unit_homecity_callback(GtkWidget * w, gpointer data);
289static void unit_upgrade_callback(GtkWidget * w, gpointer data);
290
292 gpointer data);
294 gpointer data);
295static void draw_map_canvas(struct city_dialog *pdialog);
296
297static void buy_callback(GtkWidget * w, gpointer data);
298static void change_production_callback(GtkComboBox *combo,
299 struct city_dialog *pdialog);
300
301static void sell_callback(struct impr_type *pimprove, gpointer data);
302static void sell_callback_response(GtkWidget *w, gint response, gpointer data);
303
304static void impr_callback(GtkTreeView *view, GtkTreePath *path,
306
307static void rename_callback(GtkWidget * w, gpointer data);
308static void rename_popup_callback(gpointer data, gint response,
309 const char *input);
310static void set_cityopt_values(struct city_dialog *pdialog);
311static void cityopt_callback(GtkWidget * w, gpointer data);
312static void misc_whichtab_callback(GtkWidget * w, gpointer data);
313
314static void city_destroy_callback(GtkWidget *w, gpointer data);
315static void close_city_dialog(struct city_dialog *pdialog);
316static void citydlg_response_callback(GtkDialog *dlg, gint response,
317 void *data);
318static void close_callback(GtkWidget *w, gpointer data);
319static void switch_city_callback(GtkWidget *w, gpointer data);
320
321/**********************************************************************/
330
331/**********************************************************************/
334static void initialize_city_dialogs(void)
335{
336 int height;
337
339
343
344 /* Use default layout when height cannot be determined
345 * (when height == 0) */
346 if (height > 0 && height <= TINYSCREEN_MAX_HEIGHT) {
348 } else {
350 }
351
353}
354
355/**********************************************************************/
359{
361 return;
362 }
363
365
367 /* There's no reasonable way to resize a GtkImage, so we don't try.
368 Instead we just redraw the overview within the existing area. The
369 player has to close and reopen the dialog to fix this. */
370 city_dialog_update_map(pdialog);
372
374}
375
376/**********************************************************************/
380static struct city_dialog *get_city_dialog(struct city *pcity)
381{
384 }
385
387 if (pdialog->pcity == pcity)
388 return pdialog;
389 }
391 return NULL;
392}
393
394/**********************************************************************/
398 gpointer data)
399{
400 struct city_dialog *pdialog = data;
401
404 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
405 cairo_paint_with_alpha(cr, 0.5);
406 } else {
407 cairo_paint(cr);
408 }
409
410 return TRUE;
411}
412
413/**********************************************************************/
451
452/**********************************************************************/
476
477/**********************************************************************/
481{
482 struct city_dialog *pdialog = get_city_dialog(pcity);
483
484 log_debug("CITYMAP_WIDTH: %d", CITYMAP_WIDTH);
485 log_debug("CITYMAP_HEIGHT: %d", CITYMAP_HEIGHT);
486 log_debug("CITYMAP_SCALE: %.3f", CITYMAP_SCALE);
487
491 }
492
493 if (!pdialog) {
494 return;
495 }
496
500 pdialog->overview.info_label, pdialog);
501 city_dialog_update_map(pdialog);
506
509
511
512 if (!low_citydlg) {
514 pdialog->happiness.info_label, pdialog);
515 }
519 }
520
521 if (!client_is_observer()) {
523 }
524
528 } else {
529 /* Set the buttons we do not want live while a Diplomat investigates */
531 }
532}
533
534/**********************************************************************/
539{
540 struct city *pcity_sup, *pcity_pre;
541 struct city_dialog *pdialog;
542
545
546 if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
548 }
549
550 if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
552 }
553}
554
555/**********************************************************************/
559{
560 struct city_dialog *pdialog;
561
562 if (!(pdialog = get_city_dialog(pcity))) {
563 pdialog = create_city_dialog(pcity);
564 }
565
567
568 /* center the city map(s); this must be *after* the city dialog was drawn
569 * else the size information is missing! */
571 if (pdialog->happiness.map_canvas.sw) {
573 }
574}
575
576/**********************************************************************/
580{
581 return get_city_dialog(pcity) != NULL;
582}
583
584/**********************************************************************/
588{
589 struct city_dialog *pdialog = get_city_dialog(pcity);
590
591 if (pdialog) {
592 close_city_dialog(pdialog);
593 }
594}
595
596/**********************************************************************/
612
613/**********************************************************************/
617 struct city_dialog *pdialog)
618{
619 if (event->state & GDK_CONTROL_MASK) {
620 switch (event->keyval) {
621 case GDK_KEY_Left:
623 return TRUE;
624
625 case GDK_KEY_Right:
627 return TRUE;
628
629 default:
630 break;
631 }
632 }
633
634 return FALSE;
635}
636
637/**********************************************************************/
649
650/**********************************************************************/
654 gpointer data)
655{
656 struct city_dialog *pdialog = g_object_get_data(G_OBJECT(w), "pdialog");
657
658 if (ev->button == 1) {
659 GtkWidget *p, *label, *frame;
660 char buf[1024];
661
662 switch (GPOINTER_TO_UINT(data)) {
663 case INFO_SIZE:
664 fc_snprintf(buf, sizeof(buf), _("Population: %d, Specialists: %d"),
665 pdialog->pcity->size, city_specialists(pdialog->pcity));
666 break;
667 case INFO_FOOD:
668 get_city_dialog_output_text(pdialog->pcity, O_FOOD, buf, sizeof(buf));
669 break;
670 case INFO_SHIELD:
672 buf, sizeof(buf));
673 break;
674 case INFO_TRADE:
675 get_city_dialog_output_text(pdialog->pcity, O_TRADE, buf, sizeof(buf));
676 break;
677 case INFO_GOLD:
678 get_city_dialog_output_text(pdialog->pcity, O_GOLD, buf, sizeof(buf));
679 break;
680 case INFO_SCIENCE:
682 buf, sizeof(buf));
683 break;
684 case INFO_LUXURY:
686 buf, sizeof(buf));
687 break;
688 case INFO_CULTURE:
689 get_city_dialog_culture_text(pdialog->pcity, buf, sizeof(buf));
690 break;
691 case INFO_POLLUTION:
692 get_city_dialog_pollution_text(pdialog->pcity, buf, sizeof(buf));
693 break;
694 case INFO_ILLNESS:
695 get_city_dialog_illness_text(pdialog->pcity, buf, sizeof(buf));
696 break;
697 case INFO_AIRLIFT:
698 get_city_dialog_airlift_text(pdialog->pcity, buf, sizeof(buf));
699 break;
700 default:
701 return TRUE;
702 }
703
705 gtk_widget_set_name(p, "Freeciv");
709
710 frame = gtk_frame_new(NULL);
712
713 label = gtk_label_new(buf);
714 gtk_widget_set_name(label, "city_label");
719 gtk_container_add(GTK_CONTAINER(frame), label);
721
724 TRUE, NULL, (GdkEvent *)ev, NULL, NULL);
725 gtk_grab_add(p);
726
727 g_signal_connect_after(p, "button_release_event",
729 }
730 return TRUE;
731}
732
733/**********************************************************************/
740{
741 int i;
742 GtkWidget *table, *label, *ebox;
743
744 static const char *output_label[NUM_INFO_FIELDS] = {
745 N_("Size:"),
746 N_("Food:"),
747 N_("Prod:"),
748 N_("Trade:"),
749 N_("Gold:"),
750 N_("Luxury:"),
751 N_("Science:"),
752 N_("Granary:"),
753 N_("Change in:"),
754 N_("Corruption:"),
755 N_("Waste:"),
756 N_("Culture:"),
757 N_("Pollution:"),
758 N_("Plague risk:"),
759 N_("Tech Stolen:"),
760 N_("Airlift:"),
761 };
762 static bool output_label_done;
763
765 g_object_set(table, "margin", 4, NULL);
766
768
769 for (i = 0; i < NUM_INFO_FIELDS; i++) {
770 label = gtk_label_new(output_label[i]);
771 switch (i) {
772 case INFO_SIZE:
773 case INFO_TRADE:
774 case INFO_SCIENCE:
775 case INFO_GROWTH:
777 break;
778
779 case INFO_FOOD:
780 case INFO_GOLD:
781 case INFO_GRANARY:
782 case INFO_CORRUPTION:
784 break;
785 default:
786 break;
787 }
789 gtk_widget_set_name(label, "city_label"); /* for font style? */
792 gtk_grid_attach(GTK_GRID(table), label, 0, i, 1, 1);
793
794 ebox = gtk_event_box_new();
795 switch (i) {
796 case INFO_TRADE:
797 case INFO_SCIENCE:
798 case INFO_GROWTH:
800 break;
801
802 case INFO_GOLD:
803 case INFO_GRANARY:
804 case INFO_CORRUPTION:
806 break;
807 default:
808 break;
809 }
811 g_object_set_data(G_OBJECT(ebox), "pdialog", pdialog);
812 g_signal_connect(ebox, "button_press_event",
814 info_ebox[i] = ebox;
815
816 label = gtk_label_new("");
817 info_label[i] = label;
818 gtk_widget_set_name(label, "city_label"); /* ditto */
821
822 gtk_container_add(GTK_CONTAINER(ebox), label);
823
824 gtk_grid_attach(GTK_GRID(table), ebox, 1, i, 1, 1);
825 }
826
827 /*
828 * Allow special highlighting of emergencies for granary etc by
829 * city_dialog_update_information().
830 */
831 {
832 /* This will persist, and can be shared between overview and happiness
833 * pages. */
835
836 if (emergency_provider == NULL) {
838
840 ".emergency {\n"
841 " color: rgba(255, 0.0, 0.0, 255);\n"
842 "}",
843 -1, NULL);
844 }
845
846 /* GRANARY */
850 /* GROWTH */
854 /* POLLUTION */
858 /* ILLNESS */
862 }
863
865
866 return table;
867}
868
869/**********************************************************************/
872static void create_citydlg_main_map(struct city_dialog *pdialog,
874{
875 GtkWidget *frame;
876
877 frame = gtk_frame_new(_("City map"));
881
882 city_dialog_map_create(pdialog, &pdialog->overview.map_canvas);
884}
885
886/**********************************************************************/
890 GtkWidget *vbox)
891{
893 GtkListStore *store;
895
896 /* improvements */
897 /* gtk list store columns: 0 - sell value, 1 - sprite,
898 2 - description, 3 - upkeep, 4 - is redundant, 5 - tooltip */
902
906 g_object_unref(store);
908 gtk_widget_set_name(view, "small_font");
909 pdialog->overview.improvement_list = view;
910
913 rend, "pixbuf", 1, NULL);
916 rend, "text", 2,
917 "strikethrough", 4, NULL);
919 g_object_set(rend, "xalign", 1.0, NULL);
921 rend, "text", 3,
922 "strikethrough", 4, NULL);
923
925
927 pdialog);
928
929 return view;
930}
931
932/**********************************************************************/
949{
951 GtkWidget *hbox, *right, *vbox, *frame, *table;
952 GtkWidget *label, *sw, *view, *bar, *production_combo;
955 /* TRANS: Overview tab in city dialog */
956 const char *tab_title = _("_Overview");
958
959 /* main page */
960 page = gtk_grid_new();
966
967 if (!low_citydlg) {
968 GtkWidget *middle;
969
970 /* middle: city map, improvements */
971 middle = gtk_grid_new();
974
975 /* city map */
976 create_citydlg_main_map(pdialog, middle);
977
978 /* improvements */
979 vbox = gtk_grid_new();
982 gtk_container_add(GTK_CONTAINER(middle), vbox);
983
984 view = create_citydlg_improvement_list(pdialog, middle);
985
986 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
987 "xalign", 0.0, "yalign", 0.5, NULL);
988 gtk_container_add(GTK_CONTAINER(vbox), label);
989
990 hbox = gtk_grid_new();
993
997
1006
1011 rend, "pixbuf", 0, NULL);
1012 g_object_set(rend, "xalign", 0.0, NULL);
1013
1017 rend, "text", 1, "strikethrough", 3, NULL);
1018
1019 bar = gtk_progress_bar_new();
1021 pdialog->overview.production_bar = bar;
1024
1025 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1026
1027 pdialog->overview.buy_command
1028 = icon_label_button_new("system-run", _("_Buy"));
1030 g_signal_connect(pdialog->overview.buy_command, "clicked",
1031 G_CALLBACK(buy_callback), pdialog);
1032
1033 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1034 "mnemonic-widget", view,
1035 "label", _("I_mprovements:"),
1036 "xalign", 0.0, "yalign", 0.5, NULL);
1037 gtk_container_add(GTK_CONTAINER(vbox), label);
1038
1045
1047 } else {
1048 pdialog->overview.buy_command = NULL;
1049 pdialog->overview.production_bar = NULL;
1050 pdialog->overview.production_combo = NULL;
1052 }
1053
1054 /* bottom: info, units */
1055 bottom = gtk_grid_new();
1058
1059 /* info */
1060 frame = gtk_frame_new(_("Info"));
1062
1063 table = create_city_info_table(pdialog,
1064 pdialog->overview.info_ebox,
1065 pdialog->overview.info_label);
1069
1070 /* right: present and supported units (overview page) */
1071 right = gtk_grid_new();
1075
1081 pdialog->overview.present_units_frame);
1082
1083 /* supported units */
1091 sw);
1092
1093
1094 table = gtk_grid_new();
1098
1103
1106
1107 /* present units */
1115
1116 table = gtk_grid_new();
1120
1125
1128
1129 /* show page */
1131}
1132
1133/**********************************************************************/
1136static void create_and_append_map_page(struct city_dialog *pdialog)
1137{
1138 if (low_citydlg) {
1139 GtkWidget *page;
1140 GtkWidget *label;
1141 const char *tab_title = _("Citymap");
1142
1143 page = gtk_grid_new();
1149
1150 create_citydlg_main_map(pdialog, page);
1151
1153 }
1154}
1155
1156/**********************************************************************/
1161 gint x, gint y,
1162 GtkSelectionData *data,
1163 guint info, guint time,
1164 gpointer user_data)
1165{
1166 struct city_dialog *pdialog = (struct city_dialog *) user_data;
1167 GtkTreeModel *model;
1168 GtkTreePath *path;
1169
1170 if (NULL != client.conn.playing
1171 && city_owner(pdialog->pcity) != client.conn.playing) {
1173 }
1174
1175 if (gtk_tree_get_row_drag_data(data, &model, &path)) {
1176 GtkTreeIter it;
1177
1178 if (gtk_tree_model_get_iter(model, &it, path)) {
1179 cid id;
1180 struct universal univ;
1181
1182 gtk_tree_model_get(model, &it, 0, &id, -1);
1183 univ = cid_production(id);
1184 city_change_production(pdialog->pcity, &univ);
1186 }
1187 gtk_tree_path_free(path);
1188 }
1189
1191}
1192
1193/**********************************************************************/
1198{
1199 GtkWidget *hbox, *bar;
1200
1201 hbox = gtk_grid_new();
1202 g_object_set(hbox, "margin", 2, NULL);
1205
1206 /* The label is set in city_dialog_update_building() */
1207 bar = gtk_progress_bar_new();
1210 pdialog->production.production_bar = bar;
1212 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1213
1215
1216 g_signal_connect(bar, "drag_data_received",
1218
1219 pdialog->production.buy_command
1220 = icon_label_button_new("system-run", _("_Buy"));
1222
1223 g_signal_connect(pdialog->production.buy_command, "clicked",
1224 G_CALLBACK(buy_callback), pdialog);
1225}
1226
1227/**********************************************************************/
1231{
1232 if (low_citydlg) {
1233 GtkWidget *page;
1234 GtkWidget *label;
1235 GtkWidget *vbox;
1236 GtkWidget *view;
1237 const char *tab_title = _("Buildings");
1238
1239 page = gtk_grid_new();
1244
1246 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1247
1248 vbox = gtk_grid_new();
1251 gtk_container_add(GTK_CONTAINER(page), vbox);
1252
1253 view = create_citydlg_improvement_list(pdialog, vbox);
1254
1256
1257 gtk_widget_show_all(page);
1258 }
1259}
1260
1261/**********************************************************************/
1265{
1266 const char *tab_title = _("P_roduction");
1268 GtkWidget *page, *editor;
1269
1270 page = gtk_grid_new();
1274 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1275
1276 /* stuff that's being currently built */
1277 if (!low_citydlg) {
1279 "label", _("Production:"),
1280 "xalign", 0.0, "yalign", 0.5, NULL);
1281 pdialog->production.production_label = label;
1282 gtk_container_add(GTK_CONTAINER(page), label);
1283
1285 } else {
1286 pdialog->production.production_label = NULL;
1287 }
1288
1290 g_object_set(editor, "margin", 6, NULL);
1291 reset_city_worklist(editor, pdialog->pcity);
1293 pdialog->production.worklist = editor;
1294
1295 gtk_widget_show_all(page);
1296}
1297
1298/**********************************************************************/
1309{
1310 GtkWidget *page, *label, *table, *right, *left, *frame;
1311 const char *tab_title = _("Happ_iness");
1312
1313 /* main page */
1314 page = gtk_grid_new();
1318 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1319
1320 /* left: info, citizens */
1321 left = gtk_grid_new();
1324 gtk_container_add(GTK_CONTAINER(page), left);
1325
1326 if (!low_citydlg) {
1327 /* upper left: info */
1328 frame = gtk_frame_new(_("Info"));
1329 gtk_container_add(GTK_CONTAINER(left), frame);
1330
1331 table = create_city_info_table(pdialog,
1332 pdialog->happiness.info_ebox,
1333 pdialog->happiness.info_label);
1336 }
1337
1338 /* lower left: citizens */
1340 pdialog->happiness.citizens = gtk_grid_new();
1346 citizens_dialog_display(pdialog->pcity));
1347 }
1348
1349 /* right: city map, happiness */
1350 right = gtk_grid_new();
1353 gtk_container_add(GTK_CONTAINER(page), right);
1354
1355 if (!low_citydlg) {
1356 /* upper right: city map */
1357 frame = gtk_frame_new(_("City map"));
1360 gtk_container_add(GTK_CONTAINER(right), frame);
1361
1362 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1364 }
1365
1366 /* lower right: happiness */
1367 pdialog->happiness.widget = gtk_grid_new();
1372 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
1373
1374 /* show page */
1375 gtk_widget_show_all(page);
1376}
1377
1378/**********************************************************************/
1381static void create_and_append_cma_page(struct city_dialog *pdialog)
1382{
1383 GtkWidget *page, *label;
1384 const char *tab_title = _("_Governor");
1385
1386 page = gtk_grid_new();
1387
1389
1390 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1391
1392 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1394
1395 gtk_widget_show(page);
1396}
1397
1398/**********************************************************************/
1402{
1403 int i;
1404 GtkWidget *vbox2, *page, *frame, *label, *button;
1406 GSList *group;
1407 const char *tab_title = _("_Settings");
1408
1409 static const char *new_citizens_output_label[] = {
1410 N_("Luxury"),
1411 N_("Science"),
1412 N_("Gold")
1413 };
1414
1415 static const char *disband_label
1416 = N_("Allow unit production to disband city");
1417
1418 static const char *misc_whichtab_label[NUM_PAGES] = {
1419 N_("Overview page"),
1420 N_("Production page"),
1421 N_("Happiness page"),
1422 N_("Governor page"),
1423 N_("This Settings page"),
1424 N_("Last active page")
1425 };
1426
1427 static bool new_citizens_label_done;
1428 static bool misc_whichtab_label_done;
1429
1430 /* initialize signal_blocker */
1431 pdialog->misc.block_signal = 0;
1432
1433
1434 page = gtk_grid_new();
1437
1439
1441
1442 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1443
1444 /* new_citizens radio */
1445 frame = gtk_frame_new(_("New citizens produce"));
1446 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1448
1449 vbox2 = gtk_grid_new();
1453
1456
1457 group = NULL;
1458 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1460 pdialog->misc.new_citizens_radio[i] = button;
1462 g_signal_connect(button, "toggled",
1463 G_CALLBACK(cityopt_callback), pdialog);
1465 }
1466
1467 /* next is the next-time-open radio group in the right column */
1468 frame = gtk_frame_new(_("Next time open"));
1469 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1471
1472 vbox2 = gtk_grid_new();
1476
1479
1480 group = NULL;
1481 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1483 pdialog->misc.whichtab_radio[i] = button;
1485 g_signal_connect(button, "toggled",
1488 }
1489
1490 /* now we go back and fill the hbox rename */
1491 frame = gtk_frame_new(_("City"));
1492 gtk_widget_set_margin_top(frame, 12);
1494 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1495
1496 vbox2 = gtk_grid_new();
1500
1501 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1502 pdialog->misc.rename_command = button;
1504 g_signal_connect(button, "clicked",
1505 G_CALLBACK(rename_callback), pdialog);
1506
1508
1509 /* the disband-city-on-unit-production button */
1511 pdialog->misc.disband_on_settler = button;
1513 g_signal_connect(button, "toggled",
1514 G_CALLBACK(cityopt_callback), pdialog);
1515
1516 /* we choose which page to popup by default */
1518 (pdialog->
1520 TRUE);
1521
1522 set_cityopt_values(pdialog);
1523
1524 gtk_widget_show_all(page);
1525
1526 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1528 last_page);
1529 } else {
1532 }
1533}
1534
1535/**********************************************************************/
1544{
1545 struct city_dialog *pdialog;
1547 GtkWidget *vbox, *hbox, *cbox, *ebox;
1550 struct player *owner;
1551
1554 }
1555
1556 pdialog = fc_malloc(sizeof(struct city_dialog));
1557 pdialog->pcity = pcity;
1558 pdialog->sell_shell = NULL;
1559 pdialog->rename_shell = NULL;
1560 pdialog->happiness.map_canvas.sw = NULL; /* make sure NULL if spy */
1561 pdialog->happiness.map_canvas.ebox = NULL; /* ditto */
1562 pdialog->happiness.map_canvas.darea = NULL; /* ditto */
1563 pdialog->happiness.citizens = NULL; /* ditto */
1564 pdialog->production.buy_command = NULL;
1565 pdialog->production.production_label = NULL;
1566 pdialog->production.production_bar = NULL;
1567 pdialog->cma_editor = NULL;
1571
1572 pdialog->shell = gtk_dialog_new();
1574 setup_dialog(pdialog->shell, toplevel);
1575 gtk_window_set_role(GTK_WINDOW(pdialog->shell), "city");
1576
1577 g_signal_connect(pdialog->shell, "destroy",
1580 gtk_widget_set_name(pdialog->shell, "Freeciv");
1581
1582 gtk_widget_realize(pdialog->shell);
1583
1584 /* keep the icon of the executable on Windows (see PR#36491) */
1585#ifndef FREECIV_MSWINDOWS
1586 {
1588
1589 /* Only call this after tileset_load_tiles is called. */
1592 }
1593#endif /* FREECIV_MSWINDOWS */
1594
1595 /* Restore size of the city dialog. */
1599
1600 pdialog->popup_menu = gtk_menu_new();
1601
1603 hbox = gtk_grid_new();
1606
1607 /**** Citizens bar here ****/
1608 cbox = gtk_grid_new();
1610
1611 ebox = gtk_event_box_new();
1613 gtk_container_add(GTK_CONTAINER(cbox), ebox);
1614
1617
1621
1630 g_signal_connect(G_OBJECT(ebox), "button-press-event",
1631 G_CALLBACK(citizens_callback), pdialog);
1632
1633 /**** City name label here ****/
1634 pdialog->name_label = gtk_label_new(NULL);
1639
1640 /**** -Start of Notebook- ****/
1641
1642 pdialog->notebook = gtk_notebook_new();
1645 gtk_container_add(GTK_CONTAINER(vbox), pdialog->notebook);
1646
1650
1651 owner = city_owner(pcity);
1652
1653 /* Only create these tabs if not a spy */
1657 }
1658
1659 if (owner == client_player()
1660 && !client_is_observer()) {
1663 } else {
1666 }
1667
1668 /**** End of Notebook ****/
1669
1670 /* bottom buttons */
1671
1672 pdialog->show_units_command =
1673 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1674
1675 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1677
1678 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous", 0);
1680 GTK_WIDGET(pdialog->prev_command), 1);
1681
1682 pdialog->next_command = gtk_button_new_from_icon_name("go-next", 0);
1684 GTK_WIDGET(pdialog->next_command), 2);
1685
1686 if (owner != client_player()) {
1689 }
1690
1692 _("_Close"), GTK_RESPONSE_CLOSE);
1693
1696
1698 G_CALLBACK(close_callback), pdialog);
1699
1700 g_signal_connect(pdialog->prev_command, "clicked",
1702
1703 g_signal_connect(pdialog->next_command, "clicked",
1705
1706 /* some other things we gotta do */
1707
1708 g_signal_connect(pdialog->shell, "key_press_event",
1709 G_CALLBACK(keyboard_handler), pdialog);
1710
1712
1714
1715 /* need to do this every time a new dialog is opened. */
1717
1718 gtk_widget_show_all(pdialog->shell);
1719
1721
1722 return pdialog;
1723}
1724
1725/**************** Functions to update parts of the dialog ****************/
1726/**********************************************************************/
1729static void city_dialog_update_title(struct city_dialog *pdialog)
1730{
1731 gchar *buf;
1732 const gchar *now;
1733
1734 if (city_unhappy(pdialog->pcity)) {
1735 /* TRANS: city dialog title */
1736 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
1737 city_name_get(pdialog->pcity),
1739 } else if (city_celebrating(pdialog->pcity)) {
1740 /* TRANS: city dialog title */
1741 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
1742 city_name_get(pdialog->pcity),
1744 } else if (city_happy(pdialog->pcity)) {
1745 /* TRANS: city dialog title */
1746 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
1747 city_name_get(pdialog->pcity),
1749 } else {
1750 /* TRANS: city dialog title */
1751 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
1752 city_name_get(pdialog->pcity),
1754 }
1755
1757 if (strcmp(now, buf) != 0) {
1760 }
1761
1762 g_free(buf);
1763}
1764
1765/**********************************************************************/
1768static void city_dialog_update_citizens(struct city_dialog *pdialog)
1769{
1770 enum citizen_category categories[MAX_CITY_SIZE];
1773 struct city *pcity = pdialog->pcity;
1774 int num_citizens = get_city_citizen_types(pcity, FEELING_FINAL, categories);
1775 cairo_t *cr;
1776
1777 /* If there is not enough space we stack the icons. We draw from left to */
1778 /* right. width is how far we go to the right for each drawn pixmap. The */
1779 /* last icon is always drawn in full, and so has reserved */
1780 /* tileset_small_sprite_width(tileset) pixels. */
1781
1783 if (num_citizens > 1) {
1785 / (num_citizens - 1));
1786 } else {
1787 width = full_width;
1788 }
1789 pdialog->cwidth = width;
1790
1791 /* overview page */
1792 /* keep these values in sync with create_city_dialog */
1795
1796 cr = cairo_create(pdialog->citizen_surface);
1797
1798 for (i = 0; i < num_citizens; i++) {
1800 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
1801 i * width, 0);
1802 cairo_rectangle(cr, i * width, 0,
1803 /* Always draw last citizen in full */
1804 i + 1 < num_citizens ? width : full_width,
1806 cairo_fill(cr);
1807 }
1808
1809 total_used_width = (i - 1) * width + full_width;
1810
1812 /* Clear the rest of the area.
1813 * Note that this might still be necessary even in cases where
1814 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
1815 * divided perfectly. */
1820 cairo_fill(cr);
1821 }
1822
1823 cairo_destroy(cr);
1824
1826}
1827
1828/**********************************************************************/
1833 struct city_dialog *pdialog)
1834{
1835 int i, illness = 0;
1836 char buf[NUM_INFO_FIELDS][512];
1837 struct city *pcity = pdialog->pcity;
1838 int granaryturns;
1839 int non_workers = city_specialists(pcity);
1840
1841 /* fill the buffers with the necessary info */
1842 if (non_workers) {
1843 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
1844 pcity->size, non_workers);
1845 } else {
1846 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
1847 }
1848 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
1849 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
1850 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
1851 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
1852 pcity->surplus[O_SHIELD]);
1853 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
1854 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
1855 pcity->surplus[O_TRADE]);
1856 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
1857 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
1858 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
1859 pcity->prod[O_LUXURY]);
1860 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
1861 pcity->prod[O_SCIENCE]);
1862 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
1864
1866 if (granaryturns == 0) {
1867 /* TRANS: city growth is blocked. Keep short. */
1868 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
1869 } else if (granaryturns == FC_INFINITY) {
1870 /* TRANS: city is not growing. Keep short. */
1871 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
1872 } else {
1873 /* A negative value means we'll have famine in that many turns.
1874 But that's handled down below. */
1875 /* TRANS: city growth turns. Keep short. */
1877 PL_("%d turn", "%d turns", abs(granaryturns)),
1878 abs(granaryturns));
1879 }
1881 pcity->waste[O_TRADE]);
1882 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
1883 pcity->waste[O_SHIELD]);
1884 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
1885 pcity->client.culture);
1887 pcity->pollution);
1888 if (!game.info.illness_on) {
1889 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
1890 } else {
1892 /* illness is in tenth of percent */
1893 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
1894 (float)illness / 10.0);
1895 }
1896 if (pcity->steal) {
1897 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
1898 pcity->steal);
1899 } else {
1900 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
1901 }
1902
1904
1905 /* stick 'em in the labels */
1906 for (i = 0; i < NUM_INFO_FIELDS; i++) {
1908 }
1909
1910 /*
1911 * Make use of the emergency-indicating styles set up for certain labels
1912 * in create_city_info_table().
1913 */
1914 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
1915 * of a warning. */
1916 if (granaryturns > -4 && granaryturns < 0) {
1918 } else {
1920 }
1921
1922 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
1924 } else {
1926 }
1927
1928 /* someone could add the color &orange for better granularity here */
1929 if (pcity->pollution >= 10) {
1931 } else {
1933 }
1934
1935 /* illness is in tenth of percent, i.e 100 == 10.0% */
1936 if (illness >= 100) {
1938 } else {
1940 }
1941}
1942
1943/**********************************************************************/
1946static void city_dialog_update_map(struct city_dialog *pdialog)
1947{
1948 struct canvas store = FC_STATIC_CANVAS_INIT;
1949
1950 store.surface = pdialog->map_canvas_store_unscaled;
1951
1952 /* The drawing is done in three steps.
1953 * 1. First we render to a pixmap with the appropriate canvas size.
1954 * 2. Then the pixmap is rendered into a pixbuf of equal size.
1955 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
1956 * target pixbuf.
1957 */
1958
1959 city_dialog_redraw_map(pdialog->pcity, &store);
1960
1961 /* draw to real window */
1962 draw_map_canvas(pdialog);
1963}
1964
1965/**********************************************************************/
1968static void city_dialog_update_building(struct city_dialog *pdialog)
1969{
1970 char buf[32], buf2[200];
1971 gdouble pct;
1972
1973 GtkListStore* store;
1975 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
1976 struct item items[MAX_NUM_PRODUCTION_TARGETS];
1977 int targets_used, item;
1978 struct city *pcity = pdialog->pcity;
1980 const char *descr = city_production_name_translation(pcity);
1982
1983 if (pdialog->overview.buy_command != NULL) {
1985 }
1986 if (pdialog->production.buy_command != NULL) {
1988 }
1989
1990 /* Make sure build slots info is up to date */
1991 if (pdialog->production.production_label != NULL) {
1992 int build_slots = city_build_slots(pcity);
1993
1994 /* Only display extra info if more than one slot is available */
1995 if (build_slots > 1) {
1996 fc_snprintf(buf2, sizeof(buf2),
1997 /* TRANS: never actually used with built_slots <= 1 */
1998 PL_("Production (up to %d unit per turn):",
1999 "Production (up to %d units per turn):", build_slots),
2000 build_slots);
2003 } else {
2005 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2006 }
2007 }
2008
2009 /* Update what the city is working on */
2010 get_city_dialog_production(pcity, buf, sizeof(buf));
2011
2012 if (cost > 0) {
2013 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2014 pct = CLAMP(pct, 0.0, 1.0);
2015 } else {
2016 pct = 1.0;
2017 }
2018
2019 if (pdialog->overview.production_bar != NULL) {
2020 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2021 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2026 }
2027
2028 if (pdialog->production.production_bar != NULL) {
2029 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2030 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2035 }
2036
2037 if (pdialog->overview.production_combo != NULL) {
2039 -1);
2040 }
2041
2042 store = pdialog->overview.change_production_store;
2043 if (store != NULL) {
2045
2047 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2048 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2049
2050 for (item = 0; item < targets_used; item++) {
2051 if (can_city_build_now(pcity, &items[item].item)) {
2052 const char *name;
2053 struct sprite* sprite;
2054 GdkPixbuf *pix;
2055 struct universal target = items[item].item;
2056 bool useless;
2057
2058 if (VUT_UTYPE == target.kind) {
2063 useless = FALSE;
2064 } else {
2068 }
2070 gtk_list_store_append(store, &iter);
2071 gtk_list_store_set(store, &iter, 0, pix,
2072 1, name, 3, useless,
2073 2, (gint)cid_encode(items[item].item), -1);
2075 }
2076 }
2077 }
2078
2079 /* work around GTK+ refresh bug. */
2080 if (pdialog->overview.production_bar != NULL) {
2082 }
2083 if (pdialog->production.production_bar != NULL) {
2085 }
2086}
2087
2088/**********************************************************************/
2092{
2093 int item, targets_used;
2094 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2095 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2096 GtkTreeModel *model;
2097 GtkListStore *store;
2098
2099 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2100 "sell an improvement.");
2101 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2102 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2103
2104 model =
2106 store = GTK_LIST_STORE(model);
2107
2109 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2110
2111 gtk_list_store_clear(store);
2112
2113 for (item = 0; item < targets_used; item++) {
2114 GdkPixbuf *pix;
2115 GtkTreeIter it;
2116 int upkeep;
2117 struct sprite *sprite;
2118 struct universal target = items[item].item;
2119
2120 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2121 /* This takes effects (like Adam Smith's) into account. */
2122 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2124
2126 gtk_list_store_append(store, &it);
2127 gtk_list_store_set(store, &it,
2128 0, target.value.building,
2129 1, pix,
2130 2, items[item].descr,
2131 3, upkeep,
2132 4,
2134 target.value.building),
2135 5,
2138 (is_small_wonder(target.value.building) ?
2140 -1);
2142 }
2143}
2144
2145/**********************************************************************/
2149{
2150 struct unit_list *units;
2151 struct unit_node_vector *nodes;
2152 int n, m, i;
2153 gchar *buf;
2155
2156 if (NULL != client.conn.playing
2157 && city_owner(pdialog->pcity) != client.conn.playing) {
2158 units = pdialog->pcity->client.info_units_supported;
2159 } else {
2160 units = pdialog->pcity->units_supported;
2161 }
2162
2163 nodes = &pdialog->overview.supported_units;
2164
2165 n = unit_list_size(units);
2166 m = unit_node_vector_size(nodes);
2167
2168 if (m > n) {
2169 i = 0;
2171 if (i++ >= n) {
2172 gtk_widget_destroy(elt->cmd);
2173 }
2175
2177 } else {
2178 for (i = m; i < n; i++) {
2179 GtkWidget *cmd, *pix;
2180 struct unit_node node;
2181
2182 cmd = gtk_button_new();
2183 node.cmd = cmd;
2184
2188
2189 pix = gtk_image_new();
2190 node.pix = pix;
2192
2194
2196 cmd, i, 0, 1, 1);
2197 unit_node_vector_append(nodes, node);
2198 }
2199 }
2200
2201 i = 0;
2202 unit_list_iterate(units, punit) {
2203 struct unit_node *pnode;
2204 int happy_cost = city_unit_unhappiness(punit, &free_unhappy);
2205
2206 pnode = unit_node_vector_get(nodes, i);
2207 if (pnode) {
2208 GtkWidget *cmd, *pix;
2209
2210 cmd = pnode->cmd;
2211 pix = pnode->pix;
2212
2214 punit->upkeep, happy_cost);
2215
2219
2223
2225
2226 g_signal_connect(cmd, "button_press_event",
2229
2230 g_signal_connect(cmd, "button_release_event",
2233
2234 if (city_owner(pdialog->pcity) != client.conn.playing) {
2236 } else {
2238 }
2239
2242 }
2243 i++;
2245
2246 buf = g_strdup_printf(_("Supported units %d"), n);
2248 g_free(buf);
2249}
2250
2251/**********************************************************************/
2255{
2256 struct unit_list *units;
2257 struct unit_node_vector *nodes;
2258 int n, m, i;
2259 gchar *buf;
2260
2261 if (NULL != client.conn.playing
2262 && city_owner(pdialog->pcity) != client.conn.playing) {
2263 units = pdialog->pcity->client.info_units_present;
2264 } else {
2265 units = pdialog->pcity->tile->units;
2266 }
2267
2268 nodes = &pdialog->overview.present_units;
2269
2270 n = unit_list_size(units);
2271 m = unit_node_vector_size(nodes);
2272
2273 if (m > n) {
2274 i = 0;
2276 if (i++ >= n) {
2277 gtk_widget_destroy(elt->cmd);
2278 }
2280
2282 } else {
2283 for (i = m; i < n; i++) {
2284 GtkWidget *cmd, *pix;
2285 struct unit_node node;
2286
2287 cmd = gtk_button_new();
2288 node.cmd = cmd;
2289
2293
2294 pix = gtk_image_new();
2295 node.pix = pix;
2297
2299
2301 cmd, i, 0, 1, 1);
2302 unit_node_vector_append(nodes, node);
2303 }
2304 }
2305
2306 i = 0;
2307 unit_list_iterate(units, punit) {
2308 struct unit_node *pnode;
2309
2310 pnode = unit_node_vector_get(nodes, i);
2311 if (pnode) {
2312 GtkWidget *cmd, *pix;
2313
2314 cmd = pnode->cmd;
2315 pix = pnode->pix;
2316
2318
2322
2326
2328
2329 g_signal_connect(cmd, "button_press_event",
2332
2333 g_signal_connect(cmd, "button_release_event",
2336
2337 if (city_owner(pdialog->pcity) != client.conn.playing) {
2339 } else {
2341 }
2342
2345 }
2346 i++;
2348
2349 buf = g_strdup_printf(_("Present units %d"), n);
2351 g_free(buf);
2352}
2353
2354/**********************************************************************/
2362{
2363 int count = 0;
2364 int city_number;
2365
2366 if (NULL != client.conn.playing) {
2368 } else {
2369 city_number = FC_INFINITY; /* ? */
2370 }
2371
2372 /* the first time, we see if all the city dialogs are open */
2373
2375 if (city_owner(pdialog->pcity) == client.conn.playing)
2376 count++;
2377 }
2379
2380 if (count == city_number) { /* all are open, shouldn't prev/next */
2382 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2383 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2384 }
2386 } else {
2388 if (city_owner(pdialog->pcity) == client.conn.playing) {
2389 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2390 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2391 }
2392 }
2394 }
2395}
2396
2397/**********************************************************************/
2400static void citydlg_response_callback(GtkDialog *dlg, gint response,
2401 void *data)
2402{
2403 switch (response) {
2404 case CDLGR_UNITS:
2405 show_units_response(data);
2406 break;
2407 }
2408}
2409
2410/**********************************************************************/
2413static void show_units_response(void *data)
2414{
2415 struct city_dialog *pdialog = (struct city_dialog *) data;
2416 struct tile *ptile = pdialog->pcity->tile;
2417
2418 if (unit_list_size(ptile->units)) {
2420 }
2421}
2422
2423/**********************************************************************/
2426static void destroy_func(GtkWidget *w, gpointer data)
2427{
2429}
2430
2431/**********************************************************************/
2435 gpointer data)
2436{
2437 GtkWidget *menu, *item;
2438 struct city_dialog *pdialog;
2439 struct city *pcity;
2440 struct unit *punit =
2441 player_unit_by_number(client_player(), (size_t) data);
2442
2443 if (NULL != punit
2444 && NULL != (pcity = game_city_by_number(punit->homecity))
2445 && NULL != (pdialog = get_city_dialog(pcity))) {
2446
2447 if (ev->type != GDK_BUTTON_PRESS || ev->button == 2 || ev->button == 3
2449 return FALSE;
2450 }
2451
2452 menu = pdialog->popup_menu;
2453
2456
2458 g_signal_connect(item, "activate",
2462
2463 item = gtk_menu_item_new_with_mnemonic(_("_Activate unit"));
2464 g_signal_connect(item, "activate",
2468
2469 item = gtk_menu_item_new_with_mnemonic(_("Activate unit, _close dialog"));
2470 g_signal_connect(item, "activate",
2474
2475 item = gtk_menu_item_new_with_mnemonic(_("_Disband unit"));
2476 g_signal_connect(item, "activate",
2480
2483 }
2484
2485 gtk_widget_show_all(menu);
2486
2488 }
2489
2490 return TRUE;
2491}
2492
2493/**********************************************************************/
2497 gpointer data)
2498{
2499 GtkWidget *menu, *item;
2500 struct city_dialog *pdialog;
2501 struct city *pcity;
2502 struct unit *punit =
2503 player_unit_by_number(client_player(), (size_t) data);
2504
2505 if (NULL != punit
2506 && NULL != (pcity = tile_city(unit_tile(punit)))
2507 && NULL != (pdialog = get_city_dialog(pcity))) {
2508
2509 if (ev->type != GDK_BUTTON_PRESS || ev->button == 2 || ev->button == 3
2511 return FALSE;
2512 }
2513
2514 menu = pdialog->popup_menu;
2515
2518
2519 item = gtk_menu_item_new_with_mnemonic(_("_Activate unit"));
2520 g_signal_connect(item, "activate",
2524
2525 item = gtk_menu_item_new_with_mnemonic(_("Activate unit, _close dialog"));
2526 g_signal_connect(item, "activate",
2530
2531 item = gtk_menu_item_new_with_mnemonic(_("_Load unit"));
2532 g_signal_connect(item, "activate",
2536
2537 if (!unit_can_load(punit)) {
2539 }
2540
2541 item = gtk_menu_item_new_with_mnemonic(_("_Unload unit"));
2542 g_signal_connect(item, "activate",
2546
2550 }
2551
2552 item = gtk_menu_item_new_with_mnemonic(_("_Sentry unit"));
2553 g_signal_connect(item, "activate",
2557
2561 }
2562
2563 item = gtk_menu_item_new_with_mnemonic(_("_Fortify unit"));
2564 g_signal_connect(item, "activate",
2568
2572 }
2573
2574 item = gtk_menu_item_new_with_mnemonic(_("_Disband unit"));
2575 g_signal_connect(item, "activate",
2579
2582 }
2583
2586 g_signal_connect(item, "activate",
2591
2592 item = gtk_menu_item_new_with_mnemonic(_("U_pgrade unit"));
2594 g_signal_connect(item, "activate",
2598
2601 unit_type_get(punit))) {
2603 }
2604
2605 gtk_widget_show_all(menu);
2606
2608 }
2609
2610 return TRUE;
2611}
2612
2613/**********************************************************************/
2618 gpointer data)
2619{
2620 struct city_dialog *pdialog;
2621 struct city *pcity;
2622 struct unit *punit =
2623 player_unit_by_number(client_player(), (size_t) data);
2624
2625 if (NULL != punit
2626 && NULL != (pcity = tile_city(unit_tile(punit)))
2627 && NULL != (pdialog = get_city_dialog(pcity))
2629
2630 if (ev->button == 3) {
2632 } else if (ev->button == 2) {
2634 close_city_dialog(pdialog);
2635 }
2636 }
2637
2638 return TRUE;
2639}
2640
2641/**********************************************************************/
2646 gpointer data)
2647{
2648 struct city_dialog *pdialog;
2649 struct city *pcity;
2650 struct unit *punit =
2651 player_unit_by_number(client_player(), (size_t) data);
2652
2653 if (NULL != punit
2654 && NULL != (pcity = game_city_by_number(punit->homecity))
2655 && NULL != (pdialog = get_city_dialog(pcity))
2657
2658 if (ev->button == 3) {
2660 } else if (ev->button == 2) {
2662 close_city_dialog(pdialog);
2663 }
2664 }
2665
2666 return TRUE;
2667}
2668
2669/**********************************************************************/
2673{
2674 struct unit *punit =
2675 player_unit_by_number(client_player(), (size_t)data);
2676
2677 if (NULL != punit) {
2679 }
2680}
2681
2682/**********************************************************************/
2686{
2687 struct unit *punit =
2688 player_unit_by_number(client_player(), (size_t)data);
2689
2690 if (NULL != punit) {
2692 }
2693}
2694
2695/**********************************************************************/
2700 gpointer data)
2701{
2702 struct unit *punit =
2703 player_unit_by_number(client_player(), (size_t)data);
2704
2705 if (NULL != punit) {
2706 struct city *pcity =
2708
2710 if (NULL != pcity) {
2711 struct city_dialog *pdialog = get_city_dialog(pcity);
2712
2713 if (NULL != pdialog) {
2714 close_city_dialog(pdialog);
2715 }
2716 }
2717 }
2718}
2719
2720/**********************************************************************/
2725 gpointer data)
2726{
2727 struct unit *punit =
2728 player_unit_by_number(client_player(), (size_t)data);
2729
2730 if (NULL != punit) {
2731 struct city *pcity = tile_city(unit_tile(punit));
2732
2734 if (NULL != pcity) {
2735 struct city_dialog *pdialog = get_city_dialog(pcity);
2736
2737 if (NULL != pdialog) {
2738 close_city_dialog(pdialog);
2739 }
2740 }
2741 }
2742}
2743
2744/**********************************************************************/
2748{
2749 struct unit *punit =
2750 player_unit_by_number(client_player(), (size_t)data);
2751
2752 if (NULL != punit) {
2754 }
2755}
2756
2757/**********************************************************************/
2761{
2762 struct unit *punit =
2763 player_unit_by_number(client_player(), (size_t)data);
2764
2765 if (NULL != punit) {
2767 }
2768}
2769
2770/**********************************************************************/
2774{
2775 struct unit *punit =
2776 player_unit_by_number(client_player(), (size_t)data);
2777
2778 if (NULL != punit) {
2780 }
2781}
2782
2783/**********************************************************************/
2787{
2788 struct unit *punit =
2789 player_unit_by_number(client_player(), (size_t)data);
2790
2791 if (NULL != punit) {
2793 }
2794}
2795
2796/**********************************************************************/
2800{
2801 struct unit_list *punits;
2802 struct unit *punit =
2803 player_unit_by_number(client_player(), (size_t)data);
2804
2805 if (NULL == punit) {
2806 return;
2807 }
2808
2813}
2814
2815/**********************************************************************/
2820{
2821 struct unit *punit =
2822 player_unit_by_number(client_player(), (size_t)data);
2823
2824 if (NULL != punit) {
2826 }
2827}
2828
2829/**********************************************************************/
2833{
2834 struct unit_list *punits;
2835 struct unit *punit =
2836 player_unit_by_number(client_player(), (size_t)data);
2837
2838 if (NULL == punit) {
2839 return;
2840 }
2841
2846}
2847
2848/******** Callbacks for citizen bar, map funcs that are not update *******/
2849/**********************************************************************/
2854 gpointer data)
2855{
2856 struct city_dialog *pdialog = data;
2857 struct city *pcity = pdialog->pcity;
2858 int citnum, tlen, len;
2859
2860 if (!can_client_issue_orders()) {
2861 return FALSE;
2862 }
2863
2865 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
2866 if (ev->x > len) {
2867 /* no citizen that far to the right */
2868 return FALSE;
2869 }
2870 citnum = MIN(city_size_get(pcity) - 1, ev->x / pdialog->cwidth);
2871
2873
2874 return TRUE;
2875}
2876
2877/**********************************************************************/
2881{
2882 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
2883 struct city *pcity = workertask_req.owner;
2884 struct tile *ptile = workertask_req.loc;
2885 struct packet_worker_task task;
2886
2887 task.city_id = pcity->id;
2888
2889 if (act == ACTIVITY_LAST) {
2890 task.tgt = -1;
2891 task.want = 0;
2892 } else {
2893 enum extra_cause cause = activity_to_extra_cause(act);
2895 struct extra_type *tgt;
2896
2897 if (cause != EC_NONE) {
2898 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
2899 } else if (rmcause != ERM_NONE) {
2900 tgt = prev_extra_in_tile(ptile, rmcause, city_owner(pcity), NULL);
2901 } else {
2902 tgt = NULL;
2903 }
2904
2905 if (tgt == NULL) {
2906 struct terrain *pterr = tile_terrain(ptile);
2907
2908 if ((act != ACTIVITY_TRANSFORM
2909 || pterr->transform_result == NULL || pterr->transform_result == pterr)
2910 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
2911 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
2912 /* No extra to order */
2913 output_window_append(ftc_client, _("There's no suitable extra to order."));
2914
2915 return;
2916 }
2917
2918 task.tgt = -1;
2919 } else {
2920 task.tgt = extra_index(tgt);
2921 }
2922
2923 task.want = 100;
2924 }
2925
2926 task.tile_id = ptile->index;
2927 task.activity = act;
2928
2930}
2931
2932/**********************************************************************/
2939
2940/**********************************************************************/
2943static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
2944{
2946 GtkWidget *shl;
2947 struct terrain *pterr = tile_terrain(ptile);
2948 struct universal for_terr = { .kind = VUT_TERRAIN,
2949 .value = { .terrain = pterr }};
2950 struct worker_task *ptask;
2951
2953 workertask_req.owner = pcity;
2954 workertask_req.loc = ptile;
2955
2957 _("What Action to Request"),
2958 _("Select autosettler activity:"));
2959
2961 if (ptask != NULL) {
2962 choice_dialog_add(shl, _("Clear request"),
2965 }
2966
2968 choice_dialog_add(shl, Q_("?act:Mine"),
2971 }
2972 if (pterr->plant_result != NULL
2974 NULL, &for_terr)) {
2975 choice_dialog_add(shl, _("Plant"),
2978 }
2980 choice_dialog_add(shl, _("Irrigate"),
2983 }
2984 if (pterr->cultivate_result != NULL
2986 NULL, &for_terr)) {
2987 choice_dialog_add(shl, _("Cultivate"),
2990 }
2992 choice_dialog_add(shl, _("Road"),
2995 }
2996 if (pterr->transform_result != pterr && pterr->transform_result != NULL
2998 NULL, &for_terr)) {
2999 choice_dialog_add(shl, _("Transform"),
3002 }
3004 city_owner(pcity), NULL) != NULL) {
3005 choice_dialog_add(shl, _("Clean"),
3008 }
3009
3010 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3012
3014 NULL);
3015 }
3016}
3017
3018/**********************************************************************/
3022 gpointer data)
3023{
3024 struct city_dialog *pdialog = data;
3026
3027 if (!can_client_issue_orders()) {
3028 return FALSE;
3029 }
3030
3031 if (ev->button == 1 && cma_is_city_under_agent(pdialog->pcity, NULL)) {
3032 return FALSE;
3033 }
3034
3035 canvas_x = ev->x * (double)canvas_width / (double)CITYMAP_WIDTH;
3036 canvas_y = ev->y * (double)canvas_height / (double)CITYMAP_HEIGHT;
3037
3039 city_map_radius_sq_get(pdialog->pcity),
3040 canvas_x, canvas_y)) {
3041 if (ev->button == 1) {
3043 } else if (ev->button == 3) {
3044 struct city *pcity = pdialog->pcity;
3045
3046 popup_workertask_dlg(pdialog->pcity,
3047 city_map_to_tile(&(wld.map), pcity->tile,
3049 city_x, city_y));
3050 }
3051 }
3052
3053 return TRUE;
3054}
3055
3056/**********************************************************************/
3059static void draw_map_canvas(struct city_dialog *pdialog)
3060{
3062 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3064 }
3065}
3066
3067/************** Callbacks for Buy, Change, Sell, Worklist ****************/
3068/**********************************************************************/
3071static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
3072{
3073 struct city_dialog *pdialog = data;
3074
3075 if (response == GTK_RESPONSE_YES) {
3076 city_buy_production(pdialog->pcity);
3077 }
3079}
3080
3081/**********************************************************************/
3084static void buy_callback(GtkWidget *w, gpointer data)
3085{
3087 struct city_dialog *pdialog = data;
3088 const char *name = city_production_name_translation(pdialog->pcity);
3089 int value = pdialog->pcity->client.buy_cost;
3090 char buf[1024];
3091
3092 if (!can_client_issue_orders()) {
3093 return;
3094 }
3095
3096 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3097 "Treasury contains %d gold.",
3098 client_player()->economic.gold),
3099 client_player()->economic.gold);
3100
3101 if (value <= client_player()->economic.gold) {
3105 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3106 PL_("Buy %s for %d gold?\n%s",
3107 "Buy %s for %d gold?\n%s", value),
3108 name, value, buf);
3109 setup_dialog(shell, pdialog->shell);
3110 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3113 pdialog);
3115 } else {
3119 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3120 PL_("%s costs %d gold.\n%s",
3121 "%s costs %d gold.\n%s", value),
3122 name, value, buf);
3123 setup_dialog(shell, pdialog->shell);
3124 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3126 NULL);
3128 }
3129}
3130
3131/**********************************************************************/
3135 struct city_dialog *pdialog)
3136{
3138
3140 && gtk_combo_box_get_active_iter(combo, &iter)) {
3141 cid id;
3142 struct universal univ;
3143
3144 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 2, &id, -1);
3145 univ = cid_production(id);
3146 city_change_production(pdialog->pcity, &univ);
3147 }
3148}
3149
3150/**********************************************************************/
3153static void sell_callback(struct impr_type *pimprove, gpointer data)
3154{
3155 GtkWidget *shl;
3156 struct city_dialog *pdialog = (struct city_dialog *) data;
3157 pdialog->sell_id = improvement_number(pimprove);
3158 int price;
3159
3160 if (!can_client_issue_orders()) {
3161 return;
3162 }
3163
3165 pimprove) != TR_SUCCESS) {
3166 return;
3167 }
3168
3169 price = impr_sell_gold(pimprove);
3174 PL_("Sell %s for %d gold?",
3175 "Sell %s for %d gold?", price),
3176 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3177 setup_dialog(shl, pdialog->shell);
3178 pdialog->sell_shell = shl;
3179
3180 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3182
3183 g_signal_connect(shl, "response",
3185
3187}
3188
3189/**********************************************************************/
3192static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3193{
3194 struct city_dialog *pdialog = data;
3195
3196 if (response == GTK_RESPONSE_YES) {
3197 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3198 }
3200
3201 pdialog->sell_shell = NULL;
3202}
3203
3204/**********************************************************************/
3209{
3210 GtkTreeModel *model;
3211 GtkTreeIter it;
3212 GdkWindow *win;
3213 GdkSeat *seat;
3215 struct impr_type *pimprove;
3216
3218
3219 if (!gtk_tree_model_get_iter(model, &it, path)) {
3220 return;
3221 }
3222
3223 gtk_tree_model_get(model, &it, 0, &pimprove, -1);
3224
3227
3229 NULL, NULL, &mask);
3230
3231 if (!(mask & GDK_CONTROL_MASK)) {
3232 sell_callback(pimprove, data);
3233 } else {
3234 if (is_great_wonder(pimprove)) {
3236 } else {
3238 }
3239 }
3240}
3241
3242/************ Callbacks for stuff on the Misc. Settings page *************/
3243/**********************************************************************/
3247{
3248 struct city_dialog *pdialog;
3249
3250 pdialog = (struct city_dialog *) data;
3251
3252 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3253 /* "shellrenamecity" */
3254 _("Rename City"),
3255 _("What should we rename the city to?"),
3256 city_name_get(pdialog->pcity),
3257 rename_popup_callback, pdialog);
3258}
3259
3260/**********************************************************************/
3263static void rename_popup_callback(gpointer data, gint response,
3264 const char *input)
3265{
3266 struct city_dialog *pdialog = data;
3267
3268 if (pdialog) {
3269 if (response == GTK_RESPONSE_OK) {
3270 city_rename(pdialog->pcity, input);
3271 } /* else CANCEL or DELETE_EVENT */
3272
3273 pdialog->rename_shell = NULL;
3274 }
3275}
3276
3277/**********************************************************************/
3281{
3283}
3284
3285/**********************************************************************/
3289{
3290 struct city_dialog *pdialog = (struct city_dialog *) data;
3291
3292 if (!can_client_issue_orders()) {
3293 return;
3294 }
3295
3296 if (!pdialog->misc.block_signal) {
3297 struct city *pcity = pdialog->pcity;
3299
3300 fc_assert(CITYO_LAST == 3);
3301
3305 }
3308 }
3311 }
3312
3314 }
3315}
3316
3317/**********************************************************************/
3321static void set_cityopt_values(struct city_dialog *pdialog)
3322{
3323 struct city *pcity = pdialog->pcity;
3324
3325 pdialog->misc.block_signal = 1;
3326
3329
3332 (pdialog->misc.new_citizens_radio[1]), TRUE);
3333 } else if (is_city_option_set(pcity, CITYO_GOLD_SPECIALISTS)) {
3335 (pdialog->misc.new_citizens_radio[2]), TRUE);
3336 } else {
3338 (pdialog->misc.new_citizens_radio[0]), TRUE);
3339 }
3340 pdialog->misc.block_signal = 0;
3341}
3342
3343/******************** Callbacks for: Close, Prev, Next. ******************/
3344/**********************************************************************/
3347static void close_callback(GtkWidget *w, gpointer data)
3348{
3349 close_city_dialog((struct city_dialog *) data);
3350}
3351
3352/**********************************************************************/
3356{
3357 struct city_dialog *pdialog;
3358
3359 pdialog = (struct city_dialog *) data;
3360
3361 gtk_widget_hide(pdialog->shell);
3362
3364 citizens_dialog_close(pdialog->pcity);
3365 }
3366 close_happiness_dialog(pdialog->pcity);
3367 close_cma_dialog(pdialog->pcity);
3368
3369 /* Save size of the city dialog. */
3378
3379 last_page
3381
3382 if (pdialog->popup_menu) {
3384 }
3385
3387
3390
3391 if (pdialog->sell_shell) {
3393 }
3394 if (pdialog->rename_shell) {
3396 }
3397
3400
3401 free(pdialog);
3402
3403 /* need to do this every time a new dialog is closed. */
3405}
3406
3407/**********************************************************************/
3410static void close_city_dialog(struct city_dialog *pdialog)
3411{
3412 gtk_widget_destroy(pdialog->shell);
3413}
3414
3415/**********************************************************************/
3420{
3421 struct city_dialog *pdialog = (struct city_dialog *) data;
3422 int i, j, dir, size;
3423 struct city *new_pcity = NULL;
3424
3426 return;
3427 }
3428
3430
3432 fc_assert_ret(size >= 1);
3434
3435 if (size == 1) {
3436 return;
3437 }
3438
3439 /* dir = 1 will advance to the city, dir = -1 will get previous */
3440 if (w == GTK_WIDGET(pdialog->next_command)) {
3441 dir = 1;
3442 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3443 dir = -1;
3444 } else {
3445 /* Always fails. */
3447 || w == GTK_WIDGET(pdialog->prev_command));
3448 dir = 1;
3449 }
3450
3451 for (i = 0; i < size; i++) {
3452 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3453 break;
3454 }
3455 }
3456
3457 fc_assert_ret(i < size);
3458
3459 for (j = 1; j < size; j++) {
3461 (i + dir * j + size) % size);
3463
3464 fc_assert_ret(other_pdialog != pdialog);
3465 if (!other_pdialog) {
3467 break;
3468 }
3469 }
3470
3471 if (!new_pcity) {
3472 /* Every other city has an open city dialog. */
3473 return;
3474 }
3475
3476 /* cleanup happiness dialog */
3478 citizens_dialog_close(pdialog->pcity);
3479 }
3480 close_happiness_dialog(pdialog->pcity);
3481
3482 pdialog->pcity = new_pcity;
3483
3484 /* reinitialize happiness, and cma dialogs */
3487 citizens_dialog_display(pdialog->pcity));
3488 }
3490 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
3491 if (!client_is_observer()) {
3492 fc_assert(pdialog->cma_editor != NULL);
3493 pdialog->cma_editor->pcity = new_pcity;
3494 }
3495
3496 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
3497
3498 can_slide = FALSE;
3499 center_tile_mapcanvas(pdialog->pcity->tile);
3500 can_slide = TRUE;
3501 if (!client_is_observer()) {
3502 set_cityopt_values(pdialog); /* need not be in real_city_dialog_refresh */
3503 }
3504
3506
3507 /* recenter the city map(s) */
3509 if (pdialog->happiness.map_canvas.sw) {
3511 }
3512}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2002
bool action_ever_possible(action_id action)
Definition actions.c:8081
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:927
#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:662
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:736
int city_granary_size(int city_size)
Definition city.c:2123
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:1006
int city_unit_unhappiness(struct unit *punit, int *free_unhappy)
Definition city.c:3040
int city_build_slots(const struct city *pcity)
Definition city.c:2923
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:304
const char * city_name_get(const struct city *pcity)
Definition city.c:1128
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1246
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3376
int city_population(const struct city *pcity)
Definition city.c:1182
bool city_unhappy(const struct city *pcity)
Definition city.c:1618
bool city_celebrating(const struct city *pcity)
Definition city.c:1637
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2861
bool city_happy(const struct city *pcity)
Definition city.c:1606
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:136
citizens city_specialists(const struct city *pcity)
Definition city.c:3305
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1988
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:699
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:808
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:639
cid cid_encode(struct universal target)
Definition climisc.c:481
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:901
#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:2324
void unit_focus_set(struct unit *punit)
Definition control.c:501
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2065
void request_unit_unload(struct unit *pcargo)
Definition control.c:2165
void request_unit_sentry(struct unit *punit)
Definition control.c:2313
#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:846
enum event_type event
Definition events.c:81
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:765
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:790
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1076
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1097
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:379
#define EC_NONE
Definition fc_types.h:1114
@ TR_SUCCESS
Definition fc_types.h:1247
#define ERM_NONE
Definition fc_types.h:1137
@ 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:732
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct city * game_city_by_number(int id)
Definition game.c:107
#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:2773
citydlg_response
Definition citydlg.c:81
@ CDLGR_UNITS
Definition citydlg.c:81
@ CDLGR_PREV
Definition citydlg.c:81
@ CDLGR_NEXT
Definition citydlg.c:81
static int new_dialog_def_page
Definition citydlg.c:213
static void create_and_append_buildings_page(struct city_dialog *pdialog)
Definition citydlg.c:1230
static void unit_upgrade_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2832
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:2943
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1768
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3355
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1729
static int last_page
Definition citydlg.c:214
static void init_citydlg_dimensions(void)
Definition citydlg.c:325
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1264
struct tile * loc
Definition citydlg.c:221
static gboolean canvas_exposed_cb(GtkWidget *w, cairo_t *cr, gpointer data)
Definition citydlg.c:397
@ WORKLIST_PAGE
Definition citydlg.c:111
@ CMA_PAGE
Definition citydlg.c:111
@ HAPPINESS_PAGE
Definition citydlg.c:111
@ SETTINGS_PAGE
Definition citydlg.c:112
@ STICKY_PAGE
Definition citydlg.c:112
@ NUM_PAGES
Definition citydlg.c:113
@ OVERVIEW_PAGE
Definition citydlg.c:111
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:127
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:558
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3280
static bool low_citydlg
Definition citydlg.c:224
static struct @141 workertask_req
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:579
static void city_dialog_update_building(struct city_dialog *pdialog)
Definition citydlg.c:1968
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2400
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3071
static gboolean present_unit_middle_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2616
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:480
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2672
static struct city_dialog * get_city_dialog(struct city *pcity)
Definition citydlg.c:380
#define CITY_MAP_MIN_SIZE_Y
Definition citydlg.c:128
static void city_dialog_update_information(GtkWidget **info_ebox, GtkWidget **info_label, struct city_dialog *pdialog)
Definition citydlg.c:1831
static GtkWidget * create_citydlg_improvement_list(struct city_dialog *pdialog, GtkWidget *vbox)
Definition citydlg.c:889
static void create_production_header(struct city_dialog *pdialog, GtkContainer *contain)
Definition citydlg.c:1197
static void workertask_dlg_destroy(GtkWidget *w, gpointer data)
Definition citydlg.c:2935
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2254
#define CITYMAP_SCALE
Definition citydlg.c:75
static gboolean keyboard_handler(GtkWidget *widget, GdkEventKey *event, struct city_dialog *pdialog)
Definition citydlg.c:616
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2853
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3134
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2747
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3321
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3410
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:653
static void create_and_append_overview_page(struct city_dialog *pdialog)
Definition citydlg.c:948
static void create_and_append_happiness_page(struct city_dialog *pdialog)
Definition citydlg.c:1308
void popdown_all_city_dialogs(void)
Definition citydlg.c:599
static void buy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3084
#define dialog_list_iterate_end
Definition citydlg.c:92
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3207
static void create_and_append_map_page(struct city_dialog *pdialog)
Definition citydlg.c:1136
static void city_dialog_map_create(struct city_dialog *pdialog, struct city_map_canvas *cmap_canvas)
Definition citydlg.c:416
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:538
void reset_city_dialogs(void)
Definition citydlg.c:358
static gboolean show_info_button_release(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:640
static void cityopt_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3288
static void city_dialog_map_recenter(GtkWidget *map_canvas_sw)
Definition citydlg.c:455
static void draw_map_canvas(struct city_dialog *pdialog)
Definition citydlg.c:3059
static bool is_showing_workertask_dialog
Definition citydlg.c:216
#define unit_node_vector_iterate_end
Definition citydlg.c:107
static void sell_callback(struct impr_type *pimprove, gpointer data)
Definition citydlg.c:3153
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:90
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2699
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2361
static void create_and_append_settings_page(struct city_dialog *pdialog)
Definition citydlg.c:1401
static bool city_dialogs_have_been_initialised
Definition citydlg.c:211
static void close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3347
static struct dialog_list * dialog_list
Definition citydlg.c:210
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3192
static void create_citydlg_main_map(struct city_dialog *pdialog, GtkWidget *container)
Definition citydlg.c:872
#define NUM_CITIZENS_SHOWN
Definition citydlg.c:109
#define CITYMAP_HEIGHT
Definition citydlg.c:74
static void destroy_func(GtkWidget *w, gpointer data)
Definition citydlg.c:2426
static void unit_homecity_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2819
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2786
static gboolean supported_unit_middle_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2644
static gboolean present_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2496
struct city * owner
Definition citydlg.c:220
static GtkWidget * create_city_info_table(struct city_dialog *pdialog, GtkWidget **info_ebox, GtkWidget **info_label)
Definition citydlg.c:737
static struct city_dialog * create_city_dialog(struct city *pcity)
Definition citydlg.c:1543
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:1159
static void unit_disband_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2799
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:105
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3246
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3419
static gboolean button_down_citymap(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:3021
#define CITYMAP_WIDTH
Definition citydlg.c:73
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:1946
static void unit_unload_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2760
static void show_units_response(void *data)
Definition citydlg.c:2413
static void initialize_city_dialogs(void)
Definition citydlg.c:334
static int canvas_height
Definition citydlg.c:212
static int canvas_width
Definition citydlg.c:212
#define TINYSCREEN_MAX_HEIGHT
Definition citydlg.c:77
static void city_dialog_update_supported_units(struct city_dialog *pdialog)
Definition citydlg.c:2148
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2685
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2724
@ INFO_LUXURY
Definition citydlg.c:119
@ INFO_STEAL
Definition citydlg.c:121
@ INFO_CORRUPTION
Definition citydlg.c:120
@ NUM_INFO_FIELDS
Definition citydlg.c:122
@ INFO_ILLNESS
Definition citydlg.c:121
@ INFO_WASTE
Definition citydlg.c:120
@ INFO_SIZE
Definition citydlg.c:118
@ INFO_GROWTH
Definition citydlg.c:119
@ INFO_SHIELD
Definition citydlg.c:118
@ INFO_CULTURE
Definition citydlg.c:120
@ INFO_GOLD
Definition citydlg.c:118
@ INFO_SCIENCE
Definition citydlg.c:119
@ INFO_POLLUTION
Definition citydlg.c:120
@ INFO_TRADE
Definition citydlg.c:118
@ INFO_AIRLIFT
Definition citydlg.c:121
@ INFO_GRANARY
Definition citydlg.c:119
@ INFO_FOOD
Definition citydlg.c:118
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2880
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3263
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2091
static void create_and_append_cma_page(struct city_dialog *pdialog)
Definition citydlg.c:1381
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:587
static gboolean supported_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2434
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:2615
#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
void put_unit_image_city_overlays(struct unit *punit, GtkImage *p, int height, int *upkeep_cost, int happy_cost)
Definition mapview.c:521
void put_unit_image(struct unit *punit, GtkImage *p, int height)
Definition mapview.c:496
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
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:319
bool unit_can_load(const struct unit *punit)
Definition movement.c:883
#define GUI_GTK3_22_CITYDLG_MAX_XSIZE
Definition options.h:621
#define GUI_GTK3_22_CITYDLG_MIN_XSIZE
Definition options.h:620
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
void economy_report_dialog_update(void)
#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:202
struct city_dialog::@144 happiness
GtkWidget * name_label
Definition citydlg.c:140
struct city_dialog::@142 overview
GtkWidget * citizen_images
Definition citydlg.c:145
GtkWidget * rename_shell
Definition citydlg.c:199
struct city_dialog::@145 misc
GtkWidget * info_ebox[NUM_INFO_FIELDS]
Definition citydlg.c:165
GtkWidget * rename_command
Definition citydlg.c:190
GtkWidget * production_bar
Definition citydlg.c:151
GtkWidget * supported_units_frame
Definition citydlg.c:156
GtkWidget * sell_shell
Definition citydlg.c:197
GtkWidget * production_label
Definition citydlg.c:172
GtkWidget * widget
Definition citydlg.c:181
GtkWidget * supported_unit_table
Definition citydlg.c:157
GtkWidget * disband_on_settler
Definition citydlg.c:192
struct city_map_canvas map_canvas
Definition citydlg.c:149
GtkWidget * improvement_list
Definition citydlg.c:154
GtkWidget * buy_command
Definition citydlg.c:153
short block_signal
Definition citydlg.c:194
GtkWidget * whichtab_radio[NUM_PAGES]
Definition citydlg.c:193
struct unit_node_vector supported_units
Definition citydlg.c:162
cairo_surface_t * map_canvas_store_unscaled
Definition citydlg.c:141
struct city * pcity
Definition citydlg.c:137
struct unit_node_vector present_units
Definition citydlg.c:163
city_map * view
Definition citydlg.h:450
GtkWidget * citizens
Definition citydlg.c:184
GtkWidget * popup_menu
Definition citydlg.c:144
GtkWidget * show_units_command
Definition citydlg.c:201
Impr_type_id sell_id
Definition citydlg.c:205
GtkWidget * production_combo
Definition citydlg.c:152
struct cma_dialog * cma_editor
Definition citydlg.c:187
cairo_surface_t * citizen_surface
Definition citydlg.c:146
GtkWidget * shell
Definition citydlg.c:139
GtkWidget * worklist
Definition citydlg.c:175
struct city_dialog::@143 production
GtkWidget * present_units_frame
Definition citydlg.c:159
GtkWidget * info_label[NUM_INFO_FIELDS]
Definition citydlg.c:166
GtkWidget * new_citizens_radio[3]
Definition citydlg.c:191
GtkListStore * change_production_store
Definition citydlg.c:168
GtkWidget * present_unit_table
Definition citydlg.c:160
GtkWidget * notebook
Definition citydlg.c:142
GtkWidget * next_command
Definition citydlg.c:203
GtkTreeSelection * change_selection
Definition citydlg.c:198
enum city_dialog::@189 page
GtkWidget * darea
Definition citydlg.c:133
GtkWidget * sw
Definition citydlg.c:131
GtkWidget * ebox
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
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:279
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int height
Definition citydlg.c:97
GtkWidget * cmd
Definition citydlg.c:95
GtkWidget * pix
Definition citydlg.c:96
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int id
Definition unit.h:145
int homecity
Definition unit.h:146
enum universals_n kind
Definition fc_types.h:903
universals_u value
Definition fc_types.h:902
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:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * unit_description(struct unit *punit)
Definition text.c:475
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:110
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6787
int tileset_small_sprite_width(const struct tileset *t)
Definition tilespec.c:901
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:789
int tileset_small_sprite_height(const struct tileset *t)
Definition tilespec.c:937
struct sprite * get_icon_sprite(const struct tileset *t, enum icon_type icon)
Definition tilespec.c:6983
int tileset_unit_with_upkeep_height(const struct tileset *t)
Definition tilespec.c:859
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6726
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6809
@ ICON_CITYDLG
Definition tilespec.h:314
const struct unit_type * utype
Definition fc_types.h:724
const struct impr_type * building
Definition fc_types.h:717
bool can_unit_change_homecity_to(const struct unit *punit, const struct city *pcity)
Definition unit.c:466
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2437
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:361
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:748
#define unit_tile(_pu)
Definition unit.h:390
#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
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66