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;
1237 /* TRANS: Overview tab in city dialog */
1238 const char *tab_title = _("_Overview");
1240 int page_row = 0;
1241
1242 /* Main page */
1243 page = gtk_grid_new();
1252
1253 if (!low_citydlg) {
1255 GtkWidget *list;
1257 GtkWidget *middle;
1258 GtkWidget *vbox;
1259 GtkWidget *hbox;
1260 int middle_col = 0;
1261
1262 /* Middle: city map, improvements */
1263 middle = gtk_grid_new();
1265 gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1);
1266
1267 /* City map */
1268 create_citydlg_main_map(pdialog, middle, middle_col++, 0);
1269
1270 /* Improvements */
1272 gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1);
1273
1275
1276 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
1277 "xalign", 0.0, "yalign", 0.5, NULL);
1278 gtk_box_append(GTK_BOX(vbox), label);
1279
1281 gtk_box_append(GTK_BOX(vbox), hbox);
1282
1284
1288
1294
1297
1303
1306
1307 bar = gtk_progress_bar_new();
1309 pdialog->overview.production_bar = bar;
1311
1312 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1313
1315
1316 g_signal_connect(pdialog->overview.change_prod_selection, "selection-changed",
1318
1319 pdialog->overview.buy_command
1320 = icon_label_button_new("system-run", _("_Buy"));
1322 g_signal_connect(pdialog->overview.buy_command, "clicked",
1323 G_CALLBACK(buy_callback), pdialog);
1324
1325 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1326 "mnemonic-widget", view,
1327 "label", _("I_mprovements:"),
1328 "xalign", 0.0, "yalign", 0.5, NULL);
1329 gtk_box_append(GTK_BOX(vbox), label);
1330 gtk_box_append(GTK_BOX(vbox), view);
1331 } else {
1332 pdialog->overview.buy_command = NULL;
1333 pdialog->overview.production_bar = NULL;
1334 pdialog->overview.change_prod_store = nullptr;
1335 pdialog->overview.change_prod_selection = nullptr;
1336 }
1337
1338 /* Bottom: info, units */
1341
1342 /* Info */
1343 frame = gtk_frame_new(_("Info"));
1344 gtk_box_append(GTK_BOX(bottom), frame);
1345
1346 table = create_city_info_table(pdialog,
1347 pdialog->overview.info_label);
1351
1352 /* Right: present and supported units (overview page) */
1354 gtk_box_append(GTK_BOX(bottom), right);
1355
1360
1361 /* Supported units */
1368 sw);
1369
1370
1374
1377
1378 /* Present units */
1385
1389
1392
1393 /* Show page */
1395}
1396
1397/***********************************************************************/
1400static void create_and_append_map_page(struct city_dialog *pdialog)
1401{
1402 if (low_citydlg) {
1403 GtkWidget *page;
1404 GtkWidget *label;
1405 const char *tab_title = _("Citymap");
1406 int page_row = 0;
1407
1408 page = gtk_grid_new();
1417
1418 create_citydlg_main_map(pdialog, page, 0, page_row++);
1419
1421 }
1422}
1423
1424/***********************************************************************/
1428 const GValue *value,
1429 double x, double y, gpointer data)
1430{
1431 struct city_dialog *pdialog = (struct city_dialog *) data;
1432 cid id;
1433 struct universal univ;
1434
1435 if (NULL != client.conn.playing
1436 && city_owner(pdialog->pcity) != client.conn.playing) {
1437 return FALSE;
1438 }
1439
1440 id = g_value_get_int(value);
1441 univ = cid_production(id);
1442
1443 city_change_production(pdialog->pcity, &univ);
1444
1445 return TRUE;
1446}
1447
1448/***********************************************************************/
1452static int create_production_header(struct city_dialog *pdialog,
1453 GtkWidget *grid, int row)
1454{
1455 GtkWidget *hgrid, *bar;
1456 int grid_col = 0;
1457
1458 hgrid = gtk_grid_new();
1464 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1465
1466 /* The label is set in city_dialog_update_building() */
1467 bar = gtk_progress_bar_new();
1470 pdialog->production.production_bar = bar;
1471 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1472 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1473
1475
1476 pdialog->production.buy_command
1477 = icon_label_button_new("system-run", _("_Buy"));
1479 grid_col++, 0, 1, 1);
1480
1481 g_signal_connect(pdialog->production.buy_command, "clicked",
1482 G_CALLBACK(buy_callback), pdialog);
1483
1484 return row;
1485}
1486
1487/***********************************************************************/
1491{
1492 if (low_citydlg) {
1493 GtkWidget *page;
1494 GtkWidget *label;
1495 GtkWidget *vbox;
1496 GtkWidget *view;
1497 const char *tab_title = _("Buildings");
1498 int page_row = 0;
1499
1500 page = gtk_grid_new();
1508
1509 page_row = create_production_header(pdialog, page, page_row);
1510 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1511
1513 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1514
1516
1517 gtk_box_append(GTK_BOX(vbox), view);
1518
1520 }
1521}
1522
1523/***********************************************************************/
1527{
1528 const char *tab_title = _("P_roduction");
1530 GtkWidget *page, *editor;
1531 int page_row = 0;
1532
1533 page = gtk_grid_new();
1540 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1541
1542 /* Stuff that's being currently built */
1543 if (!low_citydlg) {
1545 "label", _("Production:"),
1546 "xalign", 0.0, "yalign", 0.5, NULL);
1547 pdialog->production.production_label = label;
1548 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1549
1550 page_row = create_production_header(pdialog, page, page_row);
1551 } else {
1552 pdialog->production.production_label = NULL;
1553 }
1554
1560 reset_city_worklist(editor, pdialog->pcity);
1561 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1562 pdialog->production.worklist = editor;
1563
1565}
1566
1567/***********************************************************************/
1578{
1579 GtkWidget *page, *label, *table, *right, *left, *frame;
1580 const char *tab_title = _("Happ_iness");
1581 int page_col = 0;
1582 int left_row = 0;
1583
1584 /* Main page */
1585 page = gtk_grid_new();
1592 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1593
1594 /* Left: info, citizens */
1595 left = gtk_grid_new();
1598 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1599
1600 if (!low_citydlg) {
1601 /* Upper left: info */
1602 frame = gtk_frame_new(_("Info"));
1603 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1604
1605 table = create_city_info_table(pdialog,
1606 pdialog->happiness.info_label);
1609 }
1610
1611 /* Lower left: citizens */
1615 0, left_row++, 1, 1);
1617 citizens_dialog_display(pdialog->pcity));
1618 }
1619
1620 /* Right: city map, happiness */
1622 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1623
1624 if (!low_citydlg) {
1625 /* Upper right: city map */
1626 frame = gtk_frame_new(_("City map"));
1629 gtk_box_append(GTK_BOX(right), frame);
1630
1631 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1633 }
1634
1635 /* Lower right: happiness */
1637 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1640 pdialog->shell));
1641
1642 /* Show page */
1644}
1645
1646/**********************************************************************/
1649/**********************************************************************/
1654{
1656 GtkLabel *label = GTK_LABEL(gtk_label_new(_("Counters")));
1657
1658 pdialog->counters.container = NULL;
1659 pdialog->counters.widget = NULL;
1660
1662
1664
1666
1667 gtk_widget_show(page);
1668}
1669
1670/***********************************************************************/
1673static void create_and_append_cma_page(struct city_dialog *pdialog)
1674{
1675 GtkWidget *page, *label;
1676 const char *tab_title = _("_Governor");
1677
1679
1681
1682 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1683
1684 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1685 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1686
1688}
1689
1690/***********************************************************************/
1694{
1695 int i;
1696 GtkWidget *vgrid, *page, *frame, *label, *button;
1698 GtkWidget *group;
1699 const char *tab_title = _("_Settings");
1700 int grid_row = 0;
1701
1702 static const char *new_citizens_output_label[] = {
1703 N_("Luxury"),
1704 N_("Science"),
1705 N_("Gold")
1706 };
1707
1708 static const char *disband_label
1709 = N_("Allow unit production to disband city");
1710
1711 static const char *misc_whichtab_label[NUM_PAGES] = {
1712 N_("Overview page"),
1713 N_("Production page"),
1714 N_("Happiness page"),
1715 N_("Counters Page"),
1716 N_("Governor page"),
1717 N_("This Settings page"),
1718 N_("Last active page")
1719 };
1720
1721 static bool new_citizens_label_done;
1722 static bool misc_whichtab_label_done;
1723
1724 /* Initialize signal_blocker */
1725 pdialog->misc.block_signal = 0;
1726
1727
1728 page = gtk_grid_new();
1734
1736
1738
1739 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1740
1741 /* new_citizens radio */
1742 frame = gtk_frame_new(_("New citizens produce"));
1743 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1745
1746 vgrid = gtk_grid_new();
1750
1753
1754 group = NULL;
1755 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1758 GTK_CHECK_BUTTON(group));
1759 pdialog->misc.new_citizens_radio[i] = button;
1760 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1761 g_signal_connect(button, "toggled",
1762 G_CALLBACK(cityopt_callback), pdialog);
1763 group = button;
1764 }
1765
1766 /* Next is the next-time-open radio group in the right column */
1767 frame = gtk_frame_new(_("Next time open"));
1768 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1770
1771 vgrid = gtk_grid_new();
1772 grid_row = 0;
1776
1779
1780 group = NULL;
1781 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1784 GTK_CHECK_BUTTON(group));
1785 pdialog->misc.whichtab_radio[i] = button;
1786 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1787 g_signal_connect(button, "toggled",
1789 group = button;
1790 }
1791
1792 /* Now we go back and fill the hbox rename */
1793 frame = gtk_frame_new(_("City"));
1794 gtk_widget_set_margin_top(frame, 12);
1796 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1797
1798 vgrid = gtk_grid_new();
1799 grid_row = 0;
1803
1804 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1805 pdialog->misc.rename_command = button;
1806 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1807 g_signal_connect(button, "clicked",
1808 G_CALLBACK(rename_callback), pdialog);
1809
1811
1812 /* The disband-city-on-unit-production button */
1814 pdialog->misc.disband_on_settler = button;
1815 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1816 g_signal_connect(button, "toggled",
1817 G_CALLBACK(cityopt_callback), pdialog);
1818
1819 /* We choose which page to popup by default */
1821 (pdialog->
1823 TRUE);
1824
1825 set_cityopt_values(pdialog);
1826
1828
1829 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1831 last_page);
1832 } else {
1835 }
1836}
1837
1838/***********************************************************************/
1847{
1848 struct city_dialog *pdialog;
1850 GtkWidget *vbox, *hbox, *cbox;
1853 int ccol = 0;
1855 struct player *owner;
1856
1859 }
1860
1861 pdialog = fc_malloc(sizeof(struct city_dialog));
1862 pdialog->pcity = pcity;
1863 pdialog->sell_shell = NULL;
1864 pdialog->rename_shell = NULL;
1865 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1866 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1867 pdialog->happiness.citizens = NULL; /* Ditto */
1868 pdialog->counters.widget = NULL;
1869 pdialog->counters.container = NULL;
1870 pdialog->production.buy_command = NULL;
1871 pdialog->production.production_label = NULL;
1872 pdialog->production.production_bar = NULL;
1873 pdialog->cma_editor = NULL;
1877
1878 pdialog->shell = gtk_dialog_new();
1880 setup_dialog(pdialog->shell, toplevel);
1881
1882 g_signal_connect(pdialog->shell, "destroy",
1884 gtk_widget_set_name(pdialog->shell, "Freeciv");
1885
1886 gtk_widget_realize(pdialog->shell);
1887
1888 /* Keep the icon of the executable on Windows (see PR#36491) */
1889#ifndef FREECIV_MSWINDOWS
1890 {
1891 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1892 }
1893#endif /* FREECIV_MSWINDOWS */
1894
1895 /* Restore size of the city dialog. */
1899
1900 pdialog->popover = NULL;
1901
1905 gtk_box_append(GTK_BOX(vbox), hbox);
1906
1907 /**** Citizens bar here ****/
1908 cbox = gtk_grid_new();
1909 gtk_box_append(GTK_BOX(hbox), cbox);
1910
1913
1917 pdialog->citizen_pics = gtk_picture_new();
1918
1927 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1928
1930 g_signal_connect(controller, "pressed",
1931 G_CALLBACK(citizens_callback), pdialog);
1933
1934 /**** City name label here ****/
1935 pdialog->name_label = gtk_label_new(NULL);
1940
1941 /**** -Start of Notebook- ****/
1942
1943 pdialog->notebook = gtk_notebook_new();
1946 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1947
1951
1953
1954 /* Only create these tabs if not a spy */
1958 }
1959
1961
1962 if (owner == client_player()
1963 && !client_is_observer()) {
1966 } else {
1969 }
1970
1971 /**** End of Notebook ****/
1972
1973 /* Bottom buttons */
1974
1975 pdialog->show_units_command =
1976 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1977
1978 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1980
1981 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1983 GTK_WIDGET(pdialog->prev_command), 1);
1984
1985 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1987 GTK_WIDGET(pdialog->next_command), 2);
1988
1989 if (owner != client_player()) {
1992 }
1993
1995 _("_Close"), GTK_RESPONSE_CLOSE);
1996
1999
2001 G_CALLBACK(close_callback), pdialog);
2002
2003 g_signal_connect(pdialog->prev_command, "clicked",
2005
2006 g_signal_connect(pdialog->next_command, "clicked",
2008
2009 /* Some other things we gotta do */
2010
2012 g_signal_connect(controller, "key-pressed",
2015
2017
2019
2020 /* Need to do this every time a new dialog is opened. */
2022
2024
2026
2027 return pdialog;
2028}
2029
2030/**************** Functions to update parts of the dialog *****************/
2031
2032/***********************************************************************/
2035static void city_dialog_update_title(struct city_dialog *pdialog)
2036{
2037 gchar *buf;
2038 const gchar *now;
2039
2040 if (city_unhappy(pdialog->pcity)) {
2041 /* TRANS: city dialog title */
2042 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
2043 city_name_get(pdialog->pcity),
2045 } else if (city_celebrating(pdialog->pcity)) {
2046 /* TRANS: city dialog title */
2047 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
2048 city_name_get(pdialog->pcity),
2050 } else if (city_happy(pdialog->pcity)) {
2051 /* TRANS: city dialog title */
2052 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
2053 city_name_get(pdialog->pcity),
2055 } else {
2056 /* TRANS: city dialog title */
2057 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
2058 city_name_get(pdialog->pcity),
2060 }
2061
2063 if (strcmp(now, buf) != 0) {
2066 }
2067
2068 g_free(buf);
2069}
2070
2071/***********************************************************************/
2074static void city_dialog_update_citizens(struct city_dialog *pdialog)
2075{
2076 enum citizen_category categories[MAX_CITY_SIZE];
2079 struct city *pcity = pdialog->pcity;
2081 int num_supers
2083 ARRAY_SIZE(categories) - num_citizens,
2084 &categories[num_citizens]);
2085 cairo_t *cr;
2086
2087 if (num_supers >= 0) {
2088 /* Just draw superspecialists in the common roster */
2090 } else {
2091 /* FIXME: show them in some compact way */
2092 num_citizens = ARRAY_SIZE(categories);
2093 }
2094 /* If there is not enough space we stack the icons. We draw from left to */
2095 /* right. width is how far we go to the right for each drawn pixmap. The */
2096 /* last icon is always drawn in full, and so has reserved */
2097 /* tileset_small_sprite_width(tileset) pixels. */
2098
2100 if (num_citizens > 1) {
2102 / (num_citizens - 1));
2103 } else {
2104 width = full_width;
2105 }
2106 pdialog->cwidth = width;
2107
2108 /* overview page */
2109 /* keep these values in sync with create_city_dialog */
2112
2113 cr = cairo_create(pdialog->citizen_surface);
2114
2115 for (i = 0; i < num_citizens; i++) {
2117 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
2118 i * width, 0);
2119 cairo_rectangle(cr, i * width, 0,
2120 /* Always draw last citizen in full */
2121 i + 1 < num_citizens ? width : full_width,
2123 cairo_fill(cr);
2124 }
2125
2126 total_used_width = (i - 1) * width + full_width;
2127
2129 /* Clear the rest of the area.
2130 * Note that this might still be necessary even in cases where
2131 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
2132 * divided perfectly. */
2137 cairo_fill(cr);
2138 }
2139
2140 cairo_destroy(cr);
2141
2143 pdialog->citizen_surface);
2144
2146}
2147
2148
2149/**********************************************************************/
2152static void city_dialog_update_counters(struct city_dialog *pdialog)
2153{
2158 char int_val[101];
2159 char *text;
2160 int text_size;
2161
2162 if (NULL != pdialog->counters.widget) {
2164 GTK_WIDGET(pdialog->counters.widget));
2165 }
2166
2167 if (NULL == pdialog->counters.container) {
2169 }
2170
2174
2178 counterValue = GTK_LABEL(gtk_label_new(_("Current value is: ")));
2180 fc_snprintf(int_val, sizeof(int_val), "%d", pdialog->pcity->counter_values[counter_index(pcount)]);
2184
2186 counterValue = GTK_LABEL(gtk_label_new(_("Activated once value equal or higher than: ")));
2188 fc_snprintf(int_val, sizeof(int_val), "%d", pcount->checkpoint);
2192
2193 text_size = 0;
2194 if (NULL != pcount->helptext) {
2195 strvec_iterate(pcount->helptext, text_) {
2198 }
2199 if (0 < text_size) {
2200 text = malloc(text_size+1);
2201 text_size = 0;
2202 strvec_iterate(pcount->helptext, text_) {
2203 strcpy(&text[text_size], text_);
2207 free(text);
2209 }
2212
2215}
2216
2217/***********************************************************************/
2221 struct city_dialog *pdialog)
2222{
2223 int i, illness = 0;
2224 char buf[NUM_INFO_FIELDS][512];
2225 struct city *pcity = pdialog->pcity;
2226 int granaryturns;
2229
2230 /* fill the buffers with the necessary info */
2231 if (supers) {
2232 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d+%d)",
2233 pcity->size, non_workers, supers);
2234 } else if (non_workers) {
2235 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
2236 pcity->size, non_workers);
2237 } else {
2238 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
2239 }
2240 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
2241 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
2242 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
2243 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
2244 pcity->surplus[O_SHIELD]);
2245 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
2246 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
2247 pcity->surplus[O_TRADE]);
2248 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
2249 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
2250 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
2251 pcity->prod[O_LUXURY]);
2252 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
2253 pcity->prod[O_SCIENCE]);
2254 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
2256
2258 if (granaryturns == 0) {
2259 /* TRANS: city growth is blocked. Keep short. */
2260 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
2261 } else if (granaryturns == FC_INFINITY) {
2262 /* TRANS: city is not growing. Keep short. */
2263 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
2264 } else {
2265 /* A negative value means we'll have famine in that many turns.
2266 But that's handled down below. */
2267 /* TRANS: city growth turns. Keep short. */
2269 PL_("%d turn", "%d turns", abs(granaryturns)),
2270 abs(granaryturns));
2271 }
2273 pcity->waste[O_TRADE]);
2274 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
2275 pcity->waste[O_SHIELD]);
2276 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
2277 pcity->client.culture);
2279 pcity->pollution);
2280 if (!game.info.illness_on) {
2281 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
2282 } else {
2284 /* illness is in tenth of percent */
2285 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
2286 (float)illness / 10.0);
2287 }
2288 if (pcity->steal) {
2289 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
2290 pcity->steal);
2291 } else {
2292 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
2293 }
2294
2296
2297 /* stick 'em in the labels */
2298 for (i = 0; i < NUM_INFO_FIELDS; i++) {
2300 }
2301
2302 /*
2303 * Make use of the emergency-indicating styles set up for certain labels
2304 * in create_city_info_table().
2305 */
2306 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
2307 * of a warning. */
2308 if (granaryturns > -4 && granaryturns < 0) {
2310 } else {
2312 }
2313
2314 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
2316 } else {
2318 }
2319
2320 /* Someone could add the color &orange for better granularity here */
2321 if (pcity->pollution >= 10) {
2323 } else {
2325 }
2326
2327 /* Illness is in tenth of percent, i.e 100 == 10.0% */
2328 if (illness >= 100) {
2330 } else {
2332 }
2333}
2334
2335/***********************************************************************/
2338static void city_dialog_update_map(struct city_dialog *pdialog)
2339{
2340 struct canvas store = FC_STATIC_CANVAS_INIT;
2341
2342 store.surface = pdialog->map_canvas_store_unscaled;
2343
2344 /* The drawing is done in three steps.
2345 * 1. First we render to a pixmap with the appropriate canvas size.
2346 * 2. Then the pixmap is rendered into a pixbuf of equal size.
2347 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
2348 * target pixbuf.
2349 */
2350
2351 city_dialog_redraw_map(pdialog->pcity, &store);
2352
2353 /* draw to real window */
2354 draw_map_canvas(pdialog);
2355}
2356
2357/***********************************************************************/
2360static void city_dialog_update_building(struct city_dialog *pdialog)
2361{
2362 char buf[32], buf2[200];
2363 gdouble pct;
2364 GListStore *store;
2365 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2366 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2367 int targets_used, item;
2368 struct city *pcity = pdialog->pcity;
2370 const char *descr = city_production_name_translation(pcity);
2372
2373 if (pdialog->overview.buy_command != NULL) {
2375 }
2376 if (pdialog->production.buy_command != NULL) {
2378 }
2379
2380 /* Make sure build slots info is up to date */
2381 if (pdialog->production.production_label != NULL) {
2383
2384 /* Only display extra info if more than one slot is available */
2385 if (build_slots > 1) {
2386 fc_snprintf(buf2, sizeof(buf2),
2387 /* TRANS: never actually used with built_slots <= 1 */
2388 PL_("Production (up to %d unit per turn):",
2389 "Production (up to %d units per turn):", build_slots),
2390 build_slots);
2393 } else {
2395 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2396 }
2397 }
2398
2399 /* Update what the city is working on */
2401
2402 if (cost > 0) {
2403 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2404 pct = CLAMP(pct, 0.0, 1.0);
2405 } else {
2406 pct = 1.0;
2407 }
2408
2409 if (pdialog->overview.production_bar != NULL) {
2410 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2411 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2416 }
2417
2418 if (pdialog->production.production_bar != NULL) {
2419 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2420 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2425 }
2426
2427 store = pdialog->overview.change_prod_store;
2428 if (store != nullptr) {
2429 int cur = -1;
2430 int actcount = 0;
2431
2432 if (pdialog->overview.change_prod_selection != nullptr) {
2434 -1, TRUE);
2435 }
2436
2438
2440 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2441 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2442
2443 for (item = 0; item < targets_used; item++) {
2444 if (can_city_build_now(&(wld.map), pcity, &items[item].item)) {
2445 const char *name;
2446 struct sprite *sprite;
2447 GdkPixbuf *pix;
2448 struct universal *target = &items[item].item;
2449 bool useless;
2451
2452 if (VUT_UTYPE == target->kind) {
2456 useless = FALSE;
2457 } else {
2460 useless = is_improvement_redundant(pcity, target->value.building);
2461 }
2463
2464 row->name = name;
2465 row->id = (gint)cid_encode(items[item].item);
2466 row->sprite = pix;
2467 row->useless = useless;
2468
2469 g_list_store_append(store, row);
2471
2472 if (are_universals_equal(target, &pcity->production)) {
2473 cur = actcount;
2474 }
2475
2476 actcount++;
2477 }
2478 }
2479
2480 if (pdialog->overview.change_prod_selection != nullptr) {
2482 cur, TRUE);
2483 }
2484 }
2485}
2486
2487/***********************************************************************/
2491{
2492 int item, targets_used;
2493 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2494 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2495
2496 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2497 "sell an improvement.");
2498 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2499 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2500
2502 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2503
2505
2506 for (item = 0; item < targets_used; item++) {
2507 GdkPixbuf *pix;
2508 int upkeep;
2509 struct sprite *sprite;
2510 struct universal target = items[item].item;
2512
2513 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2514 /* This takes effects (like Adam Smith's) into account. */
2515 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2517
2519
2520 row->impr = target.value.building;
2521 row->sprite = pix;
2522 row->description = items[item].descr;
2523 row->upkeep = upkeep;
2524 row->redundant = is_improvement_redundant(pdialog->pcity,
2525 target.value.building);
2526 row->tooltip = is_great_wonder(target.value.building) ?
2528 (is_small_wonder(target.value.building) ?
2530
2533 }
2534}
2535
2536/***********************************************************************/
2540{
2541 struct unit_list *units;
2542 struct unit_node_vector *nodes;
2543 int n, m, i;
2544 gchar *buf;
2546 const struct civ_map *nmap = &(wld.map);
2547
2548 if (NULL != client.conn.playing
2549 && city_owner(pdialog->pcity) != client.conn.playing) {
2550 units = pdialog->pcity->client.info_units_supported;
2551 } else {
2552 units = pdialog->pcity->units_supported;
2553 }
2554
2555 nodes = &pdialog->overview.supported_units;
2556
2557 n = unit_list_size(units);
2558 m = unit_node_vector_size(nodes);
2559
2560 if (m > n) {
2561 i = 0;
2563 if (i++ >= n) {
2565 elt->cmd);
2566 }
2568
2570 } else {
2571 for (i = m; i < n; i++) {
2572 GtkWidget *cmd, *pix;
2573 struct unit_node node;
2574
2575 cmd = gtk_button_new();
2576 node.cmd = cmd;
2577
2579
2580 pix = gtk_picture_new();
2581 node.pix = pix;
2583
2585
2587 cmd);
2588
2589 node.left = NULL;
2590 node.middle = NULL;
2591 node.right = NULL;
2592
2593 unit_node_vector_append(nodes, node);
2594 }
2595 }
2596
2597 i = 0;
2598 unit_list_iterate(units, punit) {
2599 struct unit_node *pnode;
2600 int happy_cost = city_unit_unhappiness(nmap, punit, &free_unhappy);
2601
2602 pnode = unit_node_vector_get(nodes, i);
2603 if (pnode) {
2604 GtkWidget *cmd, *pix;
2607
2608 cmd = pnode->cmd;
2609 pix = pnode->pix;
2610
2612 punit->upkeep, happy_cost);
2613
2614 if (pnode->left != NULL) {
2618 }
2619
2621
2623 g_signal_connect(controller, "pressed",
2627 pnode->left = controller;
2631 g_signal_connect(controller, "released",
2635 pnode->middle = controller;
2639 g_signal_connect(controller, "released",
2643 pnode->right = controller;
2644
2645 if (city_owner(pdialog->pcity) != client.conn.playing) {
2647 } else {
2649 }
2650
2653 }
2654 i++;
2656
2657 buf = g_strdup_printf(_("Supported units %d"), n);
2659 g_free(buf);
2660}
2661
2662/***********************************************************************/
2666{
2667 struct unit_list *units;
2668 struct unit_node_vector *nodes;
2669 int n, m, i;
2670 gchar *buf;
2671
2672 if (NULL != client.conn.playing
2673 && city_owner(pdialog->pcity) != client.conn.playing) {
2674 units = pdialog->pcity->client.info_units_present;
2675 } else {
2676 units = pdialog->pcity->tile->units;
2677 }
2678
2679 nodes = &pdialog->overview.present_units;
2680
2681 n = unit_list_size(units);
2682 m = unit_node_vector_size(nodes);
2683
2684 if (m > n) {
2685 i = 0;
2687 if (i++ >= n) {
2689 elt->cmd);
2690 }
2692
2694 } else {
2695 for (i = m; i < n; i++) {
2696 GtkWidget *cmd, *pix;
2697 struct unit_node node;
2698
2699 cmd = gtk_button_new();
2700 node.cmd = cmd;
2701
2703
2704 pix = gtk_picture_new();
2705 node.pix = pix;
2707
2709
2711 cmd);
2712
2713 node.left = NULL;
2714 node.middle = NULL;
2715 node.right = NULL;
2716
2717 unit_node_vector_append(nodes, node);
2718 }
2719 }
2720
2721 i = 0;
2722 unit_list_iterate(units, punit) {
2723 struct unit_node *pnode;
2724
2725 pnode = unit_node_vector_get(nodes, i);
2726 if (pnode) {
2727 GtkWidget *cmd, *pix;
2730
2731 cmd = pnode->cmd;
2732 pix = pnode->pix;
2733
2735
2736 if (pnode->left != NULL) {
2740 }
2741
2743
2745 g_signal_connect(controller, "pressed",
2749 pnode->left = controller;
2753 g_signal_connect(controller, "released",
2757 pnode->middle = controller;
2761 g_signal_connect(controller, "released",
2765 pnode->right = controller;
2766
2767 if (city_owner(pdialog->pcity) != client.conn.playing) {
2769 } else {
2771 }
2772
2775 }
2776 i++;
2778
2779 buf = g_strdup_printf(_("Present units %d"), n);
2781 g_free(buf);
2782}
2783
2784/***********************************************************************/
2792{
2793 int count = 0;
2794 int city_number;
2795
2796 if (NULL != client.conn.playing) {
2798 } else {
2799 city_number = FC_INFINITY; /* ? */
2800 }
2801
2802 /* The first time, we see if all the city dialogs are open */
2804 if (city_owner(pdialog->pcity) == client.conn.playing) {
2805 count++;
2806 }
2808
2809 if (count == city_number) { /* All are open, shouldn't prev/next */
2811 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2812 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2814 } else {
2816 if (city_owner(pdialog->pcity) == client.conn.playing) {
2817 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2818 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2819 }
2821 }
2822}
2823
2824/***********************************************************************/
2827static void citydlg_response_callback(GtkDialog *dlg, gint response,
2828 void *data)
2829{
2830 switch (response) {
2831 case CDLGR_UNITS:
2832 show_units_response(data);
2833 break;
2834 }
2835}
2836
2837/***********************************************************************/
2840static void show_units_response(void *data)
2841{
2842 struct city_dialog *pdialog = (struct city_dialog *) data;
2843 struct tile *ptile = pdialog->pcity->tile;
2844
2845 if (unit_list_size(ptile->units)) {
2847 }
2848}
2849
2850/***********************************************************************/
2860static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2861 GtkWidget *wdg, bool supported)
2862{
2863 GMenu *menu;
2864 GActionGroup *group;
2865 GSimpleAction *act;
2866
2867 if (!can_client_issue_orders()) {
2868 return FALSE;
2869 }
2870
2871 if (pdialog->popover != NULL) {
2873 }
2874
2876 menu = g_menu_new();
2877
2878 if (supported) {
2879 act = g_simple_action_new("center", NULL);
2880 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2884 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2885 }
2886
2887 act = g_simple_action_new("activate", NULL);
2888 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2892 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2893 "win.activate"));
2894
2895 act = g_simple_action_new("activate_close", NULL);
2896 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2898
2899 if (supported) {
2900 g_signal_connect(act, "activate",
2903 } else {
2904 g_signal_connect(act, "activate",
2907 }
2908
2910 g_menu_item_new(_("Activate unit, _close dialog"),
2911 "win.activate_close"));
2912
2913 if (!supported) {
2914 act = g_simple_action_new("load", NULL);
2915 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2920 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2921
2922 act = g_simple_action_new("unload", NULL);
2923 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2931 unit_tile(punit)));
2932 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2933 "win.unload"));
2934
2935 act = g_simple_action_new("sentry", NULL);
2936 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2944 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2945 "win.sentry"));
2946
2947 act = g_simple_action_new("fortify", NULL);
2948 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2956 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2957 "win.fortify"));
2958 }
2959
2960 act = g_simple_action_new("disband", NULL);
2961 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2967 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2968 "win.disband"));
2969
2970 if (!supported) {
2971 act = g_simple_action_new("rehome", NULL);
2972 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2978 pdialog->pcity));
2981 "win.rehome"));
2982
2983 act = g_simple_action_new("upgrade", NULL);
2984 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2993 != NULL);
2994 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
2995 "win.upgrade"));
2996 }
2997
2999 g_object_ref(pdialog->popover);
3000 gtk_widget_insert_action_group(pdialog->popover, "win", group);
3002
3003
3005
3006 return TRUE;
3007}
3008
3009/***********************************************************************/
3013 double x, double y, gpointer data)
3014{
3015 struct city_dialog *pdialog;
3016 struct city *pcity;
3017 struct unit *punit =
3018 player_unit_by_number(client_player(), (size_t) data);
3019
3020 if (NULL != punit
3022 && NULL != (pdialog = get_city_dialog(pcity))) {
3023
3024 return create_unit_menu(pdialog, punit,
3026 TRUE);
3027 }
3028
3029 return TRUE;
3030}
3031
3032/***********************************************************************/
3036 double x, double y, gpointer data)
3037{
3038 struct city_dialog *pdialog;
3039 struct city *pcity;
3040 struct unit *punit =
3041 player_unit_by_number(client_player(), (size_t) data);
3042
3043 if (NULL != punit
3044 && NULL != (pcity = tile_city(unit_tile(punit)))
3045 && NULL != (pdialog = get_city_dialog(pcity))) {
3046
3047 return create_unit_menu(pdialog, punit,
3049 FALSE);
3050 }
3051
3052 return TRUE;
3053}
3054
3055/***********************************************************************/
3060 int n_press, double x, double y,
3061 gpointer data)
3062{
3063 struct city_dialog *pdialog;
3064 struct city *pcity;
3065 struct unit *punit =
3066 player_unit_by_number(client_player(), (size_t) data);
3067
3068 if (NULL != punit
3069 && NULL != (pcity = tile_city(unit_tile(punit)))
3070 && NULL != (pdialog = get_city_dialog(pcity))
3073 close_city_dialog(pdialog);
3074 }
3075
3076 return TRUE;
3077}
3078
3079/***********************************************************************/
3084 double x, double y, gpointer data)
3085{
3086 struct city_dialog *pdialog;
3087 struct city *pcity;
3088 struct unit *punit =
3089 player_unit_by_number(client_player(), (size_t) data);
3090
3091 if (NULL != punit
3093 && NULL != (pdialog = get_city_dialog(pcity))
3096 close_city_dialog(pdialog);
3097 }
3098
3099 return TRUE;
3100}
3101
3102/***********************************************************************/
3106 double x, double y, gpointer data)
3107{
3108 struct unit *punit =
3109 player_unit_by_number(client_player(), (size_t) data);
3110
3111 if (NULL != punit
3114 }
3115
3116 return TRUE;
3117}
3118
3119/***********************************************************************/
3124static void close_citydlg_unit_popover(struct city_dialog *pdialog)
3125{
3126 if (pdialog->popover != NULL) {
3127 gtk_widget_unparent(pdialog->popover);
3128 g_object_unref(pdialog->popover);
3129 pdialog->popover = NULL;
3130 }
3131}
3132
3133/***********************************************************************/
3137 gpointer data)
3138{
3139 struct unit *punit =
3141
3142 if (NULL != punit) {
3144 }
3145
3147}
3148
3149/***********************************************************************/
3153 gpointer data)
3154{
3155 struct unit *punit =
3157
3158 if (NULL != punit) {
3160 }
3161
3163}
3164
3165/***********************************************************************/
3170 GVariant *parameter,
3171 gpointer data)
3172{
3173 struct unit *punit =
3175
3176 if (NULL != punit) {
3177 struct city *pcity =
3179
3181 if (NULL != pcity) {
3182 struct city_dialog *pdialog = get_city_dialog(pcity);
3183
3184 if (NULL != pdialog) {
3185 close_city_dialog(pdialog);
3186 }
3187 }
3188 }
3189
3191}
3192
3193/***********************************************************************/
3198 GVariant *parameter,
3199 gpointer data)
3200{
3201 struct unit *punit =
3203
3204 if (NULL != punit) {
3205 struct city *pcity = tile_city(unit_tile(punit));
3206
3208 if (NULL != pcity) {
3209 struct city_dialog *pdialog = get_city_dialog(pcity);
3210
3211 if (NULL != pdialog) {
3212 close_city_dialog(pdialog);
3213 }
3214 }
3215 }
3216
3218}
3219
3220/***********************************************************************/
3224 gpointer data)
3225{
3226 struct unit *punit =
3228
3229 if (NULL != punit) {
3231 }
3232
3234}
3235
3236/***********************************************************************/
3240 gpointer data)
3241{
3242 struct unit *punit =
3244
3245 if (NULL != punit) {
3247 }
3248
3250}
3251
3252/***********************************************************************/
3256 gpointer data)
3257{
3258 struct unit *punit =
3260
3261 if (NULL != punit) {
3263 }
3264
3266}
3267
3268/***********************************************************************/
3272 gpointer data)
3273{
3274 struct unit *punit =
3276
3277 if (NULL != punit) {
3279 }
3280
3282}
3283
3284/***********************************************************************/
3288 gpointer data)
3289{
3290 struct unit_list *punits;
3291 struct unit *punit =
3293
3294 if (NULL == punit) {
3295 return;
3296 }
3297
3302
3304}
3305
3306/***********************************************************************/
3311 gpointer data)
3312{
3313 struct unit *punit =
3315
3316 if (NULL != punit) {
3318 }
3319
3321}
3322
3323/***********************************************************************/
3327 gpointer data)
3328{
3329 struct unit_list *punits;
3330 struct unit *punit =
3332
3333 if (NULL == punit) {
3334 return;
3335 }
3336
3341
3343}
3344
3345/******** Callbacks for citizen bar, map funcs that are not update ********/
3346
3347/***********************************************************************/
3352 double x, double y, gpointer data)
3353{
3354 struct city_dialog *pdialog = data;
3355 struct city *pcity = pdialog->pcity;
3356 int citnum, tlen, len;
3357
3358 if (!can_client_issue_orders()) {
3359 return FALSE;
3360 }
3361
3363 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
3364
3365 if (x > len) {
3366 /* No citizen that far to the right */
3367 return FALSE;
3368 }
3369 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
3370
3372
3373 return TRUE;
3374}
3375
3376/***********************************************************************/
3380{
3381 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
3382 struct city *pcity = workertask_req.owner;
3383 struct tile *ptile = workertask_req.loc;
3384 struct packet_worker_task task;
3385
3386 task.city_id = pcity->id;
3387
3388 if (act == ACTIVITY_LAST) {
3389 task.tgt = -1;
3390 task.want = 0;
3391 } else {
3392 enum extra_cause cause = activity_to_extra_cause(act);
3394 struct extra_type *tgt;
3395
3396 if (cause != EC_NONE) {
3397 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
3398 } else if (rmcause != ERM_NONE) {
3400 } else {
3401 tgt = NULL;
3402 }
3403
3404 if (tgt == NULL) {
3405 struct terrain *pterr = tile_terrain(ptile);
3406
3407 if ((act != ACTIVITY_TRANSFORM
3408 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3409 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3410 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3411 /* No extra to order */
3412 output_window_append(ftc_client, _("There's no suitable extra to order."));
3413
3414 return;
3415 }
3416
3417 task.tgt = -1;
3418 } else {
3419 task.tgt = extra_index(tgt);
3420 }
3421
3422 task.want = 100;
3423 }
3424
3425 task.tile_id = ptile->index;
3426 task.activity = act;
3427
3429}
3430
3431/***********************************************************************/
3438
3439/***********************************************************************/
3442static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3443{
3445 GtkWidget *shl;
3446 struct terrain *pterr = tile_terrain(ptile);
3447 struct universal for_terr = { .kind = VUT_TERRAIN,
3448 .value = { .terrain = pterr }};
3449 struct worker_task *ptask;
3450
3452 workertask_req.owner = pcity;
3453 workertask_req.loc = ptile;
3454
3456 _("What Action to Request"),
3457 _("Select autoworker activity:"));
3458
3459 ptask = worker_task_list_get(pcity->task_reqs, 0);
3460 if (ptask != NULL) {
3461 choice_dialog_add(shl, _("Clear request"),
3464 }
3465
3467 choice_dialog_add(shl, Q_("?act:Mine"),
3470 }
3471 if (pterr->plant_result != NULL
3473 NULL, &for_terr)) {
3474 choice_dialog_add(shl, _("Plant"),
3477 }
3479 choice_dialog_add(shl, _("Irrigate"),
3482 }
3483 if (pterr->cultivate_result != NULL
3485 NULL, &for_terr)) {
3486 choice_dialog_add(shl, _("Cultivate"),
3489 }
3491 choice_dialog_add(shl, _("Road"),
3494 }
3495 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3497 NULL, &for_terr)) {
3498 choice_dialog_add(shl, _("Transform"),
3501 }
3503 city_owner(pcity), NULL) != NULL) {
3504 choice_dialog_add(shl, _("Clean"),
3507 }
3508
3509 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3511
3513 NULL);
3514 }
3515}
3516
3517/***********************************************************************/
3521 double x, double y, gpointer data)
3522{
3523 struct city_dialog *pdialog = data;
3525
3526 if (!can_client_issue_orders()) {
3527 return FALSE;
3528 }
3529
3530 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3531 return FALSE;
3532 }
3533
3536
3538 city_map_radius_sq_get(pdialog->pcity),
3539 canvas_x, canvas_y)) {
3541 }
3542
3543 return TRUE;
3544}
3545
3546/***********************************************************************/
3550 double x, double y, gpointer data)
3551{
3552 struct city_dialog *pdialog = data;
3554
3555 if (!can_client_issue_orders()) {
3556 return FALSE;
3557 }
3558
3561
3563 city_map_radius_sq_get(pdialog->pcity),
3564 canvas_x, canvas_y)) {
3565 struct city *pcity = pdialog->pcity;
3566
3567 popup_workertask_dlg(pdialog->pcity,
3570 city_x, city_y));
3571 }
3572
3573 return TRUE;
3574}
3575
3576/***********************************************************************/
3579static void draw_map_canvas(struct city_dialog *pdialog)
3580{
3582 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3584 }
3585}
3586
3587/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3588
3589/***********************************************************************/
3592static void buy_callback_response(GObject *dialog, GAsyncResult *result,
3593 gpointer data)
3594{
3596 result, NULL);
3597
3598 if (button == 0) {
3599 struct city_dialog *pdialog = data;
3600
3601 city_buy_production(pdialog->pcity);
3602 }
3603}
3604
3605/***********************************************************************/
3608static void buy_callback(GtkWidget *w, gpointer data)
3609{
3611 struct city_dialog *pdialog = data;
3612 const char *name = city_production_name_translation(pdialog->pcity);
3613 int value = pdialog->pcity->client.buy_cost;
3614 char buf[1024];
3615
3616 if (!can_client_issue_orders()) {
3617 return;
3618 }
3619
3620 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3621 "Treasury contains %d gold.",
3622 client_player()->economic.gold),
3623 client_player()->economic.gold);
3624
3625 if (value <= client_player()->economic.gold) {
3626 const char *buttons[] = { _("Yes"), _("No"), NULL };
3627
3629 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3630 PL_("Buy %s for %d gold?\n%s",
3631 "Buy %s for %d gold?\n%s", value),
3632 name, value, buf);
3634 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3636
3638 buy_callback_response, pdialog);
3639 } else {
3640 const char *buttons[] = { _("Close"), NULL };
3641
3643 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3644 PL_("%s costs %d gold.\n%s",
3645 "%s costs %d gold.\n%s", value),
3646 name, value, buf);
3648 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3651 }
3652}
3653
3654/***********************************************************************/
3658 guint position,
3659 guint n_items,
3660 gpointer data)
3661{
3665 struct universal univ = cid_production(row->id);
3666
3667 city_change_production(((struct city_dialog *)data)->pcity, &univ);
3668 }
3669}
3670
3671/***********************************************************************/
3674static void sell_callback(const struct impr_type *pimprove, gpointer data)
3675{
3676 GtkWidget *shl;
3677 struct city_dialog *pdialog = (struct city_dialog *) data;
3678 pdialog->sell_id = improvement_number(pimprove);
3679 int price;
3680
3681 if (!can_client_issue_orders()) {
3682 return;
3683 }
3684
3686 pimprove) != TR_SUCCESS) {
3687 return;
3688 }
3689
3690 price = impr_sell_gold(pimprove);
3695 PL_("Sell %s for %d gold?",
3696 "Sell %s for %d gold?", price),
3697 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3698 setup_dialog(shl, pdialog->shell);
3699 pdialog->sell_shell = shl;
3700
3701 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3702
3703 g_signal_connect(shl, "response",
3705
3707}
3708
3709/***********************************************************************/
3712static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3713{
3714 struct city_dialog *pdialog = data;
3715
3716 if (response == GTK_RESPONSE_YES) {
3717 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3718 }
3720
3721 pdialog->sell_shell = NULL;
3722}
3723
3724/***********************************************************************/
3727static void impr_callback(GtkColumnView *self, guint position,
3728 gpointer data)
3729{
3730 GdkSeat *seat;
3732 GListStore *store = ((struct city_dialog *)data)->overview.improvement_list;
3733 FcImprRow *row = g_list_model_get_item(G_LIST_MODEL(store), position);
3734 const struct impr_type *pimpr = row->impr;
3735 GtkWidget *wdg = ((struct city_dialog *)data)->shell;
3736
3739
3740 if (!(mask & GDK_CONTROL_MASK)) {
3741 sell_callback(pimpr, data);
3742 } else {
3743 if (is_great_wonder(pimpr)) {
3745 } else {
3747 }
3748 }
3749}
3750
3751/************ Callbacks for stuff on the Misc. Settings page **************/
3752
3753/***********************************************************************/
3757{
3758 struct city_dialog *pdialog;
3759
3760 pdialog = (struct city_dialog *) data;
3761
3762 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3763 /* "shellrenamecity" */
3764 _("Rename City"),
3765 _("What should we rename the city to?"),
3766 city_name_get(pdialog->pcity),
3767 rename_popup_callback, pdialog);
3768}
3769
3770/***********************************************************************/
3773static void rename_popup_callback(gpointer data, gint response,
3774 const char *input)
3775{
3776 struct city_dialog *pdialog = data;
3777
3778 if (pdialog) {
3779 if (response == GTK_RESPONSE_OK) {
3780 city_rename(pdialog->pcity, input);
3781 } /* else CANCEL or DELETE_EVENT */
3782
3783 pdialog->rename_shell = NULL;
3784 }
3785}
3786
3787/***********************************************************************/
3791{
3793}
3794
3795/***********************************************************************/
3799{
3800 struct city_dialog *pdialog = (struct city_dialog *) data;
3801
3802 if (!can_client_issue_orders()) {
3803 return;
3804 }
3805
3806 if (!pdialog->misc.block_signal) {
3807 struct city *pcity = pdialog->pcity;
3809
3810 fc_assert(CITYO_LAST == 3);
3811
3815 }
3818 }
3821 }
3822
3824 pcity->wlcb);
3825 }
3826}
3827
3828/***********************************************************************/
3853
3854/******************** Callbacks for: Close, Prev, Next. *******************/
3855
3856/***********************************************************************/
3859static void close_callback(GtkWidget *w, gpointer data)
3860{
3861 close_city_dialog((struct city_dialog *) data);
3862}
3863
3864/***********************************************************************/
3868{
3869 struct city_dialog *pdialog;
3870 int width, height;
3871
3872 /* Save size of the city dialog. */
3874
3875 pdialog = (struct city_dialog *) data;
3877
3879 citizens_dialog_close(pdialog->pcity);
3880 }
3881 close_happiness_dialog(pdialog->pcity);
3882 close_cma_dialog(pdialog->pcity);
3883
3884 /* Save size of the city dialog. */
3887 width,
3891 height,
3893
3894 last_page
3896
3899
3902
3903 if (pdialog->sell_shell) {
3905 }
3906 if (pdialog->rename_shell) {
3908 }
3909
3912
3913 free(pdialog);
3914
3915 /* Need to do this every time a new dialog is closed. */
3917}
3918
3919/***********************************************************************/
3922static void close_city_dialog(struct city_dialog *pdialog)
3923{
3925}
3926
3927/***********************************************************************/
3932{
3933 struct city_dialog *pdialog = (struct city_dialog *) data;
3934 int i, j, dir, size;
3935 struct city *new_pcity = NULL;
3936
3938 return;
3939 }
3940
3942
3944 fc_assert_ret(size >= 1);
3946
3947 if (size == 1) {
3948 return;
3949 }
3950
3951 /* dir = 1 will advance to the city, dir = -1 will get previous */
3952 if (w == GTK_WIDGET(pdialog->next_command)) {
3953 dir = 1;
3954 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3955 dir = -1;
3956 } else {
3957 /* Always fails. */
3959 || w == GTK_WIDGET(pdialog->prev_command));
3960 dir = 1;
3961 }
3962
3963 for (i = 0; i < size; i++) {
3964 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3965 break;
3966 }
3967 }
3968
3969 fc_assert_ret(i < size);
3970
3971 for (j = 1; j < size; j++) {
3973 (i + dir * j + size) % size);
3975
3976 fc_assert_ret(other_pdialog != pdialog);
3977 if (!other_pdialog) {
3979 break;
3980 }
3981 }
3982
3983 if (!new_pcity) {
3984 /* Every other city has an open city dialog. */
3985 return;
3986 }
3987
3988 /* cleanup happiness dialog */
3990 citizens_dialog_close(pdialog->pcity);
3991 }
3992 close_happiness_dialog(pdialog->pcity);
3993
3994 pdialog->pcity = new_pcity;
3995
3996 /* reinitialize happiness, and cma dialogs */
3999 citizens_dialog_display(pdialog->pcity));
4000 }
4002 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
4003 if (!client_is_observer()) {
4004 fc_assert(pdialog->cma_editor != NULL);
4005 pdialog->cma_editor->pcity = new_pcity;
4006 }
4007
4008 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
4009
4010 can_slide = FALSE;
4011 center_tile_mapcanvas(pdialog->pcity->tile);
4012 can_slide = TRUE;
4013 if (!client_is_observer()) {
4014 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
4015 }
4016
4018
4019 /* Recenter the city map(s) */
4021 if (pdialog->happiness.map_canvas.sw) {
4023 }
4024}
4025
4026/***********************************************************************/
4030{
4032 refresh_worklist(pdialog->production.worklist);
4034}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1271
bool action_ever_possible(action_id action)
Definition actions.c:7489
#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:663
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
int city_granary_size(int city_size)
Definition city.c:2132
int city_build_slots(const struct city *pcity)
Definition city.c:2932
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:305
int city_superspecialists(const struct city *pcity)
Definition city.c:3358
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1255
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3428
int city_population(const struct city *pcity)
Definition city.c:1191
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
Definition city.c:3049
bool city_unhappy(const struct city *pcity)
Definition city.c:1626
bool city_celebrating(const struct city *pcity)
Definition city.c:1645
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2870
bool city_happy(const struct city *pcity)
Definition city.c:1614
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
citizens city_specialists(const struct city *pcity)
Definition city.c:3343
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target)
Definition city.c:1013
int city_turns_to_grow(const struct city *pcity)
Definition city.c:1996
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:700
static citizens city_size_get(const struct city *pcity)
Definition city.h:569
citizen_category
Definition city.h:265
#define city_owner(_pcity_)
Definition city.h:563
#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:76
void request_unit_fortify(struct unit *punit)
Definition control.c:2353
void unit_focus_set(struct unit *punit)
Definition control.c:506
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2094
void request_unit_unload(struct unit *pcargo)
Definition control.c:2194
void request_unit_sentry(struct unit *punit)
Definition control.c:2342
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
int counter_index(const struct counter *pcount)
Definition counters.c:174
#define city_counters_iterate_end
Definition counters.h:64
#define city_counters_iterate(pcount)
Definition counters.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
static struct editor_state * editor
Definition editor.c:100
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:779
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1090
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1111
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:236
#define EC_NONE
Definition fc_types.h:806
@ TR_SUCCESS
Definition fc_types.h:939
#define ERM_NONE
Definition fc_types.h:829
@ O_SHIELD
Definition fc_types.h:102
@ O_FOOD
Definition fc_types.h:102
@ O_TRADE
Definition fc_types.h:102
@ O_SCIENCE
Definition fc_types.h:102
@ O_LUXURY
Definition fc_types.h:102
@ O_GOLD
Definition fc_types.h:102
#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:742
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:2891
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:2950
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3061
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1869
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3474
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1830
static int last_page
Definition citydlg.c:220
static void init_citydlg_dimensions(void)
Definition citydlg.c:332
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1272
struct tile * loc
Definition citydlg.c:227
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:128
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3398
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:2084
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2517
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3189
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2790
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:1943
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:3053
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2371
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2971
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3252
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2865
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3440
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3535
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:3202
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3325
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:3406
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:3177
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:3271
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2817
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2478
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:3466
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3310
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:2937
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2904
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:2613
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:2917
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3364
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3544
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2062
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:2878
static void show_units_response(void *data)
Definition citydlg.c:2530
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:2264
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2803
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2842
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2998
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3381
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2207
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:2551
void close_cma_dialog(struct city *pcity)
Definition cma_fe.c:104
struct cma_dialog * create_cma_dialog(struct city *pcity, bool tiny)
Definition cma_fe.c:214
void refresh_cma_dialog(struct city *pcity, enum cma_refresh refresh)
Definition cma_fe.c:471
@ REFRESH_ALL
Definition cma_fe.h:26
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
GtkWidget * toplevel
Definition gui_main.c:126
GtkWidget * map_canvas
Definition gui_main.c:108
int screen_height(void)
Definition gui_main.c:2594
#define GUI_GTK_OPTION(optname)
Definition gui_main.h: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:3754
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:3265
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2775
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2576
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2821
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3236
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2840
@ COUNTERS_PAGE
Definition citydlg.c:115
static gboolean middle_supported_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2799
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:916
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:1237
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1211
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
#define CLIP(lower, current, upper)
Definition shared.h:57
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
size_t size
Definition specvec.h:72
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
#define strvec_iterate(psv, str)
#define strvec_iterate_end
GObjectClass parent_class
Definition citydlg.c:363
int upkeep
Definition citydlg.c:356
const struct impr_type * impr
Definition citydlg.c:353
GdkPixbuf * sprite
Definition citydlg.c:354
const char * tooltip
Definition citydlg.c:358
char * description
Definition citydlg.c:355
bool redundant
Definition citydlg.c:357
GObject parent_instance
Definition citydlg.c:351
GObjectClass parent_class
Definition citydlg.c:388
bool useless
Definition citydlg.c:383
GObject parent_instance
Definition citydlg.c:378
const char * name
Definition citydlg.c:380
GdkPixbuf * sprite
Definition citydlg.c:382
cairo_surface_t * surface
Definition canvas.h:23
GtkWidget * prev_command
Definition citydlg.c:208
GtkWidget * name_label
Definition citydlg.c:141
GtkWidget * rename_shell
Definition citydlg.c:205
enum city_dialog::@220 page
GtkWidget * rename_command
Definition citydlg.c:196
GtkWidget * production_bar
Definition citydlg.c:152
GtkWidget * supported_units_frame
Definition citydlg.c:157
GtkWidget * sell_shell
Definition citydlg.c:203
GtkWidget * production_label
Definition citydlg.c:173
GtkWidget * widget
Definition citydlg.c:182
GtkWidget * supported_unit_table
Definition citydlg.c:158
GtkWidget * disband_on_settler
Definition citydlg.c:198
struct city_map_canvas map_canvas
Definition citydlg.c:150
GListStore * improvement_list
Definition citydlg.c:156
GtkWidget * improvement_list
Definition citydlg.c:155
GtkWidget * container
Definition citydlg.c:189
GtkWidget * buy_command
Definition citydlg.c:154
short block_signal
Definition citydlg.c:200
GtkWidget * whichtab_radio[NUM_PAGES]
Definition citydlg.c:199
struct unit_node_vector supported_units
Definition citydlg.c:163
cairo_surface_t * map_canvas_store_unscaled
Definition citydlg.c:142
struct city * pcity
Definition citydlg.c:138
struct city_dialog::@148 happiness
struct unit_node_vector present_units
Definition citydlg.c:164
city_map * view
Definition citydlg.h: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:593
universals_u value
Definition fc_types.h:592
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:7023
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:6962
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7045
const struct unit_type * utype
Definition fc_types.h:535
const struct impr_type * building
Definition fc_types.h:528
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