Freeciv-3.2
Loading...
Searching...
No Matches
citydlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
25/* utility */
26#include "bitvector.h"
27#include "fcintl.h"
28#include "log.h"
29#include "mem.h"
30#include "shared.h"
31#include "support.h"
32
33/* common */
34#include "city.h"
35#include "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-4.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 "repodlgs.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 *production_combo;
156 GtkWidget *buy_command;
157 GtkWidget *improvement_list;
158
159 GtkWidget *supported_units_frame;
160 GtkWidget *supported_unit_table;
161
162 GtkWidget *present_units_frame;
163 GtkWidget *present_unit_table;
164
165 struct unit_node_vector supported_units;
166 struct unit_node_vector present_units;
167
169
170 GtkListStore *change_production_store;
172
173 struct {
174 GtkWidget *production_label;
175 GtkWidget *production_bar;
176 GtkWidget *buy_command;
179
180 struct {
182
187
188 struct {
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);
320static void change_production_callback(GtkComboBox *combo,
321 struct city_dialog *pdialog);
322
323static void sell_callback(struct impr_type *pimprove, gpointer data);
324static void sell_callback_response(GtkWidget *w, gint response, gpointer data);
325
326static void impr_callback(GtkTreeView *view, GtkTreePath *path,
328
329static void rename_callback(GtkWidget * w, gpointer data);
330static void rename_popup_callback(gpointer data, gint response,
331 const char *input);
332static void set_cityopt_values(struct city_dialog *pdialog);
333static void cityopt_callback(GtkWidget * w, gpointer data);
334static void misc_whichtab_callback(GtkWidget * w, gpointer data);
335
336static void city_destroy_callback(GtkWidget *w, gpointer data);
337static void close_city_dialog(struct city_dialog *pdialog);
338static void citydlg_response_callback(GtkDialog *dlg, gint response,
339 void *data);
340static void close_callback(GtkWidget *w, gpointer data);
341static void switch_city_callback(GtkWidget *w, gpointer data);
342
343/***********************************************************************/
352
353/***********************************************************************/
356static void initialize_city_dialogs(void)
357{
358 int height;
359
361
365
366 /* Use default layout when height cannot be determined
367 * (when height == 0) */
368 if (height > 0 && height <= TINYSCREEN_MAX_HEIGHT) {
370 } else {
372 }
373
375}
376
377/***********************************************************************/
381{
383 return;
384 }
385
387
389 /* There's no reasonable way to resize a GtkImage, so we don't try.
390 Instead we just redraw the overview within the existing area. The
391 player has to close and reopen the dialog to fix this. */
392 city_dialog_update_map(pdialog);
394
396}
397
398/***********************************************************************/
402static struct city_dialog *get_city_dialog(struct city *pcity)
403{
406 }
407
409 if (pdialog->pcity == pcity) {
410 return pdialog;
411 }
413
414 return NULL;
415}
416
417/***********************************************************************/
421 int width, int height, gpointer data)
422{
423 struct city_dialog *pdialog = data;
424
427 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
428 cairo_paint_with_alpha(cr, 0.5);
429 } else {
430 cairo_paint(cr);
431 }
432}
433
434/***********************************************************************/
437static void city_dialog_map_create(struct city_dialog *pdialog,
439{
440 GtkWidget *sw, *darea;
443
452
453 darea = gtk_drawing_area_new();
456 canvas_draw_cb, pdialog, NULL);
457
459 g_signal_connect(controller, "pressed",
465 g_signal_connect(controller, "pressed",
469
470 /* save all widgets for the city map */
471 cmap_canvas->sw = sw;
472 cmap_canvas->darea = darea;
473}
474
475/***********************************************************************/
499
500/***********************************************************************/
504{
505 struct city_dialog *pdialog = get_city_dialog(pcity);
506
507 log_debug("CITYMAP_WIDTH: %d", CITYMAP_WIDTH);
508 log_debug("CITYMAP_HEIGHT: %d", CITYMAP_HEIGHT);
509 log_debug("CITYMAP_SCALE: %.3f", CITYMAP_SCALE);
510
514 }
515
516 if (!pdialog) {
517 return;
518 }
519
524 city_dialog_update_map(pdialog);
529
532
534
535 if (!low_citydlg) {
537 }
541 }
542
543 if (!client_is_observer()) {
545 }
546
550 } else {
551 /* Set the buttons we do not want live while a Diplomat investigates */
553 }
554}
555
556/***********************************************************************/
561{
562 struct city *pcity_sup, *pcity_pre;
563 struct city_dialog *pdialog;
564
567
568 if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
570 }
571
572 if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
574 }
575}
576
577/***********************************************************************/
581{
582 struct city_dialog *pdialog;
583
584 if (!(pdialog = get_city_dialog(pcity))) {
585 pdialog = create_city_dialog(pcity);
586 }
587
589
590 /* center the city map(s); this must be *after* the city dialog was drawn
591 * else the size information is missing! */
593 if (pdialog->happiness.map_canvas.sw) {
595 }
596}
597
598/***********************************************************************/
602{
603 return get_city_dialog(pcity) != NULL;
604}
605
606/***********************************************************************/
610{
611 struct city_dialog *pdialog = get_city_dialog(pcity);
612
613 if (pdialog) {
614 close_city_dialog(pdialog);
615 }
616}
617
618/***********************************************************************/
634
635/***********************************************************************/
641 GdkModifierType state,
642 gpointer data)
643{
644 struct city_dialog *pdialog = (struct city_dialog *)data;
645
646 if (state & GDK_CONTROL_MASK) {
647 switch (keyval) {
648 case GDK_KEY_Left:
650 return TRUE;
651
652 case GDK_KEY_Right:
654 return TRUE;
655
656 default:
657 break;
658 }
659 }
660
661 return FALSE;
662}
663
664/***********************************************************************/
668 double x, double y, gpointer data)
669{
671 struct city_dialog *pdialog = g_object_get_data(G_OBJECT(w), "pdialog");
672 GtkWidget *p, *label;
673 char buf[1024];
674
675 switch (GPOINTER_TO_UINT(data)) {
676 case INFO_SIZE:
677 fc_snprintf(buf, sizeof(buf), _("Population: %d, Specialists: %d"),
678 pdialog->pcity->size, city_specialists(pdialog->pcity));
679 break;
680 case INFO_FOOD:
681 get_city_dialog_output_text(pdialog->pcity, O_FOOD, buf, sizeof(buf));
682 break;
683 case INFO_SHIELD:
685 buf, sizeof(buf));
686 break;
687 case INFO_TRADE:
688 get_city_dialog_output_text(pdialog->pcity, O_TRADE, buf, sizeof(buf));
689 break;
690 case INFO_GOLD:
691 get_city_dialog_output_text(pdialog->pcity, O_GOLD, buf, sizeof(buf));
692 break;
693 case INFO_SCIENCE:
695 buf, sizeof(buf));
696 break;
697 case INFO_LUXURY:
699 buf, sizeof(buf));
700 break;
701 case INFO_CULTURE:
702 get_city_dialog_culture_text(pdialog->pcity, buf, sizeof(buf));
703 break;
704 case INFO_POLLUTION:
705 get_city_dialog_pollution_text(pdialog->pcity, buf, sizeof(buf));
706 break;
707 case INFO_ILLNESS:
708 get_city_dialog_illness_text(pdialog->pcity, buf, sizeof(buf));
709 break;
710 case INFO_AIRLIFT:
711 get_city_dialog_airlift_text(pdialog->pcity, buf, sizeof(buf));
712 break;
713 default:
714 return TRUE;
715 }
716
717 p = gtk_popover_new();
718
720
721 label = gtk_label_new(buf);
722 gtk_widget_set_name(label, "city_label");
727
729
731
732 return TRUE;
733}
734
735/***********************************************************************/
741{
742 int i;
743 GtkWidget *table, *label;
744
745 static const char *output_label[NUM_INFO_FIELDS] = {
746 N_("Size:"),
747 N_("Food:"),
748 N_("Prod:"),
749 N_("Trade:"),
750 N_("Gold:"),
751 N_("Luxury:"),
752 N_("Science:"),
753 N_("Granary:"),
754 N_("Change in:"),
755 N_("Corruption:"),
756 N_("Waste:"),
757 N_("Culture:"),
758 N_("Pollution:"),
759 N_("Plague risk:"),
760 N_("Tech Stolen:"),
761 N_("Airlift:"),
762 };
763 static bool output_label_done;
765
771
773
774 for (i = 0; i < NUM_INFO_FIELDS; i++) {
775 label = gtk_label_new(output_label[i]);
776 switch (i) {
777 case INFO_SIZE:
778 case INFO_TRADE:
779 case INFO_SCIENCE:
780 case INFO_GROWTH:
782 break;
783
784 case INFO_FOOD:
785 case INFO_GOLD:
786 case INFO_GRANARY:
787 case INFO_CORRUPTION:
789 break;
790 default:
791 break;
792 }
794 gtk_widget_set_name(label, "city_label"); /* for font style? */
797 gtk_grid_attach(GTK_GRID(table), label, 0, i, 1, 1);
798
799 label = gtk_label_new("");
800 switch (i) {
801 case INFO_TRADE:
802 case INFO_SCIENCE:
803 case INFO_GROWTH:
805 break;
806
807 case INFO_GOLD:
808 case INFO_GRANARY:
809 case INFO_CORRUPTION:
811 break;
812 default:
813 break;
814 }
815
816 g_object_set_data(G_OBJECT(label), "pdialog", pdialog);
817
819 g_signal_connect(controller, "pressed",
822
823 info_label[i] = label;
824 gtk_widget_set_name(label, "city_label"); /* ditto */
827
828 gtk_grid_attach(GTK_GRID(table), label, 1, i, 1, 1);
829 }
830
831 /*
832 * Allow special highlighting of emergencies for granary etc by
833 * city_dialog_update_information().
834 */
835 {
836 /* This will persist, and can be shared between overview and happiness
837 * pages. */
839
840 if (emergency_provider == NULL) {
842
844 ".emergency {\n"
845 " color: rgba(255, 0.0, 0.0, 255);\n"
846 "}",
847 -1);
848
853 }
854 }
855
857
858 return table;
859}
860
861/***********************************************************************/
866static void create_citydlg_main_map(struct city_dialog *pdialog,
867 GtkWidget *grid, int col, int row)
868{
869 GtkWidget *frame;
870
871 frame = gtk_frame_new(_("City map"));
874 gtk_grid_attach(GTK_GRID(grid), frame, col, row, 1, 1);
875
876 city_dialog_map_create(pdialog, &pdialog->overview.map_canvas);
878}
879
880/***********************************************************************/
884{
886 GtkListStore *store;
888
889 /* improvements */
890 /* gtk list store columns: 0 - sell value, 1 - sprite,
891 2 - description, 3 - upkeep, 4 - is redundant, 5 - tooltip */
895
899 g_object_unref(store);
901 gtk_widget_set_name(view, "small_font");
902 pdialog->overview.improvement_list = view;
903
906 rend, "pixbuf", 1, NULL);
909 rend, "text", 2,
910 "strikethrough", 4, NULL);
912 g_object_set(rend, "xalign", 1.0, NULL);
914 rend, "text", 3,
915 "strikethrough", 4, NULL);
916
918
920 pdialog);
921
922 return view;
923}
924
925/***********************************************************************/
942{
944 GtkWidget *right, *frame, *table;
945 GtkWidget *label, *sw, *view, *bar, *production_combo;
948 /* TRANS: Overview tab in city dialog */
949 const char *tab_title = _("_Overview");
951 int page_row = 0;
952
953 /* Main page */
954 page = gtk_grid_new();
963
964 if (!low_citydlg) {
965 GtkWidget *middle;
966 GtkWidget *vbox;
968 int middle_col = 0;
969
970 /* Middle: city map, improvements */
971 middle = gtk_grid_new();
973 gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1);
974
975 /* City map */
976 create_citydlg_main_map(pdialog, middle, middle_col++, 0);
977
978 /* Improvements */
980 gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1);
981
983
984 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
985 "xalign", 0.0, "yalign", 0.5, NULL);
986 gtk_box_append(GTK_BOX(vbox), label);
987
990
994
995 bar = gtk_progress_bar_new();
997 pdialog->overview.production_bar = bar;
999
1000 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1001
1010
1015 rend, "pixbuf", 0, NULL);
1016 g_object_set(rend, "xalign", 0.0, NULL);
1017
1021 rend, "text", 1, "strikethrough", 3, NULL);
1022
1023 pdialog->overview.buy_command
1024 = icon_label_button_new("system-run", _("_Buy"));
1026 g_signal_connect(pdialog->overview.buy_command, "clicked",
1027 G_CALLBACK(buy_callback), pdialog);
1028
1029 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1030 "mnemonic-widget", view,
1031 "label", _("I_mprovements:"),
1032 "xalign", 0.0, "yalign", 0.5, NULL);
1033 gtk_box_append(GTK_BOX(vbox), label);
1034
1039 gtk_box_append(GTK_BOX(vbox), sw);
1040
1042 } else {
1043 pdialog->overview.buy_command = NULL;
1044 pdialog->overview.production_bar = NULL;
1045 pdialog->overview.production_combo = NULL;
1047 }
1048
1049 /* Bottom: info, units */
1052
1053 /* Info */
1054 frame = gtk_frame_new(_("Info"));
1055 gtk_box_append(GTK_BOX(bottom), frame);
1056
1057 table = create_city_info_table(pdialog,
1058 pdialog->overview.info_label);
1062
1063 /* Right: present and supported units (overview page) */
1065 gtk_box_append(GTK_BOX(bottom), right);
1066
1071
1072 /* Supported units */
1079 sw);
1080
1081
1085
1088
1089 /* Present units */
1096
1100
1103
1104 /* Show page */
1106}
1107
1108/***********************************************************************/
1111static void create_and_append_map_page(struct city_dialog *pdialog)
1112{
1113 if (low_citydlg) {
1114 GtkWidget *page;
1115 GtkWidget *label;
1116 const char *tab_title = _("Citymap");
1117 int page_row = 0;
1118
1119 page = gtk_grid_new();
1128
1129 create_citydlg_main_map(pdialog, page, 0, page_row++);
1130
1132 }
1133}
1134
1135/***********************************************************************/
1139 const GValue *value,
1140 double x, double y, gpointer data)
1141{
1142 struct city_dialog *pdialog = (struct city_dialog *) data;
1143 cid id;
1144 struct universal univ;
1145
1146 if (NULL != client.conn.playing
1147 && city_owner(pdialog->pcity) != client.conn.playing) {
1148 return FALSE;
1149 }
1150
1151 id = g_value_get_int(value);
1152 univ = cid_production(id);
1153
1154 city_change_production(pdialog->pcity, &univ);
1155
1156 return TRUE;
1157}
1158
1159/***********************************************************************/
1163static int create_production_header(struct city_dialog *pdialog,
1164 GtkWidget *grid, int row)
1165{
1166 GtkWidget *hgrid, *bar;
1167 int grid_col = 0;
1168
1169 hgrid = gtk_grid_new();
1175 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1176
1177 /* The label is set in city_dialog_update_building() */
1178 bar = gtk_progress_bar_new();
1181 pdialog->production.production_bar = bar;
1182 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1183 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1184
1186
1187 pdialog->production.buy_command
1188 = icon_label_button_new("system-run", _("_Buy"));
1190 grid_col++, 0, 1, 1);
1191
1192 g_signal_connect(pdialog->production.buy_command, "clicked",
1193 G_CALLBACK(buy_callback), pdialog);
1194
1195 return row;
1196}
1197
1198/***********************************************************************/
1202{
1203 if (low_citydlg) {
1204 GtkWidget *page;
1205 GtkWidget *label;
1206 GtkWidget *vbox;
1207 GtkWidget *view;
1208 const char *tab_title = _("Buildings");
1209 int page_row = 0;
1210
1211 page = gtk_grid_new();
1219
1220 page_row = create_production_header(pdialog, page, page_row);
1221 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1222
1224 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1225
1227
1228 gtk_box_append(GTK_BOX(vbox), view);
1229
1231 }
1232}
1233
1234/***********************************************************************/
1238{
1239 const char *tab_title = _("P_roduction");
1241 GtkWidget *page, *editor;
1242 int page_row = 0;
1243
1244 page = gtk_grid_new();
1251 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1252
1253 /* Stuff that's being currently built */
1254 if (!low_citydlg) {
1256 "label", _("Production:"),
1257 "xalign", 0.0, "yalign", 0.5, NULL);
1258 pdialog->production.production_label = label;
1259 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1260
1261 page_row = create_production_header(pdialog, page, page_row);
1262 } else {
1263 pdialog->production.production_label = NULL;
1264 }
1265
1271 reset_city_worklist(editor, pdialog->pcity);
1272 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1273 pdialog->production.worklist = editor;
1274
1276}
1277
1278/***********************************************************************/
1289{
1290 GtkWidget *page, *label, *table, *right, *left, *frame;
1291 const char *tab_title = _("Happ_iness");
1292 int page_col = 0;
1293 int left_row = 0;
1294
1295 /* Main page */
1296 page = gtk_grid_new();
1303 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1304
1305 /* Left: info, citizens */
1306 left = gtk_grid_new();
1309 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1310
1311 if (!low_citydlg) {
1312 /* Upper left: info */
1313 frame = gtk_frame_new(_("Info"));
1314 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1315
1316 table = create_city_info_table(pdialog,
1317 pdialog->happiness.info_label);
1320 }
1321
1322 /* Lower left: citizens */
1326 0, left_row++, 1, 1);
1328 citizens_dialog_display(pdialog->pcity));
1329 }
1330
1331 /* Right: city map, happiness */
1333 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1334
1335 if (!low_citydlg) {
1336 /* Upper right: city map */
1337 frame = gtk_frame_new(_("City map"));
1340 gtk_box_append(GTK_BOX(right), frame);
1341
1342 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1344 }
1345
1346 /* Lower right: happiness */
1348 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1351 pdialog->shell));
1352
1353 /* Show page */
1355}
1356
1357/***********************************************************************/
1360static void create_and_append_cma_page(struct city_dialog *pdialog)
1361{
1362 GtkWidget *page, *label;
1363 const char *tab_title = _("_Governor");
1364
1366
1368
1369 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1370
1371 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1372 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1373
1375}
1376
1377/**********************************************************************/
1380/**********************************************************************/
1385{
1387 GtkLabel *label = GTK_LABEL(gtk_label_new(_("Counters")));
1388
1389 pdialog->counters.container = NULL;
1390 pdialog->counters.widget = NULL;
1391
1393
1395
1397
1398 gtk_widget_show(page);
1399}
1400
1401/***********************************************************************/
1405{
1406 int i;
1407 GtkWidget *vgrid, *page, *frame, *label, *button;
1409 GtkWidget *group;
1410 const char *tab_title = _("_Settings");
1411 int grid_row = 0;
1412
1413 static const char *new_citizens_output_label[] = {
1414 N_("Luxury"),
1415 N_("Science"),
1416 N_("Gold")
1417 };
1418
1419 static const char *disband_label
1420 = N_("Allow unit production to disband city");
1421
1422 static const char *misc_whichtab_label[NUM_PAGES] = {
1423 N_("Overview page"),
1424 N_("Production page"),
1425 N_("Happiness page"),
1426 N_("Counters Page"),
1427 N_("Governor page"),
1428 N_("This Settings page"),
1429 N_("Last active page")
1430 };
1431
1432 static bool new_citizens_label_done;
1433 static bool misc_whichtab_label_done;
1434
1435 /* Initialize signal_blocker */
1436 pdialog->misc.block_signal = 0;
1437
1438
1439 page = gtk_grid_new();
1445
1447
1449
1450 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1451
1452 /* new_citizens radio */
1453 frame = gtk_frame_new(_("New citizens produce"));
1454 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1456
1457 vgrid = gtk_grid_new();
1461
1464
1465 group = NULL;
1466 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1469 GTK_CHECK_BUTTON(group));
1470 pdialog->misc.new_citizens_radio[i] = button;
1471 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1472 g_signal_connect(button, "toggled",
1473 G_CALLBACK(cityopt_callback), pdialog);
1474 group = button;
1475 }
1476
1477 /* Next is the next-time-open radio group in the right column */
1478 frame = gtk_frame_new(_("Next time open"));
1479 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1481
1482 vgrid = gtk_grid_new();
1483 grid_row = 0;
1487
1490
1491 group = NULL;
1492 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1495 GTK_CHECK_BUTTON(group));
1496 pdialog->misc.whichtab_radio[i] = button;
1497 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1498 g_signal_connect(button, "toggled",
1500 group = button;
1501 }
1502
1503 /* Now we go back and fill the hbox rename */
1504 frame = gtk_frame_new(_("City"));
1505 gtk_widget_set_margin_top(frame, 12);
1507 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1508
1509 vgrid = gtk_grid_new();
1510 grid_row = 0;
1514
1515 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1516 pdialog->misc.rename_command = button;
1517 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1518 g_signal_connect(button, "clicked",
1519 G_CALLBACK(rename_callback), pdialog);
1520
1522
1523 /* The disband-city-on-unit-production button */
1525 pdialog->misc.disband_on_settler = button;
1526 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1527 g_signal_connect(button, "toggled",
1528 G_CALLBACK(cityopt_callback), pdialog);
1529
1530 /* We choose which page to popup by default */
1532 (pdialog->
1534 TRUE);
1535
1536 set_cityopt_values(pdialog);
1537
1539
1540 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1542 last_page);
1543 } else {
1546 }
1547}
1548
1549/***********************************************************************/
1558{
1559 struct city_dialog *pdialog;
1561 GtkWidget *vbox, *hbox, *cbox;
1564 int ccol = 0;
1566 struct player *owner;
1567
1570 }
1571
1572 pdialog = fc_malloc(sizeof(struct city_dialog));
1573 pdialog->pcity = pcity;
1574 pdialog->sell_shell = NULL;
1575 pdialog->rename_shell = NULL;
1576 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1577 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1578 pdialog->happiness.citizens = NULL; /* Ditto */
1579 pdialog->counters.widget = NULL;
1580 pdialog->counters.container = NULL;
1581 pdialog->production.buy_command = NULL;
1582 pdialog->production.production_label = NULL;
1583 pdialog->production.production_bar = NULL;
1584 pdialog->cma_editor = NULL;
1588
1589 pdialog->shell = gtk_dialog_new();
1591 setup_dialog(pdialog->shell, toplevel);
1592
1593 g_signal_connect(pdialog->shell, "destroy",
1595 gtk_widget_set_name(pdialog->shell, "Freeciv");
1596
1597 gtk_widget_realize(pdialog->shell);
1598
1599 /* Keep the icon of the executable on Windows (see PR#36491) */
1600#ifndef FREECIV_MSWINDOWS
1601 {
1602 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1603 }
1604#endif /* FREECIV_MSWINDOWS */
1605
1606 /* Restore size of the city dialog. */
1610
1611 pdialog->popover = NULL;
1612
1616 gtk_box_append(GTK_BOX(vbox), hbox);
1617
1618 /**** Citizens bar here ****/
1619 cbox = gtk_grid_new();
1620 gtk_box_append(GTK_BOX(hbox), cbox);
1621
1624
1628 pdialog->citizen_pics = gtk_picture_new();
1629
1638 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1639
1641 g_signal_connect(controller, "pressed",
1642 G_CALLBACK(citizens_callback), pdialog);
1644
1645 /**** City name label here ****/
1646 pdialog->name_label = gtk_label_new(NULL);
1651
1652 /**** -Start of Notebook- ****/
1653
1654 pdialog->notebook = gtk_notebook_new();
1657 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1658
1662
1663 owner = city_owner(pcity);
1664
1665 /* Only create these tabs if not a spy */
1669 }
1670
1672
1673 if (owner == client_player()
1674 && !client_is_observer()) {
1677 } else {
1680 }
1681
1682 /**** End of Notebook ****/
1683
1684 /* Bottom buttons */
1685
1686 pdialog->show_units_command =
1687 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1688
1689 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1691
1692 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1694 GTK_WIDGET(pdialog->prev_command), 1);
1695
1696 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1698 GTK_WIDGET(pdialog->next_command), 2);
1699
1700 if (owner != client_player()) {
1703 }
1704
1706 _("_Close"), GTK_RESPONSE_CLOSE);
1707
1710
1712 G_CALLBACK(close_callback), pdialog);
1713
1714 g_signal_connect(pdialog->prev_command, "clicked",
1716
1717 g_signal_connect(pdialog->next_command, "clicked",
1719
1720 /* Some other things we gotta do */
1721
1723 g_signal_connect(controller, "key-pressed",
1726
1728
1730
1731 /* Need to do this every time a new dialog is opened. */
1733
1735
1737
1738 return pdialog;
1739}
1740
1741/**************** Functions to update parts of the dialog *****************/
1742
1743/**********************************************************************/
1746static void city_dialog_update_counters(struct city_dialog *pdialog)
1747{
1752 char int_val[101];
1753 char *text;
1754 int text_size;
1755
1756 if (NULL != pdialog->counters.widget) {
1758 GTK_WIDGET(pdialog->counters.widget));
1759 }
1760
1761 if (NULL == pdialog->counters.container) {
1763 }
1764
1768
1772 counterValue = GTK_LABEL(gtk_label_new(_("Current value is: ")));
1774 fc_snprintf(int_val, sizeof(int_val), "%d", pdialog->pcity->counter_values[counter_index(pcount)]);
1778
1780 counterValue = GTK_LABEL(gtk_label_new(_("Activated once value equal or higher than: ")));
1782 fc_snprintf(int_val, sizeof(int_val), "%d", pcount->checkpoint);
1786
1787 text_size = 0;
1788 if (NULL != pcount->helptext) {
1789 strvec_iterate(pcount->helptext, text_) {
1792 }
1793 if (0 < text_size) {
1794 text = malloc(text_size+1);
1795 text_size = 0;
1796 strvec_iterate(pcount->helptext, text_) {
1797 strcpy(&text[text_size], text_);
1801 free(text);
1803 }
1806
1809}
1810
1811/***********************************************************************/
1814static void city_dialog_update_title(struct city_dialog *pdialog)
1815{
1816 gchar *buf;
1817 const gchar *now;
1818
1819 if (city_unhappy(pdialog->pcity)) {
1820 /* TRANS: city dialog title */
1821 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
1822 city_name_get(pdialog->pcity),
1824 } else if (city_celebrating(pdialog->pcity)) {
1825 /* TRANS: city dialog title */
1826 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
1827 city_name_get(pdialog->pcity),
1829 } else if (city_happy(pdialog->pcity)) {
1830 /* TRANS: city dialog title */
1831 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
1832 city_name_get(pdialog->pcity),
1834 } else {
1835 /* TRANS: city dialog title */
1836 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
1837 city_name_get(pdialog->pcity),
1839 }
1840
1842 if (strcmp(now, buf) != 0) {
1845 }
1846
1847 g_free(buf);
1848}
1849
1850/***********************************************************************/
1853static void city_dialog_update_citizens(struct city_dialog *pdialog)
1854{
1855 enum citizen_category categories[MAX_CITY_SIZE];
1858 struct city *pcity = pdialog->pcity;
1859 int num_citizens = get_city_citizen_types(pcity, FEELING_FINAL, categories);
1860 cairo_t *cr;
1861
1862 /* If there is not enough space we stack the icons. We draw from left to */
1863 /* right. width is how far we go to the right for each drawn pixmap. The */
1864 /* last icon is always drawn in full, and so has reserved */
1865 /* tileset_small_sprite_width(tileset) pixels. */
1866
1868 if (num_citizens > 1) {
1870 / (num_citizens - 1));
1871 } else {
1872 width = full_width;
1873 }
1874 pdialog->cwidth = width;
1875
1876 /* overview page */
1877 /* keep these values in sync with create_city_dialog */
1880
1881 cr = cairo_create(pdialog->citizen_surface);
1882
1883 for (i = 0; i < num_citizens; i++) {
1885 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
1886 i * width, 0);
1887 cairo_rectangle(cr, i * width, 0,
1888 /* Always draw last citizen in full */
1889 i + 1 < num_citizens ? width : full_width,
1891 cairo_fill(cr);
1892 }
1893
1894 total_used_width = (i - 1) * width + full_width;
1895
1897 /* Clear the rest of the area.
1898 * Note that this might still be necessary even in cases where
1899 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
1900 * divided perfectly. */
1905 cairo_fill(cr);
1906 }
1907
1908 cairo_destroy(cr);
1909
1911 pdialog->citizen_surface);
1912
1914}
1915
1916/***********************************************************************/
1920 struct city_dialog *pdialog)
1921{
1922 int i, illness = 0;
1923 char buf[NUM_INFO_FIELDS][512];
1924 struct city *pcity = pdialog->pcity;
1925 int granaryturns;
1926 int non_workers = city_specialists(pcity);
1927
1928 /* fill the buffers with the necessary info */
1929 if (non_workers) {
1930 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
1931 pcity->size, non_workers);
1932 } else {
1933 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
1934 }
1935 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
1936 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
1937 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
1938 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
1939 pcity->surplus[O_SHIELD]);
1940 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
1941 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
1942 pcity->surplus[O_TRADE]);
1943 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
1944 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
1945 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
1946 pcity->prod[O_LUXURY]);
1947 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
1948 pcity->prod[O_SCIENCE]);
1949 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
1951
1953 if (granaryturns == 0) {
1954 /* TRANS: city growth is blocked. Keep short. */
1955 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
1956 } else if (granaryturns == FC_INFINITY) {
1957 /* TRANS: city is not growing. Keep short. */
1958 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
1959 } else {
1960 /* A negative value means we'll have famine in that many turns.
1961 But that's handled down below. */
1962 /* TRANS: city growth turns. Keep short. */
1964 PL_("%d turn", "%d turns", abs(granaryturns)),
1965 abs(granaryturns));
1966 }
1968 pcity->waste[O_TRADE]);
1969 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
1970 pcity->waste[O_SHIELD]);
1971 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
1972 pcity->client.culture);
1974 pcity->pollution);
1975 if (!game.info.illness_on) {
1976 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
1977 } else {
1979 /* illness is in tenth of percent */
1980 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
1981 (float)illness / 10.0);
1982 }
1983 if (pcity->steal) {
1984 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
1985 pcity->steal);
1986 } else {
1987 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
1988 }
1989
1991
1992 /* stick 'em in the labels */
1993 for (i = 0; i < NUM_INFO_FIELDS; i++) {
1995 }
1996
1997 /*
1998 * Make use of the emergency-indicating styles set up for certain labels
1999 * in create_city_info_table().
2000 */
2001 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
2002 * of a warning. */
2003 if (granaryturns > -4 && granaryturns < 0) {
2005 } else {
2007 }
2008
2009 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
2011 } else {
2013 }
2014
2015 /* Someone could add the color &orange for better granularity here */
2016 if (pcity->pollution >= 10) {
2018 } else {
2020 }
2021
2022 /* Illness is in tenth of percent, i.e 100 == 10.0% */
2023 if (illness >= 100) {
2025 } else {
2027 }
2028}
2029
2030/***********************************************************************/
2033static void city_dialog_update_map(struct city_dialog *pdialog)
2034{
2035 struct canvas store = FC_STATIC_CANVAS_INIT;
2036
2037 store.surface = pdialog->map_canvas_store_unscaled;
2038
2039 /* The drawing is done in three steps.
2040 * 1. First we render to a pixmap with the appropriate canvas size.
2041 * 2. Then the pixmap is rendered into a pixbuf of equal size.
2042 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
2043 * target pixbuf.
2044 */
2045
2046 city_dialog_redraw_map(pdialog->pcity, &store);
2047
2048 /* draw to real window */
2049 draw_map_canvas(pdialog);
2050}
2051
2052/***********************************************************************/
2055static void city_dialog_update_building(struct city_dialog *pdialog)
2056{
2057 char buf[32], buf2[200];
2058 gdouble pct;
2059 GtkListStore *store;
2061 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2062 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2063 int targets_used, item;
2064 struct city *pcity = pdialog->pcity;
2066 const char *descr = city_production_name_translation(pcity);
2068
2069 if (pdialog->overview.buy_command != NULL) {
2071 }
2072 if (pdialog->production.buy_command != NULL) {
2074 }
2075
2076 /* Make sure build slots info is up to date */
2077 if (pdialog->production.production_label != NULL) {
2078 int build_slots = city_build_slots(pcity);
2079
2080 /* Only display extra info if more than one slot is available */
2081 if (build_slots > 1) {
2082 fc_snprintf(buf2, sizeof(buf2),
2083 /* TRANS: never actually used with built_slots <= 1 */
2084 PL_("Production (up to %d unit per turn):",
2085 "Production (up to %d units per turn):", build_slots),
2086 build_slots);
2089 } else {
2091 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2092 }
2093 }
2094
2095 /* Update what the city is working on */
2096 get_city_dialog_production(pcity, buf, sizeof(buf));
2097
2098 if (cost > 0) {
2099 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2100 pct = CLAMP(pct, 0.0, 1.0);
2101 } else {
2102 pct = 1.0;
2103 }
2104
2105 if (pdialog->overview.production_bar != NULL) {
2106 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2107 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2112 }
2113
2114 if (pdialog->production.production_bar != NULL) {
2115 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2116 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2121 }
2122
2123 store = pdialog->overview.change_production_store;
2124 if (store != NULL) {
2125 int cur = -1;
2126 int actcount = 0;
2127
2128 if (pdialog->overview.production_combo != NULL) {
2130 -1);
2131 }
2132
2133 gtk_list_store_clear(store);
2134
2136 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2137 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2138
2139 for (item = 0; item < targets_used; item++) {
2140 if (can_city_build_now(&(wld.map), pcity, &items[item].item)) {
2141 const char *name;
2142 struct sprite *sprite;
2143 GdkPixbuf *pix;
2144 struct universal *target = &items[item].item;
2145 bool useless;
2146
2147 if (VUT_UTYPE == target->kind) {
2151 useless = FALSE;
2152 } else {
2156 }
2158 gtk_list_store_append(store, &iter);
2159 gtk_list_store_set(store, &iter, 0, pix,
2160 1, name, 3, useless,
2161 2, (gint)cid_encode(items[item].item), -1);
2163
2164 if (are_universals_equal(target, &pcity->production)) {
2165 cur = actcount;
2166 }
2167
2168 actcount++;
2169 }
2170 }
2171
2172 if (pdialog->overview.production_combo != NULL) {
2174 cur);
2175 }
2176 }
2177}
2178
2179/***********************************************************************/
2183{
2184 int item, targets_used;
2185 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2186 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2187 GtkTreeModel *model;
2188 GtkListStore *store;
2189
2190 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2191 "sell an improvement.");
2192 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2193 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2194
2195 model =
2197 store = GTK_LIST_STORE(model);
2198
2200 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2201
2202 gtk_list_store_clear(store);
2203
2204 for (item = 0; item < targets_used; item++) {
2205 GdkPixbuf *pix;
2206 GtkTreeIter it;
2207 int upkeep;
2208 struct sprite *sprite;
2209 struct universal target = items[item].item;
2210
2211 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2212 /* This takes effects (like Adam Smith's) into account. */
2213 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2215
2217 gtk_list_store_append(store, &it);
2218 gtk_list_store_set(store, &it,
2219 0, target.value.building,
2220 1, pix,
2221 2, items[item].descr,
2222 3, upkeep,
2223 4,
2225 target.value.building),
2226 5,
2229 (is_small_wonder(target.value.building) ?
2231 -1);
2233 }
2234}
2235
2236/***********************************************************************/
2240{
2241 struct unit_list *units;
2242 struct unit_node_vector *nodes;
2243 int n, m, i;
2244 gchar *buf;
2246 const struct civ_map *nmap = &(wld.map);
2247
2248 if (NULL != client.conn.playing
2249 && city_owner(pdialog->pcity) != client.conn.playing) {
2250 units = pdialog->pcity->client.info_units_supported;
2251 } else {
2252 units = pdialog->pcity->units_supported;
2253 }
2254
2255 nodes = &pdialog->overview.supported_units;
2256
2257 n = unit_list_size(units);
2258 m = unit_node_vector_size(nodes);
2259
2260 if (m > n) {
2261 i = 0;
2263 if (i++ >= n) {
2265 elt->cmd);
2266 }
2268
2270 } else {
2271 for (i = m; i < n; i++) {
2272 GtkWidget *cmd, *pix;
2273 struct unit_node node;
2274
2275 cmd = gtk_button_new();
2276 node.cmd = cmd;
2277
2279
2280 pix = gtk_picture_new();
2281 node.pix = pix;
2283
2285
2287 cmd);
2288
2289 node.left = NULL;
2290 node.middle = NULL;
2291 node.right = NULL;
2292
2293 unit_node_vector_append(nodes, node);
2294 }
2295 }
2296
2297 i = 0;
2298 unit_list_iterate(units, punit) {
2299 struct unit_node *pnode;
2300 int happy_cost = city_unit_unhappiness(nmap, punit, &free_unhappy);
2301
2302 pnode = unit_node_vector_get(nodes, i);
2303 if (pnode) {
2304 GtkWidget *cmd, *pix;
2307
2308 cmd = pnode->cmd;
2309 pix = pnode->pix;
2310
2312 punit->upkeep, happy_cost);
2313
2314 if (pnode->left != NULL) {
2318 }
2319
2321
2323 g_signal_connect(controller, "pressed",
2327 pnode->left = controller;
2331 g_signal_connect(controller, "released",
2335 pnode->middle = controller;
2339 g_signal_connect(controller, "released",
2343 pnode->right = controller;
2344
2345 if (city_owner(pdialog->pcity) != client.conn.playing) {
2347 } else {
2349 }
2350
2353 }
2354 i++;
2356
2357 buf = g_strdup_printf(_("Supported units %d"), n);
2359 g_free(buf);
2360}
2361
2362/***********************************************************************/
2366{
2367 struct unit_list *units;
2368 struct unit_node_vector *nodes;
2369 int n, m, i;
2370 gchar *buf;
2371
2372 if (NULL != client.conn.playing
2373 && city_owner(pdialog->pcity) != client.conn.playing) {
2374 units = pdialog->pcity->client.info_units_present;
2375 } else {
2376 units = pdialog->pcity->tile->units;
2377 }
2378
2379 nodes = &pdialog->overview.present_units;
2380
2381 n = unit_list_size(units);
2382 m = unit_node_vector_size(nodes);
2383
2384 if (m > n) {
2385 i = 0;
2387 if (i++ >= n) {
2389 elt->cmd);
2390 }
2392
2394 } else {
2395 for (i = m; i < n; i++) {
2396 GtkWidget *cmd, *pix;
2397 struct unit_node node;
2398
2399 cmd = gtk_button_new();
2400 node.cmd = cmd;
2401
2403
2404 pix = gtk_picture_new();
2405 node.pix = pix;
2407
2409
2411 cmd);
2412
2413 node.left = NULL;
2414 node.middle = NULL;
2415 node.right = NULL;
2416
2417 unit_node_vector_append(nodes, node);
2418 }
2419 }
2420
2421 i = 0;
2422 unit_list_iterate(units, punit) {
2423 struct unit_node *pnode;
2424
2425 pnode = unit_node_vector_get(nodes, i);
2426 if (pnode) {
2427 GtkWidget *cmd, *pix;
2430
2431 cmd = pnode->cmd;
2432 pix = pnode->pix;
2433
2435
2436 if (pnode->left != NULL) {
2440 }
2441
2443
2445 g_signal_connect(controller, "pressed",
2449 pnode->left = controller;
2453 g_signal_connect(controller, "released",
2457 pnode->middle = controller;
2461 g_signal_connect(controller, "released",
2465 pnode->right = controller;
2466
2467 if (city_owner(pdialog->pcity) != client.conn.playing) {
2469 } else {
2471 }
2472
2475 }
2476 i++;
2478
2479 buf = g_strdup_printf(_("Present units %d"), n);
2481 g_free(buf);
2482}
2483
2484/***********************************************************************/
2492{
2493 int count = 0;
2494 int city_number;
2495
2496 if (NULL != client.conn.playing) {
2498 } else {
2499 city_number = FC_INFINITY; /* ? */
2500 }
2501
2502 /* The first time, we see if all the city dialogs are open */
2504 if (city_owner(pdialog->pcity) == client.conn.playing) {
2505 count++;
2506 }
2508
2509 if (count == city_number) { /* All are open, shouldn't prev/next */
2511 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2512 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2514 } else {
2516 if (city_owner(pdialog->pcity) == client.conn.playing) {
2517 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2518 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2519 }
2521 }
2522}
2523
2524/***********************************************************************/
2527static void citydlg_response_callback(GtkDialog *dlg, gint response,
2528 void *data)
2529{
2530 switch (response) {
2531 case CDLGR_UNITS:
2532 show_units_response(data);
2533 break;
2534 }
2535}
2536
2537/***********************************************************************/
2540static void show_units_response(void *data)
2541{
2542 struct city_dialog *pdialog = (struct city_dialog *) data;
2543 struct tile *ptile = pdialog->pcity->tile;
2544
2545 if (unit_list_size(ptile->units)) {
2547 }
2548}
2549
2550/***********************************************************************/
2560static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2561 GtkWidget *wdg, bool supported)
2562{
2563 GMenu *menu;
2564 GActionGroup *group;
2565 GSimpleAction *act;
2566
2567 if (!can_client_issue_orders()) {
2568 return FALSE;
2569 }
2570
2571 if (pdialog->popover != NULL) {
2573 }
2574
2576 menu = g_menu_new();
2577
2578 if (supported) {
2579 act = g_simple_action_new("center", NULL);
2580 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2584 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2585 }
2586
2587 act = g_simple_action_new("activate", NULL);
2588 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2592 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2593 "win.activate"));
2594
2595 act = g_simple_action_new("activate_close", NULL);
2596 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2598
2599 if (supported) {
2600 g_signal_connect(act, "activate",
2603 } else {
2604 g_signal_connect(act, "activate",
2607 }
2608
2610 g_menu_item_new(_("Activate unit, _close dialog"),
2611 "win.activate_close"));
2612
2613 if (!supported) {
2614 act = g_simple_action_new("load", NULL);
2615 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2620 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2621
2622 act = g_simple_action_new("unload", NULL);
2623 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2631 unit_tile(punit)));
2632 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2633 "win.unload"));
2634
2635 act = g_simple_action_new("sentry", NULL);
2636 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2644 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2645 "win.sentry"));
2646
2647 act = g_simple_action_new("fortify", NULL);
2648 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2656 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2657 "win.fortify"));
2658 }
2659
2660 act = g_simple_action_new("disband", NULL);
2661 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2667 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2668 "win.disband"));
2669
2670 if (!supported) {
2671 act = g_simple_action_new("rehome", NULL);
2672 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2678 pdialog->pcity));
2681 "win.rehome"));
2682
2683 act = g_simple_action_new("upgrade", NULL);
2684 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2693 != NULL);
2694 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
2695 "win.upgrade"));
2696 }
2697
2699 g_object_ref(pdialog->popover);
2700 gtk_widget_insert_action_group(pdialog->popover, "win", group);
2702
2703
2705
2706 return TRUE;
2707}
2708
2709/***********************************************************************/
2713 double x, double y, gpointer data)
2714{
2715 struct city_dialog *pdialog;
2716 struct city *pcity;
2717 struct unit *punit =
2718 player_unit_by_number(client_player(), (size_t) data);
2719
2720 if (NULL != punit
2721 && NULL != (pcity = game_city_by_number(punit->homecity))
2722 && NULL != (pdialog = get_city_dialog(pcity))) {
2723
2724 return create_unit_menu(pdialog, punit,
2726 TRUE);
2727 }
2728
2729 return TRUE;
2730}
2731
2732/***********************************************************************/
2736 double x, double y, gpointer data)
2737{
2738 struct city_dialog *pdialog;
2739 struct city *pcity;
2740 struct unit *punit =
2741 player_unit_by_number(client_player(), (size_t) data);
2742
2743 if (NULL != punit
2744 && NULL != (pcity = tile_city(unit_tile(punit)))
2745 && NULL != (pdialog = get_city_dialog(pcity))) {
2746
2747 return create_unit_menu(pdialog, punit,
2749 FALSE);
2750 }
2751
2752 return TRUE;
2753}
2754
2755/***********************************************************************/
2760 int n_press, double x, double y,
2761 gpointer data)
2762{
2763 struct city_dialog *pdialog;
2764 struct city *pcity;
2765 struct unit *punit =
2766 player_unit_by_number(client_player(), (size_t) data);
2767
2768 if (NULL != punit
2769 && NULL != (pcity = tile_city(unit_tile(punit)))
2770 && NULL != (pdialog = get_city_dialog(pcity))
2773 close_city_dialog(pdialog);
2774 }
2775
2776 return TRUE;
2777}
2778
2779/***********************************************************************/
2784 double x, double y, gpointer data)
2785{
2786 struct city_dialog *pdialog;
2787 struct city *pcity;
2788 struct unit *punit =
2789 player_unit_by_number(client_player(), (size_t) data);
2790
2791 if (NULL != punit
2792 && NULL != (pcity = game_city_by_number(punit->homecity))
2793 && NULL != (pdialog = get_city_dialog(pcity))
2796 close_city_dialog(pdialog);
2797 }
2798
2799 return TRUE;
2800}
2801
2802/***********************************************************************/
2806 double x, double y, gpointer data)
2807{
2808 struct unit *punit =
2809 player_unit_by_number(client_player(), (size_t) data);
2810
2811 if (NULL != punit
2814 }
2815
2816 return TRUE;
2817}
2818
2819/***********************************************************************/
2824static void close_citydlg_unit_popover(struct city_dialog *pdialog)
2825{
2826 if (pdialog->popover != NULL) {
2827 gtk_widget_unparent(pdialog->popover);
2828 g_object_unref(pdialog->popover);
2829 pdialog->popover = NULL;
2830 }
2831}
2832
2833/***********************************************************************/
2837 gpointer data)
2838{
2839 struct unit *punit =
2841
2842 if (NULL != punit) {
2844 }
2845
2847}
2848
2849/***********************************************************************/
2853 gpointer data)
2854{
2855 struct unit *punit =
2857
2858 if (NULL != punit) {
2860 }
2861
2863}
2864
2865/***********************************************************************/
2870 GVariant *parameter,
2871 gpointer data)
2872{
2873 struct unit *punit =
2875
2876 if (NULL != punit) {
2877 struct city *pcity =
2879
2881 if (NULL != pcity) {
2882 struct city_dialog *pdialog = get_city_dialog(pcity);
2883
2884 if (NULL != pdialog) {
2885 close_city_dialog(pdialog);
2886 }
2887 }
2888 }
2889
2891}
2892
2893/***********************************************************************/
2898 GVariant *parameter,
2899 gpointer data)
2900{
2901 struct unit *punit =
2903
2904 if (NULL != punit) {
2905 struct city *pcity = tile_city(unit_tile(punit));
2906
2908 if (NULL != pcity) {
2909 struct city_dialog *pdialog = get_city_dialog(pcity);
2910
2911 if (NULL != pdialog) {
2912 close_city_dialog(pdialog);
2913 }
2914 }
2915 }
2916
2918}
2919
2920/***********************************************************************/
2924 gpointer data)
2925{
2926 struct unit *punit =
2928
2929 if (NULL != punit) {
2931 }
2932
2934}
2935
2936/***********************************************************************/
2940 gpointer data)
2941{
2942 struct unit *punit =
2944
2945 if (NULL != punit) {
2947 }
2948
2950}
2951
2952/***********************************************************************/
2956 gpointer data)
2957{
2958 struct unit *punit =
2960
2961 if (NULL != punit) {
2963 }
2964
2966}
2967
2968/***********************************************************************/
2972 gpointer data)
2973{
2974 struct unit *punit =
2976
2977 if (NULL != punit) {
2979 }
2980
2982}
2983
2984/***********************************************************************/
2988 gpointer data)
2989{
2990 struct unit_list *punits;
2991 struct unit *punit =
2993
2994 if (NULL == punit) {
2995 return;
2996 }
2997
3002
3004}
3005
3006/***********************************************************************/
3011 gpointer data)
3012{
3013 struct unit *punit =
3015
3016 if (NULL != punit) {
3018 }
3019
3021}
3022
3023/***********************************************************************/
3027 gpointer data)
3028{
3029 struct unit_list *punits;
3030 struct unit *punit =
3032
3033 if (NULL == punit) {
3034 return;
3035 }
3036
3041
3043}
3044
3045/******** Callbacks for citizen bar, map funcs that are not update ********/
3046
3047/***********************************************************************/
3052 double x, double y, gpointer data)
3053{
3054 struct city_dialog *pdialog = data;
3055 struct city *pcity = pdialog->pcity;
3056 int citnum, tlen, len;
3057
3058 if (!can_client_issue_orders()) {
3059 return FALSE;
3060 }
3061
3063 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
3064
3065 if (x > len) {
3066 /* no citizen that far to the right */
3067 return FALSE;
3068 }
3069 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
3070
3072
3073 return TRUE;
3074}
3075
3076/***********************************************************************/
3080{
3081 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
3082 struct city *pcity = workertask_req.owner;
3083 struct tile *ptile = workertask_req.loc;
3084 struct packet_worker_task task;
3085
3086 task.city_id = pcity->id;
3087
3088 if (act == ACTIVITY_LAST) {
3089 task.tgt = -1;
3090 task.want = 0;
3091 } else {
3092 enum extra_cause cause = activity_to_extra_cause(act);
3094 struct extra_type *tgt;
3095
3096 if (cause != EC_NONE) {
3097 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
3098 } else if (rmcause != ERM_NONE) {
3099 tgt = prev_extra_in_tile(ptile, rmcause, city_owner(pcity), NULL);
3100 } else {
3101 tgt = NULL;
3102 }
3103
3104 if (tgt == NULL) {
3105 struct terrain *pterr = tile_terrain(ptile);
3106
3107 if ((act != ACTIVITY_TRANSFORM
3108 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3109 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3110 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3111 /* No extra to order */
3112 output_window_append(ftc_client, _("There's no suitable extra to order."));
3113
3114 return;
3115 }
3116
3117 task.tgt = -1;
3118 } else {
3119 task.tgt = extra_index(tgt);
3120 }
3121
3122 task.want = 100;
3123 }
3124
3125 task.tile_id = ptile->index;
3126 task.activity = act;
3127
3129}
3130
3131/***********************************************************************/
3138
3139/***********************************************************************/
3142static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3143{
3145 GtkWidget *shl;
3146 struct terrain *pterr = tile_terrain(ptile);
3147 struct universal for_terr = { .kind = VUT_TERRAIN,
3148 .value = { .terrain = pterr }};
3149 struct worker_task *ptask;
3150
3152 workertask_req.owner = pcity;
3153 workertask_req.loc = ptile;
3154
3156 _("What Action to Request"),
3157 _("Select autosettler activity:"));
3158
3160 if (ptask != NULL) {
3161 choice_dialog_add(shl, _("Clear request"),
3164 }
3165
3167 choice_dialog_add(shl, Q_("?act:Mine"),
3170 }
3171 if (pterr->plant_result != NULL
3173 NULL, &for_terr)) {
3174 choice_dialog_add(shl, _("Plant"),
3177 }
3179 choice_dialog_add(shl, _("Irrigate"),
3182 }
3183 if (pterr->cultivate_result != NULL
3185 NULL, &for_terr)) {
3186 choice_dialog_add(shl, _("Cultivate"),
3189 }
3191 choice_dialog_add(shl, _("Road"),
3194 }
3195 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3197 NULL, &for_terr)) {
3198 choice_dialog_add(shl, _("Transform"),
3201 }
3203 city_owner(pcity), NULL) != NULL) {
3204 choice_dialog_add(shl, _("Clean"),
3207 }
3208
3209 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3211
3213 NULL);
3214 }
3215}
3216
3217/***********************************************************************/
3221 double x, double y, gpointer data)
3222{
3223 struct city_dialog *pdialog = data;
3225
3226 if (!can_client_issue_orders()) {
3227 return FALSE;
3228 }
3229
3230 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3231 return FALSE;
3232 }
3233
3236
3238 city_map_radius_sq_get(pdialog->pcity),
3239 canvas_x, canvas_y)) {
3241 }
3242
3243 return TRUE;
3244}
3245
3246/***********************************************************************/
3250 double x, double y, gpointer data)
3251{
3252 struct city_dialog *pdialog = data;
3254
3255 if (!can_client_issue_orders()) {
3256 return FALSE;
3257 }
3258
3261
3263 city_map_radius_sq_get(pdialog->pcity),
3264 canvas_x, canvas_y)) {
3265 struct city *pcity = pdialog->pcity;
3266
3267 popup_workertask_dlg(pdialog->pcity,
3268 city_map_to_tile(&(wld.map), pcity->tile,
3270 city_x, city_y));
3271 }
3272
3273 return TRUE;
3274}
3275
3276/***********************************************************************/
3279static void draw_map_canvas(struct city_dialog *pdialog)
3280{
3282 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3284 }
3285}
3286
3287/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3288
3289/***********************************************************************/
3292static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
3293{
3294 struct city_dialog *pdialog = data;
3295
3296 if (response == GTK_RESPONSE_YES) {
3297 city_buy_production(pdialog->pcity);
3298 }
3299
3301}
3302
3303/***********************************************************************/
3306static void buy_callback(GtkWidget *w, gpointer data)
3307{
3309 struct city_dialog *pdialog = data;
3310 const char *name = city_production_name_translation(pdialog->pcity);
3311 int value = pdialog->pcity->client.buy_cost;
3312 char buf[1024];
3313
3314 if (!can_client_issue_orders()) {
3315 return;
3316 }
3317
3318 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3319 "Treasury contains %d gold.",
3320 client_player()->economic.gold),
3321 client_player()->economic.gold);
3322
3323 if (value <= client_player()->economic.gold) {
3327 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3328 PL_("Buy %s for %d gold?\n%s",
3329 "Buy %s for %d gold?\n%s", value),
3330 name, value, buf);
3331 setup_dialog(shell, pdialog->shell);
3332 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3335 pdialog);
3337 } else {
3341 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3342 PL_("%s costs %d gold.\n%s",
3343 "%s costs %d gold.\n%s", value),
3344 name, value, buf);
3345 setup_dialog(shell, pdialog->shell);
3346 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3348 NULL);
3350 }
3351}
3352
3353/***********************************************************************/
3357 struct city_dialog *pdialog)
3358{
3360
3362 && gtk_combo_box_get_active_iter(combo, &iter)) {
3363 cid id;
3364 struct universal univ;
3365
3366 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 2, &id, -1);
3367 univ = cid_production(id);
3368 city_change_production(pdialog->pcity, &univ);
3369 }
3370}
3371
3372/***********************************************************************/
3375static void sell_callback(struct impr_type *pimprove, gpointer data)
3376{
3377 GtkWidget *shl;
3378 struct city_dialog *pdialog = (struct city_dialog *) data;
3379 pdialog->sell_id = improvement_number(pimprove);
3380 int price;
3381
3382 if (!can_client_issue_orders()) {
3383 return;
3384 }
3385
3387 pimprove) != TR_SUCCESS) {
3388 return;
3389 }
3390
3391 price = impr_sell_gold(pimprove);
3396 PL_("Sell %s for %d gold?",
3397 "Sell %s for %d gold?", price),
3398 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3399 setup_dialog(shl, pdialog->shell);
3400 pdialog->sell_shell = shl;
3401
3402 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3403
3404 g_signal_connect(shl, "response",
3406
3408}
3409
3410/***********************************************************************/
3413static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3414{
3415 struct city_dialog *pdialog = data;
3416
3417 if (response == GTK_RESPONSE_YES) {
3418 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3419 }
3421
3422 pdialog->sell_shell = NULL;
3423}
3424
3425/***********************************************************************/
3430{
3431 GtkTreeModel *model;
3432 GtkTreeIter it;
3433 GdkSeat *seat;
3435 struct impr_type *pimprove;
3436
3438
3439 if (!gtk_tree_model_get_iter(model, &it, path)) {
3440 return;
3441 }
3442
3443 gtk_tree_model_get(model, &it, 0, &pimprove, -1);
3444
3447
3448 if (!(mask & GDK_CONTROL_MASK)) {
3449 sell_callback(pimprove, data);
3450 } else {
3451 if (is_great_wonder(pimprove)) {
3453 } else {
3455 }
3456 }
3457}
3458
3459/************ Callbacks for stuff on the Misc. Settings page **************/
3460
3461/***********************************************************************/
3465{
3466 struct city_dialog *pdialog;
3467
3468 pdialog = (struct city_dialog *) data;
3469
3470 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3471 /* "shellrenamecity" */
3472 _("Rename City"),
3473 _("What should we rename the city to?"),
3474 city_name_get(pdialog->pcity),
3475 rename_popup_callback, pdialog);
3476}
3477
3478/***********************************************************************/
3481static void rename_popup_callback(gpointer data, gint response,
3482 const char *input)
3483{
3484 struct city_dialog *pdialog = data;
3485
3486 if (pdialog) {
3487 if (response == GTK_RESPONSE_OK) {
3488 city_rename(pdialog->pcity, input);
3489 } /* else CANCEL or DELETE_EVENT */
3490
3491 pdialog->rename_shell = NULL;
3492 }
3493}
3494
3495/***********************************************************************/
3499{
3501}
3502
3503/***********************************************************************/
3507{
3508 struct city_dialog *pdialog = (struct city_dialog *) data;
3509
3510 if (!can_client_issue_orders()) {
3511 return;
3512 }
3513
3514 if (!pdialog->misc.block_signal) {
3515 struct city *pcity = pdialog->pcity;
3517
3518 fc_assert(CITYO_LAST == 3);
3519
3523 }
3526 }
3529 }
3530
3532 pcity->wlcb);
3533 }
3534}
3535
3536/***********************************************************************/
3540static void set_cityopt_values(struct city_dialog *pdialog)
3541{
3542 struct city *pcity = pdialog->pcity;
3543
3544 pdialog->misc.block_signal = 1;
3545
3548
3551 (pdialog->misc.new_citizens_radio[1]), TRUE);
3552 } else if (is_city_option_set(pcity, CITYO_GOLD_SPECIALISTS)) {
3554 (pdialog->misc.new_citizens_radio[2]), TRUE);
3555 } else {
3557 (pdialog->misc.new_citizens_radio[0]), TRUE);
3558 }
3559 pdialog->misc.block_signal = 0;
3560}
3561
3562/******************** Callbacks for: Close, Prev, Next. *******************/
3563
3564/***********************************************************************/
3567static void close_callback(GtkWidget *w, gpointer data)
3568{
3569 close_city_dialog((struct city_dialog *) data);
3570}
3571
3572/***********************************************************************/
3576{
3577 struct city_dialog *pdialog;
3578
3579 pdialog = (struct city_dialog *) data;
3580
3582
3584 citizens_dialog_close(pdialog->pcity);
3585 }
3586 close_happiness_dialog(pdialog->pcity);
3587 close_cma_dialog(pdialog->pcity);
3588
3589 /* Save size of the city dialog. */
3598
3599 last_page
3601
3604
3607
3608 if (pdialog->sell_shell) {
3610 }
3611 if (pdialog->rename_shell) {
3613 }
3614
3617
3618 free(pdialog);
3619
3620 /* Need to do this every time a new dialog is closed. */
3622}
3623
3624/***********************************************************************/
3627static void close_city_dialog(struct city_dialog *pdialog)
3628{
3630}
3631
3632/***********************************************************************/
3637{
3638 struct city_dialog *pdialog = (struct city_dialog *) data;
3639 int i, j, dir, size;
3640 struct city *new_pcity = NULL;
3641
3643 return;
3644 }
3645
3647
3649 fc_assert_ret(size >= 1);
3651
3652 if (size == 1) {
3653 return;
3654 }
3655
3656 /* dir = 1 will advance to the city, dir = -1 will get previous */
3657 if (w == GTK_WIDGET(pdialog->next_command)) {
3658 dir = 1;
3659 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3660 dir = -1;
3661 } else {
3662 /* Always fails. */
3664 || w == GTK_WIDGET(pdialog->prev_command));
3665 dir = 1;
3666 }
3667
3668 for (i = 0; i < size; i++) {
3669 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3670 break;
3671 }
3672 }
3673
3674 fc_assert_ret(i < size);
3675
3676 for (j = 1; j < size; j++) {
3678 (i + dir * j + size) % size);
3680
3681 fc_assert_ret(other_pdialog != pdialog);
3682 if (!other_pdialog) {
3684 break;
3685 }
3686 }
3687
3688 if (!new_pcity) {
3689 /* Every other city has an open city dialog. */
3690 return;
3691 }
3692
3693 /* cleanup happiness dialog */
3695 citizens_dialog_close(pdialog->pcity);
3696 }
3697 close_happiness_dialog(pdialog->pcity);
3698
3699 pdialog->pcity = new_pcity;
3700
3701 /* reinitialize happiness, and cma dialogs */
3704 citizens_dialog_display(pdialog->pcity));
3705 }
3707 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
3708 if (!client_is_observer()) {
3709 fc_assert(pdialog->cma_editor != NULL);
3710 pdialog->cma_editor->pcity = new_pcity;
3711 }
3712
3713 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
3714
3715 can_slide = FALSE;
3716 center_tile_mapcanvas(pdialog->pcity->tile);
3717 can_slide = TRUE;
3718 if (!client_is_observer()) {
3719 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
3720 }
3721
3723
3724 /* Recenter the city map(s) */
3726 if (pdialog->happiness.map_canvas.sw) {
3728 }
3729}
3730
3731/***********************************************************************/
3735{
3737 refresh_worklist(pdialog->production.worklist);
3739}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:2011
bool action_ever_possible(action_id action)
Definition actions.c:8092
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:945
#define n
Definition astring.c:77
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
#define BV_SET(bv, bit)
Definition bitvector.h:81
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:663
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:737
int city_granary_size(int city_size)
Definition city.c:2132
int city_build_slots(const struct city *pcity)
Definition city.c:2932
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:305
const char * city_name_get(const struct city *pcity)
Definition city.c:1137
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1255
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3388
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:3317
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:267
#define city_owner(_pcity_)
Definition city.h:563
#define MAX_CITY_SIZE
Definition city.h:106
@ FEELING_FINAL
Definition city.h:284
void get_city_dialog_output_text(const struct city *pcity, Output_type_id otype, char *buf, size_t bufsz)
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
int city_rename(struct city *pcity, const char *name)
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
int city_buy_production(struct city *pcity)
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
void get_city_dialog_airlift_text(const struct city *pcity, char *buf, size_t bufsz)
int city_change_production(struct city *pcity, struct universal *target)
void city_rotate_specialist(struct city *pcity, int citizen_index)
int get_citydlg_canvas_width(void)
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
void get_city_dialog_airlift_value(const struct city *pcity, char *buf, size_t bufsz)
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
void get_city_dialog_pollution_text(const struct city *pcity, char *buf, size_t bufsz)
void get_city_dialog_culture_text(const struct city *pcity, char *buf, size_t bufsz)
bool city_can_buy(const struct city *pcity)
int get_citydlg_canvas_height(void)
void get_city_dialog_illness_text(const struct city *pcity, char *buf, size_t bufsz)
void city_report_dialog_update_city(struct city *pcity)
bool client_is_global_observer(void)
bool client_is_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Definition climisc.c:818
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:649
cid cid_encode(struct universal target)
Definition climisc.c:482
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:912
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:89
#define cid_production
Definition climisc.h:71
int cid
Definition climisc.h:31
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:552
char * incite_cost
Definition comments.c:75
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 cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
static struct editor_state * editor
Definition editor.c:100
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:846
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:765
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:790
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1076
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1097
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:376
#define EC_NONE
Definition fc_types.h:1113
@ TR_SUCCESS
Definition fc_types.h:1246
#define ERM_NONE
Definition fc_types.h:1136
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
@ O_SCIENCE
Definition fc_types.h:101
@ O_LUXURY
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const struct ft_color ftc_client
const char * population_to_text(int thousand_citizen)
Definition game.c:734
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:2876
citydlg_response
Definition citydlg.c:82
@ CDLGR_UNITS
Definition citydlg.c:82
@ CDLGR_PREV
Definition citydlg.c:82
@ CDLGR_NEXT
Definition citydlg.c:82
static int new_dialog_def_page
Definition citydlg.c:219
static void create_and_append_buildings_page(struct city_dialog *pdialog)
Definition citydlg.c:1238
static void unit_upgrade_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2935
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3046
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1869
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3459
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1830
static int last_page
Definition citydlg.c:220
static void init_citydlg_dimensions(void)
Definition citydlg.c:332
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1272
struct tile * loc
Definition citydlg.c:227
@ WORKLIST_PAGE
Definition citydlg.c:112
@ CMA_PAGE
Definition citydlg.c:112
@ HAPPINESS_PAGE
Definition citydlg.c:112
@ SETTINGS_PAGE
Definition citydlg.c:113
@ STICKY_PAGE
Definition citydlg.c:113
@ NUM_PAGES
Definition citydlg.c:114
@ OVERVIEW_PAGE
Definition citydlg.c:112
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:128
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3383
static bool low_citydlg
Definition citydlg.c:230
static struct @141 workertask_req
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
static void city_dialog_update_building(struct city_dialog *pdialog)
Definition citydlg.c:2069
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2502
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3174
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2775
static struct city_dialog * get_city_dialog(struct city *pcity)
Definition citydlg.c:387
#define CITY_MAP_MIN_SIZE_Y
Definition citydlg.c:129
static void city_dialog_update_information(GtkWidget **info_ebox, GtkWidget **info_label, struct city_dialog *pdialog)
Definition citydlg.c:1932
static GtkWidget * create_citydlg_improvement_list(struct city_dialog *pdialog, GtkWidget *vbox)
Definition citydlg.c:897
static void create_production_header(struct city_dialog *pdialog, GtkContainer *contain)
Definition citydlg.c:1205
static void workertask_dlg_destroy(GtkWidget *w, gpointer data)
Definition citydlg.c:3038
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2356
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2956
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3237
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2850
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3425
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3514
static gboolean show_info_popup(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:661
static void create_and_append_overview_page(struct city_dialog *pdialog)
Definition citydlg.c:956
static void create_and_append_happiness_page(struct city_dialog *pdialog)
Definition citydlg.c:1316
void popdown_all_city_dialogs(void)
Definition citydlg.c:607
static void buy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3187
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3310
static void create_and_append_map_page(struct city_dialog *pdialog)
Definition citydlg.c:1144
static void city_dialog_map_create(struct city_dialog *pdialog, struct city_map_canvas *cmap_canvas)
Definition citydlg.c:423
void refresh_unit_city_dialogs(struct unit *punit)
Definition citydlg.c:546
void reset_city_dialogs(void)
Definition citydlg.c:365
static void cityopt_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3391
static void city_dialog_map_recenter(GtkWidget *map_canvas_sw)
Definition citydlg.c:462
static void draw_map_canvas(struct city_dialog *pdialog)
Definition citydlg.c:3162
static bool is_showing_workertask_dialog
Definition citydlg.c:222
#define unit_node_vector_iterate_end
Definition citydlg.c:108
static void sell_callback(struct impr_type *pimprove, gpointer data)
Definition citydlg.c:3256
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2802
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2463
static void create_and_append_settings_page(struct city_dialog *pdialog)
Definition citydlg.c:1500
static bool city_dialogs_have_been_initialised
Definition citydlg.c:217
static void close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3451
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3295
static void create_citydlg_main_map(struct city_dialog *pdialog, GtkWidget *container)
Definition citydlg.c:880
#define NUM_CITIZENS_SHOWN
Definition citydlg.c:110
#define CITYMAP_HEIGHT
Definition citydlg.c:75
static void unit_homecity_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2922
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2889
static void city_dialog_update_counters(struct city_dialog *pdialog)
Definition citydlg.c:1413
static gboolean present_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2598
struct city * owner
Definition citydlg.c:226
static GtkWidget * create_city_info_table(struct city_dialog *pdialog, GtkWidget **info_ebox, GtkWidget **info_label)
Definition citydlg.c:745
static struct city_dialog * create_city_dialog(struct city *pcity)
Definition citydlg.c:1642
static void target_drag_data_received(GtkWidget *w, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
Definition citydlg.c:1167
static void unit_disband_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2902
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3349
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3523
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2047
static void create_and_append_counters_page(struct city_dialog *pdialog)
Definition citydlg.c:1393
static void unit_unload_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2863
static void show_units_response(void *data)
Definition citydlg.c:2515
static void initialize_city_dialogs(void)
Definition citydlg.c:341
static int canvas_height
Definition citydlg.c:218
static int canvas_width
Definition citydlg.c:218
#define TINYSCREEN_MAX_HEIGHT
Definition citydlg.c:78
static void city_dialog_update_supported_units(struct city_dialog *pdialog)
Definition citydlg.c:2249
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2788
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2827
@ INFO_LUXURY
Definition citydlg.c:120
@ INFO_STEAL
Definition citydlg.c:122
@ INFO_CORRUPTION
Definition citydlg.c:121
@ NUM_INFO_FIELDS
Definition citydlg.c:123
@ INFO_ILLNESS
Definition citydlg.c:122
@ INFO_WASTE
Definition citydlg.c:121
@ INFO_SIZE
Definition citydlg.c:119
@ INFO_GROWTH
Definition citydlg.c:120
@ INFO_SHIELD
Definition citydlg.c:119
@ INFO_CULTURE
Definition citydlg.c:121
@ INFO_GOLD
Definition citydlg.c:119
@ INFO_SCIENCE
Definition citydlg.c:120
@ INFO_POLLUTION
Definition citydlg.c:121
@ INFO_TRADE
Definition citydlg.c:119
@ INFO_AIRLIFT
Definition citydlg.c:122
@ INFO_GRANARY
Definition citydlg.c:120
@ INFO_FOOD
Definition citydlg.c:119
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:2983
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3366
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2192
static void create_and_append_cma_page(struct city_dialog *pdialog)
Definition citydlg.c:1480
void popdown_city_dialog(struct city *pcity)
Definition citydlg.c:595
static gboolean supported_unit_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2536
void close_cma_dialog(struct city *pcity)
Definition cma_fe.c:104
struct cma_dialog * create_cma_dialog(struct city *pcity, bool tiny)
Definition cma_fe.c:214
void refresh_cma_dialog(struct city *pcity, enum cma_refresh refresh)
Definition cma_fe.c:471
@ REFRESH_ALL
Definition cma_fe.h:26
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
GtkWidget * toplevel
Definition gui_main.c:125
GtkWidget * map_canvas
Definition gui_main.c:107
int screen_height(void)
Definition gui_main.c:2593
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:25
GtkWidget * icon_label_button_new(const gchar *icon_name, const gchar *label_text)
Definition gui_stuff.c:76
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void intl_slist(int n, const char **s, bool *done)
Definition gui_stuff.c:111
void close_happiness_dialog(struct city *pcity)
Definition happiness.c:330
void refresh_happiness_dialog(struct city *pcity)
Definition happiness.c:317
GtkWidget * get_top_happiness_display(struct city *pcity, bool low_dlg, GtkWidget *win)
Definition happiness.c:356
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
GtkWidget * input_dialog_create(GtkWindow *parent, const char *dialogname, const char *text, const char *postinputtest, input_dialog_callback_t response_callback, gpointer response_cli_data)
Definition inputdlg.c:66
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
bool request_transport(struct unit *cargo, struct tile *ptile)
void refresh_worklist(GtkWidget *editor)
Definition wldlg.c:1327
void add_worklist_dnd_target(GtkWidget *w)
Definition wldlg.c:339
void reset_city_worklist(GtkWidget *editor, struct city *pcity)
Definition wldlg.c:1279
GtkWidget * create_worklist(void)
Definition wldlg.c:1054
void refresh_all_city_worklists(void)
Definition citydlg.c:3734
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:3249
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2759
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2560
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2805
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3220
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2824
@ 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:2783
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:518
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:493
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
static SDL_Surface * info_label
Definition widget.c:57
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_WONDER
Definition helpdlg_g.h:21
int impr_sell_gold(const struct impr_type *pimprove)
enum test_result test_player_sell_building_now(struct player *pplayer, struct city *pcity, const struct impr_type *pimprove)
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define fc_assert_action(condition, action)
Definition log.h:187
#define log_debug(message,...)
Definition log.h:115
void center_tile_mapcanvas(const struct tile *ptile)
bool can_slide
#define fc_malloc(sz)
Definition mem.h:34
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:319
bool unit_can_load(const struct unit *punit)
Definition movement.c:883
static const char * name_translation_get(const struct name_translation *ptrans)
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:637
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:636
int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options, enum city_wl_cancel_behavior wl_cb)
int len
Definition packhand.c:127
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1229
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1203
void economy_report_dialog_update(void)
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
cairo_surface_t * surface
Definition canvas.h:23
GtkWidget * prev_command
Definition citydlg.c:208
struct city_dialog::@144 happiness
GtkWidget * name_label
Definition citydlg.c:141
struct city_dialog::@142 overview
GtkWidget * rename_shell
Definition citydlg.c:205
GtkWidget * rename_command
Definition citydlg.c:196
GtkWidget * production_bar
Definition citydlg.c:152
GtkWidget * supported_units_frame
Definition citydlg.c:157
GtkWidget * citizen_pics
Definition citydlg.c:148
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 * popover
Definition citydlg.c:147
GtkWidget * disband_on_settler
Definition citydlg.c:198
struct city_map_canvas map_canvas
Definition citydlg.c:150
GtkWidget * improvement_list
Definition citydlg.c:155
GtkWidget * 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 unit_node_vector present_units
Definition citydlg.c:164
city_map * view
Definition citydlg.h:455
struct city_dialog::@146 misc
GtkWidget * citizens
Definition citydlg.c:185
GtkWidget * show_units_command
Definition citydlg.c:207
Impr_type_id sell_id
Definition citydlg.c:211
GtkWidget * production_combo
Definition citydlg.c:153
GtkBox * container
Definition citydlg.c:189
struct cma_dialog * cma_editor
Definition citydlg.c:193
enum city_dialog::@191 page
cairo_surface_t * citizen_surface
Definition citydlg.c:147
struct city_dialog::@145 counters
GtkWidget * shell
Definition citydlg.c:140
GtkWidget * worklist
Definition citydlg.c:176
struct city_dialog::@143 production
GtkWidget * present_units_frame
Definition citydlg.c:160
GtkWidget * info_label[NUM_INFO_FIELDS]
Definition citydlg.c:167
GtkWidget * new_citizens_radio[3]
Definition citydlg.c:197
GtkBox * widget
Definition citydlg.c:190
GtkListStore * change_production_store
Definition citydlg.c:169
GtkWidget * present_unit_table
Definition citydlg.c:161
GtkWidget * notebook
Definition citydlg.c:143
GtkWidget * next_command
Definition citydlg.c:209
GtkTreeSelection * change_selection
Definition citydlg.c:204
GtkWidget * darea
Definition citydlg.c:134
GtkWidget * sw
Definition citydlg.c:132
Definition city.h:320
struct worker_task_list * task_reqs
Definition city.h:412
int surplus[O_LAST]
Definition city.h:355
enum city_wl_cancel_behavior wlcb
Definition city.h:404
int food_stock
Definition city.h:367
int * counter_values
Definition city.h:408
int pollution
Definition city.h:369
int id
Definition city.h:326
int waste[O_LAST]
Definition city.h:356
struct unit_list * info_units_present
Definition city.h:474
struct player * owner
Definition city.h:323
struct unit_list * info_units_supported
Definition city.h:473
struct worklist worklist
Definition city.h:401
struct universal production
Definition city.h:396
int steal
Definition city.h:414
citizens size
Definition city.h:332
int illness
Definition city.h:434
int culture
Definition city.h:465
int buy_cost
Definition city.h:466
struct tile * tile
Definition city.h:322
int shield_stock
Definition city.h:368
int prod[O_LAST]
Definition city.h:358
struct unit_list * units_supported
Definition city.h:406
struct city::@17::@20 client
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
GtkWidget * shell
Definition cma_fe.h:33
struct city * pcity
Definition cma_fe.h:32
struct player * playing
Definition connection.h:151
Definition climisc.h: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:279
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int height
Definition citydlg.c:98
GtkWidget * cmd
Definition citydlg.c:96
GtkWidget * pix
Definition citydlg.c:97
GtkEventController * middle
Definition citydlg.c:100
GtkEventController * left
Definition citydlg.c:99
GtkEventController * right
Definition citydlg.c:101
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int id
Definition unit.h:145
int homecity
Definition unit.h:146
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
struct tile * ptile
Definition workertask.h:22
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * unit_description(struct unit *punit)
Definition text.c:475
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:110
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6783
int tileset_small_sprite_width(const struct tileset *t)
Definition tilespec.c:901
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:789
int tileset_small_sprite_height(const struct tileset *t)
Definition tilespec.c:937
int tileset_unit_with_upkeep_height(const struct tileset *t)
Definition tilespec.c:859
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6722
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6805
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:465
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2441
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:359
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:752
#define unit_tile(_pu)
Definition unit.h:397
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66