Freeciv-3.4
Loading...
Searching...
No Matches
citydlg.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21
22#include <gtk/gtk.h>
23#include <gdk/gdkkeysyms.h>
24
25/* utility */
26#include "bitvector.h"
27#include "fcintl.h"
28#include "log.h"
29#include "mem.h"
30#include "shared.h"
31#include "support.h"
32
33/* common */
34#include "city.h"
35#include "counters.h"
36#include "game.h"
37#include "map.h"
38#include "movement.h"
39#include "packets.h"
40#include "player.h"
41#include "unitlist.h"
42
43/* client */
44#include "chatline_common.h"
45#include "client_main.h"
46#include "colors.h"
47#include "control.h"
48#include "climap.h"
49#include "options.h"
50#include "text.h"
51#include "tilespec.h"
52
53/* client/agents */
54#include "cma_fec.h"
55
56/* client/gui-gtk-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 "update_queue.h"
70#include "wldlg.h"
71
72#include "citydlg.h"
73
74#define CITYMAP_WIDTH MIN(512, canvas_width)
75#define CITYMAP_HEIGHT (CITYMAP_WIDTH * canvas_height / canvas_width)
76#define CITYMAP_SCALE ((double)CITYMAP_WIDTH / (double)canvas_width)
77
78#define TINYSCREEN_MAX_HEIGHT (500 - 1)
79
80/* Only CDLGR_UNITS button currently uses these, others have
81 * direct callback. */
83
84struct city_dialog;
85
86/* Get 'struct dialog_list' and related function */
87#define SPECLIST_TAG dialog
88#define SPECLIST_TYPE struct city_dialog
89#include "speclist.h"
90
91#define dialog_list_iterate(dialoglist, pdialog) \
92 TYPED_LIST_ITERATE(struct city_dialog, dialoglist, pdialog)
93#define dialog_list_iterate_end LIST_ITERATE_END
94
95struct unit_node {
98 int height;
102};
103
104/* Get 'struct unit_node' and related function */
105#define SPECVEC_TAG unit_node
106#define SPECVEC_TYPE struct unit_node
107#include "specvec.h"
108
109#define unit_node_vector_iterate(list, elt) \
110 TYPED_VECTOR_ITERATE(struct unit_node, list, elt)
111#define unit_node_vector_iterate_end VECTOR_ITERATE_END
112
113#define NUM_CITIZENS_SHOWN 30
114
117 NUM_PAGES /* The number of pages in city dialog notebook
118 * must match the entries in misc_whichtab_label[] */
120
121enum {
126 NUM_INFO_FIELDS /* Number of fields in city_info panel
127 * must match entries in output_label[] */
129
130/* Minimal size for the city map scrolling windows */
131#define CITY_MAP_MIN_SIZE_X 200
132#define CITY_MAP_MIN_SIZE_Y 150
133
134struct city_map_canvas {
135 GtkWidget *sw;
137};
138
139struct city_dialog {
140 struct city *pcity;
141
146
150
151 struct {
153
154 GtkWidget *production_bar;
155 GtkWidget *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.
391 The 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 gtk_widget_add_css_class(GTK_WIDGET(view), "large-pixbufs");
900 g_object_unref(store);
902 gtk_widget_set_name(view, "small_font");
903 pdialog->overview.improvement_list = view;
904
907 rend, "pixbuf", 1, NULL);
910 rend, "text", 2,
911 "strikethrough", 4, NULL);
913 g_object_set(rend, "xalign", 1.0, NULL);
915 rend, "text", 3,
916 "strikethrough", 4, NULL);
917
919
921 pdialog);
922
923 return view;
924}
925
926/***********************************************************************/
943{
945 GtkWidget *right, *frame, *table;
946 GtkWidget *label, *sw, *view, *bar, *production_combo;
947 GtkWidget *vp;
950 /* TRANS: Overview tab in city dialog */
951 const char *tab_title = _("_Overview");
953 int page_row = 0;
954
955 /* Main page */
956 page = gtk_grid_new();
965
966 if (!low_citydlg) {
967 GtkWidget *middle;
968 GtkWidget *vbox;
970 int middle_col = 0;
971
972 /* Middle: city map, improvements */
973 middle = gtk_grid_new();
975 gtk_grid_attach(GTK_GRID(page), middle, 0, page_row++, 1, 1);
976
977 /* City map */
978 create_citydlg_main_map(pdialog, middle, middle_col++, 0);
979
980 /* Improvements */
982 gtk_grid_attach(GTK_GRID(middle), vbox, middle_col++, 0, 1, 1);
983
985
986 label = g_object_new(GTK_TYPE_LABEL, "label", _("Production:"),
987 "xalign", 0.0, "yalign", 0.5, NULL);
988 gtk_box_append(GTK_BOX(vbox), label);
989
992
996
997 bar = gtk_progress_bar_new();
999 pdialog->overview.production_bar = bar;
1001
1002 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1003
1013
1018 rend, "pixbuf", 0, NULL);
1019 g_object_set(rend, "xalign", 0.0, NULL);
1020
1024 rend, "text", 1, "strikethrough", 3, NULL);
1025
1026 pdialog->overview.buy_command
1027 = icon_label_button_new("system-run", _("_Buy"));
1029 g_signal_connect(pdialog->overview.buy_command, "clicked",
1030 G_CALLBACK(buy_callback), pdialog);
1031
1032 label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE,
1033 "mnemonic-widget", view,
1034 "label", _("I_mprovements:"),
1035 "xalign", 0.0, "yalign", 0.5, NULL);
1036 gtk_box_append(GTK_BOX(vbox), label);
1037
1042 gtk_box_append(GTK_BOX(vbox), sw);
1043
1045 } else {
1046 pdialog->overview.buy_command = NULL;
1047 pdialog->overview.production_bar = NULL;
1048 pdialog->overview.production_combo = NULL;
1050 }
1051
1052 /* Bottom: info, units */
1055
1056 /* Info */
1057 frame = gtk_frame_new(_("Info"));
1058 gtk_box_append(GTK_BOX(bottom), frame);
1059
1060 table = create_city_info_table(pdialog,
1061 pdialog->overview.info_label);
1065
1066 /* Right: present and supported units (overview page) */
1068 gtk_box_append(GTK_BOX(bottom), right);
1069
1074
1075 /* Supported units */
1082 sw);
1083
1084
1091
1094
1095 /* Present units */
1102
1109
1112
1113 /* Show page */
1115}
1116
1117/***********************************************************************/
1120static void create_and_append_map_page(struct city_dialog *pdialog)
1121{
1122 if (low_citydlg) {
1123 GtkWidget *page;
1124 GtkWidget *label;
1125 const char *tab_title = _("Citymap");
1126 int page_row = 0;
1127
1128 page = gtk_grid_new();
1137
1138 create_citydlg_main_map(pdialog, page, 0, page_row++);
1139
1141 }
1142}
1143
1144/***********************************************************************/
1148 const GValue *value,
1149 double x, double y, gpointer data)
1150{
1151 struct city_dialog *pdialog = (struct city_dialog *) data;
1152 cid id;
1153 struct universal univ;
1154
1155 if (NULL != client.conn.playing
1156 && city_owner(pdialog->pcity) != client.conn.playing) {
1157 return FALSE;
1158 }
1159
1160 id = g_value_get_int(value);
1161 univ = cid_production(id);
1162
1163 city_change_production(pdialog->pcity, &univ);
1164
1165 return TRUE;
1166}
1167
1168/***********************************************************************/
1172static int create_production_header(struct city_dialog *pdialog,
1173 GtkWidget *grid, int row)
1174{
1175 GtkWidget *hgrid, *bar;
1176 int grid_col = 0;
1177
1178 hgrid = gtk_grid_new();
1184 gtk_grid_attach(GTK_GRID(grid), hgrid, 0, row++, 1, 1);
1185
1186 /* The label is set in city_dialog_update_building() */
1187 bar = gtk_progress_bar_new();
1190 pdialog->production.production_bar = bar;
1191 gtk_grid_attach(GTK_GRID(hgrid), bar, grid_col++, 0, 1, 1);
1192 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(bar), _("%d/%d %d turns"));
1193
1195
1196 pdialog->production.buy_command
1197 = icon_label_button_new("system-run", _("_Buy"));
1199 grid_col++, 0, 1, 1);
1200
1201 g_signal_connect(pdialog->production.buy_command, "clicked",
1202 G_CALLBACK(buy_callback), pdialog);
1203
1204 return row;
1205}
1206
1207/***********************************************************************/
1211{
1212 if (low_citydlg) {
1213 GtkWidget *page;
1214 GtkWidget *label;
1215 GtkWidget *vbox;
1216 GtkWidget *view;
1217 const char *tab_title = _("Buildings");
1218 int page_row = 0;
1219
1220 page = gtk_grid_new();
1228
1229 page_row = create_production_header(pdialog, page, page_row);
1230 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1231
1233 gtk_grid_attach(GTK_GRID(page), vbox, 0, page_row++, 1, 1);
1234
1236
1237 gtk_box_append(GTK_BOX(vbox), view);
1238
1240 }
1241}
1242
1243/***********************************************************************/
1247{
1248 const char *tab_title = _("P_roduction");
1250 GtkWidget *page, *editor;
1251 int page_row = 0;
1252
1253 page = gtk_grid_new();
1260 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1261
1262 /* Stuff that's being currently built */
1263 if (!low_citydlg) {
1265 "label", _("Production:"),
1266 "xalign", 0.0, "yalign", 0.5, NULL);
1267 pdialog->production.production_label = label;
1268 gtk_grid_attach(GTK_GRID(page), label, 0, page_row++, 1, 1);
1269
1270 page_row = create_production_header(pdialog, page, page_row);
1271 } else {
1272 pdialog->production.production_label = NULL;
1273 }
1274
1280 reset_city_worklist(editor, pdialog->pcity);
1281 gtk_grid_attach(GTK_GRID(page), editor, 0, page_row++, 1, 1);
1282 pdialog->production.worklist = editor;
1283
1285}
1286
1287/***********************************************************************/
1298{
1299 GtkWidget *page, *label, *table, *right, *left, *frame;
1300 const char *tab_title = _("Happ_iness");
1301 int page_col = 0;
1302 int left_row = 0;
1303
1304 /* Main page */
1305 page = gtk_grid_new();
1312 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1313
1314 /* Left: info, citizens */
1315 left = gtk_grid_new();
1318 gtk_grid_attach(GTK_GRID(page), left, page_col++, 0, 1, 1);
1319
1320 if (!low_citydlg) {
1321 /* Upper left: info */
1322 frame = gtk_frame_new(_("Info"));
1323 gtk_grid_attach(GTK_GRID(left), frame, 0, left_row++, 1, 1);
1324
1325 table = create_city_info_table(pdialog,
1326 pdialog->happiness.info_label);
1329 }
1330
1331 /* Lower left: citizens */
1335 0, left_row++, 1, 1);
1337 citizens_dialog_display(pdialog->pcity));
1338 }
1339
1340 /* Right: city map, happiness */
1342 gtk_grid_attach(GTK_GRID(page), right, page_col++, 0, 1, 1);
1343
1344 if (!low_citydlg) {
1345 /* Upper right: city map */
1346 frame = gtk_frame_new(_("City map"));
1349 gtk_box_append(GTK_BOX(right), frame);
1350
1351 city_dialog_map_create(pdialog, &pdialog->happiness.map_canvas);
1353 }
1354
1355 /* Lower right: happiness */
1357 gtk_box_append(GTK_BOX(right), pdialog->happiness.widget);
1360 pdialog->shell));
1361
1362 /* Show page */
1364}
1365
1366/**********************************************************************/
1369/**********************************************************************/
1374{
1376 GtkLabel *label = GTK_LABEL(gtk_label_new(_("Counters")));
1377
1378 pdialog->counters.container = NULL;
1379 pdialog->counters.widget = NULL;
1380
1382
1384
1386
1387 gtk_widget_show(page);
1388}
1389
1390/***********************************************************************/
1393static void create_and_append_cma_page(struct city_dialog *pdialog)
1394{
1395 GtkWidget *page, *label;
1396 const char *tab_title = _("_Governor");
1397
1399
1401
1402 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1403
1404 pdialog->cma_editor = create_cma_dialog(pdialog->pcity, low_citydlg);
1405 gtk_box_append(GTK_BOX(page), pdialog->cma_editor->shell);
1406
1408}
1409
1410/***********************************************************************/
1414{
1415 int i;
1416 GtkWidget *vgrid, *page, *frame, *label, *button;
1418 GtkWidget *group;
1419 const char *tab_title = _("_Settings");
1420 int grid_row = 0;
1421
1422 static const char *new_citizens_output_label[] = {
1423 N_("Luxury"),
1424 N_("Science"),
1425 N_("Gold")
1426 };
1427
1428 static const char *disband_label
1429 = N_("Allow unit production to disband city");
1430
1431 static const char *misc_whichtab_label[NUM_PAGES] = {
1432 N_("Overview page"),
1433 N_("Production page"),
1434 N_("Happiness page"),
1435 N_("Counters Page"),
1436 N_("Governor page"),
1437 N_("This Settings page"),
1438 N_("Last active page")
1439 };
1440
1441 static bool new_citizens_label_done;
1442 static bool misc_whichtab_label_done;
1443
1444 /* Initialize signal_blocker */
1445 pdialog->misc.block_signal = 0;
1446
1447
1448 page = gtk_grid_new();
1454
1456
1458
1459 gtk_notebook_append_page(GTK_NOTEBOOK(pdialog->notebook), page, label);
1460
1461 /* new_citizens radio */
1462 frame = gtk_frame_new(_("New citizens produce"));
1463 gtk_grid_attach(GTK_GRID(page), frame, 0, 0, 1, 1);
1465
1466 vgrid = gtk_grid_new();
1470
1473
1474 group = NULL;
1475 for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) {
1478 GTK_CHECK_BUTTON(group));
1479 pdialog->misc.new_citizens_radio[i] = button;
1480 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1481 g_signal_connect(button, "toggled",
1482 G_CALLBACK(cityopt_callback), pdialog);
1483 group = button;
1484 }
1485
1486 /* Next is the next-time-open radio group in the right column */
1487 frame = gtk_frame_new(_("Next time open"));
1488 gtk_grid_attach(GTK_GRID(page), frame, 1, 0, 1, 1);
1490
1491 vgrid = gtk_grid_new();
1492 grid_row = 0;
1496
1499
1500 group = NULL;
1501 for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) {
1504 GTK_CHECK_BUTTON(group));
1505 pdialog->misc.whichtab_radio[i] = button;
1506 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1507 g_signal_connect(button, "toggled",
1509 group = button;
1510 }
1511
1512 /* Now we go back and fill the hbox rename */
1513 frame = gtk_frame_new(_("City"));
1514 gtk_widget_set_margin_top(frame, 12);
1516 gtk_grid_attach(GTK_GRID(page), frame, 0, 1, 1, 1);
1517
1518 vgrid = gtk_grid_new();
1519 grid_row = 0;
1523
1524 button = gtk_button_new_with_mnemonic(_("R_ename..."));
1525 pdialog->misc.rename_command = button;
1526 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1527 g_signal_connect(button, "clicked",
1528 G_CALLBACK(rename_callback), pdialog);
1529
1531
1532 /* The disband-city-on-unit-production button */
1534 pdialog->misc.disband_on_settler = button;
1535 gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1);
1536 g_signal_connect(button, "toggled",
1537 G_CALLBACK(cityopt_callback), pdialog);
1538
1539 /* We choose which page to popup by default */
1541 (pdialog->
1543 TRUE);
1544
1545 set_cityopt_values(pdialog);
1546
1548
1549 if (new_dialog_def_page == (NUM_PAGES - 1)) {
1551 last_page);
1552 } else {
1555 }
1556}
1557
1558/***********************************************************************/
1567{
1568 struct city_dialog *pdialog;
1570 GtkWidget *vbox, *hbox, *cbox;
1573 int ccol = 0;
1575 struct player *owner;
1576
1579 }
1580
1581 pdialog = fc_malloc(sizeof(struct city_dialog));
1582 pdialog->pcity = pcity;
1583 pdialog->sell_shell = NULL;
1584 pdialog->rename_shell = NULL;
1585 pdialog->happiness.map_canvas.sw = NULL; /* Make sure NULL if spy */
1586 pdialog->happiness.map_canvas.darea = NULL; /* Ditto */
1587 pdialog->happiness.citizens = NULL; /* Ditto */
1588 pdialog->counters.widget = NULL;
1589 pdialog->counters.container = NULL;
1590 pdialog->production.buy_command = NULL;
1591 pdialog->production.production_label = NULL;
1592 pdialog->production.production_bar = NULL;
1593 pdialog->cma_editor = NULL;
1597
1598 pdialog->shell = gtk_dialog_new();
1601 setup_dialog(pdialog->shell, toplevel);
1602
1603 g_signal_connect(pdialog->shell, "destroy",
1605 gtk_widget_set_name(pdialog->shell, "Freeciv");
1606
1607 gtk_widget_realize(pdialog->shell);
1608
1609 /* Keep the icon of the executable on Windows (see PR#36491) */
1610#ifndef FREECIV_MSWINDOWS
1611 {
1612 gtk_window_set_icon_name(GTK_WINDOW(pdialog->shell), "citydlg");
1613 }
1614#endif /* FREECIV_MSWINDOWS */
1615
1616 /* Restore size of the city dialog. */
1620
1621 pdialog->popover = NULL;
1622
1626 gtk_box_append(GTK_BOX(vbox), hbox);
1627
1628 /**** Citizens bar here ****/
1629 cbox = gtk_grid_new();
1630 gtk_box_append(GTK_BOX(hbox), cbox);
1631
1634
1638 pdialog->citizen_pics = gtk_picture_new();
1639
1648 gtk_grid_attach(GTK_GRID(cbox), pdialog->citizen_pics, ccol++, 0, 1, 1);
1649
1651 g_signal_connect(controller, "pressed",
1652 G_CALLBACK(citizens_callback), pdialog);
1654
1655 /**** City name label here ****/
1656 pdialog->name_label = gtk_label_new(NULL);
1661
1662 /**** -Start of Notebook- ****/
1663
1664 pdialog->notebook = gtk_notebook_new();
1667 gtk_box_append(GTK_BOX(vbox), pdialog->notebook);
1668
1672
1674
1675 /* Only create these tabs if not a spy */
1679 }
1680
1682
1683 if (owner == client_player()
1684 && !client_is_observer()) {
1687 } else {
1690 }
1691
1692 /**** End of Notebook ****/
1693
1694 /* Bottom buttons */
1695
1696 pdialog->show_units_command =
1697 gtk_dialog_add_button(GTK_DIALOG(pdialog->shell), _("_List present units..."), CDLGR_UNITS);
1698
1699 g_signal_connect(GTK_DIALOG(pdialog->shell), "response",
1701
1702 pdialog->prev_command = gtk_button_new_from_icon_name("go-previous");
1704 GTK_WIDGET(pdialog->prev_command), 1);
1705
1706 pdialog->next_command = gtk_button_new_from_icon_name("go-next");
1708 GTK_WIDGET(pdialog->next_command), 2);
1709
1710 if (owner != client_player()) {
1713 }
1714
1716 _("_Close"), GTK_RESPONSE_CLOSE);
1717
1720
1722 G_CALLBACK(close_callback), pdialog);
1723
1724 g_signal_connect(pdialog->prev_command, "clicked",
1726
1727 g_signal_connect(pdialog->next_command, "clicked",
1729
1730 /* Some other things we gotta do */
1731
1733 g_signal_connect(controller, "key-pressed",
1736
1738
1740
1741 /* Need to do this every time a new dialog is opened. */
1743
1745
1747
1748 return pdialog;
1749}
1750
1751/**************** Functions to update parts of the dialog *****************/
1752
1753/***********************************************************************/
1756static void city_dialog_update_title(struct city_dialog *pdialog)
1757{
1758 gchar *buf;
1759 const gchar *now;
1760
1761 if (city_unhappy(pdialog->pcity)) {
1762 /* TRANS: city dialog title */
1763 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - DISORDER"),
1764 city_name_getx(pdialog->pcity),
1766 } else if (city_celebrating(pdialog->pcity)) {
1767 /* TRANS: city dialog title */
1768 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - celebrating"),
1769 city_name_getx(pdialog->pcity),
1771 } else if (city_happy(pdialog->pcity)) {
1772 /* TRANS: city dialog title */
1773 buf = g_strdup_printf(_("<b>%s</b> - %s citizens - happy"),
1774 city_name_getx(pdialog->pcity),
1776 } else {
1777 /* TRANS: city dialog title */
1778 buf = g_strdup_printf(_("<b>%s</b> - %s citizens"),
1779 city_name_getx(pdialog->pcity),
1781 }
1782
1784 if (strcmp(now, buf) != 0) {
1787 }
1788
1789 g_free(buf);
1790}
1791
1792/***********************************************************************/
1795static void city_dialog_update_citizens(struct city_dialog *pdialog)
1796{
1797 enum citizen_category categories[MAX_CITY_SIZE];
1800 struct city *pcity = pdialog->pcity;
1802 int num_supers
1804 ARRAY_SIZE(categories) - num_citizens,
1805 &categories[num_citizens]);
1806 cairo_t *cr;
1807
1808 if (num_supers >= 0) {
1809 /* Just draw superspecialists in the common roster */
1811 } else {
1812 /* FIXME: show them in some compact way */
1813 num_citizens = ARRAY_SIZE(categories);
1814 }
1815 /* If there is not enough space we stack the icons. We draw from left to */
1816 /* right. width is how far we go to the right for each drawn pixmap. The */
1817 /* last icon is always drawn in full, and so has reserved */
1818 /* tileset_small_sprite_width(tileset) pixels. */
1819
1821 if (num_citizens > 1) {
1823 / (num_citizens - 1));
1824 } else {
1825 width = full_width;
1826 }
1827 pdialog->cwidth = width;
1828
1829 /* overview page */
1830 /* keep these values in sync with create_city_dialog */
1833
1834 cr = cairo_create(pdialog->citizen_surface);
1835
1836 for (i = 0; i < num_citizens; i++) {
1838 get_citizen_sprite(tileset, categories[i], i, pcity)->surface,
1839 i * width, 0);
1840 cairo_rectangle(cr, i * width, 0,
1841 /* Always draw last citizen in full */
1842 i + 1 < num_citizens ? width : full_width,
1844 cairo_fill(cr);
1845 }
1846
1847 total_used_width = (i - 1) * width + full_width;
1848
1850 /* Clear the rest of the area.
1851 * Note that this might still be necessary even in cases where
1852 * num_citizens > NUM_CITIZENS_SHOWN, if the available width cannot be
1853 * divided perfectly. */
1858 cairo_fill(cr);
1859 }
1860
1861 cairo_destroy(cr);
1862
1864 pdialog->citizen_surface);
1865
1867}
1868
1869
1870/**********************************************************************/
1873static void city_dialog_update_counters(struct city_dialog *pdialog)
1874{
1879 char int_val[101];
1880 char *text;
1881 int text_size;
1882
1883 if (NULL != pdialog->counters.widget) {
1885 GTK_WIDGET(pdialog->counters.widget));
1886 }
1887
1888 if (NULL == pdialog->counters.container) {
1890 }
1891
1895
1899 counterValue = GTK_LABEL(gtk_label_new(_("Current value is: ")));
1901 fc_snprintf(int_val, sizeof(int_val), "%d", pdialog->pcity->counter_values[counter_index(pcount)]);
1905
1907 counterValue = GTK_LABEL(gtk_label_new(_("Activated once value equal or higher than: ")));
1909 fc_snprintf(int_val, sizeof(int_val), "%d", pcount->checkpoint);
1913
1914 text_size = 0;
1915 if (NULL != pcount->helptext) {
1916 strvec_iterate(pcount->helptext, text_) {
1919 }
1920 if (0 < text_size) {
1921 text = malloc(text_size+1);
1922 text_size = 0;
1923 strvec_iterate(pcount->helptext, text_) {
1924 strcpy(&text[text_size], text_);
1928 free(text);
1930 }
1933
1936}
1937
1938/***********************************************************************/
1942 struct city_dialog *pdialog)
1943{
1944 int i, illness = 0;
1945 char buf[NUM_INFO_FIELDS][512];
1946 struct city *pcity = pdialog->pcity;
1947 int granaryturns;
1950
1951 /* fill the buffers with the necessary info */
1952 if (supers) {
1953 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d+%d)",
1954 pcity->size, non_workers, supers);
1955 } else if (non_workers) {
1956 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d (%3d)",
1957 pcity->size, non_workers);
1958 } else {
1959 fc_snprintf(buf[INFO_SIZE], sizeof(buf[INFO_SIZE]), "%3d", pcity->size);
1960 }
1961 fc_snprintf(buf[INFO_FOOD], sizeof(buf[INFO_FOOD]), "%3d (%+4d)",
1962 pcity->prod[O_FOOD], pcity->surplus[O_FOOD]);
1963 fc_snprintf(buf[INFO_SHIELD], sizeof(buf[INFO_SHIELD]), "%3d (%+4d)",
1964 pcity->prod[O_SHIELD] + pcity->waste[O_SHIELD],
1965 pcity->surplus[O_SHIELD]);
1966 fc_snprintf(buf[INFO_TRADE], sizeof(buf[INFO_TRADE]), "%3d (%+4d)",
1967 pcity->surplus[O_TRADE] + pcity->waste[O_TRADE],
1968 pcity->surplus[O_TRADE]);
1969 fc_snprintf(buf[INFO_GOLD], sizeof(buf[INFO_GOLD]), "%3d (%+4d)",
1970 pcity->prod[O_GOLD], pcity->surplus[O_GOLD]);
1971 fc_snprintf(buf[INFO_LUXURY], sizeof(buf[INFO_LUXURY]), "%3d",
1972 pcity->prod[O_LUXURY]);
1973 fc_snprintf(buf[INFO_SCIENCE], sizeof(buf[INFO_SCIENCE]), "%3d",
1974 pcity->prod[O_SCIENCE]);
1975 fc_snprintf(buf[INFO_GRANARY], sizeof(buf[INFO_GRANARY]), "%4d/%-4d",
1977
1979 if (granaryturns == 0) {
1980 /* TRANS: city growth is blocked. Keep short. */
1981 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("blocked"));
1982 } else if (granaryturns == FC_INFINITY) {
1983 /* TRANS: city is not growing. Keep short. */
1984 fc_snprintf(buf[INFO_GROWTH], sizeof(buf[INFO_GROWTH]), _("never"));
1985 } else {
1986 /* A negative value means we'll have famine in that many turns.
1987 But that's handled down below. */
1988 /* TRANS: city growth turns. Keep short. */
1990 PL_("%d turn", "%d turns", abs(granaryturns)),
1991 abs(granaryturns));
1992 }
1994 pcity->waste[O_TRADE]);
1995 fc_snprintf(buf[INFO_WASTE], sizeof(buf[INFO_WASTE]), "%4d",
1996 pcity->waste[O_SHIELD]);
1997 fc_snprintf(buf[INFO_CULTURE], sizeof(buf[INFO_CULTURE]), "%4d",
1998 pcity->client.culture);
2000 pcity->pollution);
2001 if (!game.info.illness_on) {
2002 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), " -.-");
2003 } else {
2005 /* illness is in tenth of percent */
2006 fc_snprintf(buf[INFO_ILLNESS], sizeof(buf[INFO_ILLNESS]), "%5.1f%%",
2007 (float)illness / 10.0);
2008 }
2009 if (pcity->steal) {
2010 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), PL_("%d time", "%d times", pcity->steal),
2011 pcity->steal);
2012 } else {
2013 fc_snprintf(buf[INFO_STEAL], sizeof(buf[INFO_STEAL]), _("Not stolen"));
2014 }
2015
2017
2018 /* stick 'em in the labels */
2019 for (i = 0; i < NUM_INFO_FIELDS; i++) {
2021 }
2022
2023 /*
2024 * Make use of the emergency-indicating styles set up for certain labels
2025 * in create_city_info_table().
2026 */
2027 /* For starvation, the "4" below is arbitrary. 3 turns should be enough
2028 * of a warning. */
2029 if (granaryturns > -4 && granaryturns < 0) {
2031 } else {
2033 }
2034
2035 if (granaryturns == 0 || pcity->surplus[O_FOOD] < 0) {
2037 } else {
2039 }
2040
2041 /* Someone could add the color &orange for better granularity here */
2042 if (pcity->pollution >= 10) {
2044 } else {
2046 }
2047
2048 /* Illness is in tenth of percent, i.e 100 == 10.0% */
2049 if (illness >= 100) {
2051 } else {
2053 }
2054}
2055
2056/***********************************************************************/
2059static void city_dialog_update_map(struct city_dialog *pdialog)
2060{
2061 struct canvas store = FC_STATIC_CANVAS_INIT;
2062
2063 store.surface = pdialog->map_canvas_store_unscaled;
2064
2065 /* The drawing is done in three steps.
2066 * 1. First we render to a pixmap with the appropriate canvas size.
2067 * 2. Then the pixmap is rendered into a pixbuf of equal size.
2068 * 3. Finally this pixbuf is composited and scaled onto the GtkImage's
2069 * target pixbuf.
2070 */
2071
2072 city_dialog_redraw_map(pdialog->pcity, &store);
2073
2074 /* draw to real window */
2075 draw_map_canvas(pdialog);
2076}
2077
2078/***********************************************************************/
2081static void city_dialog_update_building(struct city_dialog *pdialog)
2082{
2083 char buf[32], buf2[200];
2084 gdouble pct;
2085 GtkListStore *store;
2087 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2088 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2089 int targets_used, item;
2090 struct city *pcity = pdialog->pcity;
2092 const char *descr = city_production_name_translation(pcity);
2094
2095 if (pdialog->overview.buy_command != NULL) {
2097 }
2098 if (pdialog->production.buy_command != NULL) {
2100 }
2101
2102 /* Make sure build slots info is up to date */
2103 if (pdialog->production.production_label != NULL) {
2105
2106 /* Only display extra info if more than one slot is available */
2107 if (build_slots > 1) {
2108 fc_snprintf(buf2, sizeof(buf2),
2109 /* TRANS: never actually used with built_slots <= 1 */
2110 PL_("Production (up to %d unit per turn):",
2111 "Production (up to %d units per turn):", build_slots),
2112 build_slots);
2115 } else {
2117 GTK_LABEL(pdialog->production.production_label), _("Production:"));
2118 }
2119 }
2120
2121 /* Update what the city is working on */
2123
2124 if (cost > 0) {
2125 pct = (gdouble) pcity->shield_stock / (gdouble) cost;
2126 pct = CLAMP(pct, 0.0, 1.0);
2127 } else {
2128 pct = 1.0;
2129 }
2130
2131 if (pdialog->overview.production_bar != NULL) {
2132 fc_snprintf(buf2, sizeof(buf2), "%s%s\n%s", descr,
2133 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2138 }
2139
2140 if (pdialog->production.production_bar != NULL) {
2141 fc_snprintf(buf2, sizeof(buf2), "%s%s: %s", descr,
2142 worklist_is_empty(&pcity->worklist) ? "" : " (+)", buf);
2147 }
2148
2149 store = pdialog->overview.change_production_store;
2150 if (store != NULL) {
2151 int cur = -1;
2152 int actcount = 0;
2153
2154 if (pdialog->overview.production_combo != NULL) {
2156 -1);
2157 }
2158
2159 gtk_list_store_clear(store);
2160
2162 = collect_eventually_buildable_targets(targets, pdialog->pcity, FALSE);
2163 name_and_sort_items(targets, targets_used, items, FALSE, pcity);
2164
2165 for (item = 0; item < targets_used; item++) {
2166 if (can_city_build_now(&(wld.map), pcity, &items[item].item,
2167 RPT_CERTAIN)) {
2168 const char *name;
2169 struct sprite *sprite;
2170 GdkPixbuf *pix;
2171 struct universal *target = &items[item].item;
2172 bool useless;
2173
2174 if (VUT_UTYPE == target->kind) {
2178 useless = FALSE;
2179 } else {
2182 useless = is_improvement_redundant(pcity, target->value.building);
2183 }
2185 gtk_list_store_append(store, &iter);
2186 gtk_list_store_set(store, &iter, 0, pix,
2187 1, name, 3, useless,
2188 2, (gint)cid_encode(items[item].item), -1);
2190
2191 if (are_universals_equal(target, &pcity->production)) {
2192 cur = actcount;
2193 }
2194
2195 actcount++;
2196 }
2197 }
2198
2199 if (pdialog->overview.production_combo != NULL) {
2201 cur);
2202 }
2203 }
2204}
2205
2206/***********************************************************************/
2210{
2211 int item, targets_used;
2212 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
2213 struct item items[MAX_NUM_PRODUCTION_TARGETS];
2214 GtkTreeModel *model;
2215 GtkListStore *store;
2216
2217 const char *tooltip_sellable = _("Press <b>ENTER</b> or double-click to "
2218 "sell an improvement.");
2219 const char *tooltip_great_wonder = _("Great Wonder - cannot be sold.");
2220 const char *tooltip_small_wonder = _("Small Wonder - cannot be sold.");
2221
2222 model =
2224 store = GTK_LIST_STORE(model);
2225
2227 name_and_sort_items(targets, targets_used, items, FALSE, pdialog->pcity);
2228
2229 gtk_list_store_clear(store);
2230
2231 for (item = 0; item < targets_used; item++) {
2232 GdkPixbuf *pix;
2233 GtkTreeIter it;
2234 int upkeep;
2235 struct sprite *sprite;
2236 struct universal target = items[item].item;
2237
2238 fc_assert_action(VUT_IMPROVEMENT == target.kind, continue);
2239 /* This takes effects (like Adam Smith's) into account. */
2240 upkeep = city_improvement_upkeep(pdialog->pcity, target.value.building);
2242
2244 gtk_list_store_append(store, &it);
2245 gtk_list_store_set(store, &it,
2246 0, target.value.building,
2247 1, pix,
2248 2, items[item].descr,
2249 3, upkeep,
2250 4,
2252 target.value.building),
2253 5,
2256 (is_small_wonder(target.value.building) ?
2258 -1);
2260 }
2261}
2262
2263/***********************************************************************/
2267{
2268 struct unit_list *units;
2269 struct unit_node_vector *nodes;
2270 int n, m, i;
2271 gchar *buf;
2273 const struct civ_map *nmap = &(wld.map);
2274
2275 if (NULL != client.conn.playing
2276 && city_owner(pdialog->pcity) != client.conn.playing) {
2277 units = pdialog->pcity->client.info_units_supported;
2278 } else {
2279 units = pdialog->pcity->units_supported;
2280 }
2281
2282 nodes = &pdialog->overview.supported_units;
2283
2284 n = unit_list_size(units);
2285 m = unit_node_vector_size(nodes);
2286
2287 if (m > n) {
2288 i = 0;
2290 if (i++ >= n) {
2292 elt->cmd);
2293 }
2295
2297 } else {
2298 for (i = m; i < n; i++) {
2299 GtkWidget *cmd, *pix;
2300 struct unit_node node;
2301
2302 cmd = gtk_button_new();
2303 node.cmd = cmd;
2304
2306
2307 pix = gtk_picture_new();
2308 node.pix = pix;
2310
2312
2314 cmd);
2315
2316 node.left = NULL;
2317 node.middle = NULL;
2318 node.right = NULL;
2319
2320 unit_node_vector_append(nodes, node);
2321 }
2322 }
2323
2324 i = 0;
2325 unit_list_iterate(units, punit) {
2326 struct unit_node *pnode;
2327 int happy_cost = city_unit_unhappiness(nmap, punit, &free_unhappy);
2328
2329 pnode = unit_node_vector_get(nodes, i);
2330 if (pnode) {
2331 GtkWidget *cmd, *pix;
2334
2335 cmd = pnode->cmd;
2336 pix = pnode->pix;
2337
2339 punit->upkeep, happy_cost);
2340
2341 if (pnode->left != NULL) {
2345 }
2346
2348
2350 g_signal_connect(controller, "pressed",
2354 pnode->left = controller;
2358 g_signal_connect(controller, "released",
2362 pnode->middle = controller;
2366 g_signal_connect(controller, "released",
2370 pnode->right = controller;
2371
2372 if (city_owner(pdialog->pcity) != client.conn.playing) {
2374 } else {
2376 }
2377
2380 }
2381 i++;
2383
2384 buf = g_strdup_printf(_("Supported units %d"), n);
2386 g_free(buf);
2387}
2388
2389/***********************************************************************/
2393{
2394 struct unit_list *units;
2395 struct unit_node_vector *nodes;
2396 int n, m, i;
2397 gchar *buf;
2398
2399 if (NULL != client.conn.playing
2400 && city_owner(pdialog->pcity) != client.conn.playing) {
2401 units = pdialog->pcity->client.info_units_present;
2402 } else {
2403 units = pdialog->pcity->tile->units;
2404 }
2405
2406 nodes = &pdialog->overview.present_units;
2407
2408 n = unit_list_size(units);
2409 m = unit_node_vector_size(nodes);
2410
2411 if (m > n) {
2412 i = 0;
2414 if (i++ >= n) {
2416 elt->cmd);
2417 }
2419
2421 } else {
2422 for (i = m; i < n; i++) {
2423 GtkWidget *cmd, *pix;
2424 struct unit_node node;
2425
2426 cmd = gtk_button_new();
2427 node.cmd = cmd;
2428
2430
2431 pix = gtk_picture_new();
2432 node.pix = pix;
2434
2436
2438 cmd);
2439
2440 node.left = NULL;
2441 node.middle = NULL;
2442 node.right = NULL;
2443
2444 unit_node_vector_append(nodes, node);
2445 }
2446 }
2447
2448 i = 0;
2449 unit_list_iterate(units, punit) {
2450 struct unit_node *pnode;
2451
2452 pnode = unit_node_vector_get(nodes, i);
2453 if (pnode) {
2454 GtkWidget *cmd, *pix;
2457
2458 cmd = pnode->cmd;
2459 pix = pnode->pix;
2460
2462
2463 if (pnode->left != NULL) {
2467 }
2468
2470
2472 g_signal_connect(controller, "pressed",
2476 pnode->left = controller;
2480 g_signal_connect(controller, "released",
2484 pnode->middle = controller;
2488 g_signal_connect(controller, "released",
2492 pnode->right = controller;
2493
2494 if (city_owner(pdialog->pcity) != client.conn.playing) {
2496 } else {
2498 }
2499
2502 }
2503 i++;
2505
2506 buf = g_strdup_printf(_("Present units %d"), n);
2508 g_free(buf);
2509}
2510
2511/***********************************************************************/
2519{
2520 int count = 0;
2521 int city_number;
2522
2523 if (NULL != client.conn.playing) {
2525 } else {
2526 city_number = FC_INFINITY; /* ? */
2527 }
2528
2529 /* The first time, we see if all the city dialogs are open */
2531 if (city_owner(pdialog->pcity) == client.conn.playing) {
2532 count++;
2533 }
2535
2536 if (count == city_number) { /* All are open, shouldn't prev/next */
2538 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), FALSE);
2539 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE);
2541 } else {
2543 if (city_owner(pdialog->pcity) == client.conn.playing) {
2544 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->prev_command), TRUE);
2545 gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), TRUE);
2546 }
2548 }
2549}
2550
2551/***********************************************************************/
2554static void citydlg_response_callback(GtkDialog *dlg, gint response,
2555 void *data)
2556{
2557 switch (response) {
2558 case CDLGR_UNITS:
2559 show_units_response(data);
2560 break;
2561 }
2562}
2563
2564/***********************************************************************/
2567static void show_units_response(void *data)
2568{
2569 struct city_dialog *pdialog = (struct city_dialog *) data;
2570 struct tile *ptile = pdialog->pcity->tile;
2571
2572 if (unit_list_size(ptile->units)) {
2574 }
2575}
2576
2577/***********************************************************************/
2587static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit,
2588 GtkWidget *wdg, bool supported)
2589{
2590 GMenu *menu;
2591 GActionGroup *group;
2592 GSimpleAction *act;
2593
2594 if (!can_client_issue_orders()) {
2595 return FALSE;
2596 }
2597
2598 if (pdialog->popover != NULL) {
2600 }
2601
2603 menu = g_menu_new();
2604
2605 if (supported) {
2606 act = g_simple_action_new("center", NULL);
2607 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2611 menu_item_append_unref(menu, g_menu_item_new(_("Cen_ter"), "win.center"));
2612 }
2613
2614 act = g_simple_action_new("activate", NULL);
2615 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2619 menu_item_append_unref(menu, g_menu_item_new(_("_Activate unit"),
2620 "win.activate"));
2621
2622 act = g_simple_action_new("activate_close", NULL);
2623 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2625
2626 if (supported) {
2627 g_signal_connect(act, "activate",
2630 } else {
2631 g_signal_connect(act, "activate",
2634 }
2635
2637 g_menu_item_new(_("Activate unit, _close dialog"),
2638 "win.activate_close"));
2639
2640 if (!supported) {
2641 act = g_simple_action_new("load", NULL);
2642 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2647 menu_item_append_unref(menu, g_menu_item_new(_("_Load unit"), "win.load"));
2648
2649 act = g_simple_action_new("unload", NULL);
2650 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2658 unit_tile(punit)));
2659 menu_item_append_unref(menu, g_menu_item_new(_("_Unload unit"),
2660 "win.unload"));
2661
2662 act = g_simple_action_new("sentry", NULL);
2663 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2671 menu_item_append_unref(menu, g_menu_item_new(_("_Sentry unit"),
2672 "win.sentry"));
2673
2674 act = g_simple_action_new("fortify", NULL);
2675 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2683 menu_item_append_unref(menu, g_menu_item_new(_("_Fortify unit"),
2684 "win.fortify"));
2685 }
2686
2687 act = g_simple_action_new("disband", NULL);
2688 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2694 menu_item_append_unref(menu, g_menu_item_new(_("_Disband unit"),
2695 "win.disband"));
2696
2697 if (!supported) {
2698 act = g_simple_action_new("rehome", NULL);
2699 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2705 pdialog->pcity));
2708 "win.rehome"));
2709
2710 act = g_simple_action_new("upgrade", NULL);
2711 g_object_set_data(G_OBJECT(act), "dlg", pdialog);
2720 != NULL);
2721 menu_item_append_unref(menu, g_menu_item_new(_("U_pgrade unit"),
2722 "win.upgrade"));
2723 }
2724
2726 g_object_ref(pdialog->popover);
2727 gtk_widget_insert_action_group(pdialog->popover, "win", group);
2729
2730
2732
2733 return TRUE;
2734}
2735
2736/***********************************************************************/
2740 double x, double y, gpointer data)
2741{
2742 struct city_dialog *pdialog;
2743 struct city *pcity;
2744 struct unit *punit =
2745 player_unit_by_number(client_player(), (size_t) data);
2746
2747 if (NULL != punit
2749 && NULL != (pdialog = get_city_dialog(pcity))) {
2750
2751 return create_unit_menu(pdialog, punit,
2753 TRUE);
2754 }
2755
2756 return TRUE;
2757}
2758
2759/***********************************************************************/
2763 double x, double y, gpointer data)
2764{
2765 struct city_dialog *pdialog;
2766 struct city *pcity;
2767 struct unit *punit =
2768 player_unit_by_number(client_player(), (size_t) data);
2769
2770 if (NULL != punit
2771 && NULL != (pcity = tile_city(unit_tile(punit)))
2772 && NULL != (pdialog = get_city_dialog(pcity))) {
2773
2774 return create_unit_menu(pdialog, punit,
2776 FALSE);
2777 }
2778
2779 return TRUE;
2780}
2781
2782/***********************************************************************/
2787 int n_press, double x, double y,
2788 gpointer data)
2789{
2790 struct city_dialog *pdialog;
2791 struct city *pcity;
2792 struct unit *punit =
2793 player_unit_by_number(client_player(), (size_t) data);
2794
2795 if (NULL != punit
2796 && NULL != (pcity = tile_city(unit_tile(punit)))
2797 && NULL != (pdialog = get_city_dialog(pcity))
2800 close_city_dialog(pdialog);
2801 }
2802
2803 return TRUE;
2804}
2805
2806/***********************************************************************/
2811 double x, double y, gpointer data)
2812{
2813 struct city_dialog *pdialog;
2814 struct city *pcity;
2815 struct unit *punit =
2816 player_unit_by_number(client_player(), (size_t) data);
2817
2818 if (NULL != punit
2820 && NULL != (pdialog = get_city_dialog(pcity))
2823 close_city_dialog(pdialog);
2824 }
2825
2826 return TRUE;
2827}
2828
2829/***********************************************************************/
2833 double x, double y, gpointer data)
2834{
2835 struct unit *punit =
2836 player_unit_by_number(client_player(), (size_t) data);
2837
2838 if (NULL != punit
2841 }
2842
2843 return TRUE;
2844}
2845
2846/***********************************************************************/
2851static void close_citydlg_unit_popover(struct city_dialog *pdialog)
2852{
2853 if (pdialog->popover != NULL) {
2854 gtk_widget_unparent(pdialog->popover);
2855 g_object_unref(pdialog->popover);
2856 pdialog->popover = NULL;
2857 }
2858}
2859
2860/***********************************************************************/
2864 gpointer data)
2865{
2866 struct unit *punit =
2868
2869 if (NULL != punit) {
2871 }
2872
2874}
2875
2876/***********************************************************************/
2880 gpointer data)
2881{
2882 struct unit *punit =
2884
2885 if (NULL != punit) {
2886 /* FIXME: If unit is not idle to begin with, we can only request
2887 * idling, and as we have no server reply yet,
2888 * the unit_focus_try() below will fail. */
2891 }
2892
2894}
2895
2896/***********************************************************************/
2901 GVariant *parameter,
2902 gpointer data)
2903{
2904 struct unit *punit =
2906
2907 if (NULL != punit) {
2908 struct city *pcity =
2910
2911 /* FIXME: If unit is not idle to begin with, we can only request
2912 * idling, and as we have no server reply yet,
2913 * the unit_focus_try() below will fail. */
2916
2917 if (NULL != pcity) {
2918 struct city_dialog *pdialog = get_city_dialog(pcity);
2919
2920 if (NULL != pdialog) {
2921 close_city_dialog(pdialog);
2922 }
2923 }
2924 }
2925
2927}
2928
2929/***********************************************************************/
2934 GVariant *parameter,
2935 gpointer data)
2936{
2937 struct unit *punit =
2939
2940 if (NULL != punit) {
2941 struct city *pcity = tile_city(unit_tile(punit));
2942
2943 /* FIXME: If unit is not idle to begin with, we can only request
2944 * idling, and as we have no server reply yet,
2945 * the unit_focus_try() below will fail. */
2948
2949 if (NULL != pcity) {
2950 struct city_dialog *pdialog = get_city_dialog(pcity);
2951
2952 if (NULL != pdialog) {
2953 close_city_dialog(pdialog);
2954 }
2955 }
2956 }
2957
2959}
2960
2961/***********************************************************************/
2965 gpointer data)
2966{
2967 struct unit *punit =
2969
2970 if (NULL != punit) {
2972 }
2973
2975}
2976
2977/***********************************************************************/
2981 gpointer data)
2982{
2983 struct unit *punit =
2985
2986 if (NULL != punit) {
2988 }
2989
2991}
2992
2993/***********************************************************************/
2997 gpointer data)
2998{
2999 struct unit *punit =
3001
3002 if (NULL != punit) {
3004 }
3005
3007}
3008
3009/***********************************************************************/
3013 gpointer data)
3014{
3015 struct unit *punit =
3017
3018 if (NULL != punit) {
3020 }
3021
3023}
3024
3025/***********************************************************************/
3029 gpointer data)
3030{
3031 struct unit_list *punits;
3032 struct unit *punit =
3034
3035 if (NULL == punit) {
3036 return;
3037 }
3038
3043
3045}
3046
3047/***********************************************************************/
3052 gpointer data)
3053{
3054 struct unit *punit =
3056
3057 if (NULL != punit) {
3059 }
3060
3062}
3063
3064/***********************************************************************/
3068 gpointer data)
3069{
3070 struct unit_list *punits;
3071 struct unit *punit =
3073
3074 if (NULL == punit) {
3075 return;
3076 }
3077
3082
3084}
3085
3086/******** Callbacks for citizen bar, map funcs that are not update ********/
3087
3088/***********************************************************************/
3093 double x, double y, gpointer data)
3094{
3095 struct city_dialog *pdialog = data;
3096 struct city *pcity = pdialog->pcity;
3097 int citnum, tlen, len;
3098
3099 if (!can_client_issue_orders()) {
3100 return FALSE;
3101 }
3102
3104 len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
3105
3106 if (x > len) {
3107 /* No citizen that far to the right */
3108 return FALSE;
3109 }
3110 citnum = MIN(city_size_get(pcity) - 1, x / pdialog->cwidth);
3111
3113
3114 return TRUE;
3115}
3116
3117/***********************************************************************/
3121{
3122 enum unit_activity act = (enum unit_activity)GPOINTER_TO_INT(data);
3123 struct city *pcity = workertask_req.owner;
3124 struct tile *ptile = workertask_req.loc;
3125 struct packet_worker_task task;
3126
3127 task.city_id = pcity->id;
3128
3129 if (act == ACTIVITY_LAST) {
3130 task.tgt = -1;
3131 task.want = 0;
3132 } else {
3133 enum extra_cause cause = activity_to_extra_cause(act);
3135 struct extra_type *tgt;
3136
3137 if (cause != EC_NONE) {
3138 tgt = next_extra_for_tile(ptile, cause, city_owner(pcity), NULL);
3139 } else if (rmcause != ERM_NONE) {
3141 } else {
3142 tgt = NULL;
3143 }
3144
3145 if (tgt == NULL) {
3146 struct terrain *pterr = tile_terrain(ptile);
3147
3148 if ((act != ACTIVITY_TRANSFORM
3149 || pterr->transform_result == NULL || pterr->transform_result == pterr)
3150 && (act != ACTIVITY_CULTIVATE || pterr->cultivate_result == NULL)
3151 && (act != ACTIVITY_PLANT || pterr->plant_result == NULL)) {
3152 /* No extra to order */
3153 output_window_append(ftc_client, _("There's no suitable extra to order."));
3154
3155 return;
3156 }
3157
3158 task.tgt = -1;
3159 } else {
3160 task.tgt = extra_index(tgt);
3161 }
3162
3163 task.want = 100;
3164 }
3165
3166 task.tile_id = ptile->index;
3167 task.activity = act;
3168
3170}
3171
3172/***********************************************************************/
3179
3180/***********************************************************************/
3183static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
3184{
3186 GtkWidget *shl;
3187 struct terrain *pterr = tile_terrain(ptile);
3188 struct universal for_terr = { .kind = VUT_TERRAIN,
3189 .value = { .terrain = pterr }};
3190 struct worker_task *ptask;
3191
3193 workertask_req.owner = pcity;
3194 workertask_req.loc = ptile;
3195
3197 _("What Action to Request"),
3198 _("Select autoworker activity:"));
3199
3200 ptask = worker_task_list_get(pcity->task_reqs, 0);
3201 if (ptask != NULL) {
3202 choice_dialog_add(shl, _("Clear request"),
3205 }
3206
3208 choice_dialog_add(shl, Q_("?act:Mine"),
3211 }
3212 if (pterr->plant_result != NULL
3214 NULL, &for_terr)) {
3215 choice_dialog_add(shl, _("Plant"),
3218 }
3220 choice_dialog_add(shl, _("Irrigate"),
3223 }
3224 if (pterr->cultivate_result != NULL
3226 NULL, &for_terr)) {
3227 choice_dialog_add(shl, _("Cultivate"),
3230 }
3232 choice_dialog_add(shl, _("Road"),
3235 }
3236 if (pterr->transform_result != pterr && pterr->transform_result != NULL
3238 NULL, &for_terr)) {
3239 choice_dialog_add(shl, _("Transform"),
3242 }
3244 city_owner(pcity), NULL) != NULL) {
3245 choice_dialog_add(shl, _("Clean"),
3248 }
3249
3250 choice_dialog_add(shl, _("_Cancel"), 0, 0, FALSE, NULL);
3252
3254 NULL);
3255 }
3256}
3257
3258/***********************************************************************/
3262 double x, double y, gpointer data)
3263{
3264 struct city_dialog *pdialog = data;
3266
3267 if (!can_client_issue_orders()) {
3268 return FALSE;
3269 }
3270
3271 if (cma_is_city_under_agent(pdialog->pcity, NULL)) {
3272 return FALSE;
3273 }
3274
3277
3279 city_map_radius_sq_get(pdialog->pcity),
3280 canvas_x, canvas_y)) {
3282 }
3283
3284 return TRUE;
3285}
3286
3287/***********************************************************************/
3291 double x, double y, gpointer data)
3292{
3293 struct city_dialog *pdialog = data;
3295
3296 if (!can_client_issue_orders()) {
3297 return FALSE;
3298 }
3299
3302
3304 city_map_radius_sq_get(pdialog->pcity),
3305 canvas_x, canvas_y)) {
3306 struct city *pcity = pdialog->pcity;
3307
3308 popup_workertask_dlg(pdialog->pcity,
3311 city_x, city_y));
3312 }
3313
3314 return TRUE;
3315}
3316
3317/***********************************************************************/
3320static void draw_map_canvas(struct city_dialog *pdialog)
3321{
3323 if (pdialog->happiness.map_canvas.darea) { /* in case of spy */
3325 }
3326}
3327
3328/************** Callbacks for Buy, Change, Sell, Worklist *****************/
3329
3330/***********************************************************************/
3333static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
3334{
3335 struct city_dialog *pdialog = data;
3336
3337 if (response == GTK_RESPONSE_YES) {
3338 city_buy_production(pdialog->pcity);
3339 }
3340
3342}
3343
3344/***********************************************************************/
3347static void buy_callback(GtkWidget *w, gpointer data)
3348{
3350 struct city_dialog *pdialog = data;
3351 const char *name = city_production_name_translation(pdialog->pcity);
3352 int value = pdialog->pcity->client.buy_cost;
3353 char buf[1024];
3354
3355 if (!can_client_issue_orders()) {
3356 return;
3357 }
3358
3359 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
3360 "Treasury contains %d gold.",
3361 client_player()->economic.gold),
3362 client_player()->economic.gold);
3363
3364 if (value <= client_player()->economic.gold) {
3368 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3369 PL_("Buy %s for %d gold?\n%s",
3370 "Buy %s for %d gold?\n%s", value),
3371 name, value, buf);
3372 setup_dialog(shell, pdialog->shell);
3373 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3376 pdialog);
3378 } else {
3382 /* TRANS: Last %s is pre-pluralised "Treasury contains %d gold." */
3383 PL_("%s costs %d gold.\n%s",
3384 "%s costs %d gold.\n%s", value),
3385 name, value, buf);
3386 setup_dialog(shell, pdialog->shell);
3387 gtk_window_set_title(GTK_WINDOW(shell), _("Buy It!"));
3389 NULL);
3391 }
3392}
3393
3394/***********************************************************************/
3398 struct city_dialog *pdialog)
3399{
3401
3403 && gtk_combo_box_get_active_iter(combo, &iter)) {
3404 cid id;
3405 struct universal univ;
3406
3407 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter, 2, &id, -1);
3408 univ = cid_production(id);
3409 city_change_production(pdialog->pcity, &univ);
3410 }
3411}
3412
3413/***********************************************************************/
3416static void sell_callback(struct impr_type *pimprove, gpointer data)
3417{
3418 GtkWidget *shl;
3419 struct city_dialog *pdialog = (struct city_dialog *) data;
3420 pdialog->sell_id = improvement_number(pimprove);
3421 int price;
3422
3423 if (!can_client_issue_orders()) {
3424 return;
3425 }
3426
3428 pimprove) != TR_SUCCESS) {
3429 return;
3430 }
3431
3432 price = impr_sell_gold(pimprove);
3437 PL_("Sell %s for %d gold?",
3438 "Sell %s for %d gold?", price),
3439 city_improvement_name_translation(pdialog->pcity, pimprove), price);
3440 setup_dialog(shl, pdialog->shell);
3441 pdialog->sell_shell = shl;
3442
3443 gtk_window_set_title(GTK_WINDOW(shl), _("Sell It!"));
3444
3445 g_signal_connect(shl, "response",
3447
3449}
3450
3451/***********************************************************************/
3454static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
3455{
3456 struct city_dialog *pdialog = data;
3457
3458 if (response == GTK_RESPONSE_YES) {
3459 city_sell_improvement(pdialog->pcity, pdialog->sell_id);
3460 }
3462
3463 pdialog->sell_shell = NULL;
3464}
3465
3466/***********************************************************************/
3471{
3472 GtkTreeModel *model;
3473 GtkTreeIter it;
3474 GdkSeat *seat;
3476 struct impr_type *pimprove;
3477
3479
3480 if (!gtk_tree_model_get_iter(model, &it, path)) {
3481 return;
3482 }
3483
3484 gtk_tree_model_get(model, &it, 0, &pimprove, -1);
3485
3488
3489 if (!(mask & GDK_CONTROL_MASK)) {
3490 sell_callback(pimprove, data);
3491 } else {
3492 if (is_great_wonder(pimprove)) {
3494 } else {
3496 }
3497 }
3498}
3499
3500/************ Callbacks for stuff on the Misc. Settings page **************/
3501
3502/***********************************************************************/
3506{
3507 struct city_dialog *pdialog;
3508
3509 pdialog = (struct city_dialog *) data;
3510
3511 pdialog->rename_shell = input_dialog_create(GTK_WINDOW(pdialog->shell),
3512 /* "shellrenamecity" */
3513 _("Rename City"),
3514 _("What should we rename the city to?"),
3515 city_name_get(pdialog->pcity),
3516 rename_popup_callback, pdialog);
3517}
3518
3519/***********************************************************************/
3522static void rename_popup_callback(gpointer data, gint response,
3523 const char *input)
3524{
3525 struct city_dialog *pdialog = data;
3526
3527 if (pdialog) {
3528 if (response == GTK_RESPONSE_OK) {
3529 city_rename(pdialog->pcity, input);
3530 } /* else CANCEL or DELETE_EVENT */
3531
3532 pdialog->rename_shell = NULL;
3533 }
3534}
3535
3536/***********************************************************************/
3540{
3542}
3543
3544/***********************************************************************/
3548{
3549 struct city_dialog *pdialog = (struct city_dialog *) data;
3550
3551 if (!can_client_issue_orders()) {
3552 return;
3553 }
3554
3555 if (!pdialog->misc.block_signal) {
3556 struct city *pcity = pdialog->pcity;
3558
3559 fc_assert(CITYO_LAST == 3);
3560
3564 }
3567 }
3570 }
3571
3573 pcity->wlcb);
3574 }
3575}
3576
3577/***********************************************************************/
3602
3603/******************** Callbacks for: Close, Prev, Next. *******************/
3604
3605/***********************************************************************/
3608static void close_callback(GtkWidget *w, gpointer data)
3609{
3610 close_city_dialog((struct city_dialog *) data);
3611}
3612
3613/***********************************************************************/
3617{
3618 struct city_dialog *pdialog;
3619 int width, height;
3620
3621 /* Save size of the city dialog. */
3623
3624 pdialog = (struct city_dialog *) data;
3625
3627
3629 citizens_dialog_close(pdialog->pcity);
3630 }
3631 close_happiness_dialog(pdialog->pcity);
3632 close_cma_dialog(pdialog->pcity);
3633
3634 /* Save size of the city dialog. */
3637 width,
3641 height,
3643
3644 last_page
3646
3649
3652
3653 if (pdialog->sell_shell) {
3655 }
3656 if (pdialog->rename_shell) {
3658 }
3659
3662
3663 free(pdialog);
3664
3665 /* Need to do this every time a new dialog is closed. */
3667}
3668
3669/***********************************************************************/
3672static void close_city_dialog(struct city_dialog *pdialog)
3673{
3675}
3676
3677/***********************************************************************/
3682{
3683 struct city_dialog *pdialog = (struct city_dialog *) data;
3684 int i, j, dir, size;
3685 struct city *new_pcity = NULL;
3686
3688 return;
3689 }
3690
3692
3694 fc_assert_ret(size >= 1);
3696
3697 if (size == 1) {
3698 return;
3699 }
3700
3701 /* dir = 1 will advance to the city, dir = -1 will get previous */
3702 if (w == GTK_WIDGET(pdialog->next_command)) {
3703 dir = 1;
3704 } else if (w == GTK_WIDGET(pdialog->prev_command)) {
3705 dir = -1;
3706 } else {
3707 /* Always fails. */
3709 || w == GTK_WIDGET(pdialog->prev_command));
3710 dir = 1;
3711 }
3712
3713 for (i = 0; i < size; i++) {
3714 if (pdialog->pcity == city_list_get(client.conn.playing->cities, i)) {
3715 break;
3716 }
3717 }
3718
3719 fc_assert_ret(i < size);
3720
3721 for (j = 1; j < size; j++) {
3723 (i + dir * j + size) % size);
3725
3726 fc_assert_ret(other_pdialog != pdialog);
3727 if (!other_pdialog) {
3729 break;
3730 }
3731 }
3732
3733 if (!new_pcity) {
3734 /* Every other city has an open city dialog. */
3735 return;
3736 }
3737
3738 /* cleanup happiness dialog */
3740 citizens_dialog_close(pdialog->pcity);
3741 }
3742 close_happiness_dialog(pdialog->pcity);
3743
3744 pdialog->pcity = new_pcity;
3745
3746 /* reinitialize happiness, and cma dialogs */
3749 citizens_dialog_display(pdialog->pcity));
3750 }
3752 get_top_happiness_display(pdialog->pcity, low_citydlg, pdialog->shell));
3753 if (!client_is_observer()) {
3754 fc_assert(pdialog->cma_editor != NULL);
3755 pdialog->cma_editor->pcity = new_pcity;
3756 }
3757
3758 reset_city_worklist(pdialog->production.worklist, pdialog->pcity);
3759
3760 can_slide = FALSE;
3761 center_tile_mapcanvas(pdialog->pcity->tile);
3762 can_slide = TRUE;
3763 if (!client_is_observer()) {
3764 set_cityopt_values(pdialog); /* Need not be in real_city_dialog_refresh */
3765 }
3766
3768
3769 /* Recenter the city map(s) */
3771 if (pdialog->happiness.map_canvas.sw) {
3773 }
3774}
3775
3776/***********************************************************************/
3780{
3782 refresh_worklist(pdialog->production.worklist);
3784}
const char * action_id_name_translation(action_id act_id)
Definition actions.c:1271
bool action_ever_possible(action_id action)
Definition actions.c:7500
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:740
#define n
Definition astring.c:77
#define BV_CLR_ALL(bv)
Definition bitvector.h:103
#define BV_SET(bv, bit)
Definition bitvector.h:89
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void output_window_append(const struct ft_color color, const char *featured_text)
const char * city_improvement_name_translation(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:666
int city_production_build_shield_cost(const struct city *pcity)
Definition city.c:740
const char * city_name_getx(const struct city *pcity)
Definition city.c:1166
int city_granary_size(int city_size)
Definition city.c:2189
int city_build_slots(const struct city *pcity)
Definition city.c:2990
struct tile * city_map_to_tile(const struct civ_map *nmap, const struct tile *city_center, int city_radius_sq, int city_map_x, int city_map_y)
Definition city.c:305
int city_superspecialists(const struct city *pcity)
Definition city.c:3416
const char * city_name_get(const struct city *pcity)
Definition city.c:1157
int city_improvement_upkeep(const struct city *pcity, const struct impr_type *b)
Definition city.c:1312
bool is_city_option_set(const struct city *pcity, enum city_options option)
Definition city.c:3486
int city_population(const struct city *pcity)
Definition city.c:1247
int city_unit_unhappiness(const struct civ_map *nmap, struct unit *punit, int *free_unhappy)
Definition city.c:3107
bool city_unhappy(const struct city *pcity)
Definition city.c:1683
bool city_celebrating(const struct city *pcity)
Definition city.c:1702
int city_illness_calc(const struct city *pcity, int *ill_base, int *ill_size, int *ill_trade, int *ill_pollution)
Definition city.c:2928
bool city_happy(const struct city *pcity)
Definition city.c:1671
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:137
bool can_city_build_now(const struct civ_map *nmap, const struct city *pcity, const struct universal *target, const enum req_problem_type prob_type)
Definition city.c:1028
citizens city_specialists(const struct city *pcity)
Definition city.c:3401
int city_turns_to_grow(const struct city *pcity)
Definition city.c:2053
const char * city_production_name_translation(const struct city *pcity)
Definition city.c:703
static citizens city_size_get(const struct city *pcity)
Definition city.h:570
citizen_category
Definition city.h:265
#define city_owner(_pcity_)
Definition city.h:564
#define MAX_CITY_SIZE
Definition city.h:104
@ FEELING_FINAL
Definition city.h:282
void get_city_dialog_output_text(const struct city *pcity, Output_type_id otype, char *buf, size_t bufsz)
void get_city_dialog_production(struct city *pcity, char *buffer, size_t buffer_len)
int city_rename(struct city *pcity, const char *name)
int get_city_citizen_types(struct city *pcity, enum citizen_feeling idx, enum citizen_category *categories)
int city_buy_production(struct city *pcity)
int city_toggle_worker(struct city *pcity, int city_x, int city_y)
void get_city_dialog_airlift_text(const struct city *pcity, char *buf, size_t bufsz)
int city_change_production(struct city *pcity, struct universal *target)
void city_rotate_specialist(struct city *pcity, int citizen_index)
int get_citydlg_canvas_width(void)
bool canvas_to_city_pos(int *city_x, int *city_y, int city_radius_sq, int canvas_x, int canvas_y)
int city_try_fill_superspecialists(struct city *pcity, int cat_len, enum citizen_category *categories)
void get_city_dialog_airlift_value(const struct city *pcity, char *buf, size_t bufsz)
void city_dialog_redraw_map(struct city *pcity, struct canvas *pcanvas)
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
void get_city_dialog_pollution_text(const struct city *pcity, char *buf, size_t bufsz)
void get_city_dialog_culture_text(const struct city *pcity, char *buf, size_t bufsz)
bool city_can_buy(const struct city *pcity)
int get_citydlg_canvas_height(void)
void get_city_dialog_illness_text(const struct city *pcity, char *buf, size_t bufsz)
void city_report_dialog_update_city(struct city *pcity)
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:821
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:650
cid cid_encode(struct universal target)
Definition climisc.c:483
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Definition climisc.c:918
#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:77
void request_unit_fortify(struct unit *punit)
Definition control.c:2365
void unit_focus_try(struct unit *punit)
Definition control.c:502
void request_unit_change_homecity(struct unit *punit)
Definition control.c:2106
void request_unit_unload(struct unit *pcargo)
Definition control.c:2206
void request_unit_sentry(struct unit *punit)
Definition control.c:2354
void request_new_unit_activity(struct unit *punit, enum unit_activity act)
Definition control.c:1941
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
int counter_index(const struct counter *pcount)
Definition counters.c:176
#define city_counters_iterate_end
Definition counters.h:64
#define city_counters_iterate(pcount)
Definition counters.h:57
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
static struct editor_state * editor
Definition editor.c:100
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
Definition effects.c:842
struct extra_type * next_extra_for_tile(const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:779
struct extra_type * prev_extra_in_tile(const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
Definition extras.c:804
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1090
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1111
#define extra_index(_e_)
Definition extras.h:183
int Impr_type_id
Definition fc_types.h:237
@ RPT_CERTAIN
Definition fc_types.h:516
#define EC_NONE
Definition fc_types.h:808
@ TR_SUCCESS
Definition fc_types.h:941
#define ERM_NONE
Definition fc_types.h:831
@ O_SHIELD
Definition fc_types.h:103
@ O_FOOD
Definition fc_types.h:103
@ O_TRADE
Definition fc_types.h:103
@ O_SCIENCE
Definition fc_types.h:103
@ O_LUXURY
Definition fc_types.h:103
@ O_GOLD
Definition fc_types.h:103
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const struct ft_color ftc_client
const char * population_to_text(int thousand_citizen)
Definition game.c:743
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:106
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * choice_dialog_start(GtkWindow *parent, const gchar *name, const gchar *text)
void choice_dialog_end(GtkWidget *dshell)
void choice_dialog_add(GtkWidget *dshell, const gchar *label, GCallback handler, gpointer data, bool meta, const gchar *tool_tip)
GtkWidget * citizens_dialog_display(const struct city *pcity)
void citizens_dialog_refresh(const struct city *pcity)
void citizens_dialog_close(const struct city *pcity)
static void unit_sentry_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2893
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:2952
static void popup_workertask_dlg(struct city *pcity, struct tile *ptile)
Definition citydlg.c:3063
static void city_dialog_update_citizens(struct city_dialog *pdialog)
Definition citydlg.c:1870
static void city_destroy_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3476
static void city_dialog_update_title(struct city_dialog *pdialog)
Definition citydlg.c:1831
static int last_page
Definition citydlg.c:220
static void init_citydlg_dimensions(void)
Definition citydlg.c:332
static void create_and_append_worklist_page(struct city_dialog *pdialog)
Definition citydlg.c:1272
struct tile * loc
Definition citydlg.c:227
#define CITY_MAP_MIN_SIZE_X
Definition citydlg.c:128
void real_city_dialog_popup(struct city *pcity)
Definition citydlg.c:566
static void misc_whichtab_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3400
static bool low_citydlg
Definition citydlg.c:230
bool city_dialog_is_open(struct city *pcity)
Definition citydlg.c:587
static void city_dialog_update_building(struct city_dialog *pdialog)
Definition citydlg.c:2085
static void citydlg_response_callback(GtkDialog *dlg, gint response, void *data)
Definition citydlg.c:2519
static void buy_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3191
void real_city_dialog_refresh(struct city *pcity)
Definition citydlg.c:487
static void unit_center_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2792
static struct city_dialog * get_city_dialog(struct city *pcity)
Definition citydlg.c:387
@ INFO_LUXURY
Definition citydlg.c:120
@ INFO_STEAL
Definition citydlg.c:122
@ INFO_CORRUPTION
Definition citydlg.c:121
@ NUM_INFO_FIELDS
Definition citydlg.c:123
@ INFO_ILLNESS
Definition citydlg.c:122
@ INFO_WASTE
Definition citydlg.c:121
@ INFO_SIZE
Definition citydlg.c:119
@ INFO_GROWTH
Definition citydlg.c:120
@ INFO_SHIELD
Definition citydlg.c:119
@ INFO_CULTURE
Definition citydlg.c:121
@ INFO_GOLD
Definition citydlg.c:119
@ INFO_SCIENCE
Definition citydlg.c:120
@ INFO_POLLUTION
Definition citydlg.c:121
@ INFO_TRADE
Definition citydlg.c:119
@ INFO_AIRLIFT
Definition citydlg.c:122
@ INFO_GRANARY
Definition citydlg.c:120
@ INFO_FOOD
Definition citydlg.c:119
#define CITY_MAP_MIN_SIZE_Y
Definition citydlg.c:129
static void city_dialog_update_information(GtkWidget **info_ebox, GtkWidget **info_label, struct city_dialog *pdialog)
Definition citydlg.c:1944
static GtkWidget * create_citydlg_improvement_list(struct city_dialog *pdialog, GtkWidget *vbox)
Definition citydlg.c:897
static void create_production_header(struct city_dialog *pdialog, GtkContainer *contain)
Definition citydlg.c:1205
static void workertask_dlg_destroy(GtkWidget *w, gpointer data)
Definition citydlg.c:3055
static void city_dialog_update_present_units(struct city_dialog *pdialog)
Definition citydlg.c:2373
#define CITYMAP_SCALE
Definition citydlg.c:76
static gboolean citizens_callback(GtkWidget *w, GdkEventButton *ev, gpointer data)
Definition citydlg.c:2973
static void change_production_callback(GtkComboBox *combo, struct city_dialog *pdialog)
Definition citydlg.c:3254
static void unit_load_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2867
static void set_cityopt_values(struct city_dialog *pdialog)
Definition citydlg.c:3442
static void close_city_dialog(struct city_dialog *pdialog)
Definition citydlg.c:3537
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:3204
#define dialog_list_iterate_end
Definition citydlg.c:93
static void impr_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition citydlg.c:3327
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:3408
static void city_dialog_map_recenter(GtkWidget *map_canvas_sw)
Definition citydlg.c:462
@ WORKLIST_PAGE
Definition citydlg.c:112
@ CMA_PAGE
Definition citydlg.c:112
@ HAPPINESS_PAGE
Definition citydlg.c:112
@ SETTINGS_PAGE
Definition citydlg.c:113
@ STICKY_PAGE
Definition citydlg.c:113
@ NUM_PAGES
Definition citydlg.c:114
@ OVERVIEW_PAGE
Definition citydlg.c:112
static void draw_map_canvas(struct city_dialog *pdialog)
Definition citydlg.c:3179
static struct @145 workertask_req
static bool is_showing_workertask_dialog
Definition citydlg.c:222
#define unit_node_vector_iterate_end
Definition citydlg.c:108
static void sell_callback(struct impr_type *pimprove, gpointer data)
Definition citydlg.c:3273
#define dialog_list_iterate(dialoglist, pdialog)
Definition citydlg.c:91
static void supported_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2819
static void city_dialog_update_prev_next(void)
Definition citydlg.c:2480
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:3468
static struct dialog_list * dialog_list
Definition citydlg.c:216
static void sell_callback_response(GtkWidget *w, gint response, gpointer data)
Definition citydlg.c:3312
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:2939
static void unit_fortify_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2906
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:2615
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:2919
#define unit_node_vector_iterate(list, elt)
Definition citydlg.c:106
static void rename_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3366
static void switch_city_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:3546
#define CITYMAP_WIDTH
Definition citydlg.c:74
static void city_dialog_update_map(struct city_dialog *pdialog)
Definition citydlg.c:2063
static void create_and_append_counters_page(struct city_dialog *pdialog)
Definition citydlg.c:1393
static void unit_unload_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2880
static void show_units_response(void *data)
Definition citydlg.c:2532
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:2266
static void unit_activate_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2805
static void present_unit_activate_close_callback(GtkWidget *w, gpointer data)
Definition citydlg.c:2844
static void set_city_workertask(GtkWidget *w, gpointer data)
Definition citydlg.c:3000
static void rename_popup_callback(gpointer data, gint response, const char *input)
Definition citydlg.c:3383
static void city_dialog_update_improvement_list(struct city_dialog *pdialog)
Definition citydlg.c:2209
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:2553
void close_cma_dialog(struct city *pcity)
Definition cma_fe.c:104
struct cma_dialog * create_cma_dialog(struct city *pcity, bool tiny)
Definition cma_fe.c:214
void refresh_cma_dialog(struct city *pcity, enum cma_refresh refresh)
Definition cma_fe.c:471
@ REFRESH_ALL
Definition cma_fe.h:26
void unit_select_dialog_popup(struct tile *ptile)
Definition dialogs.c:377
void popup_upgrade_dialog(struct unit_list *punits)
Definition dialogs.c:1435
void popup_disband_dialog(struct unit_list *punits)
Definition dialogs.c:1473
GtkWidget * toplevel
Definition gui_main.c:126
GtkWidget * map_canvas
Definition gui_main.c:108
int screen_height(void)
Definition gui_main.c:2591
#define GUI_GTK_OPTION(optname)
Definition gui_main.h:32
GtkWidget * icon_label_button_new(const gchar *icon_name, const gchar *label_text)
Definition gui_stuff.c:76
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void intl_slist(int n, const char **s, bool *done)
Definition gui_stuff.c:111
void close_happiness_dialog(struct city *pcity)
Definition happiness.c:330
void refresh_happiness_dialog(struct city *pcity)
Definition happiness.c:317
GtkWidget * get_top_happiness_display(struct city *pcity, bool low_dlg, GtkWidget *win)
Definition happiness.c:356
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
GtkWidget * input_dialog_create(GtkWindow *parent, const char *dialogname, const char *text, const char *postinputtest, input_dialog_callback_t response_callback, gpointer response_cli_data)
Definition inputdlg.c:66
static struct gui_dialog * shell
Definition messagedlg.c:39
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:3779
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:3290
static gboolean middle_present_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2786
static bool create_unit_menu(struct city_dialog *pdialog, struct unit *punit, GtkWidget *wdg, bool supported)
Definition citydlg.c:2587
static gboolean right_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2832
static gboolean left_button_down_citymap(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:3261
@ COUNTERS_PAGE
Definition citydlg.c:115
static void close_citydlg_unit_popover(struct city_dialog *pdialog)
Definition citydlg.c:2851
static gboolean middle_supported_unit_release(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data)
Definition citydlg.c:2810
static gboolean citydlg_keyboard_handler(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data)
Definition citydlg.c:638
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
void put_unit_picture_city_overlays(struct unit *punit, GtkPicture *p, int height, int *upkeep_cost, int happy_cost)
Definition mapview.c:519
void put_unit_picture(struct unit *punit, GtkPicture *p, int height)
Definition mapview.c:494
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
static SDL_Surface * info_label
Definition widget.c:57
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_WONDER
Definition helpdlg_g.h:21
int impr_sell_gold(const struct impr_type *pimprove)
enum test_result test_player_sell_building_now(struct player *pplayer, struct city *pcity, const struct impr_type *pimprove)
bool is_improvement_redundant(const struct city *pcity, const struct impr_type *pimprove)
Impr_type_id improvement_number(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
bool is_small_wonder(const struct impr_type *pimprove)
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:192
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_action(condition, action)
Definition log.h:188
#define log_debug(message,...)
Definition log.h:116
int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options, enum city_wl_cancel_behavior wl_cb)
void center_tile_mapcanvas(const struct tile *ptile)
bool can_slide
#define fc_malloc(sz)
Definition mem.h:34
bool can_unit_exist_at_tile(const struct civ_map *nmap, const struct unit *punit, const struct tile *ptile)
Definition movement.c:350
bool unit_can_load(const struct unit *punit)
Definition movement.c:934
static const char * name_translation_get(const struct name_translation *ptrans)
#define GUI_GTK4_CITYDLG_MAX_XSIZE
Definition options.h:707
#define GUI_GTK4_CITYDLG_MIN_YSIZE
Definition options.h:710
#define GUI_GTK4_CITYDLG_MIN_XSIZE
Definition options.h:706
#define GUI_GTK4_CITYDLG_MAX_YSIZE
Definition options.h:711
int len
Definition packhand.c:128
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
Definition player.c:1217
struct city * player_city_by_number(const struct player *pplayer, int city_id)
Definition player.c:1191
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
#define CLIP(lower, current, upper)
Definition shared.h:57
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define FC_INFINITY
Definition shared.h:36
size_t size
Definition specvec.h:72
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
#define strvec_iterate(psv, str)
#define strvec_iterate_end
cairo_surface_t * surface
Definition canvas.h:23
GtkWidget * prev_command
Definition citydlg.c:208
GtkWidget * name_label
Definition citydlg.c:141
GtkWidget * rename_shell
Definition citydlg.c:205
GtkWidget * rename_command
Definition citydlg.c:196
GtkWidget * production_bar
Definition citydlg.c:152
GtkWidget * supported_units_frame
Definition citydlg.c:157
GtkWidget * sell_shell
Definition citydlg.c:203
GtkWidget * production_label
Definition citydlg.c:173
GtkWidget * widget
Definition citydlg.c:182
GtkWidget * supported_unit_table
Definition citydlg.c:158
GtkWidget * disband_on_settler
Definition citydlg.c:198
struct city_map_canvas map_canvas
Definition citydlg.c:150
enum city_dialog::@217 page
GtkWidget * improvement_list
Definition citydlg.c:155
GtkWidget * container
Definition citydlg.c:189
GtkWidget * buy_command
Definition citydlg.c:154
short block_signal
Definition citydlg.c:200
GtkWidget * whichtab_radio[NUM_PAGES]
Definition citydlg.c:199
struct unit_node_vector supported_units
Definition citydlg.c:163
cairo_surface_t * map_canvas_store_unscaled
Definition citydlg.c:142
struct city * pcity
Definition citydlg.c:138
struct city_dialog::@148 happiness
struct unit_node_vector present_units
Definition citydlg.c:164
city_map * view
Definition citydlg.h:446
GtkWidget * popover
Definition citydlg.c:147
GtkWidget * citizen_pics
Definition citydlg.c:148
GtkWidget * citizens
Definition citydlg.c:185
GtkWidget * show_units_command
Definition citydlg.c:207
Impr_type_id sell_id
Definition citydlg.c:211
GtkWidget * production_combo
Definition citydlg.c:153
struct city_dialog::@150 misc
GtkBox * container
Definition citydlg.c:189
struct cma_dialog * cma_editor
Definition citydlg.c:193
cairo_surface_t * citizen_surface
Definition citydlg.c:147
GtkWidget * shell
Definition citydlg.c:140
GtkWidget * worklist
Definition citydlg.c:176
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
struct city_dialog::@149 counters
GtkWidget * notebook
Definition citydlg.c:143
struct city_dialog::@146 overview
GtkWidget * next_command
Definition citydlg.c:209
GtkTreeSelection * change_selection
Definition citydlg.c:204
struct city_dialog::@147 production
GtkWidget * darea
Definition citydlg.c:134
GtkWidget * sw
Definition citydlg.c:132
Definition city.h:318
int * counter_values
Definition city.h:406
struct unit_list * info_units_present
Definition city.h:474
struct unit_list * info_units_supported
Definition city.h:473
citizens size
Definition city.h:330
int illness
Definition city.h:432
int buy_cost
Definition city.h:466
struct city::@18::@21 client
struct tile * tile
Definition city.h:320
struct unit_list * units_supported
Definition city.h:404
struct packet_game_info info
Definition game.h:89
struct connection conn
Definition client_main.h:96
GtkWidget * shell
Definition cma_fe.h:33
struct city * pcity
Definition cma_fe.h:32
struct player * playing
Definition connection.h:151
Definition climisc.h:82
struct universal item
Definition climisc.h:83
char descr[MAX_LEN_NAME+40]
Definition climisc.h:84
enum unit_activity activity
struct city_list * cities
Definition player.h:281
Definition tile.h:50
int index
Definition tile.h:51
struct unit_list * units
Definition tile.h:58
int height
Definition citydlg.c:98
GtkEventController * right
Definition citydlg.c:101
GtkWidget * cmd
Definition citydlg.c:96
GtkWidget * pix
Definition citydlg.c:97
GtkEventController * middle
Definition citydlg.c:100
GtkEventController * left
Definition citydlg.c:99
Definition unit.h:140
int upkeep[O_LAST]
Definition unit.h:150
enum unit_activity activity
Definition unit.h:159
int id
Definition unit.h:147
struct tile * tile
Definition unit.h:142
struct unit::@84::@86 client
int homecity
Definition unit.h:148
struct player * owner
Definition unit.h:145
enum universals_n kind
Definition fc_types.h:595
universals_u value
Definition fc_types.h:594
struct tile * ptile
Definition workertask.h:22
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
const char * unit_description(struct unit *punit)
Definition text.c:528
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
#define tile_terrain(_tile)
Definition tile.h:115
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7033
int tileset_small_sprite_width(const struct tileset *t)
Definition tilespec.c:927
int tileset_full_tile_height(const struct tileset *t)
Definition tilespec.c:815
int tileset_small_sprite_height(const struct tileset *t)
Definition tilespec.c:963
int tileset_unit_with_upkeep_height(const struct tileset *t)
Definition tilespec.c:885
struct sprite * get_citizen_sprite(const struct tileset *t, enum citizen_category type, int citizen_index, const struct city *pcity)
Definition tilespec.c:6972
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7055
const struct unit_type * utype
Definition fc_types.h:536
const struct impr_type * building
Definition fc_types.h:529
bool can_unit_change_homecity_to(const struct civ_map *nmap, const struct unit *punit, const struct city *pcity)
Definition unit.c:508
struct unit * unit_transport_get(const struct unit *pcargo)
Definition unit.c:2525
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Definition unit.c:402
bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
Definition unit.c:793
#define unit_tile(_pu)
Definition unit.h:408
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:126
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1729
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1586
void economy_report_dialog_update(void)
bool worklist_is_empty(const struct worklist *pwl)
Definition worklist.c:66