Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-5.0/cityrep.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
cityrep.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 "fcintl.h"
27#include "log.h"
28#include "shared.h"
29#include "support.h"
30
31/* common */
32#include "city.h"
33#include "game.h"
34#include "packets.h"
35#include "unit.h"
36
37/* client/agents */
38#include "cma_fec.h"
39
40/* client */
41#include "citydlg_common.h"
42#include "cityrepdata.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "global_worklist.h"
46#include "mapctrl_common.h" /* is_city_hilited() */
47#include "mapview_common.h"
48#include "options.h"
49
50/* client/gui-gtk-5.0 */
51#include "chatline.h"
52#include "citydlg.h"
53#include "gui_main.h"
54#include "gui_stuff.h"
55#include "mapview.h"
56#include "optiondlg.h"
57#include "repodlgs.h"
58
59#include "cityrep.h"
60
61#define NEG_VAL(x) ((x)<0 ? (x) : (-x))
62
63/* Some versions of gcc have problems with negative values here (PR#39722). */
64#define CMA_NONE (10000)
65#define CMA_CUSTOM (10001)
66
67struct sell_data {
68 int count; /* Number of cities. */
69 int gold; /* Amount of gold. */
70 const struct impr_type *target; /* The target for selling. */
71};
72
73 enum city_operation_type {
74 CO_CHANGE, CO_LAST, CO_NEXT, CO_FIRST, CO_NEXT_TO_LAST, CO_SELL, CO_NONE
75};
76
77/******************************************************************/
78static void create_city_report_dialog(bool make_modal);
79
80static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
81 GtkTreeViewColumn *col, gpointer data);
82
83static void city_command_callback(struct gui_dialog *dlg, int response,
84 gpointer data);
85
86static void city_selection_changed_callback(GtkTreeSelection *selection);
87static void city_clear_worklist_callback(GSimpleAction *action, GVariant *parameter,
88 gpointer data);
89static void update_total_buy_cost(void);
90
91static GMenu *create_production_menu(GActionGroup *group);
92static GMenu *create_select_menu(GActionGroup *group);
93
94static GMenu *create_change_menu(GActionGroup *group, const char *mname,
95 const char *human_mname,
96 enum city_operation_type oper);
97
98 static struct gui_dialog *city_dialog_shell = NULL;
99
100enum {
101 CITY_CENTER = 1, CITY_POPUP, CITY_BUY
102};
103
104 static GtkWidget *city_view;
105 static GtkTreeSelection *city_selection;
106 static GtkListStore *city_model;
107#define CRD_COL_CITY_ID (0 + NUM_CREPORT_COLS)
108
109#ifdef MENUS_GTK3
110static void popup_select_menu(GtkMenuShell *menu, gpointer data);
111#endif /* MENUS_GTK3 */
112
113static void recreate_production_menu(GActionGroup *group);
114static void recreate_select_menu(GActionGroup *group);
115static void recreate_sell_menu(GActionGroup *group);
116
117 static GtkWidget *city_center_command;
118 static GtkWidget *city_popup_command;
119 static GtkWidget *city_buy_command;
120#ifdef MENUS_GTK3
121static GtkWidget *city_sell_command;
122#endif /* MENUS_GTK3 */
123 static GtkWidget *city_total_buy_cost_label;
124
125 static GMenu *prod_menu = NULL;
126 static GMenu *change_menu;
127 static GMenu *add_first_menu;
128 static GMenu *add_last_menu;
129 static GMenu *add_next_menu;
130 static GMenu *add_2ndlast_menu;
131 static GMenu *wl_set_menu;
132 static GMenu *wl_append_menu;
133
134 static GMenu *select_menu;
135 static GMenu *unit_b_select_menu = NULL;
136 static GMenu *impr_b_select_menu;
137 static GMenu *wndr_b_select_menu;
138 static GMenu *unit_s_select_menu;
139 static GMenu *unit_p_select_menu;
140 static GMenu *impr_p_select_menu;
141 static GMenu *wndr_p_select_menu;
142 static GMenu *unit_a_select_menu;
143 static GMenu *impr_a_select_menu;
144 static GMenu *wndr_a_select_menu;
145 static GMenu *governor_select_menu;
146
147 static int city_dialog_shell_is_modal;
148
149 static GMenu *cityrep_menu;
150 static GActionGroup *cityrep_group;
151 static GMenu *display_menu;
152
153/************************************************************************/
156 static void get_city_table_header(char **text, int n)
157{
158 struct city_report_spec *spec;
159 int i;
160
161 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
162 fc_snprintf(text[i], n, "%*s\n%*s",
163 NEG_VAL(spec->width), spec->title1 ? spec->title1 : "",
164 NEG_VAL(spec->width), spec->title2 ? spec->title2 : "");
165 }
166}
167
168/****************************************************************************
169 CITY REPORT DIALOG
170****************************************************************************/
171
172/************************************************************************/
175 static GtkListStore *city_report_dialog_store_new(void)
176{
177 GType model_types[NUM_CREPORT_COLS + 1];
178 gint i;
179
180 /* City report data. */
181 for (i = 0; i < NUM_CREPORT_COLS; i++) {
182 model_types[i] = G_TYPE_STRING;
183 }
184
185 /* Specific gtk client data. */
186 model_types[i++] = G_TYPE_INT; /* CRD_COL_CITY_ID */
187
188 return gtk_list_store_newv(i, model_types);
189}
190
191/************************************************************************/
194 static void city_model_set(GtkListStore *store, GtkTreeIter *iter,
195 struct city *pcity)
196{
197 struct city_report_spec *spec;
198 char buf[64];
199 gint i;
200
201 for (i = 0; i < NUM_CREPORT_COLS; i++) {
202 spec = city_report_specs + i;
203 fc_snprintf(buf, sizeof(buf), "%*s", NEG_VAL(spec->width),
204 spec->func(pcity, spec->data));
205 gtk_list_store_set(store, iter, i, buf, -1);
206 }
207 gtk_list_store_set(store, iter, CRD_COL_CITY_ID, pcity->id, -1);
208}
209
210/************************************************************************/
213 static struct city *city_model_get(GtkTreeModel *model, GtkTreeIter *iter)
214{
215 struct city *pcity;
216 int id;
217
218 gtk_tree_model_get(model, iter, CRD_COL_CITY_ID, &id, -1);
219 pcity = game_city_by_number(id);
220 return ((NULL != pcity
221 && client_has_player()
222 && city_owner(pcity) != client_player())
223 ? NULL : pcity);
224}
225
226/************************************************************************/
229 static gboolean city_model_find(GtkTreeModel *model, GtkTreeIter *iter,
230 const struct city *pcity)
231{
232 const int searched = pcity->id;
233 int id;
234
235 if (gtk_tree_model_get_iter_first(model, iter)) {
236 do {
237 gtk_tree_model_get(model, iter, CRD_COL_CITY_ID, &id, -1);
238 if (searched == id) {
239 return TRUE;
240 }
241 } while (gtk_tree_model_iter_next(model, iter));
242 }
243 return FALSE;
244}
245
246/************************************************************************/
249 static void city_model_fill(GtkListStore *store,
250 GtkTreeSelection *selection, GHashTable *select)
251{
252 GtkTreeIter iter;
253
254 if (client_has_player()) {
255 city_list_iterate(client_player()->cities, pcity) {
256 gtk_list_store_append(store, &iter);
257 city_model_set(store, &iter, pcity);
258 if (NULL != select
259 && g_hash_table_remove(select, GINT_TO_POINTER(pcity->id))) {
260 gtk_tree_selection_select_iter(selection, &iter);
261 }
262 } city_list_iterate_end;
263 } else {
264 /* Global observer case. */
265 cities_iterate(pcity) {
266 gtk_list_store_append(store, &iter);
267 city_model_set(store, &iter, pcity);
268 if (NULL != select
269 && g_hash_table_remove(select, GINT_TO_POINTER(pcity->id))) {
270 gtk_tree_selection_select_iter(selection, &iter);
271 }
272 } cities_iterate_end;
273 }
274}
275
276/************************************************************************/
279 void city_report_dialog_popup(bool raise)
280{
281 if (!city_dialog_shell) {
282 city_dialog_shell_is_modal = FALSE;
283
284 create_city_report_dialog(FALSE);
285 }
286
287 gui_dialog_present(city_dialog_shell);
288 hilite_cities_from_canvas();
289 if (raise) {
290 gui_dialog_raise(city_dialog_shell);
291 }
292}
293
294/************************************************************************/
297 void city_report_dialog_popdown(void)
298{
299 if (city_dialog_shell) {
300 gui_dialog_destroy(city_dialog_shell);
301 }
302}
303
304/************************************************************************/
307 static void append_impr_or_unit_to_menu(GMenu *menu,
308 GActionGroup *act_group,
309 const char *act_pfx,
310 const char *act_pfx2,
311 bool append_units,
312 bool append_wonders,
313 enum city_operation_type
314 city_operation,
315 TestCityFunc test_func,
316 GCallback callback,
317 int size)
318{
319 struct universal targets[MAX_NUM_PRODUCTION_TARGETS];
320 struct item items[MAX_NUM_PRODUCTION_TARGETS];
321 int i, item, targets_used;
322 char *row[4];
323 char buf[4][64];
324
325 GtkSizeGroup *size_group[3];
326
327#ifdef MENUS_GTK3
328 const char *markup[3] = {
329 "weight=\"bold\"",
330 "",
331 ""
332 };
333#endif
334
335 if (city_operation != CO_NONE) {
336 GPtrArray *selected;
337 ITree it;
338 int num_selected = 0;
339 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
340 struct city **data;
341
342 selected = g_ptr_array_sized_new(size);
343
344 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
345 struct city *pcity;
346
347 if (!itree_is_selected(city_selection, &it)
348 || !(pcity = city_model_get(model, TREE_ITER_PTR(it)))) {
349 continue;
350 }
351
352 g_ptr_array_add(selected, pcity);
353 num_selected++;
354 }
355
356 data = (struct city **)g_ptr_array_free(selected, FALSE);
357 targets_used
358 = collect_production_targets(targets, data, num_selected, append_units,
359 append_wonders, TRUE, test_func);
360 g_free(data);
361 } else {
362 targets_used = collect_production_targets(targets, NULL, 0, append_units,
363 append_wonders, FALSE,
364 test_func);
365 }
366
367 name_and_sort_items(targets, targets_used, items,
368 city_operation != CO_NONE, NULL);
369
370 for (i = 0; i < 4; i++) {
371 row[i] = buf[i];
372 }
373
374
375 for (i = 0; i < 3; i++) {
376 size_group[i] = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
377 }
378
379 for (item = 0; item < targets_used; item++) {
380 struct universal target = items[item].item;
381 GMenuItem *menu_item;
382 char actbuf[256];
383 GSimpleAction *act;
384#ifdef MENUS_GTK3
385 char txt[256];
386 GtkWidget *hgrid, *label;
387 int grid_col = 0;
388#endif /* MENUS_GTK3 */
389
390 get_city_dialog_production_row(row, sizeof(buf[0]), &target, NULL);
391
392 fc_snprintf(actbuf, sizeof(actbuf), "win.%s%s%d", act_pfx, act_pfx2, item);
393
394 menu_item = g_menu_item_new(buf[0], actbuf);
395
396 fc_snprintf(actbuf, sizeof(actbuf), "%s%s%d", act_pfx, act_pfx2, item);
397 act = g_simple_action_new(actbuf, NULL);
398 g_object_set_data(G_OBJECT(act), "freeciv_test_func", test_func);
399 g_object_set_data(G_OBJECT(act), "freeciv_city_operation",
400 GINT_TO_POINTER(city_operation));
401 g_action_map_add_action(G_ACTION_MAP(act_group), G_ACTION(act));
402 g_signal_connect(act, "activate", callback,
403 GINT_TO_POINTER(cid_encode(target)));
404 menu_item_append_unref(menu, menu_item);
405
406#ifdef MENUS_GTK3
407 hgrid = gtk_grid_new();
408 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 18);
409 gtk_container_add(GTK_CONTAINER(menu_item), hgrid);
410
411 for (i = 0; i < 3; i++) {
412 if (row[i][0] == '\0') {
413 continue;
414 }
415
416 if (city_operation == CO_SELL && i != 0) {
417 continue;
418 }
419
420 fc_snprintf(txt, ARRAY_SIZE(txt), "<span %s>%s</span>",
421 markup[i], row[i]);
422
423 label = gtk_label_new(NULL);
424 gtk_label_set_markup(GTK_LABEL(label), txt);
425
426 switch (i) {
427 case 0:
428 gtk_widget_set_halign(label, GTK_ALIGN_START);
429 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
430 break;
431 case 2:
432 gtk_widget_set_halign(label, GTK_ALIGN_END);
433 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
434 break;
435 default:
436 break;
437 }
438
439 gtk_grid_attach(GTK_GRID(hgrid), label, grid_col++, 0, 1, 1);
440 gtk_size_group_add_widget(size_group[i], label);
441 }
442
443 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
444 g_signal_connect(menu_item, "activate", callback,
445 GINT_TO_POINTER(cid_encode(target)));
446#endif /* MENUS_GTK3 */
447 }
448
449 for (i = 0; i < 3; i++) {
450 g_object_unref(size_group[i]);
451 }
452
453#ifdef MENUS_GTK3
454 gtk_widget_set_sensitive(GTK_WIDGET(parent_item), (targets_used > 0));
455#endif
456}
457
458/************************************************************************/
461 static void impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path,
462 GtkTreeIter *iter, gpointer data)
463{
464 struct universal target = cid_decode(GPOINTER_TO_INT(data));
465 struct city *pcity = city_model_get(model, iter);
466
467 if (NULL != pcity) {
468 city_change_production(pcity, &target);
469 }
470}
471
472/************************************************************************/
477 static void worklist_last_impr_or_unit_iterate(GtkTreeModel *model,
478 GtkTreePath *path,
479 GtkTreeIter *iter,
480 gpointer data)
481{
482 struct universal target = cid_decode(GPOINTER_TO_INT(data));
483 struct city *pcity = city_model_get(model, iter);
484
485 if (NULL != pcity) {
486 (void) city_queue_insert(pcity, -1, &target);
487 }
488 /* Perhaps should warn the user if not successful? */
489}
490
491/************************************************************************/
498 static void worklist_first_impr_or_unit_iterate(GtkTreeModel *model,
499 GtkTreePath *path,
500 GtkTreeIter *iter,
501 gpointer data)
502{
503 struct universal target = cid_decode(GPOINTER_TO_INT(data));
504 struct city *pcity = city_model_get(model, iter);
505
506 if (NULL != pcity) {
507 (void) city_queue_insert(pcity, 0, &target);
508 }
509 /* Perhaps should warn the user if not successful? */
510}
511
512/************************************************************************/
518 static void worklist_next_impr_or_unit_iterate(GtkTreeModel *model,
519 GtkTreePath *path,
520 GtkTreeIter *iter,
521 gpointer data)
522{
523 struct universal target = cid_decode(GPOINTER_TO_INT(data));
524 struct city *pcity = city_model_get(model, iter);
525
526 if (NULL != pcity) {
527 (void) city_queue_insert(pcity, 1, &target);
528 }
529 /* Perhaps should warn the user if not successful? */
530}
531
532/************************************************************************/
537 static void worklist_next_to_last_impr_or_unit_iterate(GtkTreeModel *model,
538 GtkTreePath *path,
539 GtkTreeIter *iter,
540 gpointer data)
541{
542 struct universal target = cid_decode(GPOINTER_TO_INT(data));
543 struct city *pcity = city_model_get(model, iter);
544
545 if (NULL != pcity) {
546 city_queue_insert(pcity, worklist_length(&pcity->worklist), &target);
547 }
548}
549
550/************************************************************************/
553 static void sell_impr_iterate(GtkTreeModel *model, GtkTreePath *path,
554 GtkTreeIter *iter, gpointer data)
555{
556 struct sell_data *sd = (struct sell_data *) data;
557 struct city *pcity = city_model_get(model, iter);
558
559 if (NULL != pcity
560 && !pcity->did_sell
561 && city_has_building(pcity, sd->target)) {
562 sd->count++;
563 sd->gold += impr_sell_gold(sd->target);
564 city_sell_improvement(pcity, improvement_number(sd->target));
565 }
566}
567
568 struct scbs_data {
569 const struct impr_type *building;
570 const char *imprname;
571};
572
573/************************************************************************/
576 static void sell_callback_response(GObject *dialog, GAsyncResult *result,
577 gpointer data)
578{
579 int button = gtk_alert_dialog_choose_finish(GTK_ALERT_DIALOG(dialog),
580 result, NULL);
581
582 if (button == 0) {
583 struct scbs_data *scbs = (struct scbs_data *)data;
584 struct sell_data sd = { 0, 0, scbs->building };
585 GtkWidget *w;
586
587 gtk_tree_selection_selected_foreach(city_selection,
588 sell_impr_iterate, &sd);
589 if (sd.count > 0) {
590 /* FIXME: plurality of sd.count is ignored! */
591 /* TRANS: "Sold 3 Harbor for 90 gold." (Pluralisation is in gold --
592 * second %d -- not in buildings.) */
593 w = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
594 GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
595 PL_("Sold %d %s for %d gold.",
596 "Sold %d %s for %d gold.",
597 sd.gold),
598 sd.count, scbs->imprname, sd.gold);
599 } else {
600 w = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
601 GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
602 _("No %s could be sold."),
603 scbs->imprname);
604 }
605
606 g_signal_connect(w, "response",
607 G_CALLBACK(gtk_window_destroy), NULL);
608 gtk_window_present(GTK_WINDOW(w)); /* Asynchron. */
609 }
610
611 free(data);
612}
613
614/************************************************************************/
618 static void select_impr_or_unit_callback(GSimpleAction *action,
619 GVariant *parameter,
620 gpointer data)
621{
622 struct universal target = cid_decode(GPOINTER_TO_INT(data));
623 TestCityFunc test_func = g_object_get_data(G_OBJECT(action), "freeciv_test_func");
624 enum city_operation_type city_operation =
625 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "freeciv_city_operation"));
626
627 /* If this is not a city operation: */
628 if (city_operation == CO_NONE) {
629 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
630 ITree it;
631
632 gtk_tree_selection_unselect_all(city_selection);
633 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
634 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
635
636 if (NULL != pcity && test_func(pcity, &target)) {
637 itree_select(city_selection, &it);
638 }
639 }
640 } else {
641 GtkTreeSelectionForeachFunc foreach_func;
642
643 connection_do_buffer(&client.conn);
644 switch (city_operation) {
645 case CO_LAST:
646 gtk_tree_selection_selected_foreach(city_selection,
647 worklist_last_impr_or_unit_iterate,
648 GINT_TO_POINTER(cid_encode(target)));
649 break;
650 case CO_CHANGE:
651 gtk_tree_selection_selected_foreach(city_selection,
652 impr_or_unit_iterate,
653 GINT_TO_POINTER(cid_encode(target)));
654 break;
655 case CO_FIRST:
656 gtk_tree_selection_selected_foreach(city_selection,
657 worklist_first_impr_or_unit_iterate,
658 GINT_TO_POINTER(cid_encode(target)));
659 break;
660 case CO_NEXT:
661 gtk_tree_selection_selected_foreach(city_selection,
662 worklist_next_impr_or_unit_iterate,
663 GINT_TO_POINTER(cid_encode(target)));
664 break;
665 case CO_NEXT_TO_LAST:
666 foreach_func = worklist_next_to_last_impr_or_unit_iterate;
667 gtk_tree_selection_selected_foreach(city_selection, foreach_func,
668 GINT_TO_POINTER(cid_encode(target)));
669 break;
670 case CO_SELL:
671 fc_assert_action(target.kind == VUT_IMPROVEMENT, break);
672 {
673 struct scbs_data *scbs = fc_malloc(sizeof(struct scbs_data));
674 GtkAlertDialog *w;
675 gchar *buf;
676 const char *buttons[] = { _("Yes"), _("No"), NULL };
677
678 scbs->building = target.value.building;
679 scbs->imprname = improvement_name_translation(scbs->building);
680
681 /* Ask confirmation */
682 buf = g_strdup_printf(_("Are you sure you want to sell those %s?"), scbs->imprname);
683 w = gtk_alert_dialog_new("%s", buf);
684 g_free(buf);
685 gtk_alert_dialog_set_buttons(w, buttons);
686 gtk_alert_dialog_set_modal(w, TRUE);
687 gtk_alert_dialog_choose(w, GTK_WINDOW(toplevel), NULL,
688 sell_callback_response, scbs);
689 }
690 break;
691 case CO_NONE:
692 break;
693 }
694 connection_do_unbuffer(&client.conn);
695 }
696}
697
698/************************************************************************/
701 static void governors_iterate(GtkTreeModel *model, GtkTreePath *path,
702 GtkTreeIter *iter, gpointer data)
703{
704 struct city *pcity = city_model_get(model, iter);
705 int idx = GPOINTER_TO_INT(data);
706
707 if (NULL != pcity) {
708 if (CMA_NONE == idx) {
709 cma_release_city(pcity);
710 } else {
711 cma_put_city_under_agent(pcity, cmafec_preset_get_parameter(idx));
712 }
713 refresh_city_dialog(pcity);
714 }
715}
716
717/************************************************************************/
721 static void select_governor_callback(GSimpleAction *action,
722 GVariant *parameter,
723 gpointer data)
724{
725 int idx = GPOINTER_TO_INT(data);
726 bool change_governor =
727 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "governor"));
728 struct cm_parameter cm;
729
730 /* If this is not the change button but the select cities button. */
731 if (!change_governor) {
732 ITree it;
733 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
734
735 gtk_tree_selection_unselect_all(city_selection);
736 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
737 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
738 int controlled;
739 bool select;
740
741 if (NULL == pcity) {
742 continue;
743 }
744 controlled = cma_is_city_under_agent(pcity, &cm);
745 select = FALSE;
746
747 if (idx == CMA_NONE) {
748 /* CMA_NONE selects not-controlled, all others require controlled */
749 if (!controlled) {
750 select = TRUE;
751 }
752 } else if (controlled) {
753 if (idx == CMA_CUSTOM) {
754 if (cmafec_preset_get_index_of_parameter(&cm) == -1) {
755 select = TRUE;
756 }
757 } else if (cm_are_parameter_equal(&cm,
758 cmafec_preset_get_parameter(idx))) {
759 select = TRUE;
760 }
761 }
762
763 if (select) {
764 itree_select(city_selection, &it);
765 }
766 }
767 } else {
768 gtk_tree_selection_selected_foreach(city_selection,
769 governors_iterate,
770 GINT_TO_POINTER(idx));
771 }
772}
773
774/************************************************************************/
780 static GMenu *create_governor_menu(GActionGroup *group,
781 bool change_governor)
782{
783 GMenu *menu;
784 int i;
785 struct cm_parameter cm;
786
787 menu = g_menu_new();
788
789 if (!can_client_issue_orders()) {
790 return menu;
791 }
792
793 if (change_governor) {
794 GSimpleAction *act;
795
796 act = g_simple_action_new("chg_governor_none", NULL);
797 g_object_set_data(G_OBJECT(act), "governor",
798 GINT_TO_POINTER(change_governor));
799 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
800 g_signal_connect(act, "activate", G_CALLBACK(select_governor_callback),
801 GINT_TO_POINTER(CMA_NONE));
802 menu_item_append_unref(menu,
803 g_menu_item_new(Q_("?cma:none"),
804 "win.chg_governor_none"));
805
806 for (i = 0; i < cmafec_preset_num(); i++) {
807 char buf[128];
808
809 fc_snprintf(buf, sizeof(buf), "chg_governor_%d", i);
810 act = g_simple_action_new(buf, NULL);
811 g_object_set_data(G_OBJECT(act), "governor",
812 GINT_TO_POINTER(change_governor));
813 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
814 g_signal_connect(act, "activate", G_CALLBACK(select_governor_callback),
815 GINT_TO_POINTER(i));
816 fc_snprintf(buf, sizeof(buf), "win.chg_governor_%d", i);
817 menu_item_append_unref(menu,
818 g_menu_item_new(cmafec_preset_get_descr(i), buf));
819 }
820 } else {
821 /* Search for a "none" */
822 bool found;
823
824 found = FALSE;
825 city_list_iterate(client.conn.playing->cities, pcity) {
826 if (!cma_is_city_under_agent(pcity, NULL)) {
827 found = TRUE;
828 break;
829 }
830 } city_list_iterate_end;
831
832 if (found) {
833 GSimpleAction *act;
834
835 act = g_simple_action_new("sel_governor_none", NULL);
836 g_object_set_data(G_OBJECT(act), "governor",
837 GINT_TO_POINTER(change_governor));
838 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
839 g_signal_connect(act, "activate", G_CALLBACK(select_governor_callback),
840 GINT_TO_POINTER(CMA_NONE));
841 menu_item_append_unref(menu,
842 g_menu_item_new(Q_("?cma:none"),
843 "win.sel_governor_none"));
844 }
845
846 /*
847 * Search for a city that's under custom (not preset) agent. Might
848 * take a lonnggg time.
849 */
850 found = FALSE;
851 city_list_iterate(client.conn.playing->cities, pcity) {
852 if (cma_is_city_under_agent(pcity, &cm)
853 && cmafec_preset_get_index_of_parameter(&cm) == -1) {
854 found = TRUE;
855 break;
856 }
857 } city_list_iterate_end;
858
859 if (found) {
860 /* We found city that's under agent but not a preset */
861 GSimpleAction *act;
862
863 act = g_simple_action_new("sel_governor_custom", NULL);
864 g_object_set_data(G_OBJECT(act), "governor",
865 GINT_TO_POINTER(change_governor));
866 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
867 g_signal_connect(act, "activate", G_CALLBACK(select_governor_callback),
868 GINT_TO_POINTER(CMA_CUSTOM));
869 menu_item_append_unref(menu,
870 g_menu_item_new(Q_("?cma:custom"),
871 "win.sel_governor_custom"));
872 }
873
874 /* Only fill in presets that are being used. */
875 for (i = 0; i < cmafec_preset_num(); i++) {
876 found = FALSE;
877 city_list_iterate(client.conn.playing->cities, pcity) {
878 if (cma_is_city_under_agent(pcity, &cm)
879 && cm_are_parameter_equal(&cm,
880 cmafec_preset_get_parameter(i))) {
881 found = TRUE;
882 break;
883 }
884 } city_list_iterate_end;
885
886 if (found) {
887 GSimpleAction *act;
888 char buf[128];
889
890 fc_snprintf(buf, sizeof(buf), "sel_governor_%d", i);
891
892 act = g_simple_action_new(buf, NULL);
893 g_object_set_data(G_OBJECT(act), "governor",
894 GINT_TO_POINTER(change_governor));
895 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
896 g_signal_connect(act, "activate", G_CALLBACK(select_governor_callback),
897 GINT_TO_POINTER(i));
898 fc_snprintf(buf, sizeof(buf), "win.sel_governor_%d", i);
899 menu_item_append_unref(menu,
900 g_menu_item_new(cmafec_preset_get_descr(i),
901 buf));
902 }
903 }
904 }
905
906 return menu;
907}
908
909/************************************************************************/
912 static void update_governor_menu(void)
913{
914 g_menu_remove(cityrep_menu, 1);
915 submenu_insert_unref(cityrep_menu, 1, _("Gover_nor"),
916 G_MENU_MODEL(create_governor_menu(cityrep_group, TRUE)));
917}
918
919/************************************************************************/
924 static void append_worklist_foreach(GtkTreeModel *model, GtkTreePath *path,
925 GtkTreeIter *iter, gpointer data)
926{
927 const struct worklist *pwl = data;
928 struct city *pcity = city_model_get(model, iter);
929
930 fc_assert_ret(pwl != NULL);
931
932 if (NULL != pcity) {
933 city_queue_insert_worklist(pcity, -1, pwl);
934 }
935}
936
937/************************************************************************/
942 static void append_worklist_callback(GSimpleAction *action,
943 GVariant *parameter,
944 gpointer data)
945{
946 struct global_worklist *pgwl =
947 global_worklist_by_id(GPOINTER_TO_INT(data));
948
949 fc_assert_ret(city_selection != NULL);
950
951 if (!pgwl) {
952 /* Maybe removed by an other way, not an error. */
953 return;
954 }
955
956 gtk_tree_selection_selected_foreach(city_selection,
957 append_worklist_foreach,
958 (gpointer) global_worklist_get(pgwl));
959}
960
961/************************************************************************/
965 static void set_worklist_foreach(GtkTreeModel *model, GtkTreePath *path,
966 GtkTreeIter *iter, gpointer data)
967{
968 const struct worklist *pwl = data;
969 struct city *pcity = city_model_get(model, iter);
970
971 fc_assert_ret(pwl != NULL);
972
973 if (NULL != pcity) {
974 city_set_queue(pcity, pwl);
975 }
976}
977
978/************************************************************************/
982 static void set_worklist_callback(GSimpleAction *action,
983 GVariant *parameter,
984 gpointer data)
985{
986 struct global_worklist *pgwl =
987 global_worklist_by_id(GPOINTER_TO_INT(data));
988
989 fc_assert_ret(city_selection != NULL);
990 gtk_tree_selection_selected_foreach(city_selection, set_worklist_foreach,
991 (gpointer) global_worklist_get(pgwl));
992
993 if (!pgwl) {
994 /* Maybe removed by an other way, not an error. */
995 return;
996 }
997
998 gtk_tree_selection_selected_foreach(city_selection,
999 set_worklist_foreach,
1000 (gpointer) global_worklist_get(pgwl));
1001}
1002
1003/************************************************************************/
1006 static GMenu *create_wl_menu(GActionGroup *group, const char *act_pfx,
1007 GCallback cb)
1008{
1009 GMenu *menu;
1010 GSimpleAction *act;
1011 int count = 0;
1012
1013 menu = g_menu_new();
1014
1015 if (!can_client_issue_orders()) {
1016 return NULL;
1017 }
1018
1019 global_worklists_iterate(pgwl) {
1020 char buf[128];
1021
1022 fc_snprintf(buf, sizeof(buf), "wl%s%d", act_pfx, count);
1023 act = g_simple_action_new(buf, NULL);
1024 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1025 g_signal_connect(act, "activate", cb,
1026 GINT_TO_POINTER(global_worklist_id(pgwl)));
1027 fc_snprintf(buf, sizeof(buf), "win.wl%s%d", act_pfx, count);
1028 menu_item_append_unref(menu,
1029 g_menu_item_new(global_worklist_name(pgwl),
1030 buf));
1031 count++;
1032 } global_worklists_iterate_end;
1033
1034 if (count == 0) {
1035 char buf[64];
1036
1037 fc_snprintf(buf, sizeof(buf), "win.wl%s_dummy", act_pfx);
1038 menu_item_append_unref(menu,
1039 g_menu_item_new(_("(no worklists defined)"), buf));
1040 }
1041
1042 return menu;
1043}
1044
1045/************************************************************************/
1048 static void city_report_update_views(void)
1049{
1050 struct city_report_spec *spec;
1051 GtkTreeView *view;
1052 GtkTreeViewColumn *col;
1053 GList *columns, *p;
1054
1055 view = GTK_TREE_VIEW(city_view);
1056 fc_assert_ret(view != NULL);
1057
1058 columns = gtk_tree_view_get_columns(view);
1059
1060 for (p = columns; p != NULL; p = p->next) {
1061 col = p->data;
1062 spec = g_object_get_data(G_OBJECT(col), "city_report_spec");
1063 gtk_tree_view_column_set_visible(col, spec->show);
1064 }
1065
1066 g_list_free(columns);
1067}
1068
1069/************************************************************************/
1073 static GMenuItem *create_display_menu_item(int pos)
1074{
1075 GMenuItem *item;
1076 char act_name[50];
1077 struct city_report_spec *spec = city_report_specs + pos;
1078
1079 fc_snprintf(act_name, sizeof(act_name), "win.display%d(%s)",
1080 pos, spec->show ? "true" : "false");
1081 item = g_menu_item_new(spec->explanation, NULL);
1082 g_menu_item_set_detailed_action(item, act_name);
1083
1084 return item;
1085}
1086
1087/************************************************************************/
1090 static void toggle_view(GSimpleAction *act, GVariant *value, gpointer data)
1091{
1092 struct city_report_spec *spec = data;
1093 int idx = spec - city_report_specs;
1094
1095 spec->show ^= 1;
1096 city_report_update_views();
1097
1098 g_menu_remove(display_menu, idx);
1099 menu_item_insert_unref(display_menu, idx, create_display_menu_item(idx));
1100}
1101
1102/************************************************************************/
1105 static GMenu *create_display_menu(GActionGroup *group)
1106{
1107 struct city_report_spec *spec;
1108 int i;
1109 GVariantType *bvart = g_variant_type_new("b");
1110
1111 display_menu = g_menu_new();
1112 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
1113 GSimpleAction *act;
1114 char act_name[50];
1115 GVariant *var = g_variant_new("b", TRUE);
1116
1117 fc_snprintf(act_name, sizeof(act_name), "display%d", i);
1118 act = g_simple_action_new_stateful(act_name, bvart, var);
1119 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1120 g_signal_connect(act, "change-state", G_CALLBACK(toggle_view), (gpointer)spec);
1121
1122 menu_item_insert_unref(display_menu, i, create_display_menu_item(i));
1123 }
1124
1125 g_variant_type_free(bvart);
1126
1127 return display_menu;
1128}
1129
1130/************************************************************************/
1133 static GtkWidget *create_city_report_menu(void)
1134{
1135 GtkWidget *vbox, *sep;
1136 GtkWidget *aux_menu;
1137 GMenu *submenu;
1138
1139 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
1140 sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
1141 gtk_box_append(GTK_BOX(vbox), sep);
1142
1143 aux_menu = aux_menu_new();
1144 cityrep_group = G_ACTION_GROUP(g_simple_action_group_new());
1145
1146 cityrep_menu = g_menu_new();
1147
1148 /* Placeholder */
1149 submenu_append_unref(cityrep_menu, _("_Production"),
1150 G_MENU_MODEL(g_menu_new()));
1151
1152 submenu_append_unref(cityrep_menu, _("Gover_nor"),
1153 G_MENU_MODEL(create_governor_menu(cityrep_group, TRUE)));
1154
1155 /* Placeholders */
1156 submenu_append_unref(cityrep_menu, _("S_ell"), G_MENU_MODEL(g_menu_new()));
1157 submenu_append_unref(cityrep_menu, _("_Select"), G_MENU_MODEL(g_menu_new()));
1158
1159 submenu = create_display_menu(cityrep_group);
1160 submenu_append_unref(cityrep_menu, _("_Display"), G_MENU_MODEL(submenu));
1161
1162 gtk_widget_insert_action_group(aux_menu, "win", cityrep_group);
1163 gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(aux_menu), G_MENU_MODEL(cityrep_menu));
1164 gtk_box_append(GTK_BOX(vbox), aux_menu);
1165
1166 return vbox;
1167}
1168
1169/************************************************************************/
1172 static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a,
1173 GtkTreeIter *b, gpointer data)
1174{
1175 gint col = GPOINTER_TO_INT(data);
1176 const gchar *str1, *str2;
1177
1178 gtk_tree_model_get(model, a, col, &str1, -1);
1179 gtk_tree_model_get(model, b, col, &str2, -1);
1180
1181 return cityrepfield_compare(str1, str2);
1182}
1183
1184/************************************************************************/
1187 static void create_city_report_dialog(bool make_modal)
1188{
1189 static char **titles;
1190 static char (*buf)[128];
1191 struct city_report_spec *spec;
1192
1193 GtkWidget *w, *sw, *aux_menu;
1194 int i;
1195
1196 gui_dialog_new(&city_dialog_shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1197 gui_dialog_set_title(city_dialog_shell, _("Cities"));
1198
1199 gui_dialog_set_default_size(city_dialog_shell, -1, 420);
1200
1201 gui_dialog_response_set_callback(city_dialog_shell,
1202 city_command_callback);
1203
1204 /* Menu */
1205 aux_menu = create_city_report_menu();
1206 gui_dialog_add_action_widget(city_dialog_shell, aux_menu);
1207
1208 /* Buttons */
1209 city_total_buy_cost_label = gtk_label_new(NULL);
1210 gtk_widget_set_hexpand(city_total_buy_cost_label, TRUE);
1211 gtk_label_set_ellipsize(GTK_LABEL(city_total_buy_cost_label),
1212 PANGO_ELLIPSIZE_START);
1213 gui_dialog_add_action_widget(city_dialog_shell,
1214 city_total_buy_cost_label);
1215
1216 w = gui_dialog_add_button(city_dialog_shell, NULL,
1217 _("_Buy"), CITY_BUY);
1218 city_buy_command = w;
1219
1220 w = gui_dialog_add_button(city_dialog_shell, NULL,
1221 _("_Inspect"), CITY_POPUP);
1222 city_popup_command = w;
1223
1224 w = gui_dialog_add_button(city_dialog_shell, NULL,
1225 _("Cen_ter"), CITY_CENTER);
1226 city_center_command = w;
1227
1228 /* Tree view */
1229 buf = fc_realloc(buf, NUM_CREPORT_COLS * sizeof(buf[0]));
1230 titles = fc_realloc(titles, NUM_CREPORT_COLS * sizeof(titles[0]));
1231 for (i = 0; i < NUM_CREPORT_COLS; i++) {
1232 titles[i] = buf[i];
1233 }
1234 get_city_table_header(titles, sizeof(buf[0]));
1235
1236 city_model = city_report_dialog_store_new();
1237
1238 city_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(city_model));
1239 gtk_widget_set_hexpand(city_view, TRUE);
1240 gtk_widget_set_vexpand(city_view, TRUE);
1241 g_object_unref(city_model);
1242 gtk_widget_set_name(city_view, "small_font");
1243 g_signal_connect(city_view, "row_activated",
1244 G_CALLBACK(city_activated_callback), NULL);
1245 city_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(city_view));
1246 gtk_tree_selection_set_mode(city_selection, GTK_SELECTION_MULTIPLE);
1247 g_signal_connect(city_selection, "changed",
1248 G_CALLBACK(city_selection_changed_callback), NULL);
1249
1250 for (i = 0, spec = city_report_specs; i < NUM_CREPORT_COLS; i++, spec++) {
1251 GtkWidget *header;
1252 GtkCellRenderer *renderer;
1253 GtkTreeViewColumn *col;
1254
1255 renderer = gtk_cell_renderer_text_new();
1256 col = gtk_tree_view_column_new_with_attributes(NULL, renderer,
1257 "text", i, NULL);
1258 header = gtk_label_new(titles[i]);
1259 gtk_widget_set_tooltip_text(header, spec->explanation);
1260 gtk_widget_set_visible(header, TRUE);
1261 gtk_tree_view_column_set_widget(col, header);
1262 gtk_tree_view_column_set_visible(col, spec->show);
1263 gtk_tree_view_column_set_sort_column_id(col, i);
1264 gtk_tree_view_column_set_reorderable(col, TRUE);
1265 g_object_set_data(G_OBJECT(col), "city_report_spec", spec);
1266 gtk_tree_view_append_column(GTK_TREE_VIEW(city_view), col);
1267 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(city_model), i,
1268 cityrep_sort_func, GINT_TO_POINTER(i),
1269 NULL);
1270 }
1271
1272 sw = gtk_scrolled_window_new();
1273 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1274 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1275 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1276 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), city_view);
1277
1278 gui_dialog_add_content_widget(city_dialog_shell, sw);
1279
1280 city_model_fill(city_model, NULL, NULL);
1281 gui_dialog_show_all(city_dialog_shell);
1282
1283 /* Real menus */
1284 recreate_production_menu(cityrep_group);
1285 recreate_select_menu(cityrep_group);
1286 recreate_sell_menu(cityrep_group);
1287
1288 city_selection_changed_callback(city_selection);
1289}
1290
1291/************************************************************************/
1294 static void city_select_all_callback(GSimpleAction *action,
1295 GVariant *parameter,
1296 gpointer data)
1297{
1298 gtk_tree_selection_select_all(city_selection);
1299}
1300
1301/************************************************************************/
1304 static void city_unselect_all_callback(GSimpleAction *action,
1305 GVariant *parameter,
1306 gpointer data)
1307{
1308 gtk_tree_selection_unselect_all(city_selection);
1309}
1310
1311/************************************************************************/
1314 static void city_invert_selection_callback(GSimpleAction *action,
1315 GVariant *parameter,
1316 gpointer data)
1317{
1318 ITree it;
1319 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1320
1321 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1322 if (itree_is_selected(city_selection, &it)) {
1323 itree_unselect(city_selection, &it);
1324 } else {
1325 itree_select(city_selection, &it);
1326 }
1327 }
1328}
1329
1330/************************************************************************/
1333 static void city_select_coastal_callback(GSimpleAction *action,
1334 GVariant *parameter,
1335 gpointer data)
1336{
1337 ITree it;
1338 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1339
1340 gtk_tree_selection_unselect_all(city_selection);
1341
1342 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1343 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1344
1345 if (pcity != NULL
1346 && is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
1347 itree_select(city_selection, &it);
1348 }
1349 }
1350}
1351
1352/************************************************************************/
1355 static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path,
1356 GtkTreeIter *iter, gpointer data)
1357{
1358 struct city *selected_pcity = city_model_get(model, iter);
1359 ITree it;
1360
1361 if (NULL == selected_pcity) {
1362 return;
1363 }
1364
1365 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1366 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1367
1368 if (NULL != pcity
1369 && (tile_continent(pcity->tile)
1370 == tile_continent(selected_pcity->tile))) {
1371 itree_select(city_selection, &it);
1372 }
1373 }
1374}
1375
1376/************************************************************************/
1379 static void city_select_island_callback(GSimpleAction *action,
1380 GVariant *parameter,
1381 gpointer data)
1382{
1383 gtk_tree_selection_selected_foreach(city_selection,
1384 same_island_iterate, NULL);
1385}
1386
1387/************************************************************************/
1390 static void city_select_building_callback(GSimpleAction *action,
1391 GVariant *parameter,
1392 gpointer data)
1393{
1394 enum production_class_type which = GPOINTER_TO_INT(data);
1395 ITree it;
1396 GtkTreeModel *model = GTK_TREE_MODEL(city_model);
1397
1398 gtk_tree_selection_unselect_all(city_selection);
1399
1400 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
1401 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
1402
1403 if (NULL != pcity
1404 && ((which == PCT_UNIT && VUT_UTYPE == pcity->production.kind)
1405 || (which == PCT_NORMAL_IMPROVEMENT
1406 && VUT_IMPROVEMENT == pcity->production.kind
1407 && !is_wonder(pcity->production.value.building))
1408 || (which == PCT_WONDER
1409 && VUT_IMPROVEMENT == pcity->production.kind
1410 && is_wonder(pcity->production.value.building)))) {
1411 itree_select(city_selection, &it);
1412 }
1413 }
1414}
1415
1416/************************************************************************/
1419 static void buy_iterate(GtkTreeModel *model, GtkTreePath *path,
1420 GtkTreeIter *iter, gpointer data)
1421{
1422 struct city *pcity = city_model_get(model, iter);
1423
1424 if (NULL != pcity) {
1425 cityrep_buy(pcity);
1426 }
1427}
1428
1429/************************************************************************/
1432 static void center_iterate(GtkTreeModel *model, GtkTreePath *path,
1433 GtkTreeIter *iter, gpointer data)
1434{
1435 struct city *pcity = city_model_get(model, iter);
1436
1437 if (NULL != pcity) {
1438 center_tile_mapcanvas(pcity->tile);
1439 }
1440}
1441
1442/************************************************************************/
1445 static void popup_iterate(GtkTreeModel *model, GtkTreePath *path,
1446 GtkTreeIter *iter, gpointer data)
1447{
1448 struct city *pcity = city_model_get(model, iter);
1449
1450 if (NULL != pcity) {
1451 if (gui_options.center_when_popup_city) {
1452 center_tile_mapcanvas(pcity->tile);
1453 }
1454 popup_city_dialog(pcity);
1455 }
1456}
1457
1458/************************************************************************/
1461 static void city_command_callback(struct gui_dialog *dlg, int response,
1462 gpointer data)
1463{
1464 switch (response) {
1465 case CITY_CENTER:
1466 if (1 == gtk_tree_selection_count_selected_rows(city_selection)) {
1467 /* Center to city doesn't make sense if many city are selected. */
1468 gtk_tree_selection_selected_foreach(city_selection, center_iterate,
1469 NULL);
1470 }
1471 break;
1472 case CITY_POPUP:
1473 gtk_tree_selection_selected_foreach(city_selection, popup_iterate, NULL);
1474 break;
1475 case CITY_BUY:
1476 gtk_tree_selection_selected_foreach(city_selection, buy_iterate, NULL);
1477 break;
1478 default:
1479 gui_dialog_destroy(dlg);
1480 break;
1481 }
1482}
1483
1484/************************************************************************/
1487 static void city_activated_callback(GtkTreeView *view, GtkTreePath *path,
1488 GtkTreeViewColumn *col, gpointer data)
1489{
1490 GtkTreeModel *model;
1491 GtkTreeIter iter;
1492 GdkSurface *win;
1493 GdkSeat *seat;
1494 GdkModifierType mask;
1495
1496 model = gtk_tree_view_get_model(view);
1497
1498 if (!gtk_tree_model_get_iter(model, &iter, path)) {
1499 return;
1500 }
1501
1502 win = gtk_native_get_surface(gtk_widget_get_native(GTK_WIDGET(view)));
1503 seat = gdk_display_get_default_seat(gdk_surface_get_display(win));
1504
1505 gdk_surface_get_device_position(win, gdk_seat_get_pointer(seat),
1506 NULL, NULL, &mask);
1507
1508 if (!(mask & GDK_CONTROL_MASK)) {
1509 popup_iterate(model, path, &iter, NULL);
1510 } else {
1511 center_iterate(model, path, &iter, NULL);
1512 }
1513}
1514
1515/************************************************************************/
1518 void real_city_report_dialog_update(void *unused)
1519{
1520 GHashTable *selected;
1521 ITree iter;
1522 gint city_id;
1523
1524 if (NULL == city_dialog_shell) {
1525 return;
1526 }
1527
1528 /* Save the selection. */
1529 selected = g_hash_table_new(NULL, NULL);
1530 for (itree_begin(GTK_TREE_MODEL(city_model), &iter);
1531 !itree_end(&iter); itree_next(&iter)) {
1532 if (itree_is_selected(city_selection, &iter)) {
1533 itree_get(&iter, CRD_COL_CITY_ID, &city_id, -1);
1534 g_hash_table_insert(selected, GINT_TO_POINTER(city_id), NULL);
1535 }
1536 }
1537
1538 /* Update and restore the selection. */
1539 gtk_list_store_clear(city_model);
1540 city_model_fill(city_model, city_selection, selected);
1541 g_hash_table_destroy(selected);
1542
1543 update_governor_menu();
1544}
1545
1546/************************************************************************/
1549 void real_city_report_update_city(struct city *pcity)
1550{
1551 GtkTreeIter iter;
1552
1553 if (NULL == city_dialog_shell) {
1554 return;
1555 }
1556
1557 if (!city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
1558 gtk_list_store_prepend(city_model, &iter);
1559 }
1560 city_model_set(city_model, &iter, pcity);
1561
1562 update_total_buy_cost();
1563}
1564
1565/************************************************************************/
1574 static GMenu *create_change_menu(GActionGroup *group, const char *mname,
1575 const char *human_mname,
1576 enum city_operation_type oper)
1577{
1578 GMenu *menu = g_menu_new();
1579 GMenu *submenu;
1580 int n;
1581 char buf[128];
1582
1583 n = gtk_tree_selection_count_selected_rows(city_selection);
1584
1585 submenu = g_menu_new();
1586 append_impr_or_unit_to_menu(submenu, group, mname, "_u",
1587 TRUE, FALSE, oper,
1588 can_city_build_now,
1589 G_CALLBACK(select_impr_or_unit_callback), n);
1590 fc_snprintf(buf, sizeof(buf), human_mname, _("Unit"));
1591 submenu_append_unref(menu, buf, G_MENU_MODEL(submenu));
1592
1593 submenu = g_menu_new();
1594 append_impr_or_unit_to_menu(submenu, group, mname, "_i",
1595 FALSE, FALSE, oper,
1596 can_city_build_now,
1597 G_CALLBACK(select_impr_or_unit_callback), n);
1598 fc_snprintf(buf, sizeof(buf), human_mname, _("Improvement"));
1599 submenu_append_unref(menu, buf, G_MENU_MODEL(submenu));
1600
1601 submenu = g_menu_new();
1602 append_impr_or_unit_to_menu(submenu, group, mname, "_w",
1603 FALSE, TRUE, oper,
1604 can_city_build_now,
1605 G_CALLBACK(select_impr_or_unit_callback), n);
1606 fc_snprintf(buf, sizeof(buf), human_mname, _("Wonder"));
1607 submenu_append_unref(menu, buf, G_MENU_MODEL(submenu));
1608
1609 return menu;
1610}
1611
1612/************************************************************************/
1615 static void recreate_sell_menu(GActionGroup *group)
1616{
1617 int n;
1618 GMenu *menu = g_menu_new();
1619
1620 n = gtk_tree_selection_count_selected_rows(city_selection);
1621
1622 append_impr_or_unit_to_menu(menu, group, "sell", "",
1623 FALSE, FALSE, CO_SELL,
1624 can_city_sell_universal,
1625 G_CALLBACK(select_impr_or_unit_callback),
1626 n);
1627
1628 g_menu_remove(cityrep_menu, 2);
1629 submenu_insert_unref(cityrep_menu, 2, _("S_ell"), G_MENU_MODEL(menu));
1630}
1631
1632/************************************************************************/
1635 static GMenu *create_production_menu(GActionGroup *group)
1636{
1637 GSimpleAction *act;
1638
1639 prod_menu = g_menu_new();
1640
1641 /* TRANS: Menu name part to be used like "Change to Improvement"
1642 * This is about changing current production. */
1643 change_menu = create_change_menu(group, "change", _("Change to %s"), CO_CHANGE);
1644 submenu_append_unref(prod_menu, _("Chan_ge"), G_MENU_MODEL(change_menu));
1645
1646 add_first_menu = g_menu_new();
1647
1648 /* TRANS: Menu name to be used like "Set Improvement first"
1649 * This is about adding item to the beginning of the worklist. */
1650 add_first_menu = create_change_menu(group, "first", _("Set %s first"), CO_FIRST);
1651 submenu_append_unref(prod_menu, _("Add _First"),
1652 G_MENU_MODEL(add_first_menu));
1653
1654 add_last_menu = g_menu_new();
1655
1656 /* TRANS: Menu name to be used like "Set Improvement last"
1657 * This is about adding item to the end of the worklist. */
1658 add_last_menu = create_change_menu(group, "last", _("Set %s last"), CO_LAST);
1659 submenu_append_unref(prod_menu, _("Add _Last"),
1660 G_MENU_MODEL(add_last_menu));
1661
1662 add_next_menu = g_menu_new();
1663
1664 /* TRANS: Menu name to be used like "Set Improvement next"
1665 * This is about adding item after current one on the worklist. */
1666 add_next_menu = create_change_menu(group, "next", _("Set %s next"), CO_NEXT);
1667 submenu_append_unref(prod_menu, _("Add _Next"),
1668 G_MENU_MODEL(add_next_menu));
1669
1670 add_2ndlast_menu = g_menu_new();
1671
1672 /* TRANS: Menu name to be used like "Set Improvement 2nd last"
1673 * This is about adding item as second last on the worklist. */
1674 add_2ndlast_menu = create_change_menu(group, "2ndlast", _("Set %s 2nd last"), CO_NEXT_TO_LAST);
1675 submenu_append_unref(prod_menu, _("Add _2nd Last"),
1676 G_MENU_MODEL(add_2ndlast_menu));
1677
1678 wl_set_menu = create_wl_menu(group, "set", G_CALLBACK(set_worklist_callback));
1679 submenu_append_unref(prod_menu, _("Set Worklist"),
1680 G_MENU_MODEL(wl_set_menu));
1681
1682 wl_append_menu = create_wl_menu(group, "append", G_CALLBACK(append_worklist_callback));
1683 submenu_append_unref(prod_menu, _("Append Worklist"),
1684 G_MENU_MODEL(wl_append_menu));
1685
1686 act = g_simple_action_new("clear_worklist", NULL);
1687 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1688 g_signal_connect(act, "activate", G_CALLBACK(city_clear_worklist_callback),
1689 NULL);
1690 menu_item_append_unref(prod_menu, g_menu_item_new(_("Clear _Worklist"),
1691 "win.clear_worklist"));
1692
1693 return prod_menu;
1694}
1695
1696/************************************************************************/
1699 static void recreate_production_menu(GActionGroup *group)
1700{
1701 if (prod_menu != NULL) {
1702 g_menu_remove_all(change_menu);
1703 g_menu_remove_all(add_first_menu);
1704 g_menu_remove_all(add_last_menu);
1705 g_menu_remove_all(add_next_menu);
1706 g_menu_remove_all(add_2ndlast_menu);
1707 g_menu_remove_all(wl_set_menu);
1708 g_menu_remove_all(wl_append_menu);
1709 g_menu_remove_all(prod_menu);
1710 }
1711 g_menu_remove(cityrep_menu, 0);
1712 submenu_insert_unref(cityrep_menu, 0, _("_Production"),
1713 G_MENU_MODEL(create_production_menu(group)));
1714}
1715
1716/************************************************************************/
1719 static bool city_building_impr_or_unit(const struct city *pcity,
1720 const struct universal *target)
1721{
1722 return are_universals_equal(&pcity->production, target);
1723}
1724
1725/************************************************************************/
1728 static GMenu *create_select_menu(GActionGroup *group)
1729{
1730 GSimpleAction *act;
1731 char buf[128];
1732
1733 select_menu = g_menu_new();
1734
1735#if 0
1736 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
1737 g_signal_connect(menu, "show", G_CALLBACK(popup_select_menu), NULL);
1738#endif
1739
1740 act = g_simple_action_new("select_all", NULL);
1741 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1742 g_signal_connect(act, "activate", G_CALLBACK(city_select_all_callback),
1743 NULL);
1744 menu_item_append_unref(select_menu, g_menu_item_new(_("All Cities"),
1745 "win.select_all"));
1746
1747 act = g_simple_action_new("select_none", NULL);
1748 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1749 g_signal_connect(act, "activate", G_CALLBACK(city_unselect_all_callback),
1750 NULL);
1751 menu_item_append_unref(select_menu, g_menu_item_new(_("No Cities"),
1752 "win.select_none"));
1753
1754 act = g_simple_action_new("select_invert", NULL);
1755 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1756 g_signal_connect(act, "activate", G_CALLBACK(city_invert_selection_callback),
1757 NULL);
1758 menu_item_append_unref(select_menu, g_menu_item_new(_("Invert Selection"),
1759 "win.select_invert"));
1760
1761 act = g_simple_action_new("select_build_unit", NULL);
1762 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1763 g_signal_connect(act, "activate", G_CALLBACK(city_select_building_callback),
1764 GINT_TO_POINTER(PCT_UNIT));
1765 menu_item_append_unref(select_menu, g_menu_item_new(_("Building Units"),
1766 "win.select_build_unit"));
1767
1768 act = g_simple_action_new("select_build_impr", NULL);
1769 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1770 g_signal_connect(act, "activate", G_CALLBACK(city_select_building_callback),
1771 GINT_TO_POINTER(PCT_NORMAL_IMPROVEMENT));
1772 menu_item_append_unref(select_menu, g_menu_item_new(_("Building Improvements"),
1773 "win.select_build_impr"));
1774
1775 act = g_simple_action_new("select_build_wonder", NULL);
1776 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1777 g_signal_connect(act, "activate", G_CALLBACK(city_select_building_callback),
1778 GINT_TO_POINTER(PCT_WONDER));
1779 menu_item_append_unref(select_menu, g_menu_item_new(_("Building Wonders"),
1780 "win.select_build_wonder"));
1781
1782 unit_b_select_menu = g_menu_new();
1783 append_impr_or_unit_to_menu(unit_b_select_menu, group, "sel", "_b_u",
1784 TRUE, FALSE, CO_NONE,
1785 city_building_impr_or_unit,
1786 G_CALLBACK(select_impr_or_unit_callback), -1);
1787 fc_snprintf(buf, sizeof(buf), _("Building %s"), _("Unit"));
1788 submenu_append_unref(select_menu, buf, G_MENU_MODEL(unit_b_select_menu));
1789
1790 impr_b_select_menu = g_menu_new();
1791 append_impr_or_unit_to_menu(impr_b_select_menu, group, "sel", "_b_b",
1792 FALSE, FALSE, CO_NONE,
1793 city_building_impr_or_unit,
1794 G_CALLBACK(select_impr_or_unit_callback), -1);
1795 fc_snprintf(buf, sizeof(buf), _("Building %s"), _("Improvement"));
1796 submenu_append_unref(select_menu, buf, G_MENU_MODEL(impr_b_select_menu));
1797
1798 wndr_b_select_menu = g_menu_new();
1799 append_impr_or_unit_to_menu(wndr_b_select_menu, group, "sel", "_b_w",
1800 FALSE, TRUE, CO_NONE,
1801 city_building_impr_or_unit,
1802 G_CALLBACK(select_impr_or_unit_callback), -1);
1803 fc_snprintf(buf, sizeof(buf), _("Building %s"), _("Wonder"));
1804 submenu_append_unref(select_menu, buf, G_MENU_MODEL(wndr_b_select_menu));
1805
1806 act = g_simple_action_new("select_coastal", NULL);
1807 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1808 g_signal_connect(act, "activate", G_CALLBACK(city_select_coastal_callback),
1809 NULL);
1810 menu_item_append_unref(select_menu, g_menu_item_new(_("Coastal Cities"),
1811 "win.select_coastal"));
1812
1813 act = g_simple_action_new("select_island", NULL);
1814 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(act));
1815 g_signal_connect(act, "activate", G_CALLBACK(city_select_island_callback),
1816 NULL);
1817 menu_item_append_unref(select_menu, g_menu_item_new(_("Same Island"),
1818 "win.select_island"));
1819
1820 unit_s_select_menu = g_menu_new();
1821 append_impr_or_unit_to_menu(unit_s_select_menu, group, "sel", "_s_u",
1822 TRUE, FALSE, CO_NONE,
1823 city_unit_supported,
1824 G_CALLBACK(select_impr_or_unit_callback), -1);
1825 fc_snprintf(buf, sizeof(buf), _("Supported %s"), _("Unit"));
1826 submenu_append_unref(select_menu, buf, G_MENU_MODEL(unit_s_select_menu));
1827
1828 unit_p_select_menu = g_menu_new();
1829 append_impr_or_unit_to_menu(unit_p_select_menu, group, "sel", "_p_u",
1830 TRUE, FALSE, CO_NONE,
1831 city_unit_present,
1832 G_CALLBACK(select_impr_or_unit_callback), -1);
1833 fc_snprintf(buf, sizeof(buf), _("Present %s"), _("Unit"));
1834 submenu_append_unref(select_menu, buf, G_MENU_MODEL(unit_p_select_menu));
1835
1836 impr_p_select_menu = g_menu_new();
1837 append_impr_or_unit_to_menu(impr_p_select_menu, group, "sel", "_p_b",
1838 FALSE, FALSE, CO_NONE,
1839 city_building_present,
1840 G_CALLBACK(select_impr_or_unit_callback), -1);
1841 fc_snprintf(buf, sizeof(buf), _("Present %s"), _("Improvement"));
1842 submenu_append_unref(select_menu, buf, G_MENU_MODEL(impr_p_select_menu));
1843
1844 wndr_p_select_menu = g_menu_new();
1845 append_impr_or_unit_to_menu(wndr_p_select_menu, group, "sel", "_p_w",
1846 FALSE, TRUE, CO_NONE,
1847 city_building_present,
1848 G_CALLBACK(select_impr_or_unit_callback), -1);
1849 fc_snprintf(buf, sizeof(buf), _("Present %s"), _("Wonder"));
1850 submenu_append_unref(select_menu, buf, G_MENU_MODEL(wndr_p_select_menu));
1851
1852 unit_a_select_menu = g_menu_new();
1853 append_impr_or_unit_to_menu(unit_a_select_menu, group, "sel", "_a_u",
1854 TRUE, FALSE, CO_NONE,
1855 can_city_build_now,
1856 G_CALLBACK(select_impr_or_unit_callback), -1);
1857 fc_snprintf(buf, sizeof(buf), _("Available %s"), _("Unit"));
1858 submenu_append_unref(select_menu, buf, G_MENU_MODEL(unit_a_select_menu));
1859
1860 impr_a_select_menu = g_menu_new();
1861 append_impr_or_unit_to_menu(impr_a_select_menu, group, "sel", "_a_b",
1862 FALSE, FALSE, CO_NONE,
1863 can_city_build_now,
1864 G_CALLBACK(select_impr_or_unit_callback), -1);
1865 fc_snprintf(buf, sizeof(buf), _("Available %s"), _("Improvement"));
1866 submenu_append_unref(select_menu, buf, G_MENU_MODEL(impr_a_select_menu));
1867
1868 wndr_a_select_menu = g_menu_new();
1869 append_impr_or_unit_to_menu(wndr_a_select_menu, group, "sel", "_a_w",
1870 FALSE, TRUE, CO_NONE,
1871 can_city_build_now,
1872 G_CALLBACK(select_impr_or_unit_callback), -1);
1873 fc_snprintf(buf, sizeof(buf), _("Available %s"), _("Wonder"));
1874 submenu_append_unref(select_menu, buf, G_MENU_MODEL(wndr_a_select_menu));
1875
1876 governor_select_menu = create_governor_menu(cityrep_group, FALSE);
1877 submenu_append_unref(select_menu, _("Citizen Governor"),
1878 G_MENU_MODEL(governor_select_menu));
1879
1880 return select_menu;
1881}
1882
1883/************************************************************************/
1886 static void recreate_select_menu(GActionGroup *group)
1887{
1888 if (unit_b_select_menu != NULL) {
1889 g_menu_remove_all(unit_b_select_menu);
1890 g_menu_remove_all(impr_b_select_menu);
1891 g_menu_remove_all(wndr_b_select_menu);
1892 g_menu_remove_all(unit_s_select_menu);
1893 g_menu_remove_all(unit_p_select_menu);
1894 g_menu_remove_all(impr_p_select_menu);
1895 g_menu_remove_all(wndr_p_select_menu);
1896 g_menu_remove_all(unit_a_select_menu);
1897 g_menu_remove_all(impr_a_select_menu);
1898 g_menu_remove_all(wndr_a_select_menu);
1899 g_menu_remove_all(governor_select_menu);
1900 g_menu_remove_all(select_menu);
1901 }
1902 g_menu_remove(cityrep_menu, 3);
1903 submenu_insert_unref(cityrep_menu, 3, _("_Select"),
1904 G_MENU_MODEL(create_select_menu(group)));
1905}
1906
1907/************************************************************************/
1911 static void update_total_buy_cost(void)
1912{
1913 GtkWidget *label, *view;
1914 GList *rows, *p;
1915 GtkTreeModel *model;
1916 GtkTreeSelection *sel;
1917 GtkTreePath *path;
1918 GtkTreeIter iter;
1919 struct city *pcity;
1920 int total = 0;
1921
1922 view = city_view;
1923 label = city_total_buy_cost_label;
1924
1925 if (!view || !label) {
1926 return;
1927 }
1928
1929 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1930 rows = gtk_tree_selection_get_selected_rows(sel, &model);
1931
1932 for (p = rows; p != NULL; p = p->next) {
1933 path = p->data;
1934 if (gtk_tree_model_get_iter(model, &iter, path)) {
1935 if ((pcity = city_model_get(model, &iter))) {
1936 total += pcity->client.buy_cost;
1937 }
1938 }
1939 gtk_tree_path_free(path);
1940 }
1941 g_list_free(rows);
1942
1943 if (total > 0) {
1944 gchar *buf = g_strdup_printf(_("Total Buy Cost: %d"), total);
1945
1946 gtk_label_set_text(GTK_LABEL(label), buf);
1947 g_free(buf);
1948 } else {
1949 gtk_label_set_text(GTK_LABEL(label), NULL);
1950 }
1951}
1952
1953/************************************************************************/
1957 static void city_selection_changed_callback(GtkTreeSelection *selection)
1958{
1959#ifdef MENUS_GTK3
1960 int n;
1961 bool obs_may, plr_may;
1962
1963 n = gtk_tree_selection_count_selected_rows(selection);
1964 obs_may = n > 0;
1965 plr_may = obs_may && can_client_issue_orders();
1966#endif /* MENUS_GTK3 */
1967
1968 update_governor_menu();
1969
1970#ifdef MENUS_GTK3
1971 gtk_widget_set_sensitive(city_center_command, obs_may);
1972 gtk_widget_set_sensitive(city_popup_command, obs_may);
1973 gtk_widget_set_sensitive(city_buy_command, plr_may);
1974#endif /* MENUS_GTK3 */
1975
1976 recreate_production_menu(cityrep_group);
1977 recreate_select_menu(cityrep_group);
1978 recreate_sell_menu(cityrep_group);
1979
1980#ifdef MENUS_GTK3
1981 if (!plr_may) {
1982 gtk_widget_set_sensitive(city_sell_command, FALSE);
1983 }
1984#endif /* MENUS_GTK3 */
1985
1986 update_total_buy_cost();
1987}
1988
1989/************************************************************************/
1992 static void clear_worklist_foreach_func(GtkTreeModel *model,
1993 GtkTreePath *path,
1994 GtkTreeIter *iter,
1995 gpointer data)
1996{
1997 struct city *pcity = city_model_get(model, iter);
1998
1999 if (NULL != pcity) {
2000 struct worklist empty;
2001
2002 worklist_init(&empty);
2003 city_set_worklist(pcity, &empty);
2004 }
2005}
2006
2007/************************************************************************/
2010 static void city_clear_worklist_callback(GSimpleAction *action, GVariant *parameter,
2011 gpointer data)
2012{
2013 struct connection *pconn = &client.conn;
2014
2015 fc_assert_ret(city_selection != NULL);
2016
2017 connection_do_buffer(pconn);
2018 gtk_tree_selection_selected_foreach(city_selection,
2019 clear_worklist_foreach_func, NULL);
2020 connection_do_unbuffer(pconn);
2021}
2022
2023/************************************************************************/
2028 void hilite_cities_from_canvas(void)
2029{
2030 ITree it;
2031 GtkTreeModel *model;
2032
2033 if (!city_dialog_shell) {
2034 return;
2035 }
2036
2037 model = GTK_TREE_MODEL(city_model);
2038
2039 gtk_tree_selection_unselect_all(city_selection);
2040
2041 for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
2042 struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
2043
2044 if (NULL != pcity && is_city_hilited(pcity)) {
2045 itree_select(city_selection, &it);
2046 }
2047 }
2048}
2049
2050/************************************************************************/
2053 void toggle_city_hilite(struct city *pcity, bool on_off)
2054{
2055 GtkTreeIter iter;
2056
2057 if (NULL == city_dialog_shell) {
2058 return;
2059 }
2060
2061 if (city_model_find(GTK_TREE_MODEL(city_model), &iter, pcity)) {
2062 if (on_off) {
2063 gtk_tree_selection_select_iter(city_selection, &iter);
2064 } else {
2065 gtk_tree_selection_unselect_iter(city_selection, &iter);
2066 }
2067 }
2068}
n
#define n
Definition astring.c:77
can_city_build_now
bool can_city_build_now(const struct city *pcity, const struct universal *target)
Definition city.c:1006
city_has_building
bool city_has_building(const struct city *pcity, const struct impr_type *pimprove)
Definition city.c:1231
city.h
cities_iterate_end
#define cities_iterate_end
Definition city.h:517
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
cities_iterate
#define cities_iterate(pcity)
Definition city.h:512
city_owner
#define city_owner(_pcity_)
Definition city.h:563
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
production_class_type
production_class_type
Definition city.h:38
PCT_UNIT
@ PCT_UNIT
Definition city.h:39
PCT_NORMAL_IMPROVEMENT
@ PCT_NORMAL_IMPROVEMENT
Definition city.h:40
PCT_WONDER
@ PCT_WONDER
Definition city.h:41
get_city_dialog_production_row
void get_city_dialog_production_row(char *buf[], size_t column_size, struct universal *target, struct city *pcity)
Definition citydlg_common.c:373
city_set_worklist
int city_set_worklist(struct city *pcity, const struct worklist *pworklist)
Definition citydlg_common.c:1301
city_queue_insert
bool city_queue_insert(struct city *pcity, int position, struct universal *item)
Definition citydlg_common.c:1411
city_queue_insert_worklist
bool city_queue_insert_worklist(struct city *pcity, int position, const struct worklist *worklist)
Definition citydlg_common.c:1439
city_set_queue
bool city_set_queue(struct city *pcity, const struct worklist *pqueue)
Definition citydlg_common.c:1486
city_change_production
int city_change_production(struct city *pcity, struct universal *target)
Definition citydlg_common.c:1289
city_sell_improvement
int city_sell_improvement(struct city *pcity, Impr_type_id sell_id)
Definition citydlg_common.c:1544
citydlg_common.h
popup_city_dialog
void popup_city_dialog(struct city *pcity)
Definition update_queue.c:623
refresh_city_dialog
void refresh_city_dialog(struct city *pcity)
Definition update_queue.c:632
can_city_sell_universal
bool can_city_sell_universal(const struct city *pcity, const struct universal *target)
Definition cityrepdata.c:1150
city_report_specs
struct city_report_spec * city_report_specs
Definition cityrepdata.c:844
cityrepfield_compare
int cityrepfield_compare(const char *str1, const char *str2)
Definition cityrepdata.c:1123
cityrepdata.h
NUM_CREPORT_COLS
#define NUM_CREPORT_COLS
Definition cityrepdata.h:25
city_model
Definition cityrep.h:103
client
struct civclient client
Definition client_main.c:150
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
client_has_player
bool client_has_player(void)
Definition client_main.c:1364
client_main.h
client_player
#define client_player()
Definition client_main.h:106
city_unit_supported
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Definition climisc.c:544
cityrep_buy
void cityrep_buy(struct city *pcity)
Definition climisc.c:1144
name_and_sort_items
void name_and_sort_items(struct universal *targets, int num_targets, struct item *items, bool show_cost, struct city *pcity)
Definition climisc.c:640
cid_encode
cid cid_encode(struct universal target)
Definition climisc.c:482
city_building_present
bool city_building_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:582
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:525
city_unit_present
bool city_unit_present(const struct city *pcity, const struct universal *target)
Definition climisc.c:563
collect_production_targets
int collect_production_targets(struct universal *targets, struct city **selected_cities, int num_selected_cities, bool append_units, bool append_wonders, bool change_prod, TestCityFunc test_func)
Definition climisc.c:690
climisc.h
MAX_NUM_PRODUCTION_TARGETS
#define MAX_NUM_PRODUCTION_TARGETS
Definition climisc.h:87
TestCityFunc
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition climisc.h:85
cm_are_parameter_equal
bool cm_are_parameter_equal(const struct cm_parameter *const p1, const struct cm_parameter *const p2)
Definition cm.c:2138
cma_is_city_under_agent
bool cma_is_city_under_agent(const struct city *pcity, struct cm_parameter *parameter)
Definition cma_core.c:551
cma_put_city_under_agent
void cma_put_city_under_agent(struct city *pcity, const struct cm_parameter *const parameter)
Definition cma_core.c:523
cma_release_city
void cma_release_city(struct city *pcity)
Definition cma_core.c:541
cmafec_preset_get_descr
char * cmafec_preset_get_descr(int idx)
Definition cma_fec.c:169
cmafec_preset_get_parameter
const struct cm_parameter * cmafec_preset_get_parameter(int idx)
Definition cma_fec.c:182
cmafec_preset_get_index_of_parameter
int cmafec_preset_get_index_of_parameter(const struct cm_parameter *const parameter)
Definition cma_fec.c:196
cmafec_preset_num
int cmafec_preset_num(void)
Definition cma_fec.c:213
cma_fec.h
incite_cost
char * incite_cost
Definition comments.c:74
connection_do_buffer
void connection_do_buffer(struct connection *pc)
Definition connection.c:324
connection_do_unbuffer
void connection_do_unbuffer(struct connection *pc)
Definition connection.c:336
id
int int id
Definition editgui_g.h:28
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
wld
struct world wld
Definition game.c:63
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:107
game.h
global_worklist_by_id
struct global_worklist * global_worklist_by_id(int id)
Definition global_worklist.c:298
global_worklist_name
const char * global_worklist_name(const struct global_worklist *pgwl)
Definition global_worklist.c:323
global_worklist_id
int global_worklist_id(const struct global_worklist *pgwl)
Definition global_worklist.c:288
global_worklist_get
const struct worklist * global_worklist_get(const struct global_worklist *pgwl)
Definition global_worklist.c:276
global_worklist.h
global_worklists_iterate
#define global_worklists_iterate(pgwl)
Definition global_worklist.h:65
global_worklists_iterate_end
#define global_worklists_iterate_end
Definition global_worklist.h:68
append_worklist_foreach
static void append_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:857
create_city_report_dialog
static void create_city_report_dialog(bool make_modal)
Definition cityrep.c:1138
city_invert_selection_callback
static void city_invert_selection_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1259
city_popup_command
static GtkWidget * city_popup_command
Definition cityrep.c:119
worklist_next_impr_or_unit_iterate
static void worklist_next_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:513
city_total_buy_cost_label
static GtkWidget * city_total_buy_cost_label
Definition cityrep.c:124
city_buy_command
static GtkWidget * city_buy_command
Definition cityrep.c:120
update_total_buy_cost
static void update_total_buy_cost(void)
Definition cityrep.c:1959
real_city_report_dialog_update
void real_city_report_dialog_update(void *unused)
Definition cityrep.c:1454
CRD_COL_CITY_ID
#define CRD_COL_CITY_ID
Definition cityrep.c:107
real_city_report_update_city
void real_city_report_update_city(struct city *pcity)
Definition cityrep.c:1489
city_select_building_callback
static void city_select_building_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1328
popup_iterate
static void popup_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1381
create_select_menu
static void create_select_menu(GtkWidget *item)
Definition cityrep.c:1770
city_activated_callback
static void city_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition cityrep.c:1423
select_impr_or_unit_callback
static void select_impr_or_unit_callback(GtkWidget *wdg, gpointer data)
Definition cityrep.c:567
impr_or_unit_iterate
static void impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:456
city_model_fill
static void city_model_fill(GtkListStore *store, GtkTreeSelection *selection, GHashTable *select)
Definition cityrep.c:262
center_iterate
static void center_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1368
toggle_city_hilite
void toggle_city_hilite(struct city *pcity, bool on_off)
Definition cityrep.c:2089
city_building_impr_or_unit
static bool city_building_impr_or_unit(const struct city *pcity, const struct universal *target)
Definition cityrep.c:1889
CITY_POPUP
@ CITY_POPUP
Definition cityrep.c:101
CITY_CENTER
@ CITY_CENTER
Definition cityrep.c:101
CITY_BUY
@ CITY_BUY
Definition cityrep.c:101
CMA_NONE
#define CMA_NONE
Definition cityrep.c:64
cityrep_sort_func
static gint cityrep_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer data)
Definition cityrep.c:1123
city_model_get
static struct city * city_model_get(GtkTreeModel *model, GtkTreeIter *iter)
Definition cityrep.c:226
city_select_coastal_callback
static void city_select_coastal_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1276
popup_select_menu
static void popup_select_menu(GtkMenuShell *menu, gpointer data)
Definition cityrep.c:1898
city_command_callback
static void city_command_callback(struct gui_dialog *dlg, int response, gpointer data)
Definition cityrep.c:1397
city_model_set
static void city_model_set(GtkListStore *store, GtkTreeIter *iter, struct city *pcity)
Definition cityrep.c:207
city_clear_worklist_callback
static void city_clear_worklist_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:2049
city_model
static GtkListStore * city_model
Definition cityrep.c:106
clear_worklist_foreach_func
static void clear_worklist_foreach_func(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:2031
city_sell_command
static GtkWidget * city_sell_command
Definition cityrep.c:123
NEG_VAL
#define NEG_VAL(x)
Definition cityrep.c:61
city_select_all_callback
static void city_select_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1243
CMA_CUSTOM
#define CMA_CUSTOM
Definition cityrep.c:65
sell_impr_iterate
static void sell_impr_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:548
city_selection
static GtkTreeSelection * city_selection
Definition cityrep.c:105
same_island_iterate
static void same_island_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1296
set_worklist_callback
static void set_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:913
city_selection_changed_callback
static void city_selection_changed_callback(GtkTreeSelection *selection)
Definition cityrep.c:2005
city_model_find
static gboolean city_model_find(GtkTreeModel *model, GtkTreeIter *iter, const struct city *pcity)
Definition cityrep.c:242
worklist_next_to_last_impr_or_unit_iterate
static void worklist_next_to_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:532
city_report_dialog_store_new
static GtkListStore * city_report_dialog_store_new(void)
Definition cityrep.c:188
city_dialog_shell_is_modal
static int city_dialog_shell_is_modal
Definition cityrep.c:162
city_report_update_views
static void city_report_update_views(void)
Definition cityrep.c:986
get_city_table_header
static void get_city_table_header(char **text, int n)
Definition cityrep.c:169
hilite_cities_from_canvas
void hilite_cities_from_canvas(void)
Definition cityrep.c:2066
city_report_dialog_popdown
void city_report_dialog_popdown(void)
Definition cityrep.c:312
city_report_dialog_popup
void city_report_dialog_popup(bool raise)
Definition cityrep.c:292
city_view
static GtkWidget * city_view
Definition cityrep.c:104
city_dialog_shell
static struct gui_dialog * city_dialog_shell
Definition cityrep.c:98
worklist_first_impr_or_unit_iterate
static void worklist_first_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:493
set_worklist_foreach
static void set_worklist_foreach(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:896
toggle_view
static void toggle_view(GtkCheckMenuItem *item, gpointer data)
Definition cityrep.c:1010
append_worklist_callback
static void append_worklist_callback(GtkMenuItem *menuitem, gpointer data)
Definition cityrep.c:875
city_unselect_all_callback
static void city_unselect_all_callback(GtkMenuItem *item, gpointer data)
Definition cityrep.c:1251
worklist_last_impr_or_unit_iterate
static void worklist_last_impr_or_unit_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:472
city_center_command
static GtkWidget * city_center_command
Definition cityrep.c:118
buy_iterate
static void buy_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:1355
city_operation_type
city_operation_type
Definition cityrep.c:73
CO_SELL
@ CO_SELL
Definition cityrep.c:74
CO_NEXT_TO_LAST
@ CO_NEXT_TO_LAST
Definition cityrep.c:74
CO_NEXT
@ CO_NEXT
Definition cityrep.c:74
CO_CHANGE
@ CO_CHANGE
Definition cityrep.c:74
CO_FIRST
@ CO_FIRST
Definition cityrep.c:74
CO_LAST
@ CO_LAST
Definition cityrep.c:74
CO_NONE
@ CO_NONE
Definition cityrep.c:74
recreate_sell_menu
static void recreate_sell_menu(void)
Definition cityrep.c:1743
create_change_menu
static void create_change_menu(GtkWidget *item)
Definition cityrep.c:1508
pos
static struct tile * pos
Definition finddlg.c:53
top_notebook
GtkWidget * top_notebook
Definition gui_main.c:129
toplevel
GtkWidget * toplevel
Definition gui_main.c:125
gui_dialog_destroy
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
gui_dialog_present
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
itree_get
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
gui_dialog_raise
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
gui_dialog_new
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
gui_dialog_response_set_callback
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
itree_begin
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
itree_unselect
void itree_unselect(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:206
gui_dialog_show_all
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
itree_select
void itree_select(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:198
gui_dialog_set_title
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
gui_dialog_set_default_size
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
itree_next
void itree_next(ITree *it)
Definition gui_stuff.c:144
itree_is_selected
gboolean itree_is_selected(GtkTreeSelection *selection, ITree *it)
Definition gui_stuff.c:190
gui_dialog_add_button
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
itree_end
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
TREE_ITER_PTR
#define TREE_ITER_PTR(x)
Definition gui_stuff.h:38
impr_b_select_menu
static GMenu * impr_b_select_menu
Definition cityrep.c:136
create_city_report_menu
static GtkWidget * create_city_report_menu(void)
Definition cityrep.c:1112
wl_set_menu
static GMenu * wl_set_menu
Definition cityrep.c:131
recreate_production_menu
static void recreate_production_menu(GActionGroup *group)
Definition cityrep.c:1678
unit_b_select_menu
static GMenu * unit_b_select_menu
Definition cityrep.c:135
city_select_island_callback
static void city_select_island_callback(GSimpleAction *action, GVariant *parameter, gpointer data)
Definition cityrep.c:1358
display_menu
static GMenu * display_menu
Definition cityrep.c:151
add_first_menu
static GMenu * add_first_menu
Definition cityrep.c:127
add_2ndlast_menu
static GMenu * add_2ndlast_menu
Definition cityrep.c:130
add_next_menu
static GMenu * add_next_menu
Definition cityrep.c:129
impr_a_select_menu
static GMenu * impr_a_select_menu
Definition cityrep.c:143
select_governor_callback
static void select_governor_callback(GSimpleAction *action, GVariant *parameter, gpointer data)
Definition cityrep.c:700
unit_s_select_menu
static GMenu * unit_s_select_menu
Definition cityrep.c:138
impr_p_select_menu
static GMenu * impr_p_select_menu
Definition cityrep.c:140
cityrep_group
static GActionGroup * cityrep_group
Definition cityrep.c:150
wl_append_menu
static GMenu * wl_append_menu
Definition cityrep.c:132
governors_iterate
static void governors_iterate(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
Definition cityrep.c:680
create_governor_menu
static GMenu * create_governor_menu(GActionGroup *group, bool change_governor)
Definition cityrep.c:759
create_display_menu
static GMenu * create_display_menu(GActionGroup *group)
Definition cityrep.c:1084
recreate_select_menu
static void recreate_select_menu(GActionGroup *group)
Definition cityrep.c:1865
create_production_menu
static GMenu * create_production_menu(GActionGroup *group)
Definition cityrep.c:1614
create_display_menu_item
static GMenuItem * create_display_menu_item(int pos)
Definition cityrep.c:1052
select_menu
static GMenu * select_menu
Definition cityrep.c:134
prod_menu
static GMenu * prod_menu
Definition cityrep.c:125
add_last_menu
static GMenu * add_last_menu
Definition cityrep.c:128
cityrep_menu
static GMenu * cityrep_menu
Definition cityrep.c:149
create_wl_menu
static GMenu * create_wl_menu(GActionGroup *group, const char *act_pfx, GCallback cb)
Definition cityrep.c:985
append_impr_or_unit_to_menu
static void append_impr_or_unit_to_menu(GMenu *menu, GActionGroup *act_group, const char *act_pfx, const char *act_pfx2, bool append_units, bool append_wonders, enum city_operation_type city_operation, TestCityFunc test_func, GCallback callback, int size)
Definition cityrep.c:307
unit_a_select_menu
static GMenu * unit_a_select_menu
Definition cityrep.c:142
unit_p_select_menu
static GMenu * unit_p_select_menu
Definition cityrep.c:139
update_governor_menu
static void update_governor_menu(void)
Definition cityrep.c:891
governor_select_menu
static GMenu * governor_select_menu
Definition cityrep.c:145
change_menu
static GMenu * change_menu
Definition cityrep.c:126
wndr_b_select_menu
static GMenu * wndr_b_select_menu
Definition cityrep.c:137
wndr_p_select_menu
static GMenu * wndr_p_select_menu
Definition cityrep.c:141
wndr_a_select_menu
static GMenu * wndr_a_select_menu
Definition cityrep.c:144
aux_menu_new
GtkWidget * aux_menu_new(void)
Definition gui_stuff.c:244
gui_dialog_add_content_widget
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1105
gui_dialog_add_action_widget
GtkWidget * gui_dialog_add_action_widget(struct gui_dialog *dlg, GtkWidget *widget)
Definition gui_stuff.c:690
submenu_append_unref
#define submenu_append_unref(menu, name, submenu)
Definition gui_stuff.h:165
menu_item_insert_unref
#define menu_item_insert_unref(menu, index, item)
Definition gui_stuff.h:142
submenu_insert_unref
#define submenu_insert_unref(menu, index, name, submenu)
Definition gui_stuff.h:156
menu_item_append_unref
#define menu_item_append_unref(menu, item)
Definition gui_stuff.h:149
sell_callback_response
static void sell_callback_response(GObject *dialog, GAsyncResult *result, gpointer data)
Definition cityrep.c:576
gui_stuff.h
chatline.h
citydlg.h
cityrep.h
gui_main.h
mapview.h
optiondlg.h
repodlgs.h
impr_sell_gold
int impr_sell_gold(const struct impr_type *pimprove)
Definition improvement.c:334
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:184
is_wonder
bool is_wonder(const struct impr_type *pimprove)
Definition improvement.c:343
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert_action
#define fc_assert_action(condition, action)
Definition log.h:187
is_city_hilited
bool is_city_hilited(struct city *pcity)
Definition mapctrl_common.c:301
mapctrl_common.h
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
mapview_common.h
fc_realloc
#define fc_realloc(ptr, sz)
Definition mem.h:36
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
gui_options
struct client_options gui_options
Definition options.c:71
options.h
packets.h
cities
struct city_list * cities
Definition packhand.c:119
are_universals_equal
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
Definition requirements.c:6667
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
size
size_t size
Definition specvec.h:72
mask
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
ITree
Definition gui_stuff.h:32
action
Definition actions.h:106
callback
Definition gui_main.c:2404
city_report_spec
Definition cityrepdata.h:27
city_report_spec::func
const char *(* func)(const struct city *pcity, const void *data)
Definition cityrepdata.h:34
city_report_spec::width
int width
Definition cityrepdata.h:29
city_report_spec::title2
const char * title2
Definition cityrepdata.h:31
city_report_spec::data
void * data
Definition cityrepdata.h:33
city_report_spec::show
bool show
Definition cityrepdata.h:28
city_report_spec::explanation
const char * explanation
Definition cityrepdata.h:32
city_report_spec::title1
const char * title1
Definition cityrepdata.h:30
city
Definition city.h:320
city::did_sell
bool did_sell
Definition city.h:380
city::id
int id
Definition city.h:326
city::worklist
struct worklist worklist
Definition city.h:401
city::production
struct universal production
Definition city.h:396
city::buy_cost
int buy_cost
Definition city.h:466
city::tile
struct tile * tile
Definition city.h:322
city::client
struct city::@17::@20 client
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::center_when_popup_city
bool center_when_popup_city
Definition options.h:162
cm_parameter
Definition cm.h:40
connection
Definition connection.h:136
connection::playing
struct player * playing
Definition connection.h:151
global_worklist
Definition global_worklist.c:49
gui_dialog
Definition gui_stuff.h:70
impr_type
Definition improvement.h:50
item
Definition climisc.h:80
item::item
struct universal item
Definition climisc.h:81
player::cities
struct city_list * cities
Definition player.h:281
scbs_data
Definition cityrep.c:568
scbs_data::imprname
const char * imprname
Definition cityrep.c:570
scbs_data::building
const struct impr_type * building
Definition cityrep.c:569
sell_data
Definition cityrep.c:67
sell_data::gold
int gold
Definition cityrep.c:69
sell_data::count
int count
Definition cityrep.c:68
sell_data::target
const struct impr_type * target
Definition cityrep.c:70
test_func
Definition mapgen.c:684
universal
Definition fc_types.h:908
universal::kind
enum universals_n kind
Definition fc_types.h:910
universal::value
universals_u value
Definition fc_types.h:909
view
Definition mapview_common.h:36
worklist
Definition worklist.h:28
world::map
struct civ_map map
Definition world_object.h:38
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
is_terrain_class_near_tile
bool is_terrain_class_near_tile(const struct civ_map *nmap, const struct tile *ptile, enum terrain_class tclass)
Definition terrain.c:612
tile_continent
#define tile_continent(_tile)
Definition tile.h:93
universals_u::building
const struct impr_type * building
Definition fc_types.h:721
unit.h
worklist_init
void worklist_init(struct worklist *pwl)
Definition worklist.c:38
worklist_length
int worklist_length(const struct worklist *pwl)
Definition worklist.c:57