Freeciv-3.3
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-5.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
1027 gtk_tree_model_get(model, &iter,
1028 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
1029 &count, -1);
1030 if (count == 0) {
1031 break;
1032 }
1037 redundant
1038 /* TRANS: %s is an improvement */
1039 ? _("Do you really wish to sell "
1040 "every redundant %s (%d total)?")
1041 /* TRANS: %s is an improvement */
1042 : _("Do you really wish to sell "
1043 "every %s (%d total)?"),
1045 count);
1047 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1048
1050 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1051 }
1053 }
1054 }
1055 break;
1056 case VUT_UTYPE:
1057 {
1058 if (ERD_RES_DISBAND_UNITS == response) {
1059 const struct unit_type *putype = selected.value.utype;
1060 gint count;
1061
1062 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1063
1068 /* TRANS: %s is a unit */
1069 _("Do you really wish to disband "
1070 "every %s (%d total)?"),
1072 count);
1074 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1075
1077 disband_all_units(putype, FALSE, buf, sizeof(buf));
1078 }
1080 }
1081 }
1082 break;
1083 default:
1084 log_error("Not supported type: %d.", selected.kind);
1085 }
1086
1087 if ('\0' != buf[0]) {
1090 "%s", buf);
1093 NULL);
1094 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1096 }
1097}
1098
1099/************************************************************************/
1103 gpointer data)
1104{
1105 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1106 GtkTreeModel *model;
1108
1110 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1111 struct universal selected;
1112 cid id;
1113
1114 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1115 selected = cid_decode(id);
1116 switch (selected.kind) {
1117 case VUT_IMPROVEMENT:
1118 {
1119 bool can_sell = can_sell_building(selected.value.building);
1120 gint redundant;
1121
1122 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1123
1125 can_sell && redundant > 0);
1128 FALSE);
1129 }
1130 return;
1131 case VUT_UTYPE:
1133 FALSE);
1136 TRUE);
1137 return;
1138 default:
1139 log_error("Not supported type: %d.", selected.kind);
1140 break;
1141 }
1142 }
1143
1147}
1148
1149/************************************************************************/
1153{
1154 GtkWidget *view, *sw, *label, *button;
1155 GtkListStore *store;
1156 GtkTreeSelection *selection;
1157 const char *title;
1159
1161
1163 gui_dialog_set_title(preport->shell, _("Economy"));
1164
1171
1172 store = economy_report_store_new();
1175 g_object_unref(store);
1176 gtk_widget_set_name(view, "small_font");
1179 preport->tree_view = GTK_TREE_VIEW(view);
1180
1182 g_signal_connect(selection, "changed",
1184
1185 for (i = 0; (title = economy_report_column_name(i)); i++) {
1186 GtkCellRenderer *renderer;
1189
1190 if (GDK_TYPE_PIXBUF == type) {
1191 renderer = gtk_cell_renderer_pixbuf_new();
1193 "pixbuf", i, NULL);
1194#if 0
1195 } else if (G_TYPE_BOOLEAN == type) {
1196 renderer = gtk_cell_renderer_toggle_new();
1198 "active", i, NULL);
1199#endif
1200 } else {
1201 bool is_redundant = (i == ERD_COL_REDUNDANT);
1202
1203 renderer = gtk_cell_renderer_text_new();
1204 if (is_redundant) {
1205 /* Special treatment: hide "Redundant" column for units */
1207 "text", i,
1208 "visible",
1210 NULL);
1211 } else {
1213 "text", i, NULL);
1214 }
1215 }
1216
1217 if (i > 1) {
1218 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1220 }
1221
1223 }
1224
1225 label = gtk_label_new(NULL);
1228 gtk_widget_set_margin_end(label, 5);
1229 gtk_widget_set_margin_top(label, 5);
1231 preport->label = GTK_LABEL(label);
1232
1233 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1235
1236 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1239
1240 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1243
1244 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1247
1250
1251 gui_dialog_set_default_size(preport->shell, -1, 350);
1253
1255
1257}
1258
1259/************************************************************************/
1263{
1265
1267 fc_assert(NULL == preport->shell);
1268
1269 memset(preport, 0, sizeof(*preport));
1270}
1271
1272/************************************************************************/
1286
1287/************************************************************************/
1296
1297/************************************************************************/
1306
1307
1308/****************************************************************************
1309 UNITS REPORT DIALOG
1310****************************************************************************/
1311struct units_report {
1312 struct gui_dialog *shell;
1314};
1315
1316static struct units_report units_report = { NULL, NULL };
1317
1322
1323/* Those values must match the order of unit_report_columns[]. */
1343
1344static const struct {
1346 const char *title;
1347 const char *tooltip;
1350} unit_report_columns[] = {
1351 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1352 NULL, FALSE, -1 },
1353 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1354 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1355 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1357 /* TRANS: "In progress" abbreviation. */
1358 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1359 N_("In progress"), TRUE, -1 },
1360 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1361 NULL, TRUE, -1 },
1362 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1363 N_("Total shield upkeep"), TRUE, -1 },
1364 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1365 N_("Total food upkeep"), TRUE, -1 },
1366 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1367 N_("Total gold upkeep"), TRUE, -1 },
1368 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1369 " ", TRUE, -1 },
1370
1371 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1372 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1373 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1374 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1376
1377/************************************************************************/
1381{
1382 int i;
1384
1386
1387 for (i = 0; i < URD_COL_NUM; i++) {
1388 cols[i] = unit_report_columns[i].type;
1389 }
1390
1392}
1393
1394/************************************************************************/
1398{
1399 struct urd_info {
1400 int active_count;
1401 int building_count;
1402 int upkeep[O_LAST];
1403 };
1404
1406 struct urd_info unit_totals;
1407 struct urd_info *info;
1408 int total_upgradable_count = 0;
1409 GtkTreeSelection *selection;
1410 GtkTreeModel *model;
1411 GtkListStore *store;
1413 Unit_type_id selected, utype_id;
1414
1416
1417 memset(unit_array, '\0', sizeof(unit_array));
1418 memset(&unit_totals, '\0', sizeof(unit_totals));
1419
1420 /* Count units. */
1421 players_iterate(pplayer) {
1422 if (client_has_player() && pplayer != client_player()) {
1423 continue;
1424 }
1425
1426 unit_list_iterate(pplayer->units, punit) {
1428
1429 if (0 != punit->homecity) {
1431 info->upkeep[o] += punit->upkeep[o];
1433 }
1434 info->active_count++;
1436 city_list_iterate(pplayer->cities, pcity) {
1437 if (VUT_UTYPE == pcity->production.kind) {
1438 int num_units;
1439 info = unit_array + utype_index(pcity->production.value.utype);
1440 /* Account for build slots in city */
1442 /* Unit is in progress even if it won't be done this turn */
1443 num_units = MAX(num_units, 1);
1444 info->building_count += num_units;
1445 }
1448
1449 /* Save selection. */
1450 selection = gtk_tree_view_get_selection(preport->tree_view);
1451 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1452 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1453 } else {
1454 selected = -1;
1455 }
1456
1457 /* Make the store. */
1458 model = gtk_tree_view_get_model(preport->tree_view);
1459 store = GTK_LIST_STORE(model);
1460 gtk_list_store_clear(store);
1461
1462 unit_type_iterate(utype) {
1463 bool upgradable;
1464
1465 utype_id = utype_index(utype);
1466 info = unit_array + utype_id;
1467
1468 if (0 == info->active_count && 0 == info->building_count) {
1469 continue; /* We don't need a row for this type. */
1470 }
1471
1473 && NULL != can_upgrade_unittype(client_player(), utype);
1474
1475 gtk_list_store_append(store, &iter);
1476 gtk_list_store_set(store, &iter,
1479 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1480 URD_COL_IN_PROGRESS, info->building_count,
1481 URD_COL_ACTIVE, info->active_count,
1482 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1483 URD_COL_FOOD, info->upkeep[O_FOOD],
1484 URD_COL_GOLD, info->upkeep[O_GOLD],
1485 URD_COL_EMPTY, " ",
1490 -1);
1491 if (selected == utype_id) {
1492 /* Restore the selection. */
1494 }
1495
1496 /* Update totals. */
1497 unit_totals.active_count += info->active_count;
1499 unit_totals.upkeep[o] += info->upkeep[o];
1501 unit_totals.building_count += info->building_count;
1502 if (upgradable) {
1503 total_upgradable_count += info->active_count;
1504 }
1506
1507 /* Add the total row. */
1508 gtk_list_store_append(store, &iter);
1509 gtk_list_store_set(store, &iter,
1510 URD_COL_UTYPE_NAME, _("Totals:"),
1511 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1513 URD_COL_IN_PROGRESS, unit_totals.building_count,
1514 URD_COL_ACTIVE, unit_totals.active_count,
1518 URD_COL_EMPTY, " ",
1523 -1);
1524 if (selected == U_LAST) {
1525 /* Restore the selection. */
1527 }
1528}
1529
1530/************************************************************************/
1534 gpointer data)
1535{
1536 struct units_report *preport = data;
1537 GtkTreeModel *model;
1538 GtkTreeIter it;
1539 int active_count;
1540 struct unit_type *utype = NULL;
1541
1542 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1543 int ut;
1544
1545 gtk_tree_model_get(model, &it,
1546 URD_COL_ACTIVE, &active_count,
1548 -1);
1549 if (0 < active_count) {
1550 utype = utype_by_number(ut);
1551 }
1552 }
1553
1554 if (NULL == utype) {
1556 FALSE);
1558 FALSE);
1559 } else {
1564 && NULL != can_upgrade_unittype(client_player(), utype)));
1565 }
1566}
1567
1568/************************************************************************/
1571static struct unit *find_nearest_unit(const struct unit_type *utype,
1572 struct tile *ptile)
1573{
1574 struct unit *best_candidate = NULL;
1575 int best_dist = FC_INFINITY, dist;
1576
1577 players_iterate(pplayer) {
1578 if (client_has_player() && pplayer != client_player()) {
1579 continue;
1580 }
1581
1582 unit_list_iterate(pplayer->units, punit) {
1583 if (utype == unit_type_get(punit)
1585 && 0 < punit->moves_left
1586 && !punit->done_moving
1587 && punit->ssa_controller == SSA_NONE) {
1588 dist = sq_map_distance(unit_tile(punit), ptile);
1589 if (dist < best_dist) {
1591 best_dist = dist;
1592 }
1593 }
1596
1597 return best_candidate;
1598}
1599
1600/************************************************************************/
1603static void units_report_command_callback(struct gui_dialog *pdialog,
1604 int response,
1605 gpointer data)
1606{
1607 struct units_report *preport = data;
1608 struct unit_type *utype = NULL;
1609 GtkTreeSelection *selection;
1610 GtkTreeModel *model;
1611 GtkTreeIter it;
1612
1613 switch (response) {
1614 case URD_RES_NEAREST:
1615 case URD_RES_UPGRADE:
1616 break;
1617 default:
1618 gui_dialog_destroy(pdialog);
1619 return;
1620 }
1621
1622 /* Nearest & upgrade commands. */
1623 selection = gtk_tree_view_get_selection(preport->tree_view);
1624 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1625 int ut;
1626
1627 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1628 utype = utype_by_number(ut);
1629 }
1630
1631 if (response == URD_RES_NEAREST) {
1632 struct tile *ptile;
1633 struct unit *punit;
1634
1635 ptile = get_center_tile_mapcanvas();
1636 if ((punit = find_nearest_unit(utype, ptile))) {
1638
1643 }
1644 }
1645 }
1646 } else if (can_client_issue_orders()) {
1648 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1649 char buf[1024];
1650 int price = unit_upgrade_price(client_player(), utype, upgrade);
1651
1652 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1653 "Treasury contains %d gold.",
1654 client_player()->economic.gold),
1655 client_player()->economic.gold);
1656
1661 /* TRANS: Last %s is pre-pluralised
1662 * "Treasury contains %d gold." */
1663 PL_("Upgrade as many %s to %s as possible "
1664 "for %d gold each?\n%s",
1665 "Upgrade as many %s to %s as possible "
1666 "for %d gold each?\n%s", price),
1668 utype_name_translation(upgrade),
1669 price, buf);
1671
1672 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1673
1676 }
1677
1679 }
1680}
1681
1682/************************************************************************/
1686{
1687 GtkWidget *view, *sw, *button;
1688 GtkListStore *store;
1689 GtkTreeSelection *selection;
1692
1694
1696 gui_dialog_set_title(preport->shell, _("Units"));
1697
1704
1705 store = units_report_store_new();
1708 g_object_unref(store);
1709 gtk_widget_set_name(view, "small_font");
1712 preport->tree_view = GTK_TREE_VIEW(view);
1713
1715 g_signal_connect(selection, "changed",
1717
1718 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1719 GtkCellRenderer *renderer;
1720
1721 if (strlen(unit_report_columns[i].title) > 0) {
1723
1727 }
1733 }
1735 } /* else add new renderer to previous TreeViewColumn */
1736
1737 fc_assert(col != NULL);
1739 renderer = gtk_cell_renderer_toggle_new();
1741 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1742 } else {
1743 renderer = gtk_cell_renderer_text_new();
1745 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1747 "weight", URD_COL_TEXT_WEIGHT);
1748 }
1749
1750 if (unit_report_columns[i].visible_col >= 0) {
1751 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1753 }
1754
1756 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1757 }
1758 }
1759
1760 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1762
1763 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1766
1767 button = gui_dialog_add_button(preport->shell, "edit-find",
1768 _("Find _Nearest"), URD_RES_NEAREST);
1770
1773
1774 gui_dialog_set_default_size(preport->shell, -1, 350);
1776
1779}
1780
1781/************************************************************************/
1785{
1787
1789 fc_assert(NULL == preport->shell);
1790
1791 memset(preport, 0, sizeof(*preport));
1792}
1793
1794/************************************************************************/
1808
1809/************************************************************************/
1819
1820/************************************************************************/
1829
1830
1831/****************************************************************************
1832 FINAL REPORT DIALOG
1833****************************************************************************/
1834struct endgame_report {
1835 struct gui_dialog *shell;
1838 int player_count;
1839 int players_received;
1840};
1841
1850
1852
1853/************************************************************************/
1856static const char *
1858{
1859 switch (col) {
1860 case FRD_COL_PLAYER:
1861 return _("Player\n");
1862 case FRD_COL_NATION:
1863 return _("Nation\n");
1864 case FRD_COL_SCORE:
1865 return _("Score\n");
1866 case FRD_COL_TOOLTIP:
1867 case FRD_COL_NUM:
1868 break;
1869 }
1870
1871 return NULL;
1872}
1873
1874/************************************************************************/
1878 const struct packet_endgame_report *packet)
1879{
1880 const size_t col_num = packet->category_num + FRD_COL_NUM;
1884 int i;
1885
1887
1888 /* Remove the old columns. */
1889 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1891 }
1892
1893 /* Create the new model. */
1898 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1900 }
1904
1905 /* Create the new columns. */
1906 for (i = 0; (guint)i < col_num; i++) {
1907 GtkCellRenderer *renderer;
1908 const char *title;
1909 const char *attribute;
1910
1911 if (GDK_TYPE_PIXBUF == col_types[i]) {
1912 renderer = gtk_cell_renderer_pixbuf_new();
1913 attribute = "pixbuf";
1914 } else {
1915 renderer = gtk_cell_renderer_text_new();
1916 attribute = "text";
1917 }
1918
1919 if (i < FRD_COL_NUM) {
1921 } else {
1922 title = packet->category_name[i - FRD_COL_NUM];
1923 }
1924
1925 if (title != NULL) {
1927 attribute, i, NULL);
1929 if (GDK_TYPE_PIXBUF != col_types[i]) {
1931 }
1932 }
1933 }
1934
1937
1938 preport->store = store;
1939 preport->player_count = packet->player_num;
1940 preport->players_received = 0;
1941}
1942
1943/************************************************************************/
1947{
1948 /* Fill the model with player stats. */
1950 const struct player *pplayer = player_by_number(packet->player_id);
1952 int i;
1953
1956 FRD_COL_PLAYER, player_name(pplayer),
1958 FRD_COL_SCORE, packet->score,
1959 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1960 -1);
1961 for (i = 0; i < packet->category_num; i++) {
1963 i + FRD_COL_NUM, packet->category_score[i],
1964 -1);
1965 }
1966
1967 preport->players_received++;
1968
1969 if (preport->players_received == preport->player_count) {
1971 }
1972}
1973
1974/************************************************************************/
2007
2008/************************************************************************/
bool action_ever_possible(action_id action)
Definition actions.c:7550
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:505
#define output_type_iterate(output)
Definition city.h:842
#define city_list_iterate_end
Definition city.h:507
#define output_type_iterate_end
Definition city.h:848
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:505
struct universal cid_decode(cid id)
Definition climisc.c:526
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:493
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:76
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
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int int id
Definition editgui_g.h:28
int Tech_type_id
Definition fc_types.h:236
int Unit_type_id
Definition fc_types.h:241
@ 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:130
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
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 const struct @162 unit_report_columns[]
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:1136
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1105
static gboolean science_diagram_left_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:202
static gboolean science_diagram_right_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:238
const char * tooltip
Definition repodlgs.c:1347
const char * title
Definition repodlgs.c:1346
GType type
Definition repodlgs.c:1345
int visible_col
Definition repodlgs.c:1349
bool rightalign
Definition repodlgs.c:1348
@ 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:192
#define fc_assert(condition)
Definition log.h:177
#define log_error(message,...)
Definition log.h:104
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:686
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:788
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:542
#define players_iterate(_pplayer)
Definition player.h:537
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:1045
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:878
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1185
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1209
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:478
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:847
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:1370
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:89
Tech_type_id researching
Definition research.h:52
struct gui_dialog * shell
Definition repodlgs.c:70
GtkProgressBar * progress_bar
Definition repodlgs.c:75
GtkLayout * drawing_area
Definition repodlgs.c:77
GtkComboBox * reachable_techs
Definition repodlgs.c:71
GtkComboBox * reachable_goals
Definition repodlgs.c:72
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:140
int upkeep[O_LAST]
Definition unit.h:150
enum unit_activity activity
Definition unit.h:159
int moves_left
Definition unit.h:152
struct unit::@84::@86 client
int homecity
Definition unit.h:148
bool done_moving
Definition unit.h:184
const struct unit_type * utype
Definition unit.h:141
enum unit_focus_status focus_status
Definition unit.h:217
enum server_side_agent ssa_controller
Definition unit.h:175
GtkTreeView * tree_view
Definition repodlgs.c:1281
struct gui_dialog * shell
Definition repodlgs.c:1280
enum universals_n kind
Definition fc_types.h:608
universals_u value
Definition fc_types.h:607
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:471
#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:248
#define advance_index_iterate_max_end
Definition tech.h:254
static Tech_type_id advance_count(void)
Definition tech.h:165
#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:2174
const char * get_science_target_text(double *percent)
Definition text.c:867
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:913
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7007
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7743
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7029
const struct unit_type * utype
Definition fc_types.h:553
const struct impr_type * building
Definition fc_types.h:546
#define unit_tile(_pu)
Definition unit.h:404
@ FOCUS_AVAIL
Definition unit.h:54
#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:1709
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:1566
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1737
#define unit_type_iterate(_p)
Definition unittype.h:862
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:869