Freeciv-3.4
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, *vp;
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
1377
1380
1381 /* Present units */
1388
1395
1398
1399 /* Show page */
1401}
1402
1403/***********************************************************************/
1406static void create_and_append_map_page(struct city_dialog *pdialog)
1407{
1408 if (low_citydlg) {
1409 GtkWidget *page;
1410 GtkWidget *label;
1411 const char *tab_title = _("Citymap");
1412 int page_row = 0;
1413
1414 page = gtk_grid_new();
1423
1424 create_citydlg_main_map(pdialog, page, 0, page_row++);
1425
1427 }
1428}
1429
1430/***********************************************************************/
1434 const GValue *value,
1435 double x, double y, gpointer data)
1436{
1437 struct city_dialog *pdialog = (struct city_dialog *) data;
1438 cid id;
1439 struct universal univ;
1440
1441 if (NULL != client.conn.playing
1442 && city_owner(pdialog->pcity) != client.conn.playing) {
1443 return FALSE;
1444 }
1445
1446 id = g_value_get_int(value);
1447 univ = cid_production(id);
1448
1449 city_change_production(pdialog->pcity, &univ);
1450
1451 return TRUE;
1452}
1453
1454/***********************************************************************/
1458static int create_production_header(struct city_dialog *pdialog,
1459 GtkWidget *grid, int row)
1460{
1461 GtkWidget *hgrid, *bar;
1462 int grid_col = 0;
1463
1464 hgrid = gtk_grid_new();
1470 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1471
1472 /* The label is set in city_dialog_update_building() */
1473 bar = gtk_progress_bar_new();
1476 pdialog->production.production_bar = bar;
1477 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1478 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1479
1481
1482 pdialog->production.buy_command
1483 = icon_label_button_new("system-run", _("_Buy"));
1485 grid_col++, 0, 1, 1);
1486
1487 g_signal_connect(pdialog->production.buy_command, "clicked",
1488 G_CALLBACK(buy_callback), pdialog);
1489
1490 return row;
1491}
1492
1493/***********************************************************************/
1497{
1498 if (low_citydlg) {
1499 GtkWidget *page;
1500 GtkWidget *label;
1501 GtkWidget *vbox;
1502 GtkWidget *view;
1503 const char *tab_title = _("Buildings");
1504 int page_row = 0;
1505
1506 page = gtk_grid_new();
1514
1515 page_row = create_production_header(pdialog, page, page_row);
1516 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1517
1519 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1520
1522
1523 gtk_box_append(GTK_BOX(vbox), view);
1524
1526 }
1527}
1528
1529/***********************************************************************/
1533{
1534 const char *tab_title = _("P_roduction");
1536 GtkWidget *page, *editor;
1537 int page_row = 0;
1538
1539 page = gtk_grid_new();
1546 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1547
1548 /* Stuff that's being currently built */
1549 if (!low_citydlg) {
1551 "label", _("Production:"),
1552 "xalign", 0.0, "yalign", 0.5, NULL);
1553 pdialog->production.production_label = label;
1554 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1555
1556 page_row = create_production_header(pdialog, page, page_row);
1557 } else {
1558 pdialog->production.production_label = NULL;
1559 }
1560
1566 reset_city_worklist(editor, pdialog->pcity);
1567 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1568 pdialog->production.worklist = editor;
1569
1571}
1572
1573/***********************************************************************/
1584{
1585 GtkWidget *page, *label, *table, *right, *left, *frame;
1586 const char *tab_title = _("Happ_iness");
1587 int page_col = 0;
1588 int left_row = 0;
1589
1590 /* Main page */
1591 page = gtk_grid_new();
1598 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1599
1600 /* Left: info, citizens */
1601 left = gtk_grid_new();
1604 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1605
1606 if (!low_citydlg) {
1607 /* Upper left: info */
1608 frame = gtk_frame_new(_("Info"));
1609 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1610
1611 table = create_city_info_table(pdialog,
1612 pdialog->happiness.info_label);
1615 }
1616
1617 /* Lower left: citizens */
1621 0, left_row++, 1, 1);
1623 citizens_dialog_display(pdialog->pcity));
1624 }
1625
1626 /* Right: city map, happiness */
1628 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1629
1630 if (!low_citydlg) {
1631 /* Upper right: city map */
1632 frame = gtk_frame_new(_("City map"));
1635 gtk_box_append(GTK_BOX(right), frame);
1636
1637 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1639 }
1640
1641 /* Lower right: happiness */
1643 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1646 pdialog->shell));
1647
1648 /* Show page */
1650}
1651
1652/**********************************************************************/
1655/**********************************************************************/
1660{
1662 GtkLabel *label = GTK_LABEL(gtk_label_new(_("Counters")));
1663
1664 pdialog->counters.container = NULL;
1665 pdialog->counters.widget = NULL;
1666
1668
1670
1672
1673 gtk_widget_show(page);
1674}
1675
1676/***********************************************************************/
1679static void create_and_append_cma_page(struct city_dialog *pdialog)
1680{
1681 GtkWidget *page, *label;
1682 const char *tab_title = _("_Governor");
1683
1685
1687
1688 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1689
1690 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1691 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1692
1694}
1695
1696/***********************************************************************/
1700{
1701 int i;
1702 GtkWidget *vgrid, *page, *frame, *label, *button;
1704 GtkWidget *group;
1705 const char *tab_title = _("_Settings");
1706 int grid_row = 0;
1707
1708 static const char *new_citizens_output_label[] = {
1709 N_("Luxury"),
1710 N_("Science"),
1711 N_("Gold")
1712 };
1713
1714 static const char *disband_label
1715 = N_("Allow unit production to disband city");
1716
1717 static const char *misc_whichtab_label[NUM_PAGES] = {
1718 N_("Overview page"),
1719 N_("Production page"),
1720 N_("Happiness page"),
1721 N_("Counters Page"),
1722 N_("Governor page"),
1723 N_("This Settings page"),
1724 N_("Last active page")
1725 };
1726
1727 static bool new_citizens_label_done;
1728 static bool misc_whichtab_label_done;
1729
1730 /* Initialize signal_blocker */
1731 pdialog->misc.block_signal = 0;
1732
1733
1734 page = gtk_grid_new();
1740
1742
1744
1745 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1746
1747 /* new_citizens radio */
1748 frame = gtk_frame_new(_("New citizens produce"));
1749 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1751
1752 vgrid = gtk_grid_new();
1756
1759
1760 group = NULL;
1761 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1764 GTK_CHECK_BUTTON(group));
1765 pdialog->misc.new_citizens_radio[i] = button;
1766 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1767 g_signal_connect(button, "toggled",
1768 G_CALLBACK(cityopt_callback), pdialog);
1769 group = button;
1770 }
1771
1772 /* Next is the next-time-open radio group in the right column */
1773 frame = gtk_frame_new(_("Next time open"));
1774 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1776
1777 vgrid = gtk_grid_new();
1778 grid_row = 0;
1782
1785
1786 group = NULL;
1787 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1790 GTK_CHECK_BUTTON(group));
1791 pdialog->misc.whichtab_radio[i] = button;
1792 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1793 g_signal_connect(button, "toggled",
1795 group = button;
1796 }
1797
1798 /* Now we go back and fill the hbox rename */
1799 frame = gtk_frame_new(_("City"));
1800 gtk_widget_set_margin_top(frame, 12);
1802 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1803
1804 vgrid = gtk_grid_new();
1805 grid_row = 0;
1809
1810 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1811 pdialog->misc.rename_command = button;
1812 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1813 g_signal_connect(button, "clicked",
1814 G_CALLBACK(rename_callback), pdialog);
1815
1817
1818 /* The disband-city-on-unit-production button */
1820 pdialog->misc.disband_on_settler = button;
1821 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1822 g_signal_connect(button, "toggled",
1823 G_CALLBACK(cityopt_callback), pdialog);
1824
1825 /* We choose which page to popup by default */
1827 (pdialog->
1829 TRUE);
1830
1831 set_cityopt_values(pdialog);
1832
1834
1835 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1837 last_page);
1838 } else {
1841 }
1842}
1843
1844/***********************************************************************/
1853{
1854 struct city_dialog *pdialog;
1856 GtkWidget *vbox, *hbox, *cbox;
1859 int ccol = 0;
1861 struct player *owner;
1862
1865 }
1866
1867 pdialog = fc_malloc(sizeof(struct city_dialog));
1868 pdialog->pcity = pcity;
1869 pdialog->sell_shell = NULL;
1870 pdialog->rename_shell = NULL;
1871 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1872 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1873 pdialog->happiness.citizens = NULL; /* Ditto */
1874 pdialog->counters.widget = NULL;
1875 pdialog->counters.container = NULL;
1876 pdialog->production.buy_command = NULL;
1877 pdialog->production.production_label = NULL;
1878 pdialog->production.production_bar = NULL;
1879 pdialog->cma_editor = NULL;
1883
1884 pdialog->shell = gtk_dialog_new();
1886 setup_dialog(pdialog->shell, toplevel);
1887
1888 g_signal_connect(pdialog->shell, "destroy",
1890 gtk_widget_set_name(pdialog->shell, "Freeciv");
1891
1892 gtk_widget_realize(pdialog->shell);
1893
1894 /* Keep the icon of the executable on Windows (see PR#36491) */
1895#ifndef FREECIV_MSWINDOWS
1896 {
1897 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1898 }
1899#endif /* FREECIV_MSWINDOWS */
1900
1901 /* Restore size of the city dialog. */
1905
1906 pdialog->popover = NULL;
1907
1911 gtk_box_append(GTK_BOX(vbox), hbox);
1912
1913 /**** Citizens bar here ****/
1914 cbox = gtk_grid_new();
1915 gtk_box_append(GTK_BOX(hbox), cbox);
1916
1919
1923 pdialog->citizen_pics = gtk_picture_new();
1924
1933 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1934
1936 g_signal_connect(controller, "pressed",
1937 G_CALLBACK(citizens_callback), pdialog);
1939
1940 /**** City name label here ****/
1941 pdialog->name_label = gtk_label_new(NULL);
1946
1947 /**** -Start of Notebook- ****/
1948
1949 pdialog->notebook = gtk_notebook_new();
1952 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1953
1957
1959
1960 /* Only create these tabs if not a spy */
1964 }
1965
1967
1968 if (owner == client_player()
1969 && !client_is_observer()) {
1972 } else {
1975 }
1976
1977 /**** End of Notebook ****/
1978
1979 /* Bottom buttons */
1980
1981 pdialog->show_units_command =
1982 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1983
1984 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1986
1987 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1989 GTK_WIDGET(pdialog->prev_command), 1);
1990
1991 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1993 GTK_WIDGET(pdialog->next_command), 2);
1994
1995 if (owner != client_player()) {
1998 }
1999
2001 _("_Close"), GTK_RESPONSE_CLOSE);
2002
2005
2007 G_CALLBACK(close_callback), pdialog);
2008
2009 g_signal_connect(pdialog->prev_command, "clicked",
2011
2012 g_signal_connect(pdialog->next_command, "clicked",
2014
2015 /* Some other things we gotta do */
2016
2018 g_signal_connect(controller, "key-pressed",
2021
2023
2025
2026 /* Need to do this every time a new dialog is opened. */
2028
2030
2032
2033 return pdialog;
2034}
2035
2036/**************** Functions to update parts of the dialog *****************/
2037
2038/***********************************************************************/
2041static void city_dialog_update_title(struct city_dialog *pdialog)
2042{
2043 gchar *buf;
2044 const gchar *now;
2045
2046 if (city_unhappy(pdialog->pcity)) {
2047 /* TRANS: city dialog title */
2048 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
2049 city_name_getx(pdialog->pcity),
2051 } else if (city_celebrating(pdialog->pcity)) {
2052 /* TRANS: city dialog title */
2053 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
2054 city_name_getx(pdialog->pcity),
2056 } else if (city_happy(pdialog->pcity)) {
2057 /* TRANS: city dialog title */
2058 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
2059 city_name_getx(pdialog->pcity),
2061 } else {
2062 /* TRANS: city dialog title */
2063 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
2064 city_name_getx(pdialog->pcity),
2066 }
2067
2069 if (strcmp(now, buf) != 0) {
2072 }
2073
2074 g_free(buf);
2075}
2076
2077/***********************************************************************/
2080static void city_dialog_update_citizens(struct city_dialog *pdialog)
2081{
2082 enum citizen_category categories[MAX_CITY_SIZE];
2085 struct city *pcity = pdialog->pcity;
2087 int num_supers
2089 ARRAY_SIZE(categories) - num_citizens,
2090 &categories[num_citizens]);
2091 cairo_t *cr;
2092
2093 if (num_supers >= 0) {
2094 /* Just draw superspecialists in the common roster */
2096 } else {
2097 /* FIXME: show them in some compact way */
2098 num_citizens = ARRAY_SIZE(categories);
2099 }
2100 /* If there is not enough space we stack the icons. We draw from left to */
2101 /* right. width is how far we go to the right for each drawn pixmap. The */
2102 /* last icon is always drawn in full, and so has reserved */
2103 /* tileset_small_sprite_width(tileset) pixels. */
2104
2106 if (num_citizens > 1) {
2108 / (num_citizens - 1));
2109 } else {
2110 width = full_width;
2111 }
2112 pdialog->cwidth = width;
2113
2114 /* overview page */
2115 /* keep these values in sync with create_city_dialog */
2118
2119 cr = cairo_create(pdialog->citizen_surface);
2120
2121 for (i = 0; i < num_citizens; i++) {
2123 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
2124 i * width, 0);
2125 cairo_rectangle(cr, i * width, 0,
2126 /* Always draw last citizen in full */
2127 i + 1 < num_citizens ? width : full_width,
2129 cairo_fill(cr);
2130 }
2131
2132 total_used_width = (i - 1) * width + full_width;
2133
2135 /* Clear the rest of the area.
2136 * Note that this might still be necessary even in cases where
2137 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
2138 * divided perfectly. */
2143 cairo_fill(cr);
2144 }
2145
2146 cairo_destroy(cr);
2147
2149 pdialog->citizen_surface);
2150
2152}
2153
2154
2155/**********************************************************************/
2158static void city_dialog_update_counters(struct city_dialog *pdialog)
2159{
2164 char int_val[101];
2165 char *text;
2166 int text_size;
2167
2168 if (NULL != pdialog->counters.widget) {
2170 GTK_WIDGET(pdialog->counters.widget));
2171 }
2172
2173 if (NULL == pdialog->counters.container) {
2175 }
2176
2180
2184 counterValue = GTK_LABEL(gtk_label_new(_("Current value is: ")));
2186 fc_snprintf(int_val, sizeof(int_val), "%d", pdialog->pcity->counter_values[counter_index(pcount)]);
2190
2192 counterValue = GTK_LABEL(gtk_label_new(_("Activated once value equal or higher than: ")));
2194 fc_snprintf(int_val, sizeof(int_val), "%d", pcount->checkpoint);
2198
2199 text_size = 0;
2200 if (NULL != pcount->helptext) {
2201 strvec_iterate(pcount->helptext, text_) {
2204 }
2205 if (0 < text_size) {
2206 text = malloc(text_size+1);
2207 text_size = 0;
2208 strvec_iterate(pcount->helptext, text_) {
2209 strcpy(&text[text_size], text_);
2213 free(text);
2215 }
2218
2221}
2222
2223/***********************************************************************/
2227 struct city_dialog *pdialog)
2228{
2229 int i, illness = 0;
2230 char buf[NUM_INFO_FIELDS][512];
2231 struct city *pcity = pdialog->pcity;
2232 int granaryturns;
2235
2236 /* fill the buffers with the necessary info */
2237 if (supers) {
2238 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d+%d)",
2239 pcity->size, non_workers, supers);
2240 } else if (non_workers) {
2241 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
2242 pcity->size, non_workers);
2243 } else {
2244 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
2245 }
2246 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
2247 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
2248 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
2249 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
2250 pcity->surplus[O_SHIELD]);
2251 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
2252 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
2253 pcity->surplus[O_TRADE]);
2254 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
2255 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
2256 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
2257 pcity->prod[O_LUXURY]);
2258 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
2259 pcity->prod[O_SCIENCE]);
2260 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
2262
2264 if (granaryturns == 0) {
2265 /* TRANS: city growth is blocked. Keep short. */
2266 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
2267 } else if (granaryturns == FC_INFINITY) {
2268 /* TRANS: city is not growing. Keep short. */
2269 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
2270 } else {
2271 /* A negative value means we'll have famine in that many turns.
2272 But that's handled down below. */
2273 /* TRANS: city growth turns. Keep short. */
2275 PL_("%d turn", "%d turns", abs(granaryturns)),
2276 abs(granaryturns));
2277 }
2279 pcity->waste[O_TRADE]);
2280 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
2281 pcity->waste[O_SHIELD]);
2282 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
2283 pcity->client.culture);
2285 pcity->pollution);
2286 if (!game.info.illness_on) {
2287 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
2288 } else {
2290 /* illness is in tenth of percent */
2291 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
2292 (float)illness / 10.0);
2293 }
2294 if (pcity->steal) {
2295 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
2296 pcity->steal);
2297 } else {
2298 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
2299 }
2300
2302
2303 /* stick 'em in the labels */
2304 for (i = 0; i < NUM_INFO_FIELDS; i++) {
2306 }
2307
2308 /*
2309 * Make use of the emergency-indicating styles set up for certain labels
2310 * in create_city_info_table().
2311 */
2312 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
2313 * of a warning. */
2314 if (granaryturns > -4 && granaryturns < 0) {
2316 } else {
2318 }
2319
2320 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
2322 } else {
2324 }
2325
2326 /* Someone could add the color &orange for better granularity here */
2327 if (pcity->pollution >= 10) {
2329 } else {
2331 }
2332
2333 /* Illness is in tenth of percent, i.e 100 == 10.0% */
2334 if (illness >= 100) {
2336 } else {
2338 }
2339}
2340
2341/***********************************************************************/
2344static void city_dialog_update_map(struct city_dialog *pdialog)
2345{
2346 struct canvas store = FC_STATIC_CANVAS_INIT;
2347
2348 store.surface = pdialog->map_canvas_store_unscaled;
2349
2350 /* The drawing is done in three steps.
2351 * 1. First we render to a pixmap with the appropriate canvas size.
2352 * 2. Then the pixmap is rendered into a pixbuf of equal size.
2353 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
2354 * target pixbuf.
2355 */
2356
2357 city_dialog_redraw_map(pdialog->pcity, &store);
2358
2359 /* draw to real window */
2360 draw_map_canvas(pdialog);
2361}
2362
2363/***********************************************************************/
2366static void city_dialog_update_building(struct city_dialog *pdialog)
2367{
2368 char buf[32], buf2[200];
2369 gdouble pct;
2370 GListStore *store;
2371 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2372 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2373 int targets_used, item;
2374 struct city *pcity = pdialog->pcity;
2376 const char *descr = city_production_name_translation(pcity);
2378
2379 if (pdialog->overview.buy_command != NULL) {
2381 }
2382 if (pdialog->production.buy_command != NULL) {
2384 }
2385
2386 /* Make sure build slots info is up to date */
2387 if (pdialog->production.production_label != NULL) {
2389
2390 /* Only display extra info if more than one slot is available */
2391 if (build_slots > 1) {
2392 fc_snprintf(buf2, sizeof(buf2),
2393 /* TRANS: never actually used with built_slots <= 1 */
2394 PL_("Production (up to %d unit per turn):",
2395 "Production (up to %d units per turn):", build_slots),
2396 build_slots);
2399 } else {
2401 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2402 }
2403 }
2404
2405 /* Update what the city is working on */
2407
2408 if (cost > 0) {
2409 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2410 pct = CLAMP(pct, 0.0, 1.0);
2411 } else {
2412 pct = 1.0;
2413 }
2414
2415 if (pdialog->overview.production_bar != NULL) {
2416 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2417 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2422 }
2423
2424 if (pdialog->production.production_bar != NULL) {
2425 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2426 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2431 }
2432
2433 store = pdialog->overview.change_prod_store;
2434 if (store != nullptr) {
2435 int cur = -1;
2436 int actcount = 0;
2437
2438 if (pdialog->overview.change_prod_selection != nullptr) {
2440 -1, TRUE);
2441 }
2442
2444
2446 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2447 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2448
2449 for (item = 0; item < targets_used; item++) {
2450 if (can_city_build_now(&(wld.map), pcity, &items[item].item)) {
2451 const char *name;
2452 struct sprite *sprite;
2453 GdkPixbuf *pix;
2454 struct universal *target = &items[item].item;
2455 bool useless;
2457
2458 if (VUT_UTYPE == target->kind) {
2462 useless = FALSE;
2463 } else {
2466 useless = is_improvement_redundant(pcity, target->value.building);
2467 }
2469
2470 row->name = name;
2471 row->id = (gint)cid_encode(items[item].item);
2472 row->sprite = pix;
2473 row->useless = useless;
2474
2475 g_list_store_append(store, row);
2477
2478 if (are_universals_equal(target, &pcity->production)) {
2479 cur = actcount;
2480 }
2481
2482 actcount++;
2483 }
2484 }
2485
2486 if (pdialog->overview.change_prod_selection != nullptr) {
2488 cur, TRUE);
2489 }
2490 }
2491}
2492
2493/***********************************************************************/
2497{
2498 int item, targets_used;
2499 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2500 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2501
2502 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2503 "sell an improvement.");
2504 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2505 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2506
2508 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2509
2511
2512 for (item = 0; item < targets_used; item++) {
2513 GdkPixbuf *pix;
2514 int upkeep;
2515 struct sprite *sprite;
2516 struct universal target = items[item].item;
2518
2519 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2520 /* This takes effects (like Adam Smith's) into account. */
2521 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2523
2525
2526 row->impr = target.value.building;
2527 row->sprite = pix;
2528 row->description = items[item].descr;
2529 row->upkeep = upkeep;
2530 row->redundant = is_improvement_redundant(pdialog->pcity,
2531 target.value.building);
2532 row->tooltip = is_great_wonder(target.value.building) ?
2534 (is_small_wonder(target.value.building) ?
2536
2539 }
2540}
2541
2542/***********************************************************************/
2546{
2547 struct unit_list *units;
2548 struct unit_node_vector *nodes;
2549 int n, m, i;
2550 gchar *buf;
2552 const struct civ_map *nmap = &(wld.map);
2553
2554 if (NULL != client.conn.playing
2555 && city_owner(pdialog->pcity) != client.conn.playing) {
2556 units = pdialog->pcity->client.info_units_supported;
2557 } else {
2558 units = pdialog->pcity->units_supported;
2559 }
2560
2561 nodes = &pdialog->overview.supported_units;
2562
2563 n = unit_list_size(units);
2564 m = unit_node_vector_size(nodes);
2565
2566 if (m > n) {
2567 i = 0;
2569 if (i++ >= n) {
2571 elt->cmd);
2572 }
2574
2576 } else {
2577 for (i = m; i < n; i++) {
2578 GtkWidget *cmd, *pix;
2579 struct unit_node node;
2580
2581 cmd = gtk_button_new();
2582 node.cmd = cmd;
2583
2585
2586 pix = gtk_picture_new();
2587 node.pix = pix;
2589
2591
2593 cmd);
2594
2595 node.left = NULL;
2596 node.middle = NULL;
2597 node.right = NULL;
2598
2599 unit_node_vector_append(nodes, node);
2600 }
2601 }
2602
2603 i = 0;
2604 unit_list_iterate(units, punit) {
2605 struct unit_node *pnode;
2606 int happy_cost = city_unit_unhappiness(nmap, punit, &free_unhappy);
2607
2608 pnode = unit_node_vector_get(nodes, i);
2609 if (pnode) {
2610 GtkWidget *cmd, *pix;
2613
2614 cmd = pnode->cmd;
2615 pix = pnode->pix;
2616
2618 punit->upkeep, happy_cost);
2619
2620 if (pnode->left != NULL) {
2624 }
2625
2627
2629 g_signal_connect(controller, "pressed",
2633 pnode->left = controller;
2637 g_signal_connect(controller, "released",
2641 pnode->middle = controller;
2645 g_signal_connect(controller, "released",
2649 pnode->right = controller;
2650
2651 if (city_owner(pdialog->pcity) != client.conn.playing) {
2653 } else {
2655 }
2656
2659 }
2660 i++;
2662
2663 buf = g_strdup_printf(_("Supported units %d"), n);
2665 g_free(buf);
2666}
2667
2668/***********************************************************************/
2672{
2673 struct unit_list *units;
2674 struct unit_node_vector *nodes;
2675 int n, m, i;
2676 gchar *buf;
2677
2678 if (NULL != client.conn.playing
2679 && city_owner(pdialog->pcity) != client.conn.playing) {
2680 units = pdialog->pcity->client.info_units_present;
2681 } else {
2682 units = pdialog->pcity->tile->units;
2683 }
2684
2685 nodes = &pdialog->overview.present_units;
2686
2687 n = unit_list_size(units);
2688 m = unit_node_vector_size(nodes);
2689
2690 if (m > n) {
2691 i = 0;
2693 if (i++ >= n) {
2695 elt->cmd);
2696 }
2698
2700 } else {
2701 for (i = m; i < n; i++) {
2702 GtkWidget *cmd, *pix;
2703 struct unit_node node;
2704
2705 cmd = gtk_button_new();
2706 node.cmd = cmd;
2707
2709
2710 pix = gtk_picture_new();
2711 node.pix = pix;
2713
2715
2717 cmd);
2718
2719 node.left = NULL;
2720 node.middle = NULL;
2721 node.right = NULL;
2722
2723 unit_node_vector_append(nodes, node);
2724 }
2725 }
2726
2727 i = 0;
2728 unit_list_iterate(units, punit) {
2729 struct unit_node *pnode;
2730
2731 pnode = unit_node_vector_get(nodes, i);
2732 if (pnode) {
2733 GtkWidget *cmd, *pix;
2736
2737 cmd = pnode->cmd;
2738 pix = pnode->pix;
2739
2741
2742 if (pnode->left != NULL) {
2746 }
2747
2749
2751 g_signal_connect(controller, "pressed",
2755 pnode->left = controller;
2759 g_signal_connect(controller, "released",
2763 pnode->middle = controller;
2767 g_signal_connect(controller, "released",
2771 pnode->right = controller;
2772
2773 if (city_owner(pdialog->pcity) != client.conn.playing) {
2775 } else {
2777 }
2778
2781 }
2782 i++;
2784
2785 buf = g_strdup_printf(_("Present units %d"), n);
2787 g_free(buf);
2788}
2789
2790/***********************************************************************/
2798{
2799 int count = 0;
2800 int city_number;
2801
2802 if (NULL != client.conn.playing) {
2804 } else {
2805 city_number = FC_INFINITY; /* ? */
2806 }
2807
2808 /* The first time, we see if all the city dialogs are open */
2810 if (city_owner(pdialog->pcity) == client.conn.playing) {
2811 count++;
2812 }
2814
2815 if (count == city_number) { /* All are open, shouldn't prev/next */
2817 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2818 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2820 } else {
2822 if (city_owner(pdialog->pcity) == client.conn.playing) {
2823 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2824 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2825 }
2827 }
2828}
2829
2830/***********************************************************************/
2833static void citydlg_response_callback(GtkDialog *dlg, gint response,
2834 void *data)
2835{
2836 switch (response) {
2837 case CDLGR_UNITS:
2838 show_units_response(data);
2839 break;
2840 }
2841}
2842
2843/***********************************************************************/
2846static void show_units_response(void *data)
2847{
2848 struct city_dialog *pdialog = (struct city_dialog *) data;
2849 struct tile *ptile = pdialog->pcity->tile;
2850
2851 if (unit_list_size(ptile->units)) {
2853 }
2854}
2855
2856/***********************************************************************/
2866static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2867 GtkWidget *wdg, bool supported)
2868{
2869 GMenu *menu;
2870 GActionGroup *group;
2871 GSimpleAction *act;
2872
2873 if (!can_client_issue_orders()) {
2874 return FALSE;
2875 }
2876
2877 if (pdialog->popover != NULL) {
2879 }
2880
2882 menu = g_menu_new();
2883
2884 if (supported) {
2885 act = g_simple_action_new("center", NULL);
2886 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2890 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2891 }
2892
2893 act = g_simple_action_new("activate", NULL);
2894 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2898 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2899 "win.activate"));
2900
2901 act = g_simple_action_new("activate_close", NULL);
2902 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2904
2905 if (supported) {
2906 g_signal_connect(act, "activate",
2909 } else {
2910 g_signal_connect(act, "activate",
2913 }
2914
2916 g_menu_item_new(_("Activate unit, _close dialog"),
2917 "win.activate_close"));
2918
2919 if (!supported) {
2920 act = g_simple_action_new("load", NULL);
2921 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2926 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2927
2928 act = g_simple_action_new("unload", NULL);
2929 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2937 unit_tile(punit)));
2938 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2939 "win.unload"));
2940
2941 act = g_simple_action_new("sentry", NULL);
2942 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2950 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2951 "win.sentry"));
2952
2953 act = g_simple_action_new("fortify", NULL);
2954 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2962 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2963 "win.fortify"));
2964 }
2965
2966 act = g_simple_action_new("disband", NULL);
2967 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2973 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2974 "win.disband"));
2975
2976 if (!supported) {
2977 act = g_simple_action_new("rehome", NULL);
2978 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2984 pdialog->pcity));
2987 "win.rehome"));
2988
2989 act = g_simple_action_new("upgrade", NULL);
2990 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2999 != NULL);
3000 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
3001 "win.upgrade"));
3002 }
3003
3005 g_object_ref(pdialog->popover);
3006 gtk_widget_insert_action_group(pdialog->popover, "win", group);
3008
3009
3011
3012 return TRUE;
3013}
3014
3015/***********************************************************************/
3019 double x, double y, gpointer data)
3020{
3021 struct city_dialog *pdialog;
3022 struct city *pcity;
3023 struct unit *punit =
3024 player_unit_by_number(client_player(), (size_t) data);
3025
3026 if (NULL != punit
3028 && NULL != (pdialog = get_city_dialog(pcity))) {
3029
3030 return create_unit_menu(pdialog, punit,
3032 TRUE);
3033 }
3034
3035 return TRUE;
3036}
3037
3038/***********************************************************************/
3042 double x, double y, gpointer data)
3043{
3044 struct city_dialog *pdialog;
3045 struct city *pcity;
3046 struct unit *punit =
3047 player_unit_by_number(client_player(), (size_t) data);
3048
3049 if (NULL != punit
3050 && NULL != (pcity = tile_city(unit_tile(punit)))
3051 && NULL != (pdialog = get_city_dialog(pcity))) {
3052
3053 return create_unit_menu(pdialog, punit,
3055 FALSE);
3056 }
3057
3058 return TRUE;
3059}
3060
3061/***********************************************************************/
3066 int n_press, double x, double y,
3067 gpointer data)
3068{
3069 struct city_dialog *pdialog;
3070 struct city *pcity;
3071 struct unit *punit =
3072 player_unit_by_number(client_player(), (size_t) data);
3073
3074 if (NULL != punit
3075 && NULL != (pcity = tile_city(unit_tile(punit)))
3076 && NULL != (pdialog = get_city_dialog(pcity))
3079 close_city_dialog(pdialog);
3080 }
3081
3082 return TRUE;
3083}
3084
3085/***********************************************************************/
3090 double x, double y, gpointer data)
3091{
3092 struct city_dialog *pdialog;
3093 struct city *pcity;
3094 struct unit *punit =
3095 player_unit_by_number(client_player(), (size_t) data);
3096
3097 if (NULL != punit
3099 && NULL != (pdialog = get_city_dialog(pcity))
3102 close_city_dialog(pdialog);
3103 }
3104
3105 return TRUE;
3106}
3107
3108/***********************************************************************/
3112 double x, double y, gpointer data)
3113{
3114 struct unit *punit =
3115 player_unit_by_number(client_player(), (size_t) data);
3116
3117 if (NULL != punit
3120 }
3121
3122 return TRUE;
3123}
3124
3125/***********************************************************************/
3130static void close_citydlg_unit_popover(struct city_dialog *pdialog)
3131{
3132 if (pdialog->popover != NULL) {
3133 gtk_widget_unparent(pdialog->popover);
3134 g_object_unref(pdialog->popover);
3135 pdialog->popover = NULL;
3136 }
3137}
3138
3139/***********************************************************************/
3143 gpointer data)
3144{
3145 struct unit *punit =
3147
3148 if (NULL != punit) {
3150 }
3151
3153}
3154
3155/***********************************************************************/
3159 gpointer data)
3160{
3161 struct unit *punit =
3163
3164 if (NULL != punit) {
3165 /* FIXME: If unit is not idle to begin with, we can only request
3166 * idling, and as we have no server reply yet,
3167 * the unit_focus_try() below will fail. */
3170 }
3171
3173}
3174
3175/***********************************************************************/
3180 GVariant *parameter,
3181 gpointer data)
3182{
3183 struct unit *punit =
3185
3186 if (NULL != punit) {
3187 struct city *pcity =
3189
3190 /* FIXME: If unit is not idle to begin with, we can only request
3191 * idling, and as we have no server reply yet,
3192 * the unit_focus_try() below will fail. */
3195
3196 if (NULL != pcity) {
3197 struct city_dialog *pdialog = get_city_dialog(pcity);
3198
3199 if (NULL != pdialog) {
3200 close_city_dialog(pdialog);
3201 }
3202 }
3203 }
3204
3206}
3207
3208/***********************************************************************/
3213 GVariant *parameter,
3214 gpointer data)
3215{
3216 struct unit *punit =
3218
3219 if (NULL != punit) {
3220 struct city *pcity = tile_city(unit_tile(punit));
3221
3222 /* FIXME: If unit is not idle to begin with, we can only request
3223 * idling, and as we have no server reply yet,
3224 * the unit_focus_try() below will fail. */
3227
3228 if (NULL != pcity) {
3229 struct city_dialog *pdialog = get_city_dialog(pcity);
3230
3231 if (NULL != pdialog) {
3232 close_city_dialog(pdialog);
3233 }
3234 }
3235 }
3236
3238}
3239
3240/***********************************************************************/
3244 gpointer data)
3245{
3246 struct unit *punit =
3248
3249 if (NULL != punit) {
3251 }
3252
3254}
3255
3256/***********************************************************************/
3260 gpointer data)
3261{
3262 struct unit *punit =
3264
3265 if (NULL != punit) {
3267 }
3268
3270}
3271
3272/***********************************************************************/
3276 gpointer data)
3277{
3278 struct unit *punit =
3280
3281 if (NULL != punit) {
3283 }
3284
3286}
3287
3288/***********************************************************************/
3292 gpointer data)
3293{
3294 struct unit *punit =
3296
3297 if (NULL != punit) {
3299 }
3300
3302}
3303
3304/***********************************************************************/
3308 gpointer data)
3309{
3310 struct unit_list *punits;
3311 struct unit *punit =
3313
3314 if (NULL == punit) {
3315 return;
3316 }
3317
3322
3324}
3325
3326/***********************************************************************/
3331 gpointer data)
3332{
3333 struct unit *punit =
3335
3336 if (NULL != punit) {
3338 }
3339
3341}
3342
3343/***********************************************************************/
3347 gpointer data)
3348{
3349 struct unit_list *punits;
3350 struct unit *punit =
3352
3353 if (NULL == punit) {
3354 return;
3355 }
3356
3361
3363}
3364
3365/******** Callbacks for citizen bar, map funcs that are not update ********/
3366
3367/***********************************************************************/
3372 double x, double y, gpointer data)
3373{
3374 struct city_dialog *pdialog = data;
3375 struct city *pcity = pdialog->pcity;
3376 int citnum, tlen, len;
3377
3378 if (!can_client_issue_orders()) {
3379 return FALSE;
3380 }
3381
3383 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
3384
3385 if (x > len) {
3386 /* No citizen that far to the right */
3387 return FALSE;
3388 }
3389 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
3390
3392
3393 return TRUE;
3394}
3395
3396/***********************************************************************/
3400{
3401 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
3402 struct city *pcity = workertask_req.owner;
3403 struct tile *ptile = workertask_req.loc;
3404 struct packet_worker_task task;
3405
3406 task.city_id = pcity->id;
3407
3408 if (act == ACTIVITY_LAST) {
3409 task.tgt = -1;
3410 task.want = 0;
3411 } else {
3412 enum extra_cause cause = activity_to_extra_cause(act);
3414 struct extra_type *tgt;
3415
3416 if (cause != EC_NONE) {
3417 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
3418 } else if (rmcause != ERM_NONE) {
3420 } else {
3421 tgt = NULL;
3422 }
3423
3424 if (tgt == NULL) {
3425 struct terrain *pterr = tile_terrain(ptile);
3426
3427 if ((act != ACTIVITY_TRANSFORM
3428 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3429 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3430 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3431 /* No extra to order */
3432 output_window_append(ftc_client, _("There's no suitable extra to order."));
3433
3434 return;
3435 }
3436
3437 task.tgt = -1;
3438 } else {
3439 task.tgt = extra_index(tgt);
3440 }
3441
3442 task.want = 100;
3443 }
3444
3445 task.tile_id = ptile->index;
3446 task.activity = act;
3447
3449}
3450
3451/***********************************************************************/
3458
3459/***********************************************************************/
3462static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3463{
3465 GtkWidget *shl;
3466 struct terrain *pterr = tile_terrain(ptile);
3467 struct universal for_terr = { .kind = VUT_TERRAIN,
3468 .value = { .terrain = pterr }};
3469 struct worker_task *ptask;
3470
3472 workertask_req.owner = pcity;
3473 workertask_req.loc = ptile;
3474
3476 _("What Action to Request"),
3477 _("Select autoworker activity:"));
3478
3479 ptask = worker_task_list_get(pcity->task_reqs, 0);
3480 if (ptask != NULL) {
3481 choice_dialog_add(shl, _("Clear request"),
3484 }
3485
3487 choice_dialog_add(shl, Q_("?act:Mine"),
3490 }
3491 if (pterr->plant_result != NULL
3493 NULL, &for_terr)) {
3494 choice_dialog_add(shl, _("Plant"),
3497 }
3499 choice_dialog_add(shl, _("Irrigate"),
3502 }
3503 if (pterr->cultivate_result != NULL
3505 NULL, &for_terr)) {
3506 choice_dialog_add(shl, _("Cultivate"),
3509 }
3511 choice_dialog_add(shl, _("Road"),
3514 }
3515 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3517 NULL, &for_terr)) {
3518 choice_dialog_add(shl, _("Transform"),
3521 }
3523 city_owner(pcity), NULL) != NULL) {
3524 choice_dialog_add(shl, _("Clean"),
3527 }
3528
3529 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3531
3533 NULL);
3534 }
3535}
3536
3537/***********************************************************************/
3541 double x, double y, gpointer data)
3542{
3543 struct city_dialog *pdialog = data;
3545
3546 if (!can_client_issue_orders()) {
3547 return FALSE;
3548 }
3549
3550 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3551 return FALSE;
3552 }
3553
3556
3558 city_map_radius_sq_get(pdialog->pcity),
3559 canvas_x, canvas_y)) {
3561 }
3562
3563 return TRUE;
3564}
3565
3566/***********************************************************************/
3570 double x, double y, gpointer data)
3571{
3572 struct city_dialog *pdialog = data;
3574
3575 if (!can_client_issue_orders()) {
3576 return FALSE;
3577 }
3578
3581
3583 city_map_radius_sq_get(pdialog->pcity),
3584 canvas_x, canvas_y)) {
3585 struct city *pcity = pdialog->pcity;
3586
3587 popup_workertask_dlg(pdialog->pcity,
3590 city_x, city_y));
3591 }
3592
3593 return TRUE;
3594}
3595
3596/***********************************************************************/
3599static void draw_map_canvas(struct city_dialog *pdialog)
3600{
3602 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3604 }
3605}
3606
3607/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3608
3609/***********************************************************************/
3612static void buy_callback_response(GObject *dialog, GAsyncResult *result,
3613 gpointer data)
3614{
3616 result, NULL);
3617
3618 if (button == 0) {
3619 struct city_dialog *pdialog = data;
3620
3621 city_buy_production(pdialog->pcity);
3622 }
3623}
3624
3625/***********************************************************************/
3628static void buy_callback(GtkWidget *w, gpointer data)
3629{
3631 struct city_dialog *pdialog = data;
3632 const char *name = city_production_name_translation(pdialog->pcity);
3633 int value = pdialog->pcity->client.buy_cost;
3634 char buf[1024];
3635
3636 if (!can_client_issue_orders()) {
3637 return;
3638 }
3639
3640 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3641 "Treasury contains %d gold.",
3642 client_player()->economic.gold),
3643 client_player()->economic.gold);
3644
3645 if (value <= client_player()->economic.gold) {
3646 const char *buttons[] = { _("Yes"), _("No"), NULL };
3647
3649 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3650 PL_("Buy %s for %d gold?\n%s",
3651 "Buy %s for %d gold?\n%s", value),
3652 name, value, buf);
3654 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3656
3658 buy_callback_response, pdialog);
3659 } else {
3660 const char *buttons[] = { _("Close"), NULL };
3661
3663 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3664 PL_("%s costs %d gold.\n%s",
3665 "%s costs %d gold.\n%s", value),
3666 name, value, buf);
3668 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3671 }
3672}
3673
3674/***********************************************************************/
3678 guint position,
3679 guint n_items,
3680 gpointer data)
3681{
3685 struct universal univ = cid_production(row->id);
3686
3687 city_change_production(((struct city_dialog *)data)->pcity, &univ);
3688 }
3689}
3690
3691/***********************************************************************/
3694static void sell_callback(const struct impr_type *pimprove, gpointer data)
3695{
3696 GtkWidget *shl;
3697 struct city_dialog *pdialog = (struct city_dialog *) data;
3698 pdialog->sell_id = improvement_number(pimprove);
3699 int price;
3700
3701 if (!can_client_issue_orders()) {
3702 return;
3703 }
3704
3706 pimprove) != TR_SUCCESS) {
3707 return;
3708 }
3709
3710 price = impr_sell_gold(pimprove);
3715 PL_("Sell %s for %d gold?",
3716 "Sell %s for %d gold?", price),
3717 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3718 setup_dialog(shl, pdialog->shell);
3719 pdialog->sell_shell = shl;
3720
3721 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3722
3723 g_signal_connect(shl, "response",
3725
3727}
3728
3729/***********************************************************************/
3732static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3733{
3734 struct city_dialog *pdialog = data;
3735
3736 if (response == GTK_RESPONSE_YES) {
3737 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3738 }
3740
3741 pdialog->sell_shell = NULL;
3742}
3743
3744/***********************************************************************/
3747static void impr_callback(GtkColumnView *self, guint position,
3748 gpointer data)
3749{
3750 GdkSeat *seat;
3752 GListStore *store = ((struct city_dialog *)data)->overview.improvement_list;
3753 FcImprRow *row = g_list_model_get_item(G_LIST_MODEL(store), position);
3754 const struct impr_type *pimpr = row->impr;
3755 GtkWidget *wdg = ((struct city_dialog *)data)->shell;
3756
3759
3760 if (!(mask & GDK_CONTROL_MASK)) {
3761 sell_callback(pimpr, data);
3762 } else {
3763 if (is_great_wonder(pimpr)) {
3765 } else {
3767 }
3768 }
3769}
3770
3771/************ Callbacks for stuff on the Misc. Settings page **************/
3772
3773/***********************************************************************/
3777{
3778 struct city_dialog *pdialog;
3779
3780 pdialog = (struct city_dialog *) data;
3781
3782 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3783 /* "shellrenamecity" */
3784 _("Rename City"),
3785 _("What should we rename the city to?"),
3786 city_name_get(pdialog->pcity),
3787 rename_popup_callback, pdialog);
3788}
3789
3790/***********************************************************************/
3793static void rename_popup_callback(gpointer data, gint response,
3794 const char *input)
3795{
3796 struct city_dialog *pdialog = data;
3797
3798 if (pdialog) {
3799 if (response == GTK_RESPONSE_OK) {
3800 city_rename(pdialog->pcity, input);
3801 } /* else CANCEL or DELETE_EVENT */
3802
3803 pdialog->rename_shell = NULL;
3804 }
3805}
3806
3807/***********************************************************************/
3811{
3813}
3814
3815/***********************************************************************/
3819{
3820 struct city_dialog *pdialog = (struct city_dialog *) data;
3821
3822 if (!can_client_issue_orders()) {
3823 return;
3824 }
3825
3826 if (!pdialog->misc.block_signal) {
3827 struct city *pcity = pdialog->pcity;
3829
3830 fc_assert(CITYO_LAST == 3);
3831
3835 }
3838 }
3841 }
3842
3844 pcity->wlcb);
3845 }
3846}
3847
3848/***********************************************************************/
3873
3874/******************** Callbacks for: Close, Prev, Next. *******************/
3875
3876/***********************************************************************/
3879static void close_callback(GtkWidget *w, gpointer data)
3880{
3881 close_city_dialog((struct city_dialog *) data);
3882}
3883
3884/***********************************************************************/
3888{
3889 struct city_dialog *pdialog;
3890 int width, height;
3891
3892 /* Save size of the city dialog. */
3894
3895 pdialog = (struct city_dialog *) data;
3897
3899 citizens_dialog_close(pdialog->pcity);
3900 }
3901 close_happiness_dialog(pdialog->pcity);
3902 close_cma_dialog(pdialog->pcity);
3903
3904 /* Save size of the city dialog. */
3907 width,
3911 height,
3913
3914 last_page
3916
3919
3922
3923 if (pdialog->sell_shell) {
3925 }
3926 if (pdialog->rename_shell) {
3928 }
3929
3932
3933 free(pdialog);
3934
3935 /* Need to do this every time a new dialog is closed. */
3937}
3938
3939/***********************************************************************/
3942static void close_city_dialog(struct city_dialog *pdialog)
3943{
3945}
3946
3947/***********************************************************************/
3952{
3953 struct city_dialog *pdialog = (struct city_dialog *) data;
3954 int i, j, dir, size;
3955 struct city *new_pcity = NULL;
3956
3958 return;
3959 }
3960
3962
3964 fc_assert_ret(size >= 1);
3966
3967 if (size == 1) {
3968 return;
3969 }
3970
3971 /* dir = 1 will advance to the city, dir = -1 will get previous */
3972 if (w == GTK_WIDGET(pdialog->next_command)) {
3973 dir = 1;
3974 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3975 dir = -1;
3976 } else {
3977 /* Always fails. */
3979 || w == GTK_WIDGET(pdialog->prev_command));
3980 dir = 1;
3981 }
3982
3983 for (i = 0; i < size; i++) {
3984 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3985 break;
3986 }
3987 }
3988
3989 fc_assert_ret(i < size);
3990
3991 for (j = 1; j < size; j++) {
3993 (i + dir * j + size) % size);
3995
3996 fc_assert_ret(other_pdialog != pdialog);
3997 if (!other_pdialog) {
3999 break;
4000 }
4001 }
4002
4003 if (!new_pcity) {
4004 /* Every other city has an open city dialog. */
4005 return;
4006 }
4007
4008 /* cleanup happiness dialog */
4010 citizens_dialog_close(pdialog->pcity);
4011 }
4012 close_happiness_dialog(pdialog->pcity);
4013
4014 pdialog->pcity = new_pcity;
4015
4016 /* reinitialize happiness, and cma dialogs */
4019 citizens_dialog_display(pdialog->pcity));
4020 }
4022 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
4023 if (!client_is_observer()) {
4024 fc_assert(pdialog->cma_editor != NULL);
4025 pdialog->cma_editor->pcity = new_pcity;
4026 }
4027
4028 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
4029
4030 can_slide = FALSE;
4031 center_tile_mapcanvas(pdialog->pcity->tile);
4032 can_slide = TRUE;
4033 if (!client_is_observer()) {
4034 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
4035 }
4036
4038
4039 /* Recenter the city map(s) */
4041 if (pdialog->happiness.map_canvas.sw) {
4043 }
4044}
4045
4046/***********************************************************************/
4050{
4052 refresh_worklist(pdialog->production.worklist);
4054}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1271
bool action_ever_possible(action_id action)
Definition actions.c:7500
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:740
#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:666
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:740
const char * city_name_getx(const struct city *pcity)
Definition city.c:1150
int city_granary_size(int city_size)
Definition city.c:2173
int city_build_slots(const struct city *pcity)
Definition city.c:2974
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
int city_superspecialists(const struct city *pcity)
Definition city.c:3400
const char * city_name_get(const struct city *pcity)
Definition city.c:1141
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1296
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3470
int city_population(const struct city *pcity)
Definition city.c:1231
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
Definition city.c:3091
bool city_unhappy(const struct city *pcity)
Definition city.c:1667
bool city_celebrating(const struct city *pcity)
Definition city.c:1686
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2912
bool city_happy(const struct city *pcity)
Definition city.c:1655
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
citizens city_specialists(const struct city *pcity)
Definition city.c:3385
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
Definition city.c:1017
int city_turns_to_grow(const struct city *pcity)
Definition city.c:2037
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:703
static citizens city_size_get(const struct city *pcity)
Definition city.h:570
citizen_category
Definition city.h:265
#define city_owner(_pcity_)
Definition city.h:564
#define MAX_CITY_SIZE
Definition city.h:104
@ FEELING_FINAL
Definition city.h:282
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)
int city_try_fill_superspecialists(struct city *pcity, int cat_len, enum citizen_category *categories)
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:77
void request_unit_fortify(struct unit *punit)
Definition control.c:2365
void unit_focus_try(struct unit *punit)
Definition control.c:502
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2106
void request_unit_unload(struct unit *pcargo)
Definition control.c:2206
void request_unit_sentry(struct unit *punit)
Definition control.c:2354
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1941
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
int counter_index(const struct counter *pcount)
Definition counters.c:176
#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:237
#define EC_NONE
Definition fc_types.h:808
@ TR_SUCCESS
Definition fc_types.h:941
#define ERM_NONE
Definition fc_types.h:831
@ O_SHIELD
Definition fc_types.h:103
@ O_FOOD
Definition fc_types.h:103
@ O_TRADE
Definition fc_types.h:103
@ O_SCIENCE
Definition fc_types.h:103
@ O_LUXURY
Definition fc_types.h:103
@ O_GOLD
Definition fc_types.h:103
#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:744
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
struct city * game_city_by_number(int id)
Definition game.c:107
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
void choice_dialog_end(GtkWidget *dshell)
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
GtkWidget * citizens_dialog_display(const struct city *pcity)
void citizens_dialog_refresh(const struct city *pcity)
void citizens_dialog_close(const struct city *pcity)
static void unit_sentry_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2892
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:2951
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3062
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1870
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3475
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1831
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:3399
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:2085
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2518
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3190
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2791
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:1944
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:3054
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2372
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2972
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3253
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2866
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3441
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3536
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:3203
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3326
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:3407
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:3178
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:3272
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2818
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2479
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:3467
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3311
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:2938
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2905
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:2614
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:2918
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3365
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3545
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2063
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:2879
static void show_units_response(void *data)
Definition citydlg.c:2531
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:2265
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2804
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2843
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2999
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3382
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2208
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:2552
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:2593
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:32
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:3778
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:3289
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2785
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2586
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2831
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3260
@ COUNTERS_PAGE
Definition citydlg.c:115
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2850
static gboolean middle_supported_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2809
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
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)
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:350
bool unit_can_load(const struct unit *punit)
Definition movement.c:934
static const char * name_translation_get(const struct name_translation *ptrans)
#define GUI_GTK5_CITYDLG_MAX_XSIZE
Definition options.h:742
#define GUI_GTK5_CITYDLG_MAX_YSIZE
Definition options.h:746
#define GUI_GTK5_CITYDLG_MIN_XSIZE
Definition options.h:741
#define GUI_GTK5_CITYDLG_MIN_YSIZE
Definition options.h:745
int len
Definition packhand.c:128
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1217
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1191
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
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
enum city_dialog::@217 page
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:446
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:318
int * counter_values
Definition city.h:406
struct unit_list * info_units_present
Definition city.h:474
struct unit_list * info_units_supported
Definition city.h:473
citizens size
Definition city.h:330
int illness
Definition city.h:432
int buy_cost
Definition city.h:466
struct city::@18::@21 client
struct tile * tile
Definition city.h:320
struct unit_list * units_supported
Definition city.h:404
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:595
universals_u value
Definition fc_types.h:594
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:528
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:115
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7033
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:6972
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7055
const struct unit_type * utype
Definition fc_types.h:536
const struct impr_type * building
Definition fc_types.h:529
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:508
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2545
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:795
#define unit_tile(_pu)
Definition unit.h:407
#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:126
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1729
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1586
void economy_report_dialog_update(void)
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66