Freeciv-3.2
Loading...
Searching...
No Matches
repodlgs.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 <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "fc_types.h" /* LINE_BREAK */
34#include "game.h"
35#include "government.h"
36#include "packets.h"
37#include "research.h"
38#include "tech.h"
39#include "unitlist.h"
40
41/* client */
42#include "chatline_common.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "control.h"
46#include "mapview_common.h"
47#include "options.h"
48#include "packhand_gen.h"
49#include "control.h"
50#include "reqtree.h"
51#include "text.h"
52
53/* client/gui-gtk-4.0 */
54#include "canvas.h"
55#include "cityrep.h"
56#include "dialogs.h"
57#include "gui_main.h"
58#include "gui_stuff.h"
59#include "helpdlg.h"
60#include "plrdlg.h"
61#include "sprite.h"
62
63#include "repodlgs.h"
64
65
66/****************************************************************************
67 RESEARCH REPORT DIALOG
68****************************************************************************/
69struct science_report {
70 struct gui_dialog *shell;
74 GtkLabel *main_label; /* Gets science_dialog_text(). */
78};
79
81static inline void science_report_store_set(GtkListStore *store,
83 Tech_type_id tech);
85 Tech_type_id *tech,
86 char **name);
88 Tech_type_id tech);
90 int n_press,
91 double x, double y);
93 int n_press,
94 double x, double y);
95
97 int width, int height, gpointer data);
98static GtkWidget *science_diagram_new(void);
99static void science_diagram_data(GtkWidget *widget, bool show_all);
101static void science_report_redraw(struct science_report *preport);
103static void science_report_update(struct science_report *preport);
105 gpointer data);
107 gpointer data);
108static void science_report_goal_callback(GtkComboBox *combo, gpointer data);
109static void science_report_init(struct science_report *preport);
110static void science_report_free(struct science_report *preport);
111
112static struct science_report science_report = { NULL, };
114
115/* Those values must match the function science_report_store_new(). */
119
120 /* Not visible. */
121 SRD_COL_ID, /* Tech_type_id */
122
125
126/************************************************************************/
130{
132 G_TYPE_STRING, /* SRD_COL_NAME */
133 G_TYPE_INT, /* SRD_COL_STEPS */
134 G_TYPE_INT); /* SRD_COL_ID */
135}
136
137/************************************************************************/
140static inline void science_report_store_set(GtkListStore *store,
142 Tech_type_id tech)
143{
144 const struct research *presearch = research_get(client_player());
145
151 SRD_COL_ID, tech,
152 -1);
153}
154
155/************************************************************************/
159 Tech_type_id *tech,
160 char **name)
161{
163
165 || !gtk_combo_box_get_active_iter(combo, &iter)) {
166 return FALSE;
167 }
168
171 SRD_COL_ID, tech,
172 -1);
173
174 return TRUE;
175}
176
177/************************************************************************/
181 Tech_type_id tech)
182{
183 ITree iter;
185
189 if (iter_tech == tech) {
193 return;
194 }
195 }
196 log_error("%s(): Tech %d not found in the combo.", __FUNCTION__, tech);
197}
198
199/************************************************************************/
203 int n_press,
204 double x, double y)
205{
208 struct reqtree *reqtree = g_object_get_data(G_OBJECT(w), "reqtree");
209 Tech_type_id tech;
210
211 tech = get_tech_on_reqtree(reqtree, x, y);
212
213 if (tech == A_NONE) {
214 return TRUE;
215 }
216
218 /* Set research or research goal */
220 tech)) {
223 break;
224 case TECH_UNKNOWN:
226 break;
227 case TECH_KNOWN:
228 break;
229 }
230 }
231
232 return TRUE;
233}
234
235/************************************************************************/
239 int n_press,
240 double x, double y)
241{
242 const struct research *presearch;
245 struct reqtree *reqtree = g_object_get_data(G_OBJECT(w), "reqtree");
246 Tech_type_id tech;
247
248 tech = get_tech_on_reqtree(reqtree, x, y);
249
250 if (tech == A_NONE) {
251 return TRUE;
252 }
253
255
256 /* Open help */
258 tech),
259 HELP_TECH);
260
261 return TRUE;
262}
263
264/************************************************************************/
300
301/************************************************************************/
328
329/************************************************************************/
332static void science_diagram_data(GtkWidget *widget, bool show_all)
333{
334 struct reqtree *reqtree;
335
336 if (can_conn_edit(&client.conn)) {
337 /* Show all techs in editor mode, not only currently reachable ones */
339 } else {
340 /* Show only at some point reachable techs */
341 reqtree = create_reqtree(client_player(), show_all);
342 }
343
346}
347
348/************************************************************************/
376
377/************************************************************************/
381{
382 Tech_type_id researching;
383
385
388 preport->button_show_all)));
389
390 if (client_has_player()) {
391 researching = research_get(client_player())->researching;
392 } else {
393 researching = A_UNSET;
394 }
395 science_diagram_center(GTK_WIDGET(preport->drawing_area), researching);
396
398}
399
400/************************************************************************/
414
415/************************************************************************/
419{
420 GtkListStore *store;
424 const char *text;
425 double pct;
426 Tech_type_id tech;
428
431
432 /* Disable callbacks. */
434
436
438
439 /* Update the progress bar. */
441 gtk_progress_bar_set_text(preport->progress_bar, text);
443 /* Work around GTK refresh bug? */
445
446 /* Update reachable techs. */
447 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
450
451 /* Collect all techs which are reachable in the next step. */
453 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
455 }
457
458 if (sorting_list != NULL) {
459 if (A_UNSET == presearch->researching
460 || is_future_tech(presearch->researching)) {
462 science_report_store_set(store, &iter, presearch->researching);
463 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
464 }
465
466 /* Sort the list, append it to the store. */
468 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
469 tech = GPOINTER_TO_INT(item->data);
471 science_report_store_set(store, &iter, tech);
472 if (tech == presearch->researching) {
473 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
474 }
475 }
476
477 /* Free, re-init. */
480 } else {
481 /* No reachable normal techs. Can we select Future Tech? */
482 Tech_type_id next;
483
486 next = A_FUTURE;
487 } else {
488 next = presearch->researching;
489 }
490 science_report_store_set(store, &iter, next);
491
492 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
493 }
494
495 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_goals));
497
498 /* Update the tech goal. */
499 gtk_label_set_text(preport->goal_label,
500 get_science_goal_text(presearch->tech_goal));
501
502 /* Collect all techs which are reachable in next 10 steps. */
505 && TECH_KNOWN != presearch->inventions[i].state
506 && (i == presearch->tech_goal
507 || 10 >= presearch->inventions[i].num_required_techs)) {
509 }
511
512 if (sorting_list != NULL) {
513 if (A_UNSET == presearch->tech_goal) {
516 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
517 }
518
519 /* Sort the list, append it to the store. */
521 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
522 tech = GPOINTER_TO_INT(item->data);
524 science_report_store_set(store, &iter, tech);
525 if (tech == presearch->tech_goal) {
526 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
527 }
528 }
529
530 /* Free. */
532 } else {
533 /* No reachable normal techs. Can we select Future Tech? */
534 Tech_type_id goal;
535
537
539 goal = A_FUTURE;
540 } else {
541 goal = A_UNSET;
542 }
543
544 science_report_store_set(store, &iter, goal);
545 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
546 }
547
548 /* Re-enable callbacks. */
550}
551
552/************************************************************************/
556 gpointer data)
557{
558 Tech_type_id tech;
559 char *tech_name;
560
561 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
562 return;
563 }
564
567 } else if (can_client_issue_orders()) {
569 }
570
571 free(tech_name);
572 /* Revert, or we will not be in sync with the server. */
575}
576
577/************************************************************************/
581 gpointer data)
582{
583 struct science_report *preport = (struct science_report *) data;
584
586}
587
588/************************************************************************/
592{
593 Tech_type_id tech;
594 char *tech_name;
595
596 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
597 return;
598 }
599
602 } else if (can_client_issue_orders()) {
604 }
605
606 free(tech_name);
607 /* Revert, or we will not be in sync with the server. */
609 (client_player())->tech_goal);
610}
611
612/************************************************************************/
616{
617 GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w;
618 GtkSizeGroup *group;
619 GtkListStore *store;
620 GtkCellRenderer *renderer;
621
623
625 /* TRANS: Research report title */
626 gui_dialog_set_title(preport->shell, _("Research"));
627
628 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
630
632
633 w = gtk_label_new(NULL);
635 preport->main_label = GTK_LABEL(w);
636
637 /* Current research target line. */
638 frame = gtk_frame_new(_("Researching"));
640
644
647
648 store = science_report_store_new();
651 g_object_unref(G_OBJECT(store));
652 renderer = gtk_cell_renderer_text_new();
659 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
660 preport->reachable_techs = GTK_COMBO_BOX(w);
661
665 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
667 preport->progress_bar = GTK_PROGRESS_BAR(w);
668
669 /* Research goal line. */
670 frame = gtk_frame_new( _("Goal"));
672
676
677 store = science_report_store_new();
680 g_object_unref(G_OBJECT(store));
681 renderer = gtk_cell_renderer_text_new();
685 renderer = gtk_cell_renderer_text_new();
692 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
693 preport->reachable_goals = GTK_COMBO_BOX(w);
694
695 w = gtk_label_new(NULL);
697 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
699 preport->goal_label = GTK_LABEL(w);
700
701 /* Toggle "Show All" button. */
702 /* TRANS: As in 'Show all (even not reachable) techs'. */
709 preport->button_show_all = show_all_button;
710
711 /* Science diagram. */
716
721 preport->drawing_area = GTK_DRAWING_AREA(w);
722
726 g_object_unref(group);
727
728 /* This must be _after_ the dialog is drawn to really center it ... */
730}
731
732/************************************************************************/
736{
738
740 fc_assert(NULL == preport->shell);
741
742 memset(preport, 0, sizeof(*preport));
743}
744
745/************************************************************************/
749{
751
752 if (NULL == science_report.shell) {
754 }
755
756 if (NULL != presearch
757 && A_UNSET == presearch->tech_goal
758 && A_UNSET == presearch->researching) {
760 } else {
762 }
763
764 if (raise) {
766 }
767}
768
769/************************************************************************/
779
780/************************************************************************/
789
790/************************************************************************/
799
800
801/****************************************************************************
802 ECONOMY REPORT DIALOG
803****************************************************************************/
804struct economy_report {
805 struct gui_dialog *shell;
808};
809
811
817
818/* Those values must match the functions economy_report_store_new() and
819 * economy_report_column_name(). */
835
836/************************************************************************/
840{
842 GDK_TYPE_PIXBUF, /* ERD_COL_SPRITE */
843 G_TYPE_STRING, /* ERD_COL_NAME */
844 G_TYPE_INT, /* ERD_COL_REDUNDANT */
845 G_TYPE_INT, /* ERD_COL_COUNT */
846 G_TYPE_INT, /* ERD_COL_COST */
847 G_TYPE_INT, /* ERD_COL_TOTAL_COST */
848 G_TYPE_STRING, /* ERD_COL_EMPTY */
849 G_TYPE_BOOLEAN, /* ERD_COL_IS_IMPROVEMENT */
850 G_TYPE_INT, /* ERD_COL_UNI_KIND */
851 G_TYPE_INT); /* ERD_COL_UNI_VALUE_ID */
852}
853
854/************************************************************************/
857static const char *
859{
860 switch (col) {
861 case ERD_COL_SPRITE:
862 /* TRANS: Image header */
863 return _("Type");
864 case ERD_COL_NAME:
865 return Q_("?Building or Unit type:Name");
867 return _("Redundant");
868 case ERD_COL_COUNT:
869 return _("Count");
870 case ERD_COL_COST:
871 return _("Cost");
873 /* TRANS: Upkeep total, count*cost. */
874 return _("U Total");
875 case ERD_COL_EMPTY:
876 /* empty space for scrollbar*/
877 return " ";
879 case ERD_COL_CID:
880 case ERD_COL_NUM:
881 break; /* no more columns will be displayed after reaching this */
882 }
883
884 return NULL;
885}
886
887/************************************************************************/
891{
892 GtkTreeSelection *selection;
893 GtkTreeModel *model;
894 GtkListStore *store;
896 GdkPixbuf *pix;
900 char buf[256];
901 cid selected;
902
904
905 /* Save the selection. */
906 selection = gtk_tree_view_get_selection(preport->tree_view);
907 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
908 gtk_tree_model_get(model, &iter, ERD_COL_CID, &selected, -1);
909 } else {
910 selected = -1;
911 }
912
913 model = gtk_tree_view_get_model(preport->tree_view);
914 store = GTK_LIST_STORE(model);
916
917 /* Buildings. */
919 &building_total, &tax);
920 for (i = 0; i < entries_used; i++) {
922 struct impr_type *pimprove = pentry->type;
923 struct sprite *sprite = get_building_sprite(tileset, pimprove);
924 cid id = cid_encode_building(pimprove);
925
928 gtk_list_store_set(store, &iter,
929 ERD_COL_SPRITE, pix,
931 ERD_COL_REDUNDANT, pentry->redundant,
932 ERD_COL_COUNT, pentry->count,
933 ERD_COL_COST, pentry->cost,
934 ERD_COL_TOTAL_COST, pentry->total_cost,
935 ERD_COL_EMPTY, " ",
937 ERD_COL_CID, id,
938 -1);
940 if (selected == id) {
941 /* Restore the selection. */
943 }
944 }
945
946 /* Units. */
948 for (i = 0; i < entries_used; i++) {
949 struct unit_entry *pentry = unit_entries + i;
950 struct unit_type *putype = pentry->type;
955
958 gtk_list_store_set(store, &iter,
959 ERD_COL_SPRITE, pix,
962 ERD_COL_COUNT, pentry->count,
963 ERD_COL_COST, pentry->cost,
964 ERD_COL_TOTAL_COST, pentry->total_cost,
965 ERD_COL_EMPTY, " ",
967 ERD_COL_CID, id,
968 -1);
970 if (selected == id) {
971 /* Restore the selection. */
973 }
974 }
975
976 /* Update the label. */
977 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
980}
981
982/************************************************************************/
985static void economy_report_command_callback(struct gui_dialog *pdialog,
986 int response,
987 gpointer data)
988{
989 struct economy_report *preport = data;
991 GtkTreeModel *model;
994 struct universal selected;
995 cid id;
996 char buf[256] = "";
997
998 switch (response) {
1000 case ERD_RES_SELL_ALL:
1002 break;
1003 default:
1004 gui_dialog_destroy(pdialog);
1005 return;
1006 }
1007
1009 || !gtk_tree_selection_get_selected(selection, &model, &iter)) {
1010 return;
1011 }
1012
1013 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1014 selected = cid_decode(id);
1015
1016 switch (selected.kind) {
1017 case VUT_IMPROVEMENT:
1018 {
1019 const struct impr_type *pimprove = selected.value.building;
1020
1021 if (can_sell_building(pimprove)
1022 && (ERD_RES_SELL_ALL == response
1023 || (ERD_RES_SELL_REDUNDANT == response))) {
1024 bool redundant = (ERD_RES_SELL_REDUNDANT == response);
1025 gint count;
1026 gtk_tree_model_get(model, &iter,
1027 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
1028 &count, -1);
1029 if (count == 0) {
1030 break;
1031 }
1036 redundant
1037 /* TRANS: %s is an improvement */
1038 ? _("Do you really wish to sell "
1039 "every redundant %s (%d total)?")
1040 /* TRANS: %s is an improvement */
1041 : _("Do you really wish to sell "
1042 "every %s (%d total)?"),
1044 count);
1046 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1047
1049 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1050 }
1052 }
1053 }
1054 break;
1055 case VUT_UTYPE:
1056 {
1057 if (ERD_RES_DISBAND_UNITS == response) {
1058 const struct unit_type *putype = selected.value.utype;
1059 gint count;
1060
1061 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1062
1067 /* TRANS: %s is a unit */
1068 _("Do you really wish to disband "
1069 "every %s (%d total)?"),
1071 count);
1073 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1074
1076 disband_all_units(putype, FALSE, buf, sizeof(buf));
1077 }
1079 }
1080 }
1081 break;
1082 default:
1083 log_error("Not supported type: %d.", selected.kind);
1084 }
1085
1086 if ('\0' != buf[0]) {
1089 "%s", buf);
1092 NULL);
1093 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1095 }
1096}
1097
1098/************************************************************************/
1102 gpointer data)
1103{
1104 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1105 GtkTreeModel *model;
1107
1109 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1110 struct universal selected;
1111 cid id;
1112
1113 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1114 selected = cid_decode(id);
1115 switch (selected.kind) {
1116 case VUT_IMPROVEMENT:
1117 {
1118 bool can_sell = can_sell_building(selected.value.building);
1119 gint redundant;
1120 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1121
1123 can_sell && redundant > 0);
1126 FALSE);
1127 }
1128 return;
1129 case VUT_UTYPE:
1131 FALSE);
1134 TRUE);
1135 return;
1136 default:
1137 log_error("Not supported type: %d.", selected.kind);
1138 break;
1139 }
1140 }
1141
1145}
1146
1147/************************************************************************/
1151{
1152 GtkWidget *view, *sw, *label, *button;
1153 GtkListStore *store;
1154 GtkTreeSelection *selection;
1155 const char *title;
1157
1159
1161 gui_dialog_set_title(preport->shell, _("Economy"));
1162
1169
1170 store = economy_report_store_new();
1173 g_object_unref(store);
1174 gtk_widget_set_name(view, "small_font");
1177 preport->tree_view = GTK_TREE_VIEW(view);
1178
1180 g_signal_connect(selection, "changed",
1182
1183 for (i = 0; (title = economy_report_column_name(i)); i++) {
1184 GtkCellRenderer *renderer;
1187
1188 if (GDK_TYPE_PIXBUF == type) {
1189 renderer = gtk_cell_renderer_pixbuf_new();
1191 "pixbuf", i, NULL);
1192#if 0
1193 } else if (G_TYPE_BOOLEAN == type) {
1194 renderer = gtk_cell_renderer_toggle_new();
1196 "active", i, NULL);
1197#endif
1198 } else {
1199 bool is_redundant = (i == ERD_COL_REDUNDANT);
1200 renderer = gtk_cell_renderer_text_new();
1201 if (is_redundant) {
1202 /* Special treatment: hide "Redundant" column for units */
1204 "text", i,
1205 "visible",
1207 NULL);
1208 } else {
1210 "text", i, NULL);
1211 }
1212 }
1213
1214 if (i > 1) {
1215 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1217 }
1218
1220 }
1221
1222 label = gtk_label_new(NULL);
1225 gtk_widget_set_margin_end(label, 5);
1226 gtk_widget_set_margin_top(label, 5);
1228 preport->label = GTK_LABEL(label);
1229
1230 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1232
1233 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1236
1237 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1240
1241 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1244
1247
1248 gui_dialog_set_default_size(preport->shell, -1, 350);
1250
1252
1254}
1255
1256/************************************************************************/
1260{
1262
1264 fc_assert(NULL == preport->shell);
1265
1266 memset(preport, 0, sizeof(*preport));
1267}
1268
1269/************************************************************************/
1283
1284/************************************************************************/
1293
1294/************************************************************************/
1303
1304
1305/****************************************************************************
1306 UNITS REPORT DIALOG
1307****************************************************************************/
1308struct units_report {
1309 struct gui_dialog *shell;
1311};
1312
1313static struct units_report units_report = { NULL, NULL };
1314
1319
1320/* Those values must match the order of unit_report_columns[]. */
1340
1341static const struct {
1343 const char *title;
1344 const char *tooltip;
1347} unit_report_columns[] = {
1348 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1349 NULL, FALSE, -1 },
1350 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1351 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1352 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1354 /* TRANS: "In progress" abbreviation. */
1355 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1356 N_("In progress"), TRUE, -1 },
1357 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1358 NULL, TRUE, -1 },
1359 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1360 N_("Total shield upkeep"), TRUE, -1 },
1361 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1362 N_("Total food upkeep"), TRUE, -1 },
1363 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1364 N_("Total gold upkeep"), TRUE, -1 },
1365 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1366 " ", TRUE, -1 },
1367
1368 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1369 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1370 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1371 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1373
1374/************************************************************************/
1378{
1379 int i;
1381
1383
1384 for (i = 0; i < URD_COL_NUM; i++) {
1385 cols[i] = unit_report_columns[i].type;
1386 }
1387
1389}
1390
1391/************************************************************************/
1395{
1396 struct urd_info {
1397 int active_count;
1398 int building_count;
1399 int upkeep[O_LAST];
1400 };
1401
1403 struct urd_info unit_totals;
1404 struct urd_info *info;
1405 int total_upgradable_count = 0;
1406 GtkTreeSelection *selection;
1407 GtkTreeModel *model;
1408 GtkListStore *store;
1410 Unit_type_id selected, utype_id;
1411
1413
1414 memset(unit_array, '\0', sizeof(unit_array));
1415 memset(&unit_totals, '\0', sizeof(unit_totals));
1416
1417 /* Count units. */
1418 players_iterate(pplayer) {
1419 if (client_has_player() && pplayer != client_player()) {
1420 continue;
1421 }
1422
1423 unit_list_iterate(pplayer->units, punit) {
1425
1426 if (0 != punit->homecity) {
1428 info->upkeep[o] += punit->upkeep[o];
1430 }
1431 info->active_count++;
1433 city_list_iterate(pplayer->cities, pcity) {
1434 if (VUT_UTYPE == pcity->production.kind) {
1435 int num_units;
1436 info = unit_array + utype_index(pcity->production.value.utype);
1437 /* Account for build slots in city */
1439 /* Unit is in progress even if it won't be done this turn */
1440 num_units = MAX(num_units, 1);
1441 info->building_count += num_units;
1442 }
1445
1446 /* Save selection. */
1447 selection = gtk_tree_view_get_selection(preport->tree_view);
1448 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1449 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1450 } else {
1451 selected = -1;
1452 }
1453
1454 /* Make the store. */
1455 model = gtk_tree_view_get_model(preport->tree_view);
1456 store = GTK_LIST_STORE(model);
1457 gtk_list_store_clear(store);
1458
1459 unit_type_iterate(utype) {
1460 bool upgradable;
1461
1462 utype_id = utype_index(utype);
1463 info = unit_array + utype_id;
1464
1465 if (0 == info->active_count && 0 == info->building_count) {
1466 continue; /* We don't need a row for this type. */
1467 }
1468
1470 && NULL != can_upgrade_unittype(client_player(), utype);
1471
1472 gtk_list_store_append(store, &iter);
1473 gtk_list_store_set(store, &iter,
1476 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1477 URD_COL_IN_PROGRESS, info->building_count,
1478 URD_COL_ACTIVE, info->active_count,
1479 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1480 URD_COL_FOOD, info->upkeep[O_FOOD],
1481 URD_COL_GOLD, info->upkeep[O_GOLD],
1482 URD_COL_EMPTY, " ",
1487 -1);
1488 if (selected == utype_id) {
1489 /* Restore the selection. */
1491 }
1492
1493 /* Update totals. */
1494 unit_totals.active_count += info->active_count;
1496 unit_totals.upkeep[o] += info->upkeep[o];
1498 unit_totals.building_count += info->building_count;
1499 if (upgradable) {
1500 total_upgradable_count += info->active_count;
1501 }
1503
1504 /* Add the total row. */
1505 gtk_list_store_append(store, &iter);
1506 gtk_list_store_set(store, &iter,
1507 URD_COL_UTYPE_NAME, _("Totals:"),
1508 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1510 URD_COL_IN_PROGRESS, unit_totals.building_count,
1511 URD_COL_ACTIVE, unit_totals.active_count,
1515 URD_COL_EMPTY, " ",
1520 -1);
1521 if (selected == U_LAST) {
1522 /* Restore the selection. */
1524 }
1525}
1526
1527/************************************************************************/
1531 gpointer data)
1532{
1533 struct units_report *preport = data;
1534 GtkTreeModel *model;
1535 GtkTreeIter it;
1536 int active_count;
1537 struct unit_type *utype = NULL;
1538
1539 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1540 int ut;
1541
1542 gtk_tree_model_get(model, &it,
1543 URD_COL_ACTIVE, &active_count,
1545 -1);
1546 if (0 < active_count) {
1547 utype = utype_by_number(ut);
1548 }
1549 }
1550
1551 if (NULL == utype) {
1553 FALSE);
1555 FALSE);
1556 } else {
1561 && NULL != can_upgrade_unittype(client_player(), utype)));
1562 }
1563}
1564
1565/************************************************************************/
1568static struct unit *find_nearest_unit(const struct unit_type *utype,
1569 struct tile *ptile)
1570{
1571 struct unit *best_candidate = NULL;
1572 int best_dist = FC_INFINITY, dist;
1573
1574 players_iterate(pplayer) {
1575 if (client_has_player() && pplayer != client_player()) {
1576 continue;
1577 }
1578
1579 unit_list_iterate(pplayer->units, punit) {
1580 if (utype == unit_type_get(punit)
1582 && 0 < punit->moves_left
1583 && !punit->done_moving
1584 && punit->ssa_controller == SSA_NONE) {
1585 dist = sq_map_distance(unit_tile(punit), ptile);
1586 if (dist < best_dist) {
1588 best_dist = dist;
1589 }
1590 }
1593
1594 return best_candidate;
1595}
1596
1597/************************************************************************/
1600static void units_report_command_callback(struct gui_dialog *pdialog,
1601 int response,
1602 gpointer data)
1603{
1604 struct units_report *preport = data;
1605 struct unit_type *utype = NULL;
1606 GtkTreeSelection *selection;
1607 GtkTreeModel *model;
1608 GtkTreeIter it;
1609
1610 switch (response) {
1611 case URD_RES_NEAREST:
1612 case URD_RES_UPGRADE:
1613 break;
1614 default:
1615 gui_dialog_destroy(pdialog);
1616 return;
1617 }
1618
1619 /* Nearest & upgrade commands. */
1620 selection = gtk_tree_view_get_selection(preport->tree_view);
1621 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1622 int ut;
1623
1624 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1625 utype = utype_by_number(ut);
1626 }
1627
1628 if (response == URD_RES_NEAREST) {
1629 struct tile *ptile;
1630 struct unit *punit;
1631
1632 ptile = get_center_tile_mapcanvas();
1633 if ((punit = find_nearest_unit(utype, ptile))) {
1635
1640 }
1641 }
1642 }
1643 } else if (can_client_issue_orders()) {
1645 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1646 char buf[1024];
1647 int price = unit_upgrade_price(client_player(), utype, upgrade);
1648
1649 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1650 "Treasury contains %d gold.",
1651 client_player()->economic.gold),
1652 client_player()->economic.gold);
1653
1658 /* TRANS: Last %s is pre-pluralised
1659 * "Treasury contains %d gold." */
1660 PL_("Upgrade as many %s to %s as possible "
1661 "for %d gold each?\n%s",
1662 "Upgrade as many %s to %s as possible "
1663 "for %d gold each?\n%s", price),
1665 utype_name_translation(upgrade),
1666 price, buf);
1668
1669 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1670
1673 }
1674
1676 }
1677}
1678
1679/************************************************************************/
1683{
1684 GtkWidget *view, *sw, *button;
1685 GtkListStore *store;
1686 GtkTreeSelection *selection;
1689
1691
1693 gui_dialog_set_title(preport->shell, _("Units"));
1694
1701
1702 store = units_report_store_new();
1705 g_object_unref(store);
1706 gtk_widget_set_name(view, "small_font");
1709 preport->tree_view = GTK_TREE_VIEW(view);
1710
1712 g_signal_connect(selection, "changed",
1714
1715 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1716 GtkCellRenderer *renderer;
1717
1718 if (strlen(unit_report_columns[i].title) > 0) {
1720
1724 }
1730 }
1732 } /* else add new renderer to previous TreeViewColumn */
1733
1734 fc_assert(col != NULL);
1736 renderer = gtk_cell_renderer_toggle_new();
1738 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1739 } else {
1740 renderer = gtk_cell_renderer_text_new();
1742 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1744 "weight", URD_COL_TEXT_WEIGHT);
1745 }
1746
1747 if (unit_report_columns[i].visible_col >= 0) {
1748 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1750 }
1751
1753 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1754 }
1755 }
1756
1757 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1759
1760 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1763
1764 button = gui_dialog_add_button(preport->shell, "edit-find",
1765 _("Find _Nearest"), URD_RES_NEAREST);
1767
1770
1771 gui_dialog_set_default_size(preport->shell, -1, 350);
1773
1776}
1777
1778/************************************************************************/
1782{
1784
1786 fc_assert(NULL == preport->shell);
1787
1788 memset(preport, 0, sizeof(*preport));
1789}
1790
1791/************************************************************************/
1805
1806/************************************************************************/
1816
1817/************************************************************************/
1826
1827
1828/****************************************************************************
1829 FINAL REPORT DIALOG
1830****************************************************************************/
1831struct endgame_report {
1832 struct gui_dialog *shell;
1835 int player_count;
1836 int players_received;
1837};
1838
1847
1849
1850/************************************************************************/
1853static const char *
1855{
1856 switch (col) {
1857 case FRD_COL_PLAYER:
1858 return _("Player\n");
1859 case FRD_COL_NATION:
1860 return _("Nation\n");
1861 case FRD_COL_SCORE:
1862 return _("Score\n");
1863 case FRD_COL_TOOLTIP:
1864 case FRD_COL_NUM:
1865 break;
1866 }
1867
1868 return NULL;
1869}
1870
1871/************************************************************************/
1875 const struct packet_endgame_report *packet)
1876{
1877 const size_t col_num = packet->category_num + FRD_COL_NUM;
1881 int i;
1882
1884
1885 /* Remove the old columns. */
1886 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1888 }
1889
1890 /* Create the new model. */
1895 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1897 }
1901
1902 /* Create the new columns. */
1903 for (i = 0; (guint)i < col_num; i++) {
1904 GtkCellRenderer *renderer;
1905 const char *title;
1906 const char *attribute;
1907
1908 if (GDK_TYPE_PIXBUF == col_types[i]) {
1909 renderer = gtk_cell_renderer_pixbuf_new();
1910 attribute = "pixbuf";
1911 } else {
1912 renderer = gtk_cell_renderer_text_new();
1913 attribute = "text";
1914 }
1915
1916 if (i < FRD_COL_NUM) {
1918 } else {
1919 title = packet->category_name[i - FRD_COL_NUM];
1920 }
1921
1922 if (title != NULL) {
1924 attribute, i, NULL);
1926 if (GDK_TYPE_PIXBUF != col_types[i]) {
1928 }
1929 }
1930 }
1931
1934
1935 preport->store = store;
1936 preport->player_count = packet->player_num;
1937 preport->players_received = 0;
1938}
1939
1940/************************************************************************/
1944{
1945 /* Fill the model with player stats. */
1947 const struct player *pplayer = player_by_number(packet->player_id);
1949 int i;
1950
1953 FRD_COL_PLAYER, player_name(pplayer),
1955 FRD_COL_SCORE, packet->score,
1956 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1957 -1);
1958 for (i = 0; i < packet->category_num; i++) {
1960 i + FRD_COL_NUM, packet->category_score[i],
1961 -1);
1962 }
1963
1964 preport->players_received++;
1965
1966 if (preport->players_received == preport->player_count) {
1968 }
1969}
1970
1971/************************************************************************/
2004
2005/************************************************************************/
bool action_ever_possible(action_id action)
Definition actions.c:8092
int entries_used
Definition agents.c:77
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:747
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define output_type_iterate(output)
Definition city.h:845
#define city_list_iterate_end
Definition city.h:510
#define output_type_iterate_end
Definition city.h:851
bool client_is_global_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:504
struct universal cid_decode(cid id)
Definition climisc.c:525
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:75
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:636
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
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
int int id
Definition editgui_g.h:28
int Tech_type_id
Definition fc_types.h:377
int Unit_type_id
Definition fc_types.h:382
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
@ O_LAST
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * top_notebook
Definition gui_main.c:129
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:888
void itree_next(ITree *it)
Definition gui_stuff.c:144
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:760
GtkWidget * gui_dialog_get_toplevel(struct gui_dialog *dlg)
Definition gui_stuff.c:787
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
@ GUI_DIALOG_TAB
Definition gui_stuff.h:62
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
static struct endgame_report endgame_report
Definition repodlgs.c:1822
static void units_report_init(struct units_report *preport)
Definition repodlgs.c:1653
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
static GtkListStore * units_report_store_new(void)
Definition repodlgs.c:1348
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
static void science_report_store_set(GtkListStore *store, GtkTreeIter *iter, Tech_type_id tech)
Definition repodlgs.c:136
static void economy_report_init(struct economy_report *preport)
Definition repodlgs.c:1117
static void science_report_update(struct science_report *preport)
Definition repodlgs.c:383
static void units_report_update(struct units_report *preport)
Definition repodlgs.c:1365
static bool science_report_combo_get_active(GtkComboBox *combo, Tech_type_id *tech, char **name)
Definition repodlgs.c:154
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
Definition repodlgs.c:312
units_report_response
Definition repodlgs.c:1286
@ URD_RES_UPGRADE
Definition repodlgs.c:1288
@ URD_RES_NEAREST
Definition repodlgs.c:1287
static void endgame_report_update(struct endgame_report *preport, const struct packet_endgame_report *packet)
Definition repodlgs.c:1848
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
const char * tooltip
Definition repodlgs.c:1315
static const struct @158 unit_report_columns[]
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
Definition repodlgs.c:235
static const char * endgame_report_column_name(enum endgame_report_columns col)
Definition repodlgs.c:1828
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
static void endgame_report_init(struct endgame_report *preport)
Definition repodlgs.c:1948
static void science_report_combo_set_active(GtkComboBox *combo, Tech_type_id tech)
Definition repodlgs.c:175
const char * title
Definition repodlgs.c:1314
static void science_diagram_data(GtkWidget *widget, bool show_all)
Definition repodlgs.c:290
static void science_report_free(struct science_report *preport)
Definition repodlgs.c:703
static bool science_report_no_combo_callback
Definition repodlgs.c:109
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
static void economy_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:953
GType type
Definition repodlgs.c:1313
static void units_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:1571
static void units_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1501
static void economy_report_update(struct economy_report *preport)
Definition repodlgs.c:858
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
units_report_columns
Definition repodlgs.c:1292
@ URD_COL_NUM
Definition repodlgs.c:1309
@ URD_COL_UPG_VISIBLE
Definition repodlgs.c:1305
@ URD_COL_ACTIVE
Definition repodlgs.c:1297
@ URD_COL_IN_PROGRESS
Definition repodlgs.c:1296
@ URD_COL_TEXT_WEIGHT
Definition repodlgs.c:1304
@ URD_COL_GOLD
Definition repodlgs.c:1300
@ URD_COL_UPGRADABLE
Definition repodlgs.c:1294
@ URD_COL_FOOD
Definition repodlgs.c:1299
@ URD_COL_N_UPGRADABLE
Definition repodlgs.c:1295
@ URD_COL_NUPG_VISIBLE
Definition repodlgs.c:1306
@ URD_COL_UTYPE_NAME
Definition repodlgs.c:1293
@ URD_COL_UTYPE_ID
Definition repodlgs.c:1307
@ URD_COL_SHIELD
Definition repodlgs.c:1298
@ URD_COL_EMPTY
Definition repodlgs.c:1301
science_report_columns
Definition repodlgs.c:112
@ SRD_COL_ID
Definition repodlgs.c:117
@ SRD_COL_NAME
Definition repodlgs.c:113
@ SRD_COL_NUM
Definition repodlgs.c:119
@ SRD_COL_STEPS
Definition repodlgs.c:114
static const char * economy_report_column_name(enum economy_report_columns col)
Definition repodlgs.c:826
static GtkWidget * science_diagram_new(void)
Definition repodlgs.c:270
int visible_col
Definition repodlgs.c:1317
static void science_report_show_all_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:545
economy_report_columns
Definition repodlgs.c:788
@ ERD_COL_NUM
Definition repodlgs.c:801
@ ERD_COL_SPRITE
Definition repodlgs.c:789
@ ERD_COL_IS_IMPROVEMENT
Definition repodlgs.c:798
@ ERD_COL_CID
Definition repodlgs.c:799
@ ERD_COL_NAME
Definition repodlgs.c:790
@ ERD_COL_EMPTY
Definition repodlgs.c:795
@ ERD_COL_REDUNDANT
Definition repodlgs.c:791
@ ERD_COL_TOTAL_COST
Definition repodlgs.c:794
@ ERD_COL_COUNT
Definition repodlgs.c:792
@ ERD_COL_COST
Definition repodlgs.c:793
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
bool rightalign
Definition repodlgs.c:1316
static GtkListStore * economy_report_store_new(void)
Definition repodlgs.c:807
static struct unit * find_nearest_unit(const struct unit_type *utype, struct tile *ptile)
Definition repodlgs.c:1539
endgame_report_columns
Definition repodlgs.c:1813
@ FRD_COL_NUM
Definition repodlgs.c:1819
@ FRD_COL_TOOLTIP
Definition repodlgs.c:1817
@ FRD_COL_NATION
Definition repodlgs.c:1815
@ FRD_COL_PLAYER
Definition repodlgs.c:1814
@ FRD_COL_SCORE
Definition repodlgs.c:1816
economy_report_response
Definition repodlgs.c:780
@ ERD_RES_SELL_REDUNDANT
Definition repodlgs.c:781
@ ERD_RES_SELL_ALL
Definition repodlgs.c:782
@ ERD_RES_DISBAND_UNITS
Definition repodlgs.c:783
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
static void economy_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1068
static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:556
static void economy_report_free(struct economy_report *preport)
Definition repodlgs.c:1230
static void science_report_init(struct science_report *preport)
Definition repodlgs.c:580
static void science_report_current_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:520
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
static void units_report_free(struct units_report *preport)
Definition repodlgs.c:1755
static GtkListStore * science_report_store_new(void)
Definition repodlgs.c:125
static void science_report_redraw(struct science_report *preport)
Definition repodlgs.c:345
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1135
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1104
static gboolean science_diagram_left_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:202
const char * tooltip
Definition repodlgs.c:1344
const char * title
Definition repodlgs.c:1343
GType type
Definition repodlgs.c:1342
int visible_col
Definition repodlgs.c:1346
bool rightalign
Definition repodlgs.c:1345
static gboolean science_diagram_right_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:238
@ HELP_TECH
Definition helpdlg_g.h:21
bool can_sell_building(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:641
struct tile * get_center_tile_mapcanvas(void)
void center_tile_mapcanvas(const struct tile *ptile)
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:741
struct player * player_by_number(const int player_id)
Definition player.c:849
const char * player_name(const struct player *pplayer)
Definition player.c:895
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
endgame_report_dialog_player
Definition repodlgs_g.h:33
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Definition reqtree.c:1036
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:870
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1176
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1199
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:473
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:839
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
bool research_future_next(const struct research *presearch)
Definition research.c:1362
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
#define ARRAY_SIZE(x)
Definition shared.h:85
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
cairo_t * drawable
Definition canvas.h:24
struct connection conn
Definition client_main.h:96
GtkLabel * label
Definition repodlgs.c:775
GtkTreeView * tree_view
Definition repodlgs.c:774
struct gui_dialog * shell
Definition repodlgs.c:773
GtkListStore * store
Definition repodlgs.c:1808
GtkTreeView * tree_view
Definition repodlgs.c:1807
struct gui_dialog * shell
Definition repodlgs.c:1806
Definition climisc.h:82
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:85
Tech_type_id researching
Definition research.h:52
struct gui_dialog * shell
Definition repodlgs.c:70
GtkProgressBar * progress_bar
Definition repodlgs.c:75
GtkComboBox * reachable_techs
Definition repodlgs.c:71
GtkComboBox * reachable_goals
Definition repodlgs.c:72
GtkDrawingArea * drawing_area
Definition repodlgs.c:77
GtkLabel * goal_label
Definition repodlgs.c:76
GtkLabel * main_label
Definition repodlgs.c:74
GtkWidget * button_show_all
Definition repodlgs.c:73
Definition tile.h:50
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int homecity
Definition unit.h:146
bool done_moving
Definition unit.h:181
const struct unit_type * utype
Definition unit.h:139
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
GtkTreeView * tree_view
Definition repodlgs.c:1281
struct gui_dialog * shell
Definition repodlgs.c:1280
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:473
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
#define A_FUTURE
Definition tech.h:46
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2126
const char * get_science_target_text(double *percent)
Definition text.c:820
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6783
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7514
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6805
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
#define unit_tile(_pu)
Definition unit.h:397
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862