Freeciv-3.3
Loading...
Searching...
No Matches
citydlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
25/* utility */
26#include "bitvector.h"
27#include "fcintl.h"
28#include "log.h"
29#include "mem.h"
30#include "shared.h"
31#include "support.h"
32
33/* common */
34#include "city.h"
35#include "counters.h"
36#include "game.h"
37#include "map.h"
38#include "movement.h"
39#include "packets.h"
40#include "player.h"
41#include "unitlist.h"
42
43/* client */
44#include "chatline_common.h"
45#include "client_main.h"
46#include "colors.h"
47#include "control.h"
48#include "climap.h"
49#include "options.h"
50#include "text.h"
51#include "tilespec.h"
52
53/* client/agents */
54#include "cma_fec.h"
55
56/* client/gui-gtk-5.0 */
57#include "choice_dialog.h"
58#include "citizensinfo.h"
59#include "cityrep.h"
60#include "cma_fe.h"
61#include "dialogs.h"
62#include "graphics.h"
63#include "gui_main.h"
64#include "gui_stuff.h"
65#include "happiness.h"
66#include "helpdlg.h"
67#include "inputdlg.h"
68#include "mapview.h"
69#include "update_queue.h"
70#include "wldlg.h"
71
72#include "citydlg.h"
73
74#define CITYMAP_WIDTH MIN(512, canvas_width)
75#define CITYMAP_HEIGHT (CITYMAP_WIDTH * canvas_height / canvas_width)
76#define CITYMAP_SCALE ((double)CITYMAP_WIDTH / (double)canvas_width)
77
78#define TINYSCREEN_MAX_HEIGHT (500 - 1)
79
80/* Only CDLGR_UNITS button currently uses these, others have
81 * direct callback. */
83
84struct city_dialog;
85
86/* Get 'struct dialog_list' and related function */
87#define SPECLIST_TAG dialog
88#define SPECLIST_TYPE struct city_dialog
89#include "speclist.h"
90
91#define dialog_list_iterate(dialoglist, pdialog) \
92 TYPED_LIST_ITERATE(struct city_dialog, dialoglist, pdialog)
93#define dialog_list_iterate_end LIST_ITERATE_END
94
95struct unit_node {
98 int height;
102};
103
104/* Get 'struct unit_node' and related function */
105#define SPECVEC_TAG unit_node
106#define SPECVEC_TYPE struct unit_node
107#include "specvec.h"
108
109#define unit_node_vector_iterate(list, elt) \
110 TYPED_VECTOR_ITERATE(struct unit_node, list, elt)
111#define unit_node_vector_iterate_end VECTOR_ITERATE_END
112
113#define NUM_CITIZENS_SHOWN 30
114
117 NUM_PAGES /* The number of pages in city dialog notebook
118 * must match the entries in misc_whichtab_label[] */
120
121enum {
126 NUM_INFO_FIELDS /* Number of fields in city_info panel
127 * must match entries in output_label[] */
129
130/* Minimal size for the city map scrolling windows */
131#define CITY_MAP_MIN_SIZE_X 200
132#define CITY_MAP_MIN_SIZE_Y 150
133
134struct city_map_canvas {
135 GtkWidget *sw;
137};
138
139struct city_dialog {
140 struct city *pcity;
141
146
150
151 struct {
153
154 GtkWidget *production_bar;
155 GtkWidget *buy_command;
157
158 GtkWidget *supported_units_frame;
159 GtkWidget *supported_unit_table;
160
161 GtkWidget *present_units_frame;
162 GtkWidget *present_unit_table;
163
164 struct unit_node_vector supported_units;
165 struct unit_node_vector present_units;
166
168
172
173 struct {
174 GtkWidget *production_label;
175 GtkWidget *production_bar;
176 GtkWidget *buy_command;
179
180 struct {
182
187
188 struct {
190 GtkBox *widget;
192
193 struct cma_dialog *cma_editor;
194
195 struct {
196 GtkWidget *rename_command;
197 GtkWidget *new_citizens_radio[3];
198 GtkWidget *disband_on_settler;
199 GtkWidget *whichtab_radio[NUM_PAGES];
200 short block_signal;
202
206
210
212
213 int cwidth;
214};
215
221
223
224static struct
225{
226 struct city *owner;
227 struct tile *loc;
229
230static bool low_citydlg;
231
232/****************************************/
233
234static void initialize_city_dialogs(void);
235static void city_dialog_map_create(struct city_dialog *pdialog,
238
239static struct city_dialog *get_city_dialog(struct city *pcity);
243 GdkModifierType state,
244 gpointer data);
245
246static GtkWidget *create_city_info_table(struct city_dialog *pdialog,
248static void create_and_append_overview_page(struct city_dialog *pdialog);
249static void create_and_append_map_page(struct city_dialog *pdialog);
250static void create_and_append_buildings_page(struct city_dialog *pdialog);
251static void create_and_append_worklist_page(struct city_dialog *pdialog);
252static void create_and_append_happiness_page(struct city_dialog *pdialog);
253static void create_and_append_cma_page(struct city_dialog *pdialog);
254static void create_and_append_settings_page(struct city_dialog *pdialog);
255
256static struct city_dialog *create_city_dialog(struct city *pcity);
257
258static void city_dialog_update_title(struct city_dialog *pdialog);
259static void city_dialog_update_citizens(struct city_dialog *pdialog);
260static void city_dialog_update_counters(struct city_dialog *pdialog);
262 struct city_dialog *pdialog);
263static void city_dialog_update_map(struct city_dialog *pdialog);
264static void city_dialog_update_building(struct city_dialog *pdialog);
266 *pdialog);
268 *pdialog);
269static void city_dialog_update_present_units(struct city_dialog *pdialog);
270static void city_dialog_update_prev_next(void);
271
272static void show_units_response(void *data);
273
275 double x, double y, gpointer data);
277 double x, double y, gpointer data);
279 double x, double y, gpointer data);
281 double x, double y, gpointer data);
283 double x, double y, gpointer data);
284
285static void close_citydlg_unit_popover(struct city_dialog *pdialog);
286
287static void unit_center_callback(GSimpleAction *action, GVariant *parameter,
288 gpointer data);
289static void unit_activate_callback(GSimpleAction *action, GVariant *parameter,
290 gpointer data);
292 GVariant *parameter,
293 gpointer data);
295 GVariant *parameter,
296 gpointer data);
297static void unit_load_callback(GSimpleAction *action, GVariant *parameter,
298 gpointer data);
299static void unit_unload_callback(GSimpleAction *action, GVariant *parameter,
300 gpointer data);
301static void unit_sentry_callback(GSimpleAction *action, GVariant *parameter,
302 gpointer data);
303static void unit_fortify_callback(GSimpleAction *action, GVariant *parameter,
304 gpointer data);
305static void unit_disband_callback(GSimpleAction *action, GVariant *parameter,
306 gpointer data);
307static void unit_homecity_callback(GSimpleAction *action, GVariant *parameter,
308 gpointer data);
309static void unit_upgrade_callback(GSimpleAction *action, GVariant *parameter,
310 gpointer data);
312 double x, double y, gpointer data);
314 double x, double y, gpointer data);
316 double x, double y, gpointer data);
317static void draw_map_canvas(struct city_dialog *pdialog);
318
319static void buy_callback(GtkWidget * w, gpointer data);
321 guint position,
323 gpointer data);
324
325static void sell_callback(const struct impr_type *pimprove, gpointer data);
326static void sell_callback_response(GtkWidget *w, gint response, gpointer data);
327
328static void impr_callback(GtkColumnView *self, guint position,
329 gpointer data);
330
331static void rename_callback(GtkWidget * w, gpointer data);
332static void rename_popup_callback(gpointer data, gint response,
333 const char *input);
334static void set_cityopt_values(struct city_dialog *pdialog);
335static void cityopt_callback(GtkWidget * w, gpointer data);
336static void misc_whichtab_callback(GtkWidget * w, gpointer data);
337
338static void city_destroy_callback(GtkWidget *w, gpointer data);
339static void close_city_dialog(struct city_dialog *pdialog);
340static void citydlg_response_callback(GtkDialog *dlg, gint response,
341 void *data);
342static void close_callback(GtkWidget *w, gpointer data);
343static void switch_city_callback(GtkWidget *w, gpointer data);
344
345#define FC_TYPE_IMPR_ROW (fc_impr_row_get_type())
346
348
360
365
367
368#define IMPR_ROW_PIXBUF 0
369#define IMPR_ROW_DESC 1
370#define IMPR_ROW_UPKEEP 2
371
372#define FC_TYPE_PROD_ROW (fc_prod_row_get_type())
373
375
385
390
392
393#define PROD_ROW_PIXBUF 0
394#define PROD_ROW_NAME 1
395
396/**********************************************************************/
400{
402
403 if (row->sprite != nullptr) {
404 g_object_unref(G_OBJECT(row->sprite));
405 row->sprite = nullptr;
406 }
407
409}
410
411/**********************************************************************/
414static void
421
422/**********************************************************************/
425static void
427{
428 self->sprite = nullptr;
429}
430
431/**********************************************************************/
435{
436 FcImprRow *result;
437
438 result = g_object_new(FC_TYPE_IMPR_ROW, nullptr);
439
440 return result;
441}
442
443/**********************************************************************/
447{
449
450 if (row->sprite != nullptr) {
451 g_object_unref(G_OBJECT(row->sprite));
452 row->sprite = nullptr;
453 }
454
456}
457
458/**********************************************************************/
461static void
468
469/**********************************************************************/
472static void
474{
475 self->sprite = nullptr;
476}
477
478/**********************************************************************/
482{
483 FcProdRow *result;
484
485 result = g_object_new(FC_TYPE_PROD_ROW, nullptr);
486
487 return result;
488}
489
490/***********************************************************************/
499
500/***********************************************************************/
503static void initialize_city_dialogs(void)
504{
505 int height;
506
508
512
513 /* Use default layout when height cannot be determined
514 * (when height == 0) */
515 if (height > 0 && height <= TINYSCREEN_MAX_HEIGHT) {
517 } else {
519 }
520
522}
523
524/***********************************************************************/
528{
530 return;
531 }
532
534
536 /* There's no reasonable way to resize a GtkImage, so we don't try.
537 Instead we just redraw the overview within the existing area.
538 The player has to close and reopen the dialog to fix this. */
539 city_dialog_update_map(pdialog);
541
543}
544
545/***********************************************************************/
549static struct city_dialog *get_city_dialog(struct city *pcity)
550{
553 }
554
556 if (pdialog->pcity == pcity) {
557 return pdialog;
558 }
560
561 return NULL;
562}
563
564/***********************************************************************/
568 int width, int height, gpointer data)
569{
570 struct city_dialog *pdialog = data;
571
574 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
575 cairo_paint_with_alpha(cr, 0.5);
576 } else {
577 cairo_paint(cr);
578 }
579}
580
581/***********************************************************************/
584static void city_dialog_map_create(struct city_dialog *pdialog,
586{
587 GtkWidget *sw, *darea;
590
599
600 darea = gtk_drawing_area_new();
603 canvas_draw_cb, pdialog, NULL);
604
606 g_signal_connect(controller, "pressed",
612 g_signal_connect(controller, "pressed",
616
617 /* save all widgets for the city map */
618 cmap_canvas->sw = sw;
619 cmap_canvas->darea = darea;
620}
621
622/***********************************************************************/
646
647/***********************************************************************/
651{
652 struct city_dialog *pdialog = get_city_dialog(pcity);
653
654 log_debug("CITYMAP_WIDTH: %d", CITYMAP_WIDTH);
655 log_debug("CITYMAP_HEIGHT: %d", CITYMAP_HEIGHT);
656 log_debug("CITYMAP_SCALE: %.3f", CITYMAP_SCALE);
657
661 }
662
663 if (!pdialog) {
664 return;
665 }
666
671 city_dialog_update_map(pdialog);
676
679
681
682 if (!low_citydlg) {
684 }
688 }
689
690 if (!client_is_observer()) {
692 }
693
697 } else {
698 /* Set the buttons we do not want live while a Diplomat investigates */
700 }
701}
702
703/***********************************************************************/
708{
709 struct city *pcity_sup, *pcity_pre;
710 struct city_dialog *pdialog;
711
714
715 if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
717 }
718
719 if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
721 }
722}
723
724/***********************************************************************/
728{
729 struct city_dialog *pdialog;
730
731 if (!(pdialog = get_city_dialog(pcity))) {
732 pdialog = create_city_dialog(pcity);
733 }
734
736
737 /* center the city map(s); this must be *after* the city dialog was drawn
738 * else the size information is missing! */
740 if (pdialog->happiness.map_canvas.sw) {
742 }
743}
744
745/***********************************************************************/
749{
750 return get_city_dialog(pcity) != NULL;
751}
752
753/***********************************************************************/
757{
758 struct city_dialog *pdialog = get_city_dialog(pcity);
759
760 if (pdialog) {
761 close_city_dialog(pdialog);
762 }
763}
764
765/***********************************************************************/
781
782/***********************************************************************/
788 GdkModifierType state,
789 gpointer data)
790{
791 struct city_dialog *pdialog = (struct city_dialog *)data;
792
793 if (state & GDK_CONTROL_MASK) {
794 switch (keyval) {
795 case GDK_KEY_Left:
797 return TRUE;
798
799 case GDK_KEY_Right:
801 return TRUE;
802
803 default:
804 break;
805 }
806 }
807
808 return FALSE;
809}
810
811/***********************************************************************/
815 double x, double y, gpointer data)
816{
818 struct city_dialog *pdialog = g_object_get_data(G_OBJECT(w), "pdialog");
819 GtkWidget *p, *label;
820 char buf[1024];
821
822 switch (GPOINTER_TO_UINT(data)) {
823 case INFO_SIZE:
824 fc_snprintf(buf, sizeof(buf), _("Population: %d, Specialists: %d"),
825 pdialog->pcity->size, city_specialists(pdialog->pcity));
826 break;
827 case INFO_FOOD:
828 get_city_dialog_output_text(pdialog->pcity, O_FOOD, buf, sizeof(buf));
829 break;
830 case INFO_SHIELD:
832 buf, sizeof(buf));
833 break;
834 case INFO_TRADE:
835 get_city_dialog_output_text(pdialog->pcity, O_TRADE, buf, sizeof(buf));
836 break;
837 case INFO_GOLD:
838 get_city_dialog_output_text(pdialog->pcity, O_GOLD, buf, sizeof(buf));
839 break;
840 case INFO_SCIENCE:
842 buf, sizeof(buf));
843 break;
844 case INFO_LUXURY:
846 buf, sizeof(buf));
847 break;
848 case INFO_CULTURE:
849 get_city_dialog_culture_text(pdialog->pcity, buf, sizeof(buf));
850 break;
851 case INFO_POLLUTION:
852 get_city_dialog_pollution_text(pdialog->pcity, buf, sizeof(buf));
853 break;
854 case INFO_ILLNESS:
855 get_city_dialog_illness_text(pdialog->pcity, buf, sizeof(buf));
856 break;
857 case INFO_AIRLIFT:
858 get_city_dialog_airlift_text(pdialog->pcity, buf, sizeof(buf));
859 break;
860 default:
861 return TRUE;
862 }
863
864 p = gtk_popover_new();
865
867
868 label = gtk_label_new(buf);
869 gtk_widget_set_name(label, "city_label");
874
876
878
879 return TRUE;
880}
881
882/***********************************************************************/
888{
889 int i;
890 GtkWidget *table, *label;
891
892 static const char *output_label[NUM_INFO_FIELDS] = {
893 N_("Size:"),
894 N_("Food:"),
895 N_("Prod:"),
896 N_("Trade:"),
897 N_("Gold:"),
898 N_("Luxury:"),
899 N_("Science:"),
900 N_("Granary:"),
901 N_("Change in:"),
902 N_("Corruption:"),
903 N_("Waste:"),
904 N_("Culture:"),
905 N_("Pollution:"),
906 N_("Plague risk:"),
907 N_("Tech Stolen:"),
908 N_("Airlift:"),
909 };
910 static bool output_label_done;
912
918
920
921 for (i = 0; i < NUM_INFO_FIELDS; i++) {
922 label = gtk_label_new(output_label[i]);
923 switch (i) {
924 case INFO_SIZE:
925 case INFO_TRADE:
926 case INFO_SCIENCE:
927 case INFO_GROWTH:
929 break;
930
931 case INFO_FOOD:
932 case INFO_GOLD:
933 case INFO_GRANARY:
934 case INFO_CORRUPTION:
936 break;
937 default:
938 break;
939 }
941 gtk_widget_set_name(label, "city_label"); /* For font style? */
944 gtk_grid_attach(GTK_GRID(table), label, 0, i, 1, 1);
945
946 label = gtk_label_new("");
947 switch (i) {
948 case INFO_TRADE:
949 case INFO_SCIENCE:
950 case INFO_GROWTH:
952 break;
953
954 case INFO_GOLD:
955 case INFO_GRANARY:
956 case INFO_CORRUPTION:
958 break;
959 default:
960 break;
961 }
962
963 g_object_set_data(G_OBJECT(label), "pdialog", pdialog);
964
966 g_signal_connect(controller, "pressed",
969
970 info_label[i] = label;
971 gtk_widget_set_name(label, "city_label"); /* Ditto */
974
975 gtk_grid_attach(GTK_GRID(table), label, 1, i, 1, 1);
976 }
977
978 /*
979 * Allow special highlighting of emergencies for granary etc by
980 * city_dialog_update_information().
981 */
982 {
983 /* This will persist, and can be shared between overview and happiness
984 * pages. */
986
987 if (emergency_provider == NULL) {
989
991 ".emergency {\n"
992 " color: rgba(255, 0.0, 0.0, 255);\n"
993 "}",
994 -1);
995
1000 }
1001 }
1002
1004
1005 return table;
1006}
1007
1008/***********************************************************************/
1013static void create_citydlg_main_map(struct city_dialog *pdialog,
1014 GtkWidget *grid, int col, int row)
1015{
1016 GtkWidget *frame;
1017
1018 frame = gtk_frame_new(_("City map"));
1021 gtk_grid_attach(GTK_GRID(grid), frame, col, row, 1, 1);
1022
1023 city_dialog_map_create(pdialog, &pdialog->overview.map_canvas);
1025}
1026
1027/**********************************************************************/
1032 gpointer user_data)
1033{
1034 FcImprRow *row;
1036
1038
1039 switch (GPOINTER_TO_INT(user_data)) {
1040 case IMPR_ROW_PIXBUF:
1041 gtk_image_set_from_pixbuf(GTK_IMAGE(child), row->sprite);
1042 break;
1043 case IMPR_ROW_DESC:
1044 {
1045 gtk_label_set_text(GTK_LABEL(child), row->description);
1046
1047 if (row->redundant) {
1050
1054
1056 }
1057 }
1058 break;
1059 case IMPR_ROW_UPKEEP:
1060 {
1061 char buf[256];
1062
1063 fc_snprintf(buf, sizeof(buf), "%d", row->upkeep);
1065 }
1066 break;
1067 }
1068}
1069
1070/**********************************************************************/
1075 gpointer user_data)
1076{
1077 switch (GPOINTER_TO_INT(user_data)) {
1078 case IMPR_ROW_PIXBUF:
1080 break;
1081 case IMPR_ROW_DESC:
1082 case IMPR_ROW_UPKEEP:
1084 break;
1085 }
1086}
1087
1088/**********************************************************************/
1094 gpointer data)
1095{
1097
1098 if (rnum >= 0) {
1100
1101 if (row != nullptr && row->tooltip != nullptr) {
1103
1104 return TRUE;
1105 }
1106 }
1107
1108 return FALSE;
1109}
1110
1111/***********************************************************************/
1115{
1116 GtkWidget *list;
1119 GtkSingleSelection *selection;
1120
1121 /* Improvements */
1123
1126
1132
1135
1141
1142 column = gtk_column_view_column_new(_("Description"), factory);
1144
1150
1153
1154 g_object_set(list, "has-tooltip", TRUE, nullptr);
1155 g_signal_connect(list, "query-tooltip",
1157
1158 g_signal_connect(list, "activate",
1159 G_CALLBACK(impr_callback), pdialog);
1160
1161 return list;
1162}
1163
1164/**********************************************************************/
1169 gpointer user_data)
1170{
1171 FcProdRow *row;
1173
1175
1176 switch (GPOINTER_TO_INT(user_data)) {
1177 case PROD_ROW_PIXBUF:
1178 gtk_image_set_from_pixbuf(GTK_IMAGE(child), row->sprite);
1179 break;
1180 case PROD_ROW_NAME:
1181 {
1182 gtk_label_set_text(GTK_LABEL(child), row->name);
1183
1184 if (row->useless) {
1187
1191
1193 }
1194 }
1195 break;
1196 }
1197}
1198
1199/**********************************************************************/
1204 gpointer user_data)
1205{
1206 switch (GPOINTER_TO_INT(user_data)) {
1207 case PROD_ROW_PIXBUF:
1209 break;
1210 case PROD_ROW_NAME:
1212 break;
1213 }
1214}
1215
1216/***********************************************************************/
1233{
1235 GtkWidget *right, *frame, *table;
1236 GtkWidget *label, *sw, *view, *bar;
1237 /* TRANS: Overview tab in city dialog */
1238 const char *tab_title = _("_Overview");
1240 int page_row = 0;
1241
1242 /* Main page */
1243 page = gtk_grid_new();
1252
1253 if (!low_citydlg) {
1255 GtkWidget *list;
1257 GtkWidget *middle;
1258 GtkWidget *vbox;
1259 GtkWidget *hbox;
1260 int middle_col = 0;
1261
1262 /* Middle: city map, improvements */
1263 middle = gtk_grid_new();
1265 gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1);
1266
1267 /* City map */
1268 create_citydlg_main_map(pdialog, middle, middle_col++, 0);
1269
1270 /* Improvements */
1272 gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1);
1273
1275
1276 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
1277 "xalign", 0.0, "yalign", 0.5, NULL);
1278 gtk_box_append(GTK_BOX(vbox), label);
1279
1281 gtk_box_append(GTK_BOX(vbox), hbox);
1282
1284
1288
1294
1297
1303
1306
1307 bar = gtk_progress_bar_new();
1309 pdialog->overview.production_bar = bar;
1311
1312 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1313
1315
1316 g_signal_connect(pdialog->overview.change_prod_selection, "selection-changed",
1318
1319 pdialog->overview.buy_command
1320 = icon_label_button_new("system-run", _("_Buy"));
1322 g_signal_connect(pdialog->overview.buy_command, "clicked",
1323 G_CALLBACK(buy_callback), pdialog);
1324
1325 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1326 "mnemonic-widget", view,
1327 "label", _("I_mprovements:"),
1328 "xalign", 0.0, "yalign", 0.5, NULL);
1329 gtk_box_append(GTK_BOX(vbox), label);
1330 gtk_box_append(GTK_BOX(vbox), view);
1331 } else {
1332 pdialog->overview.buy_command = NULL;
1333 pdialog->overview.production_bar = NULL;
1334 pdialog->overview.change_prod_store = nullptr;
1335 pdialog->overview.change_prod_selection = nullptr;
1336 }
1337
1338 /* Bottom: info, units */
1341
1342 /* Info */
1343 frame = gtk_frame_new(_("Info"));
1344 gtk_box_append(GTK_BOX(bottom), frame);
1345
1346 table = create_city_info_table(pdialog,
1347 pdialog->overview.info_label);
1351
1352 /* Right: present and supported units (overview page) */
1354 gtk_box_append(GTK_BOX(bottom), right);
1355
1360
1361 /* Supported units */
1368 sw);
1369
1370
1374
1377
1378 /* Present units */
1385
1389
1392
1393 /* Show page */
1395}
1396
1397/***********************************************************************/
1400static void create_and_append_map_page(struct city_dialog *pdialog)
1401{
1402 if (low_citydlg) {
1403 GtkWidget *page;
1404 GtkWidget *label;
1405 const char *tab_title = _("Citymap");
1406 int page_row = 0;
1407
1408 page = gtk_grid_new();
1417
1418 create_citydlg_main_map(pdialog, page, 0, page_row++);
1419
1421 }
1422}
1423
1424/***********************************************************************/
1428 const GValue *value,
1429 double x, double y, gpointer data)
1430{
1431 struct city_dialog *pdialog = (struct city_dialog *) data;
1432 cid id;
1433 struct universal univ;
1434
1435 if (NULL != client.conn.playing
1436 && city_owner(pdialog->pcity) != client.conn.playing) {
1437 return FALSE;
1438 }
1439
1440 id = g_value_get_int(value);
1441 univ = cid_production(id);
1442
1443 city_change_production(pdialog->pcity, &univ);
1444
1445 return TRUE;
1446}
1447
1448/***********************************************************************/
1452static int create_production_header(struct city_dialog *pdialog,
1453 GtkWidget *grid, int row)
1454{
1455 GtkWidget *hgrid, *bar;
1456 int grid_col = 0;
1457
1458 hgrid = gtk_grid_new();
1464 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1465
1466 /* The label is set in city_dialog_update_building() */
1467 bar = gtk_progress_bar_new();
1470 pdialog->production.production_bar = bar;
1471 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1472 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1473
1475
1476 pdialog->production.buy_command
1477 = icon_label_button_new("system-run", _("_Buy"));
1479 grid_col++, 0, 1, 1);
1480
1481 g_signal_connect(pdialog->production.buy_command, "clicked",
1482 G_CALLBACK(buy_callback), pdialog);
1483
1484 return row;
1485}
1486
1487/***********************************************************************/
1491{
1492 if (low_citydlg) {
1493 GtkWidget *page;
1494 GtkWidget *label;
1495 GtkWidget *vbox;
1496 GtkWidget *view;
1497 const char *tab_title = _("Buildings");
1498 int page_row = 0;
1499
1500 page = gtk_grid_new();
1508
1509 page_row = create_production_header(pdialog, page, page_row);
1510 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1511
1513 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1514
1516
1517 gtk_box_append(GTK_BOX(vbox), view);
1518
1520 }
1521}
1522
1523/***********************************************************************/
1527{
1528 const char *tab_title = _("P_roduction");
1530 GtkWidget *page, *editor;
1531 int page_row = 0;
1532
1533 page = gtk_grid_new();
1540 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1541
1542 /* Stuff that's being currently built */
1543 if (!low_citydlg) {
1545 "label", _("Production:"),
1546 "xalign", 0.0, "yalign", 0.5, NULL);
1547 pdialog->production.production_label = label;
1548 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1549
1550 page_row = create_production_header(pdialog, page, page_row);
1551 } else {
1552 pdialog->production.production_label = NULL;
1553 }
1554
1560 reset_city_worklist(editor, pdialog->pcity);
1561 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1562 pdialog->production.worklist = editor;
1563
1565}
1566
1567/***********************************************************************/
1578{
1579 GtkWidget *page, *label, *table, *right, *left, *frame;
1580 const char *tab_title = _("Happ_iness");
1581 int page_col = 0;
1582 int left_row = 0;
1583
1584 /* Main page */
1585 page = gtk_grid_new();
1592 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1593
1594 /* Left: info, citizens */
1595 left = gtk_grid_new();
1598 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1599
1600 if (!low_citydlg) {
1601 /* Upper left: info */
1602 frame = gtk_frame_new(_("Info"));
1603 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1604
1605 table = create_city_info_table(pdialog,
1606 pdialog->happiness.info_label);
1609 }
1610
1611 /* Lower left: citizens */
1615 0, left_row++, 1, 1);
1617 citizens_dialog_display(pdialog->pcity));
1618 }
1619
1620 /* Right: city map, happiness */
1622 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1623
1624 if (!low_citydlg) {
1625 /* Upper right: city map */
1626 frame = gtk_frame_new(_("City map"));
1629 gtk_box_append(GTK_BOX(right), frame);
1630
1631 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1633 }
1634
1635 /* Lower right: happiness */
1637 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1640 pdialog->shell));
1641
1642 /* Show page */
1644}
1645
1646/**********************************************************************/
1649/**********************************************************************/
1654{
1656 GtkLabel *label = GTK_LABEL(gtk_label_new(_("Counters")));
1657
1658 pdialog->counters.container = NULL;
1659 pdialog->counters.widget = NULL;
1660
1662
1664
1666
1667 gtk_widget_show(page);
1668}
1669
1670/***********************************************************************/
1673static void create_and_append_cma_page(struct city_dialog *pdialog)
1674{
1675 GtkWidget *page, *label;
1676 const char *tab_title = _("_Governor");
1677
1679
1681
1682 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1683
1684 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1685 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1686
1688}
1689
1690/***********************************************************************/
1694{
1695 int i;
1696 GtkWidget *vgrid, *page, *frame, *label, *button;
1698 GtkWidget *group;
1699 const char *tab_title = _("_Settings");
1700 int grid_row = 0;
1701
1702 static const char *new_citizens_output_label[] = {
1703 N_("Luxury"),
1704 N_("Science"),
1705 N_("Gold")
1706 };
1707
1708 static const char *disband_label
1709 = N_("Allow unit production to disband city");
1710
1711 static const char *misc_whichtab_label[NUM_PAGES] = {
1712 N_("Overview page"),
1713 N_("Production page"),
1714 N_("Happiness page"),
1715 N_("Counters Page"),
1716 N_("Governor page"),
1717 N_("This Settings page"),
1718 N_("Last active page")
1719 };
1720
1721 static bool new_citizens_label_done;
1722 static bool misc_whichtab_label_done;
1723
1724 /* Initialize signal_blocker */
1725 pdialog->misc.block_signal = 0;
1726
1727
1728 page = gtk_grid_new();
1734
1736
1738
1739 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1740
1741 /* new_citizens radio */
1742 frame = gtk_frame_new(_("New citizens produce"));
1743 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1745
1746 vgrid = gtk_grid_new();
1750
1753
1754 group = NULL;
1755 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1758 GTK_CHECK_BUTTON(group));
1759 pdialog->misc.new_citizens_radio[i] = button;
1760 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1761 g_signal_connect(button, "toggled",
1762 G_CALLBACK(cityopt_callback), pdialog);
1763 group = button;
1764 }
1765
1766 /* Next is the next-time-open radio group in the right column */
1767 frame = gtk_frame_new(_("Next time open"));
1768 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1770
1771 vgrid = gtk_grid_new();
1772 grid_row = 0;
1776
1779
1780 group = NULL;
1781 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1784 GTK_CHECK_BUTTON(group));
1785 pdialog->misc.whichtab_radio[i] = button;
1786 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1787 g_signal_connect(button, "toggled",
1789 group = button;
1790 }
1791
1792 /* Now we go back and fill the hbox rename */
1793 frame = gtk_frame_new(_("City"));
1794 gtk_widget_set_margin_top(frame, 12);
1796 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1797
1798 vgrid = gtk_grid_new();
1799 grid_row = 0;
1803
1804 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1805 pdialog->misc.rename_command = button;
1806 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1807 g_signal_connect(button, "clicked",
1808 G_CALLBACK(rename_callback), pdialog);
1809
1811
1812 /* The disband-city-on-unit-production button */
1814 pdialog->misc.disband_on_settler = button;
1815 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1816 g_signal_connect(button, "toggled",
1817 G_CALLBACK(cityopt_callback), pdialog);
1818
1819 /* We choose which page to popup by default */
1821 (pdialog->
1823 TRUE);
1824
1825 set_cityopt_values(pdialog);
1826
1828
1829 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1831 last_page);
1832 } else {
1835 }
1836}
1837
1838/***********************************************************************/
1847{
1848 struct city_dialog *pdialog;
1850 GtkWidget *vbox, *hbox, *cbox;
1853 int ccol = 0;
1855 struct player *owner;
1856
1859 }
1860
1861 pdialog = fc_malloc(sizeof(struct city_dialog));
1862 pdialog->pcity = pcity;
1863 pdialog->sell_shell = NULL;
1864 pdialog->rename_shell = NULL;
1865 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1866 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1867 pdialog->happiness.citizens = NULL; /* Ditto */
1868 pdialog->counters.widget = NULL;
1869 pdialog->counters.container = NULL;
1870 pdialog->production.buy_command = NULL;
1871 pdialog->production.production_label = NULL;
1872 pdialog->production.production_bar = NULL;
1873 pdialog->cma_editor = NULL;
1877
1878 pdialog->shell = gtk_dialog_new();
1880 setup_dialog(pdialog->shell, toplevel);
1881
1882 g_signal_connect(pdialog->shell, "destroy",
1884 gtk_widget_set_name(pdialog->shell, "Freeciv");
1885
1886 gtk_widget_realize(pdialog->shell);
1887
1888 /* Keep the icon of the executable on Windows (see PR#36491) */
1889#ifndef FREECIV_MSWINDOWS
1890 {
1891 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1892 }
1893#endif /* FREECIV_MSWINDOWS */
1894
1895 /* Restore size of the city dialog. */
1899
1900 pdialog->popover = NULL;
1901
1905 gtk_box_append(GTK_BOX(vbox), hbox);
1906
1907 /**** Citizens bar here ****/
1908 cbox = gtk_grid_new();
1909 gtk_box_append(GTK_BOX(hbox), cbox);
1910
1913
1917 pdialog->citizen_pics = gtk_picture_new();
1918
1927 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1928
1930 g_signal_connect(controller, "pressed",
1931 G_CALLBACK(citizens_callback), pdialog);
1933
1934 /**** City name label here ****/
1935 pdialog->name_label = gtk_label_new(NULL);
1940
1941 /**** -Start of Notebook- ****/
1942
1943 pdialog->notebook = gtk_notebook_new();
1946 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1947
1951
1953
1954 /* Only create these tabs if not a spy */
1958 }
1959
1961
1962 if (owner == client_player()
1963 && !client_is_observer()) {
1966 } else {
1969 }
1970
1971 /**** End of Notebook ****/
1972
1973 /* Bottom buttons */
1974
1975 pdialog->show_units_command =
1976 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1977
1978 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1980
1981 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1983 GTK_WIDGET(pdialog->prev_command), 1);
1984
1985 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1987 GTK_WIDGET(pdialog->next_command), 2);
1988
1989 if (owner != client_player()) {
1992 }
1993
1995 _("_Close"), GTK_RESPONSE_CLOSE);
1996
1999
2001 G_CALLBACK(close_callback), pdialog);
2002
2003 g_signal_connect(pdialog->prev_command, "clicked",
2005
2006 g_signal_connect(pdialog->next_command, "clicked",
2008
2009 /* Some other things we gotta do */
2010
2012 g_signal_connect(controller, "key-pressed",
2015
2017
2019
2020 /* Need to do this every time a new dialog is opened. */
2022
2024
2026
2027 return pdialog;
2028}
2029
2030/**************** Functions to update parts of the dialog *****************/
2031
2032/***********************************************************************/
2035static void city_dialog_update_title(struct city_dialog *pdialog)
2036{
2037 gchar *buf;
2038 const gchar *now;
2039
2040 if (city_unhappy(pdialog->pcity)) {
2041 /* TRANS: city dialog title */
2042 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
2043 city_name_get(pdialog->pcity),
2045 } else if (city_celebrating(pdialog->pcity)) {
2046 /* TRANS: city dialog title */
2047 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
2048 city_name_get(pdialog->pcity),
2050 } else if (city_happy(pdialog->pcity)) {
2051 /* TRANS: city dialog title */
2052 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
2053 city_name_get(pdialog->pcity),
2055 } else {
2056 /* TRANS: city dialog title */
2057 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
2058 city_name_get(pdialog->pcity),
2060 }
2061
2063 if (strcmp(now, buf) != 0) {
2066 }
2067
2068 g_free(buf);
2069}
2070
2071/***********************************************************************/
2074static void city_dialog_update_citizens(struct city_dialog *pdialog)
2075{
2076 enum citizen_category categories[MAX_CITY_SIZE];
2079 struct city *pcity = pdialog->pcity;
2081 cairo_t *cr;
2082
2083 /* If there is not enough space we stack the icons. We draw from left to */
2084 /* right. width is how far we go to the right for each drawn pixmap. The */
2085 /* last icon is always drawn in full, and so has reserved */
2086 /* tileset_small_sprite_width(tileset) pixels. */
2087
2089 if (num_citizens > 1) {
2091 / (num_citizens - 1));
2092 } else {
2093 width = full_width;
2094 }
2095 pdialog->cwidth = width;
2096
2097 /* overview page */
2098 /* keep these values in sync with create_city_dialog */
2101
2102 cr = cairo_create(pdialog->citizen_surface);
2103
2104 for (i = 0; i < num_citizens; i++) {
2106 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
2107 i * width, 0);
2108 cairo_rectangle(cr, i * width, 0,
2109 /* Always draw last citizen in full */
2110 i + 1 < num_citizens ? width : full_width,
2112 cairo_fill(cr);
2113 }
2114
2115 total_used_width = (i - 1) * width + full_width;
2116
2118 /* Clear the rest of the area.
2119 * Note that this might still be necessary even in cases where
2120 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
2121 * divided perfectly. */
2126 cairo_fill(cr);
2127 }
2128
2129 cairo_destroy(cr);
2130
2132 pdialog->citizen_surface);
2133
2135}
2136
2137
2138/**********************************************************************/
2141static void city_dialog_update_counters(struct city_dialog *pdialog)
2142{
2147 char int_val[101];
2148 char *text;
2149 int text_size;
2150
2151 if (NULL != pdialog->counters.widget) {
2153 GTK_WIDGET(pdialog->counters.widget));
2154 }
2155
2156 if (NULL == pdialog->counters.container) {
2158 }
2159
2163
2167 counterValue = GTK_LABEL(gtk_label_new(_("Current value is: ")));
2169 fc_snprintf(int_val, sizeof(int_val), "%d", pdialog->pcity->counter_values[counter_index(pcount)]);
2173
2175 counterValue = GTK_LABEL(gtk_label_new(_("Activated once value equal or higher than: ")));
2177 fc_snprintf(int_val, sizeof(int_val), "%d", pcount->checkpoint);
2181
2182 text_size = 0;
2183 if (NULL != pcount->helptext) {
2184 strvec_iterate(pcount->helptext, text_) {
2187 }
2188 if (0 < text_size) {
2189 text = malloc(text_size+1);
2190 text_size = 0;
2191 strvec_iterate(pcount->helptext, text_) {
2192 strcpy(&text[text_size], text_);
2196 free(text);
2198 }
2201
2204}
2205
2206/***********************************************************************/
2210 struct city_dialog *pdialog)
2211{
2212 int i, illness = 0;
2213 char buf[NUM_INFO_FIELDS][512];
2214 struct city *pcity = pdialog->pcity;
2215 int granaryturns;
2217
2218 /* fill the buffers with the necessary info */
2219 if (non_workers) {
2220 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
2221 pcity->size, non_workers);
2222 } else {
2223 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
2224 }
2225 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
2226 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
2227 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
2228 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
2229 pcity->surplus[O_SHIELD]);
2230 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
2231 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
2232 pcity->surplus[O_TRADE]);
2233 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
2234 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
2235 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
2236 pcity->prod[O_LUXURY]);
2237 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
2238 pcity->prod[O_SCIENCE]);
2239 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
2241
2243 if (granaryturns == 0) {
2244 /* TRANS: city growth is blocked. Keep short. */
2245 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
2246 } else if (granaryturns == FC_INFINITY) {
2247 /* TRANS: city is not growing. Keep short. */
2248 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
2249 } else {
2250 /* A negative value means we'll have famine in that many turns.
2251 But that's handled down below. */
2252 /* TRANS: city growth turns. Keep short. */
2254 PL_("%d turn", "%d turns", abs(granaryturns)),
2255 abs(granaryturns));
2256 }
2258 pcity->waste[O_TRADE]);
2259 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
2260 pcity->waste[O_SHIELD]);
2261 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
2262 pcity->client.culture);
2264 pcity->pollution);
2265 if (!game.info.illness_on) {
2266 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
2267 } else {
2269 /* illness is in tenth of percent */
2270 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
2271 (float)illness / 10.0);
2272 }
2273 if (pcity->steal) {
2274 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
2275 pcity->steal);
2276 } else {
2277 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
2278 }
2279
2281
2282 /* stick 'em in the labels */
2283 for (i = 0; i < NUM_INFO_FIELDS; i++) {
2285 }
2286
2287 /*
2288 * Make use of the emergency-indicating styles set up for certain labels
2289 * in create_city_info_table().
2290 */
2291 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
2292 * of a warning. */
2293 if (granaryturns > -4 && granaryturns < 0) {
2295 } else {
2297 }
2298
2299 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
2301 } else {
2303 }
2304
2305 /* Someone could add the color &orange for better granularity here */
2306 if (pcity->pollution >= 10) {
2308 } else {
2310 }
2311
2312 /* Illness is in tenth of percent, i.e 100 == 10.0% */
2313 if (illness >= 100) {
2315 } else {
2317 }
2318}
2319
2320/***********************************************************************/
2323static void city_dialog_update_map(struct city_dialog *pdialog)
2324{
2325 struct canvas store = FC_STATIC_CANVAS_INIT;
2326
2327 store.surface = pdialog->map_canvas_store_unscaled;
2328
2329 /* The drawing is done in three steps.
2330 * 1. First we render to a pixmap with the appropriate canvas size.
2331 * 2. Then the pixmap is rendered into a pixbuf of equal size.
2332 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
2333 * target pixbuf.
2334 */
2335
2336 city_dialog_redraw_map(pdialog->pcity, &store);
2337
2338 /* draw to real window */
2339 draw_map_canvas(pdialog);
2340}
2341
2342/***********************************************************************/
2345static void city_dialog_update_building(struct city_dialog *pdialog)
2346{
2347 char buf[32], buf2[200];
2348 gdouble pct;
2349 GListStore *store;
2350 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2351 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2352 int targets_used, item;
2353 struct city *pcity = pdialog->pcity;
2355 const char *descr = city_production_name_translation(pcity);
2357
2358 if (pdialog->overview.buy_command != NULL) {
2360 }
2361 if (pdialog->production.buy_command != NULL) {
2363 }
2364
2365 /* Make sure build slots info is up to date */
2366 if (pdialog->production.production_label != NULL) {
2368
2369 /* Only display extra info if more than one slot is available */
2370 if (build_slots > 1) {
2371 fc_snprintf(buf2, sizeof(buf2),
2372 /* TRANS: never actually used with built_slots <= 1 */
2373 PL_("Production (up to %d unit per turn):",
2374 "Production (up to %d units per turn):", build_slots),
2375 build_slots);
2378 } else {
2380 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2381 }
2382 }
2383
2384 /* Update what the city is working on */
2386
2387 if (cost > 0) {
2388 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2389 pct = CLAMP(pct, 0.0, 1.0);
2390 } else {
2391 pct = 1.0;
2392 }
2393
2394 if (pdialog->overview.production_bar != NULL) {
2395 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2396 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2401 }
2402
2403 if (pdialog->production.production_bar != NULL) {
2404 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2405 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2410 }
2411
2412 store = pdialog->overview.change_prod_store;
2413 if (store != nullptr) {
2414 int cur = -1;
2415 int actcount = 0;
2416
2417 if (pdialog->overview.change_prod_selection != nullptr) {
2419 -1, TRUE);
2420 }
2421
2423
2425 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2426 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2427
2428 for (item = 0; item < targets_used; item++) {
2429 if (can_city_build_now(&(wld.map), pcity, &items[item].item)) {
2430 const char *name;
2431 struct sprite *sprite;
2432 GdkPixbuf *pix;
2433 struct universal *target = &items[item].item;
2434 bool useless;
2436
2437 if (VUT_UTYPE == target->kind) {
2441 useless = FALSE;
2442 } else {
2445 useless = is_improvement_redundant(pcity, target->value.building);
2446 }
2448
2449 row->name = name;
2450 row->id = (gint)cid_encode(items[item].item);
2451 row->sprite = pix;
2452 row->useless = useless;
2453
2454 g_list_store_append(store, row);
2456
2457 if (are_universals_equal(target, &pcity->production)) {
2458 cur = actcount;
2459 }
2460
2461 actcount++;
2462 }
2463 }
2464
2465 if (pdialog->overview.change_prod_selection != nullptr) {
2467 cur, TRUE);
2468 }
2469 }
2470}
2471
2472/***********************************************************************/
2476{
2477 int item, targets_used;
2478 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2479 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2480
2481 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2482 "sell an improvement.");
2483 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2484 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2485
2487 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2488
2490
2491 for (item = 0; item < targets_used; item++) {
2492 GdkPixbuf *pix;
2493 int upkeep;
2494 struct sprite *sprite;
2495 struct universal target = items[item].item;
2497
2498 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2499 /* This takes effects (like Adam Smith's) into account. */
2500 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2502
2504
2505 row->impr = target.value.building;
2506 row->sprite = pix;
2507 row->description = items[item].descr;
2508 row->upkeep = upkeep;
2509 row->redundant = is_improvement_redundant(pdialog->pcity,
2510 target.value.building);
2511 row->tooltip = is_great_wonder(target.value.building) ?
2513 (is_small_wonder(target.value.building) ?
2515
2518 }
2519}
2520
2521/***********************************************************************/
2525{
2526 struct unit_list *units;
2527 struct unit_node_vector *nodes;
2528 int n, m, i;
2529 gchar *buf;
2531 const struct civ_map *nmap = &(wld.map);
2532
2533 if (NULL != client.conn.playing
2534 && city_owner(pdialog->pcity) != client.conn.playing) {
2535 units = pdialog->pcity->client.info_units_supported;
2536 } else {
2537 units = pdialog->pcity->units_supported;
2538 }
2539
2540 nodes = &pdialog->overview.supported_units;
2541
2542 n = unit_list_size(units);
2543 m = unit_node_vector_size(nodes);
2544
2545 if (m > n) {
2546 i = 0;
2548 if (i++ >= n) {
2550 elt->cmd);
2551 }
2553
2555 } else {
2556 for (i = m; i < n; i++) {
2557 GtkWidget *cmd, *pix;
2558 struct unit_node node;
2559
2560 cmd = gtk_button_new();
2561 node.cmd = cmd;
2562
2564
2565 pix = gtk_picture_new();
2566 node.pix = pix;
2568
2570
2572 cmd);
2573
2574 node.left = NULL;
2575 node.middle = NULL;
2576 node.right = NULL;
2577
2578 unit_node_vector_append(nodes, node);
2579 }
2580 }
2581
2582 i = 0;
2583 unit_list_iterate(units, punit) {
2584 struct unit_node *pnode;
2585 int happy_cost = city_unit_unhappiness(nmap, punit, &free_unhappy);
2586
2587 pnode = unit_node_vector_get(nodes, i);
2588 if (pnode) {
2589 GtkWidget *cmd, *pix;
2592
2593 cmd = pnode->cmd;
2594 pix = pnode->pix;
2595
2597 punit->upkeep, happy_cost);
2598
2599 if (pnode->left != NULL) {
2603 }
2604
2606
2608 g_signal_connect(controller, "pressed",
2612 pnode->left = controller;
2616 g_signal_connect(controller, "released",
2620 pnode->middle = controller;
2624 g_signal_connect(controller, "released",
2628 pnode->right = controller;
2629
2630 if (city_owner(pdialog->pcity) != client.conn.playing) {
2632 } else {
2634 }
2635
2638 }
2639 i++;
2641
2642 buf = g_strdup_printf(_("Supported units %d"), n);
2644 g_free(buf);
2645}
2646
2647/***********************************************************************/
2651{
2652 struct unit_list *units;
2653 struct unit_node_vector *nodes;
2654 int n, m, i;
2655 gchar *buf;
2656
2657 if (NULL != client.conn.playing
2658 && city_owner(pdialog->pcity) != client.conn.playing) {
2659 units = pdialog->pcity->client.info_units_present;
2660 } else {
2661 units = pdialog->pcity->tile->units;
2662 }
2663
2664 nodes = &pdialog->overview.present_units;
2665
2666 n = unit_list_size(units);
2667 m = unit_node_vector_size(nodes);
2668
2669 if (m > n) {
2670 i = 0;
2672 if (i++ >= n) {
2674 elt->cmd);
2675 }
2677
2679 } else {
2680 for (i = m; i < n; i++) {
2681 GtkWidget *cmd, *pix;
2682 struct unit_node node;
2683
2684 cmd = gtk_button_new();
2685 node.cmd = cmd;
2686
2688
2689 pix = gtk_picture_new();
2690 node.pix = pix;
2692
2694
2696 cmd);
2697
2698 node.left = NULL;
2699 node.middle = NULL;
2700 node.right = NULL;
2701
2702 unit_node_vector_append(nodes, node);
2703 }
2704 }
2705
2706 i = 0;
2707 unit_list_iterate(units, punit) {
2708 struct unit_node *pnode;
2709
2710 pnode = unit_node_vector_get(nodes, i);
2711 if (pnode) {
2712 GtkWidget *cmd, *pix;
2715
2716 cmd = pnode->cmd;
2717 pix = pnode->pix;
2718
2720
2721 if (pnode->left != NULL) {
2725 }
2726
2728
2730 g_signal_connect(controller, "pressed",
2734 pnode->left = controller;
2738 g_signal_connect(controller, "released",
2742 pnode->middle = controller;
2746 g_signal_connect(controller, "released",
2750 pnode->right = controller;
2751
2752 if (city_owner(pdialog->pcity) != client.conn.playing) {
2754 } else {
2756 }
2757
2760 }
2761 i++;
2763
2764 buf = g_strdup_printf(_("Present units %d"), n);
2766 g_free(buf);
2767}
2768
2769/***********************************************************************/
2777{
2778 int count = 0;
2779 int city_number;
2780
2781 if (NULL != client.conn.playing) {
2783 } else {
2784 city_number = FC_INFINITY; /* ? */
2785 }
2786
2787 /* The first time, we see if all the city dialogs are open */
2789 if (city_owner(pdialog->pcity) == client.conn.playing) {
2790 count++;
2791 }
2793
2794 if (count == city_number) { /* All are open, shouldn't prev/next */
2796 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2797 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2799 } else {
2801 if (city_owner(pdialog->pcity) == client.conn.playing) {
2802 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2803 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2804 }
2806 }
2807}
2808
2809/***********************************************************************/
2812static void citydlg_response_callback(GtkDialog *dlg, gint response,
2813 void *data)
2814{
2815 switch (response) {
2816 case CDLGR_UNITS:
2817 show_units_response(data);
2818 break;
2819 }
2820}
2821
2822/***********************************************************************/
2825static void show_units_response(void *data)
2826{
2827 struct city_dialog *pdialog = (struct city_dialog *) data;
2828 struct tile *ptile = pdialog->pcity->tile;
2829
2830 if (unit_list_size(ptile->units)) {
2832 }
2833}
2834
2835/***********************************************************************/
2845static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2846 GtkWidget *wdg, bool supported)
2847{
2848 GMenu *menu;
2849 GActionGroup *group;
2850 GSimpleAction *act;
2851
2852 if (!can_client_issue_orders()) {
2853 return FALSE;
2854 }
2855
2856 if (pdialog->popover != NULL) {
2858 }
2859
2861 menu = g_menu_new();
2862
2863 if (supported) {
2864 act = g_simple_action_new("center", NULL);
2865 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2869 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2870 }
2871
2872 act = g_simple_action_new("activate", NULL);
2873 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2877 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2878 "win.activate"));
2879
2880 act = g_simple_action_new("activate_close", NULL);
2881 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2883
2884 if (supported) {
2885 g_signal_connect(act, "activate",
2888 } else {
2889 g_signal_connect(act, "activate",
2892 }
2893
2895 g_menu_item_new(_("Activate unit, _close dialog"),
2896 "win.activate_close"));
2897
2898 if (!supported) {
2899 act = g_simple_action_new("load", NULL);
2900 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2905 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2906
2907 act = g_simple_action_new("unload", NULL);
2908 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2916 unit_tile(punit)));
2917 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2918 "win.unload"));
2919
2920 act = g_simple_action_new("sentry", NULL);
2921 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2929 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2930 "win.sentry"));
2931
2932 act = g_simple_action_new("fortify", NULL);
2933 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2941 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2942 "win.fortify"));
2943 }
2944
2945 act = g_simple_action_new("disband", NULL);
2946 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2952 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2953 "win.disband"));
2954
2955 if (!supported) {
2956 act = g_simple_action_new("rehome", NULL);
2957 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2963 pdialog->pcity));
2966 "win.rehome"));
2967
2968 act = g_simple_action_new("upgrade", NULL);
2969 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2978 != NULL);
2979 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
2980 "win.upgrade"));
2981 }
2982
2984 g_object_ref(pdialog->popover);
2985 gtk_widget_insert_action_group(pdialog->popover, "win", group);
2987
2988
2990
2991 return TRUE;
2992}
2993
2994/***********************************************************************/
2998 double x, double y, gpointer data)
2999{
3000 struct city_dialog *pdialog;
3001 struct city *pcity;
3002 struct unit *punit =
3003 player_unit_by_number(client_player(), (size_t) data);
3004
3005 if (NULL != punit
3007 && NULL != (pdialog = get_city_dialog(pcity))) {
3008
3009 return create_unit_menu(pdialog, punit,
3011 TRUE);
3012 }
3013
3014 return TRUE;
3015}
3016
3017/***********************************************************************/
3021 double x, double y, gpointer data)
3022{
3023 struct city_dialog *pdialog;
3024 struct city *pcity;
3025 struct unit *punit =
3026 player_unit_by_number(client_player(), (size_t) data);
3027
3028 if (NULL != punit
3029 && NULL != (pcity = tile_city(unit_tile(punit)))
3030 && NULL != (pdialog = get_city_dialog(pcity))) {
3031
3032 return create_unit_menu(pdialog, punit,
3034 FALSE);
3035 }
3036
3037 return TRUE;
3038}
3039
3040/***********************************************************************/
3045 int n_press, double x, double y,
3046 gpointer data)
3047{
3048 struct city_dialog *pdialog;
3049 struct city *pcity;
3050 struct unit *punit =
3051 player_unit_by_number(client_player(), (size_t) data);
3052
3053 if (NULL != punit
3054 && NULL != (pcity = tile_city(unit_tile(punit)))
3055 && NULL != (pdialog = get_city_dialog(pcity))
3058 close_city_dialog(pdialog);
3059 }
3060
3061 return TRUE;
3062}
3063
3064/***********************************************************************/
3069 double x, double y, gpointer data)
3070{
3071 struct city_dialog *pdialog;
3072 struct city *pcity;
3073 struct unit *punit =
3074 player_unit_by_number(client_player(), (size_t) data);
3075
3076 if (NULL != punit
3078 && NULL != (pdialog = get_city_dialog(pcity))
3081 close_city_dialog(pdialog);
3082 }
3083
3084 return TRUE;
3085}
3086
3087/***********************************************************************/
3091 double x, double y, gpointer data)
3092{
3093 struct unit *punit =
3094 player_unit_by_number(client_player(), (size_t) data);
3095
3096 if (NULL != punit
3099 }
3100
3101 return TRUE;
3102}
3103
3104/***********************************************************************/
3109static void close_citydlg_unit_popover(struct city_dialog *pdialog)
3110{
3111 if (pdialog->popover != NULL) {
3112 gtk_widget_unparent(pdialog->popover);
3113 g_object_unref(pdialog->popover);
3114 pdialog->popover = NULL;
3115 }
3116}
3117
3118/***********************************************************************/
3122 gpointer data)
3123{
3124 struct unit *punit =
3126
3127 if (NULL != punit) {
3129 }
3130
3132}
3133
3134/***********************************************************************/
3138 gpointer data)
3139{
3140 struct unit *punit =
3142
3143 if (NULL != punit) {
3145 }
3146
3148}
3149
3150/***********************************************************************/
3155 GVariant *parameter,
3156 gpointer data)
3157{
3158 struct unit *punit =
3160
3161 if (NULL != punit) {
3162 struct city *pcity =
3164
3166 if (NULL != pcity) {
3167 struct city_dialog *pdialog = get_city_dialog(pcity);
3168
3169 if (NULL != pdialog) {
3170 close_city_dialog(pdialog);
3171 }
3172 }
3173 }
3174
3176}
3177
3178/***********************************************************************/
3183 GVariant *parameter,
3184 gpointer data)
3185{
3186 struct unit *punit =
3188
3189 if (NULL != punit) {
3190 struct city *pcity = tile_city(unit_tile(punit));
3191
3193 if (NULL != pcity) {
3194 struct city_dialog *pdialog = get_city_dialog(pcity);
3195
3196 if (NULL != pdialog) {
3197 close_city_dialog(pdialog);
3198 }
3199 }
3200 }
3201
3203}
3204
3205/***********************************************************************/
3209 gpointer data)
3210{
3211 struct unit *punit =
3213
3214 if (NULL != punit) {
3216 }
3217
3219}
3220
3221/***********************************************************************/
3225 gpointer data)
3226{
3227 struct unit *punit =
3229
3230 if (NULL != punit) {
3232 }
3233
3235}
3236
3237/***********************************************************************/
3241 gpointer data)
3242{
3243 struct unit *punit =
3245
3246 if (NULL != punit) {
3248 }
3249
3251}
3252
3253/***********************************************************************/
3257 gpointer data)
3258{
3259 struct unit *punit =
3261
3262 if (NULL != punit) {
3264 }
3265
3267}
3268
3269/***********************************************************************/
3273 gpointer data)
3274{
3275 struct unit_list *punits;
3276 struct unit *punit =
3278
3279 if (NULL == punit) {
3280 return;
3281 }
3282
3287
3289}
3290
3291/***********************************************************************/
3296 gpointer data)
3297{
3298 struct unit *punit =
3300
3301 if (NULL != punit) {
3303 }
3304
3306}
3307
3308/***********************************************************************/
3312 gpointer data)
3313{
3314 struct unit_list *punits;
3315 struct unit *punit =
3317
3318 if (NULL == punit) {
3319 return;
3320 }
3321
3326
3328}
3329
3330/******** Callbacks for citizen bar, map funcs that are not update ********/
3331
3332/***********************************************************************/
3337 double x, double y, gpointer data)
3338{
3339 struct city_dialog *pdialog = data;
3340 struct city *pcity = pdialog->pcity;
3341 int citnum, tlen, len;
3342
3343 if (!can_client_issue_orders()) {
3344 return FALSE;
3345 }
3346
3348 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
3349
3350 if (x > len) {
3351 /* No citizen that far to the right */
3352 return FALSE;
3353 }
3354 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
3355
3357
3358 return TRUE;
3359}
3360
3361/***********************************************************************/
3365{
3366 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
3367 struct city *pcity = workertask_req.owner;
3368 struct tile *ptile = workertask_req.loc;
3369 struct packet_worker_task task;
3370
3371 task.city_id = pcity->id;
3372
3373 if (act == ACTIVITY_LAST) {
3374 task.tgt = -1;
3375 task.want = 0;
3376 } else {
3377 enum extra_cause cause = activity_to_extra_cause(act);
3379 struct extra_type *tgt;
3380
3381 if (cause != EC_NONE) {
3382 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
3383 } else if (rmcause != ERM_NONE) {
3385 } else {
3386 tgt = NULL;
3387 }
3388
3389 if (tgt == NULL) {
3390 struct terrain *pterr = tile_terrain(ptile);
3391
3392 if ((act != ACTIVITY_TRANSFORM
3393 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3394 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3395 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3396 /* No extra to order */
3397 output_window_append(ftc_client, _("There's no suitable extra to order."));
3398
3399 return;
3400 }
3401
3402 task.tgt = -1;
3403 } else {
3404 task.tgt = extra_index(tgt);
3405 }
3406
3407 task.want = 100;
3408 }
3409
3410 task.tile_id = ptile->index;
3411 task.activity = act;
3412
3414}
3415
3416/***********************************************************************/
3423
3424/***********************************************************************/
3427static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3428{
3430 GtkWidget *shl;
3431 struct terrain *pterr = tile_terrain(ptile);
3432 struct universal for_terr = { .kind = VUT_TERRAIN,
3433 .value = { .terrain = pterr }};
3434 struct worker_task *ptask;
3435
3437 workertask_req.owner = pcity;
3438 workertask_req.loc = ptile;
3439
3441 _("What Action to Request"),
3442 _("Select autoworker activity:"));
3443
3444 ptask = worker_task_list_get(pcity->task_reqs, 0);
3445 if (ptask != NULL) {
3446 choice_dialog_add(shl, _("Clear request"),
3449 }
3450
3452 choice_dialog_add(shl, Q_("?act:Mine"),
3455 }
3456 if (pterr->plant_result != NULL
3458 NULL, &for_terr)) {
3459 choice_dialog_add(shl, _("Plant"),
3462 }
3464 choice_dialog_add(shl, _("Irrigate"),
3467 }
3468 if (pterr->cultivate_result != NULL
3470 NULL, &for_terr)) {
3471 choice_dialog_add(shl, _("Cultivate"),
3474 }
3476 choice_dialog_add(shl, _("Road"),
3479 }
3480 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3482 NULL, &for_terr)) {
3483 choice_dialog_add(shl, _("Transform"),
3486 }
3488 city_owner(pcity), NULL) != NULL) {
3489 choice_dialog_add(shl, _("Clean"),
3492 }
3493
3494 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3496
3498 NULL);
3499 }
3500}
3501
3502/***********************************************************************/
3506 double x, double y, gpointer data)
3507{
3508 struct city_dialog *pdialog = data;
3510
3511 if (!can_client_issue_orders()) {
3512 return FALSE;
3513 }
3514
3515 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3516 return FALSE;
3517 }
3518
3521
3523 city_map_radius_sq_get(pdialog->pcity),
3524 canvas_x, canvas_y)) {
3526 }
3527
3528 return TRUE;
3529}
3530
3531/***********************************************************************/
3535 double x, double y, gpointer data)
3536{
3537 struct city_dialog *pdialog = data;
3539
3540 if (!can_client_issue_orders()) {
3541 return FALSE;
3542 }
3543
3546
3548 city_map_radius_sq_get(pdialog->pcity),
3549 canvas_x, canvas_y)) {
3550 struct city *pcity = pdialog->pcity;
3551
3552 popup_workertask_dlg(pdialog->pcity,
3555 city_x, city_y));
3556 }
3557
3558 return TRUE;
3559}
3560
3561/***********************************************************************/
3564static void draw_map_canvas(struct city_dialog *pdialog)
3565{
3567 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3569 }
3570}
3571
3572/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3573
3574/***********************************************************************/
3577static void buy_callback_response(GObject *dialog, GAsyncResult *result,
3578 gpointer data)
3579{
3581 result, NULL);
3582
3583 if (button == 0) {
3584 struct city_dialog *pdialog = data;
3585
3586 city_buy_production(pdialog->pcity);
3587 }
3588}
3589
3590/***********************************************************************/
3593static void buy_callback(GtkWidget *w, gpointer data)
3594{
3596 struct city_dialog *pdialog = data;
3597 const char *name = city_production_name_translation(pdialog->pcity);
3598 int value = pdialog->pcity->client.buy_cost;
3599 char buf[1024];
3600
3601 if (!can_client_issue_orders()) {
3602 return;
3603 }
3604
3605 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3606 "Treasury contains %d gold.",
3607 client_player()->economic.gold),
3608 client_player()->economic.gold);
3609
3610 if (value <= client_player()->economic.gold) {
3611 const char *buttons[] = { _("Yes"), _("No"), NULL };
3612
3614 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3615 PL_("Buy %s for %d gold?\n%s",
3616 "Buy %s for %d gold?\n%s", value),
3617 name, value, buf);
3619 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3621
3623 buy_callback_response, pdialog);
3624 } else {
3625 const char *buttons[] = { _("Close"), NULL };
3626
3628 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3629 PL_("%s costs %d gold.\n%s",
3630 "%s costs %d gold.\n%s", value),
3631 name, value, buf);
3633 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3636 }
3637}
3638
3639/***********************************************************************/
3643 guint position,
3644 guint n_items,
3645 gpointer data)
3646{
3650 struct universal univ = cid_production(row->id);
3651
3652 city_change_production(((struct city_dialog *)data)->pcity, &univ);
3653 }
3654}
3655
3656/***********************************************************************/
3659static void sell_callback(const struct impr_type *pimprove, gpointer data)
3660{
3661 GtkWidget *shl;
3662 struct city_dialog *pdialog = (struct city_dialog *) data;
3663 pdialog->sell_id = improvement_number(pimprove);
3664 int price;
3665
3666 if (!can_client_issue_orders()) {
3667 return;
3668 }
3669
3671 pimprove) != TR_SUCCESS) {
3672 return;
3673 }
3674
3675 price = impr_sell_gold(pimprove);
3680 PL_("Sell %s for %d gold?",
3681 "Sell %s for %d gold?", price),
3682 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3683 setup_dialog(shl, pdialog->shell);
3684 pdialog->sell_shell = shl;
3685
3686 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3687
3688 g_signal_connect(shl, "response",
3690
3692}
3693
3694/***********************************************************************/
3697static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3698{
3699 struct city_dialog *pdialog = data;
3700
3701 if (response == GTK_RESPONSE_YES) {
3702 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3703 }
3705
3706 pdialog->sell_shell = NULL;
3707}
3708
3709/***********************************************************************/
3712static void impr_callback(GtkColumnView *self, guint position,
3713 gpointer data)
3714{
3715 GdkSeat *seat;
3717 GListStore *store = ((struct city_dialog *)data)->overview.improvement_list;
3718 FcImprRow *row = g_list_model_get_item(G_LIST_MODEL(store), position);
3719 const struct impr_type *pimpr = row->impr;
3720 GtkWidget *wdg = ((struct city_dialog *)data)->shell;
3721
3724
3725 if (!(mask & GDK_CONTROL_MASK)) {
3726 sell_callback(pimpr, data);
3727 } else {
3728 if (is_great_wonder(pimpr)) {
3730 } else {
3732 }
3733 }
3734}
3735
3736/************ Callbacks for stuff on the Misc. Settings page **************/
3737
3738/***********************************************************************/
3742{
3743 struct city_dialog *pdialog;
3744
3745 pdialog = (struct city_dialog *) data;
3746
3747 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3748 /* "shellrenamecity" */
3749 _("Rename City"),
3750 _("What should we rename the city to?"),
3751 city_name_get(pdialog->pcity),
3752 rename_popup_callback, pdialog);
3753}
3754
3755/***********************************************************************/
3758static void rename_popup_callback(gpointer data, gint response,
3759 const char *input)
3760{
3761 struct city_dialog *pdialog = data;
3762
3763 if (pdialog) {
3764 if (response == GTK_RESPONSE_OK) {
3765 city_rename(pdialog->pcity, input);
3766 } /* else CANCEL or DELETE_EVENT */
3767
3768 pdialog->rename_shell = NULL;
3769 }
3770}
3771
3772/***********************************************************************/
3776{
3778}
3779
3780/***********************************************************************/
3784{
3785 struct city_dialog *pdialog = (struct city_dialog *) data;
3786
3787 if (!can_client_issue_orders()) {
3788 return;
3789 }
3790
3791 if (!pdialog->misc.block_signal) {
3792 struct city *pcity = pdialog->pcity;
3794
3795 fc_assert(CITYO_LAST == 3);
3796
3800 }
3803 }
3806 }
3807
3809 pcity->wlcb);
3810 }
3811}
3812
3813/***********************************************************************/
3838
3839/******************** Callbacks for: Close, Prev, Next. *******************/
3840
3841/***********************************************************************/
3844static void close_callback(GtkWidget *w, gpointer data)
3845{
3846 close_city_dialog((struct city_dialog *) data);
3847}
3848
3849/***********************************************************************/
3853{
3854 struct city_dialog *pdialog;
3855
3856 pdialog = (struct city_dialog *) data;
3857
3859
3861 citizens_dialog_close(pdialog->pcity);
3862 }
3863 close_happiness_dialog(pdialog->pcity);
3864 close_cma_dialog(pdialog->pcity);
3865
3866 /* Save size of the city dialog. */
3875
3876 last_page
3878
3881
3884
3885 if (pdialog->sell_shell) {
3887 }
3888 if (pdialog->rename_shell) {
3890 }
3891
3894
3895 free(pdialog);
3896
3897 /* Need to do this every time a new dialog is closed. */
3899}
3900
3901/***********************************************************************/
3904static void close_city_dialog(struct city_dialog *pdialog)
3905{
3907}
3908
3909/***********************************************************************/
3914{
3915 struct city_dialog *pdialog = (struct city_dialog *) data;
3916 int i, j, dir, size;
3917 struct city *new_pcity = NULL;
3918
3920 return;
3921 }
3922
3924
3926 fc_assert_ret(size >= 1);
3928
3929 if (size == 1) {
3930 return;
3931 }
3932
3933 /* dir = 1 will advance to the city, dir = -1 will get previous */
3934 if (w == GTK_WIDGET(pdialog->next_command)) {
3935 dir = 1;
3936 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3937 dir = -1;
3938 } else {
3939 /* Always fails. */
3941 || w == GTK_WIDGET(pdialog->prev_command));
3942 dir = 1;
3943 }
3944
3945 for (i = 0; i < size; i++) {
3946 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3947 break;
3948 }
3949 }
3950
3951 fc_assert_ret(i < size);
3952
3953 for (j = 1; j < size; j++) {
3955 (i + dir * j + size) % size);
3957
3958 fc_assert_ret(other_pdialog != pdialog);
3959 if (!other_pdialog) {
3961 break;
3962 }
3963 }
3964
3965 if (!new_pcity) {
3966 /* Every other city has an open city dialog. */
3967 return;
3968 }
3969
3970 /* cleanup happiness dialog */
3972 citizens_dialog_close(pdialog->pcity);
3973 }
3974 close_happiness_dialog(pdialog->pcity);
3975
3976 pdialog->pcity = new_pcity;
3977
3978 /* reinitialize happiness, and cma dialogs */
3981 citizens_dialog_display(pdialog->pcity));
3982 }
3984 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
3985 if (!client_is_observer()) {
3986 fc_assert(pdialog->cma_editor != NULL);
3987 pdialog->cma_editor->pcity = new_pcity;
3988 }
3989
3990 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
3991
3992 can_slide = FALSE;
3993 center_tile_mapcanvas(pdialog->pcity->tile);
3994 can_slide = TRUE;
3995 if (!client_is_observer()) {
3996 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
3997 }
3998
4000
4001 /* Recenter the city map(s) */
4003 if (pdialog->happiness.map_canvas.sw) {
4005 }
4006}
4007
4008/***********************************************************************/
4012{
4014 refresh_worklist(pdialog->production.worklist);
4016}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1250
bool action_ever_possible(action_id action)
Definition actions.c:7550
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:710
#define n
Definition astring.c:77
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
int city_granary_size(int city_size)
Definition city.c:2132
int city_build_slots(const struct city *pcity)
Definition city.c:2932
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:305
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1255
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3413
int city_population(const struct city *pcity)
Definition city.c:1191
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
Definition city.c:3049
bool city_unhappy(const struct city *pcity)
Definition city.c:1626
bool city_celebrating(const struct city *pcity)
Definition city.c:1645
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2870
bool city_happy(const struct city *pcity)
Definition city.c:1614
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
citizens city_specialists(const struct city *pcity)
Definition city.c:3342
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
Definition city.c:1013
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1996
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:700
static citizens city_size_get(const struct city *pcity)
Definition city.h:566
citizen_category
Definition city.h:264
#define city_owner(_pcity_)
Definition city.h:560
#define MAX_CITY_SIZE
Definition city.h:103
@ FEELING_FINAL
Definition city.h:281
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)
static struct ai_type * self
Definition classicai.c:46
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:819
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:650
cid cid_encode(struct universal target)
Definition climisc.c:483
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:913
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:89
#define cid_production
Definition climisc.h:71
int cid
Definition climisc.h:31
static struct fc_sockaddr_list * list
Definition clinet.c:102
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:552
char * incite_cost
Definition comments.c:76
void request_unit_fortify(struct unit *punit)
Definition control.c:2353
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2094
void request_unit_unload(struct unit *pcargo)
Definition control.c:2194
void request_unit_sentry(struct unit *punit)
Definition control.c:2342
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
int counter_index(const struct counter *pcount)
Definition counters.c:174
#define city_counters_iterate_end
Definition counters.h:64
#define city_counters_iterate(pcount)
Definition counters.h:57
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 const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
static struct editor_state * editor
Definition editor.c:100
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:779
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1090
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1111
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:235
#define EC_NONE
Definition fc_types.h:821
@ TR_SUCCESS
Definition fc_types.h:954
#define ERM_NONE
Definition fc_types.h:844
@ 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:739
struct civ_game game
Definition game.c:61
struct world wld
Definition game.c:62
struct city * game_city_by_number(int id)
Definition game.c:106
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
void choice_dialog_end(GtkWidget *dshell)
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
GtkWidget * citizens_dialog_display(const struct city *pcity)
void citizens_dialog_refresh(const struct city *pcity)
void citizens_dialog_close(const struct city *pcity)
static void unit_sentry_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2876
citydlg_response
Definition citydlg.c:82
@ CDLGR_UNITS
Definition citydlg.c:82
@ CDLGR_PREV
Definition citydlg.c:82
@ CDLGR_NEXT
Definition citydlg.c:82
static int new_dialog_def_page
Definition citydlg.c:219
static void create_and_append_buildings_page(struct city_dialog *pdialog)
Definition citydlg.c:1238
static void unit_upgrade_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2935
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3046
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1869
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3459
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1830
static int last_page
Definition citydlg.c:220
static void init_citydlg_dimensions(void)
Definition citydlg.c:332
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1272
struct tile * loc
Definition citydlg.c:227
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:128
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3383
static bool low_citydlg
Definition citydlg.c:230
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
static void city_dialog_update_building(struct city_dialog *pdialog)
Definition citydlg.c:2069
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2502
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3174
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2775
static struct city_dialog * get_city_dialog(struct city *pcity)
Definition citydlg.c:387
@ INFO_LUXURY
Definition citydlg.c:120
@ INFO_STEAL
Definition citydlg.c:122
@ INFO_CORRUPTION
Definition citydlg.c:121
@ NUM_INFO_FIELDS
Definition citydlg.c:123
@ INFO_ILLNESS
Definition citydlg.c:122
@ INFO_WASTE
Definition citydlg.c:121
@ INFO_SIZE
Definition citydlg.c:119
@ INFO_GROWTH
Definition citydlg.c:120
@ INFO_SHIELD
Definition citydlg.c:119
@ INFO_CULTURE
Definition citydlg.c:121
@ INFO_GOLD
Definition citydlg.c:119
@ INFO_SCIENCE
Definition citydlg.c:120
@ INFO_POLLUTION
Definition citydlg.c:121
@ INFO_TRADE
Definition citydlg.c:119
@ INFO_AIRLIFT
Definition citydlg.c:122
@ INFO_GRANARY
Definition citydlg.c:120
@ INFO_FOOD
Definition citydlg.c:119
#define CITY_MAP_MIN_SIZE_Y
Definition citydlg.c:129
static void city_dialog_update_information(GtkWidget **info_ebox, GtkWidget **info_label, struct city_dialog *pdialog)
Definition citydlg.c:1932
static GtkWidget * create_citydlg_improvement_list(struct city_dialog *pdialog, GtkWidget *vbox)
Definition citydlg.c:897
static void create_production_header(struct city_dialog *pdialog, GtkContainer *contain)
Definition citydlg.c:1205
static void workertask_dlg_destroy(GtkWidget *w, gpointer data)
Definition citydlg.c:3038
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2356
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2956
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3237
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2850
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3425
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3514
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:661
static void create_and_append_overview_page(struct city_dialog *pdialog)
Definition citydlg.c:956
static void create_and_append_happiness_page(struct city_dialog *pdialog)
Definition citydlg.c:1316
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
static void buy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3187
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3310
static void create_and_append_map_page(struct city_dialog *pdialog)
Definition citydlg.c:1144
static void city_dialog_map_create(struct city_dialog *pdialog, struct city_map_canvas *cmap_canvas)
Definition citydlg.c:423
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
void reset_city_dialogs(void)
Definition citydlg.c:365
static void cityopt_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3391
static void city_dialog_map_recenter(GtkWidget *map_canvas_sw)
Definition citydlg.c:462
@ WORKLIST_PAGE
Definition citydlg.c:112
@ CMA_PAGE
Definition citydlg.c:112
@ HAPPINESS_PAGE
Definition citydlg.c:112
@ SETTINGS_PAGE
Definition citydlg.c:113
@ STICKY_PAGE
Definition citydlg.c:113
@ NUM_PAGES
Definition citydlg.c:114
@ OVERVIEW_PAGE
Definition citydlg.c:112
static void draw_map_canvas(struct city_dialog *pdialog)
Definition citydlg.c:3162
static struct @145 workertask_req
static bool is_showing_workertask_dialog
Definition citydlg.c:222
#define unit_node_vector_iterate_end
Definition citydlg.c:108
static void sell_callback(struct impr_type *pimprove, gpointer data)
Definition citydlg.c:3256
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2802
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2463
static void create_and_append_settings_page(struct city_dialog *pdialog)
Definition citydlg.c:1500
static bool city_dialogs_have_been_initialised
Definition citydlg.c:217
static void close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3451
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3295
static void create_citydlg_main_map(struct city_dialog *pdialog, GtkWidget *container)
Definition citydlg.c:880
#define NUM_CITIZENS_SHOWN
Definition citydlg.c:110
#define CITYMAP_HEIGHT
Definition citydlg.c:75
static void unit_homecity_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2922
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2889
static void city_dialog_update_counters(struct city_dialog *pdialog)
Definition citydlg.c:1413
static gboolean present_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2598
struct city * owner
Definition citydlg.c:226
static GtkWidget * create_city_info_table(struct city_dialog *pdialog, GtkWidget **info_ebox, GtkWidget **info_label)
Definition citydlg.c:745
static struct city_dialog * create_city_dialog(struct city *pcity)
Definition citydlg.c:1642
static void target_drag_data_received(GtkWidget *w, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
Definition citydlg.c:1167
static void unit_disband_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2902
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3349
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3523
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2047
static void create_and_append_counters_page(struct city_dialog *pdialog)
Definition citydlg.c:1393
static void unit_unload_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2863
static void show_units_response(void *data)
Definition citydlg.c:2515
static void initialize_city_dialogs(void)
Definition citydlg.c:341
static int canvas_height
Definition citydlg.c:218
static int canvas_width
Definition citydlg.c:218
#define TINYSCREEN_MAX_HEIGHT
Definition citydlg.c:78
static void city_dialog_update_supported_units(struct city_dialog *pdialog)
Definition citydlg.c:2249
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2788
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2827
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2983
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3366
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2192
static void create_and_append_cma_page(struct city_dialog *pdialog)
Definition citydlg.c:1480
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:595
static gboolean supported_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2536
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:126
GtkWidget * map_canvas
Definition gui_main.c:108
int screen_height(void)
Definition gui_main.c:2594
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
GtkWidget * icon_label_button_new(const gchar *icon_name, const gchar *label_text)
Definition gui_stuff.c:76
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void intl_slist(int n, const char **s, bool *done)
Definition gui_stuff.c:111
void close_happiness_dialog(struct city *pcity)
Definition happiness.c:330
void refresh_happiness_dialog(struct city *pcity)
Definition happiness.c:317
GtkWidget * get_top_happiness_display(struct city *pcity, bool low_dlg, GtkWidget *win)
Definition happiness.c:356
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
GtkWidget * input_dialog_create(GtkWindow *parent, const char *dialogname, const char *text, const char *postinputtest, input_dialog_callback_t response_callback, gpointer response_cli_data)
Definition inputdlg.c:66
static struct gui_dialog * shell
Definition messagedlg.c:39
const char * tooltip
Definition repodlgs.c:1315
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
bool request_transport(struct unit *cargo, struct tile *ptile)
void refresh_worklist(GtkWidget *editor)
Definition wldlg.c:1327
void add_worklist_dnd_target(GtkWidget *w)
Definition wldlg.c:339
void reset_city_worklist(GtkWidget *editor, struct city *pcity)
Definition wldlg.c:1279
GtkWidget * create_worklist(void)
Definition wldlg.c:1054
void refresh_all_city_worklists(void)
Definition citydlg.c:3735
static void canvas_draw_cb(GtkDrawingArea *w, cairo_t *cr, int width, int height, gpointer data)
Definition citydlg.c:420
static gboolean right_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3250
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2760
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2561
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2806
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3221
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2825
@ COUNTERS_PAGE
Definition citydlg.c:115
static gboolean middle_supported_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2784
static gboolean citydlg_keyboard_handler(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
Definition citydlg.c:638
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
void put_unit_picture_city_overlays(struct unit *punit, GtkPicture *p, int height, int *upkeep_cost, int happy_cost)
Definition mapview.c:519
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:494
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
static FcProdRow * fc_prod_row_new(void)
Definition citydlg.c:481
static void prod_factory_setup(GtkSignalListItemFactory *self, GtkListItem *list_item, gpointer user_data)
Definition citydlg.c:1202
static void fc_impr_row_finalize(GObject *gobject)
Definition citydlg.c:399
#define FC_TYPE_IMPR_ROW
Definition citydlg.c:345
#define IMPR_ROW_UPKEEP
Definition citydlg.c:370
#define FC_TYPE_PROD_ROW
Definition citydlg.c:372
#define PROD_ROW_NAME
Definition citydlg.c:394
static void fc_impr_row_class_init(FcImprRowClass *klass)
Definition citydlg.c:415
#define IMPR_ROW_DESC
Definition citydlg.c:369
static FcImprRow * fc_impr_row_new(void)
Definition citydlg.c:434
static void fc_impr_row_init(FcImprRow *self)
Definition citydlg.c:426
static void impr_factory_setup(GtkSignalListItemFactory *self, GtkListItem *list_item, gpointer user_data)
Definition citydlg.c:1073
#define IMPR_ROW_PIXBUF
Definition citydlg.c:368
static void fc_prod_row_finalize(GObject *gobject)
Definition citydlg.c:446
#define PROD_ROW_PIXBUF
Definition citydlg.c:393
static void fc_prod_row_init(FcProdRow *self)
Definition citydlg.c:473
static void prod_factory_bind(GtkSignalListItemFactory *self, GtkListItem *list_item, gpointer user_data)
Definition citydlg.c:1167
static gboolean query_impr_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_tip, GtkTooltip *tooltip, gpointer data)
Definition citydlg.c:1091
static void impr_factory_bind(GtkSignalListItemFactory *self, GtkListItem *list_item, gpointer user_data)
Definition citydlg.c:1030
static void fc_prod_row_class_init(FcProdRowClass *klass)
Definition citydlg.c:462
void alert_close_response(GObject *dialog, GAsyncResult *result, gpointer data)
Definition gui_stuff.c:1173
int get_column_view_row(GtkWidget *cview, int y)
Definition gui_stuff.c:1182
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:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_debug(message,...)
Definition log.h:116
void center_tile_mapcanvas(const struct tile *ptile)
bool can_slide
#define fc_malloc(sz)
Definition mem.h:34
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:318
bool unit_can_load(const struct unit *punit)
Definition movement.c:884
static const char * name_translation_get(const struct name_translation *ptrans)
#define GUI_GTK5_CITYDLG_MAX_XSIZE
Definition options.h:691
#define GUI_GTK5_CITYDLG_MIN_XSIZE
Definition options.h:690
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, enum city_wl_cancel_behavior wl_cb)
int len
Definition packhand.c:127
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1203
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
#define CLIP(lower, current, upper)
Definition shared.h:57
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
size_t size
Definition specvec.h:72
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
#define strvec_iterate(psv, str)
#define strvec_iterate_end
GObjectClass parent_class
Definition citydlg.c:363
int upkeep
Definition citydlg.c:356
const struct impr_type * impr
Definition citydlg.c:353
GdkPixbuf * sprite
Definition citydlg.c:354
const char * tooltip
Definition citydlg.c:358
char * description
Definition citydlg.c:355
bool redundant
Definition citydlg.c:357
GObject parent_instance
Definition citydlg.c:351
GObjectClass parent_class
Definition citydlg.c:388
bool useless
Definition citydlg.c:383
GObject parent_instance
Definition citydlg.c:378
const char * name
Definition citydlg.c:380
GdkPixbuf * sprite
Definition citydlg.c:382
cairo_surface_t * surface
Definition canvas.h:23
GtkWidget * prev_command
Definition citydlg.c:208
GtkWidget * name_label
Definition citydlg.c:141
GtkWidget * rename_shell
Definition citydlg.c:205
enum city_dialog::@220 page
GtkWidget * rename_command
Definition citydlg.c:196
GtkWidget * production_bar
Definition citydlg.c:152
GtkWidget * supported_units_frame
Definition citydlg.c:157
GtkWidget * sell_shell
Definition citydlg.c:203
GtkWidget * production_label
Definition citydlg.c:173
GtkWidget * widget
Definition citydlg.c:182
GtkWidget * supported_unit_table
Definition citydlg.c:158
GtkWidget * disband_on_settler
Definition citydlg.c:198
struct city_map_canvas map_canvas
Definition citydlg.c:150
GListStore * improvement_list
Definition citydlg.c:156
GtkWidget * improvement_list
Definition citydlg.c:155
GtkWidget * container
Definition citydlg.c:189
GtkWidget * buy_command
Definition citydlg.c:154
short block_signal
Definition citydlg.c:200
GtkWidget * whichtab_radio[NUM_PAGES]
Definition citydlg.c:199
struct unit_node_vector supported_units
Definition citydlg.c:163
cairo_surface_t * map_canvas_store_unscaled
Definition citydlg.c:142
struct city * pcity
Definition citydlg.c:138
struct city_dialog::@148 happiness
struct unit_node_vector present_units
Definition citydlg.c:164
city_map * view
Definition citydlg.h:455
GtkWidget * popover
Definition citydlg.c:147
GtkWidget * citizen_pics
Definition citydlg.c:148
GtkWidget * citizens
Definition citydlg.c:185
GListStore * change_prod_store
Definition citydlg.c:169
GtkWidget * show_units_command
Definition citydlg.c:207
Impr_type_id sell_id
Definition citydlg.c:211
struct city_dialog::@150 misc
struct cma_dialog * cma_editor
Definition citydlg.c:193
cairo_surface_t * citizen_surface
Definition citydlg.c:147
GtkWidget * shell
Definition citydlg.c:140
GtkWidget * worklist
Definition citydlg.c:176
GtkSingleSelection * change_prod_selection
Definition citydlg.c:170
GtkWidget * present_units_frame
Definition citydlg.c:160
GtkWidget * info_label[NUM_INFO_FIELDS]
Definition citydlg.c:167
GtkWidget * new_citizens_radio[3]
Definition citydlg.c:197
GtkWidget * present_unit_table
Definition citydlg.c:161
struct city_dialog::@149 counters
GtkWidget * notebook
Definition citydlg.c:143
struct city_dialog::@146 overview
GtkWidget * next_command
Definition citydlg.c:209
GtkTreeSelection * change_selection
Definition citydlg.c:204
struct city_dialog::@147 production
GtkWidget * darea
Definition citydlg.c:134
GtkWidget * sw
Definition citydlg.c:132
Definition city.h:317
int * counter_values
Definition city.h:405
struct unit_list * info_units_present
Definition city.h:471
struct unit_list * info_units_supported
Definition city.h:470
citizens size
Definition city.h:329
int illness
Definition city.h:431
int buy_cost
Definition city.h:463
struct city::@18::@21 client
struct tile * tile
Definition city.h:319
struct unit_list * units_supported
Definition city.h:403
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:82
struct universal item
Definition climisc.h:83
char descr[MAX_LEN_NAME+40]
Definition climisc.h:84
enum unit_activity activity
struct city_list * cities
Definition player.h:281
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int height
Definition citydlg.c:98
GtkEventController * right
Definition citydlg.c:101
GtkWidget * cmd
Definition citydlg.c:96
GtkWidget * pix
Definition citydlg.c:97
GtkEventController * middle
Definition citydlg.c:100
GtkEventController * left
Definition citydlg.c:99
Definition unit.h:140
int upkeep[O_LAST]
Definition unit.h:150
enum unit_activity activity
Definition unit.h:159
int id
Definition unit.h:147
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
int homecity
Definition unit.h:148
struct player * owner
Definition unit.h:145
enum universals_n kind
Definition fc_types.h:608
universals_u value
Definition fc_types.h:607
struct tile * ptile
Definition workertask.h:22
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * unit_description(struct unit *punit)
Definition text.c:522
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:111
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7007
int tileset_small_sprite_width(const struct tileset *t)
Definition tilespec.c:927
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:815
int tileset_small_sprite_height(const struct tileset *t)
Definition tilespec.c:963
int tileset_unit_with_upkeep_height(const struct tileset *t)
Definition tilespec.c:885
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6946
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7029
const struct unit_type * utype
Definition fc_types.h:553
const struct impr_type * building
Definition fc_types.h:546
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:489
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2518
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:383
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:776
#define unit_tile(_pu)
Definition unit.h:404
#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:1709
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1566
void economy_report_dialog_update(void)
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66