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/gdk.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/************************************************************************/
268 int width, int height, gpointer data)
269{
270 /* FIXME: This currently redraws everything! */
272 struct reqtree *reqtree = g_object_get_data(G_OBJECT(widget), "reqtree");
273 int rtwidth, rtheight;
274
276 return;
277 }
278
281
282 canvas.drawable = cr;
283
284 draw_reqtree(reqtree, &canvas, 0, 0, 0, 0, rtwidth, rtheight);
285}
286
287/************************************************************************/
314
315/************************************************************************/
318static void science_diagram_data(GtkWidget *widget, bool show_all)
319{
320 struct reqtree *reqtree;
321
322 if (can_conn_edit(&client.conn)) {
323 /* Show all techs in editor mode, not only currently reachable ones */
325 } else {
326 /* Show only at some point reachable techs */
327 reqtree = create_reqtree(client_player(), show_all);
328 }
329
332}
333
334/************************************************************************/
362
363/************************************************************************/
367{
368 Tech_type_id researching;
369
371
374 preport->button_show_all)));
375
376 if (client_has_player()) {
377 researching = research_get(client_player())->researching;
378 } else {
379 researching = A_UNSET;
380 }
381 science_diagram_center(GTK_WIDGET(preport->drawing_area), researching);
382
384}
385
386/************************************************************************/
400
401/************************************************************************/
405{
406 GtkListStore *store;
410 const char *text;
411 double pct;
412 Tech_type_id tech;
414
417
418 /* Disable callbacks. */
420
422
424
425 /* Update the progress bar. */
427 gtk_progress_bar_set_text(preport->progress_bar, text);
429 /* Work around GTK refresh bug? */
431
432 /* Update reachable techs. */
433 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
436
437 /* Collect all techs which are reachable in the next step. */
439 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
441 }
443
444 if (sorting_list != NULL) {
445 if (A_UNSET == presearch->researching
446 || is_future_tech(presearch->researching)) {
448 science_report_store_set(store, &iter, presearch->researching);
449 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
450 }
451
452 /* Sort the list, append it to the store. */
454 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
455 tech = GPOINTER_TO_INT(item->data);
457 science_report_store_set(store, &iter, tech);
458 if (tech == presearch->researching) {
459 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
460 }
461 }
462
463 /* Free, re-init. */
466 } else {
467 /* No reachable normal techs. Can we select Future Tech? */
468 Tech_type_id next;
469
472 next = A_FUTURE;
473 } else {
474 next = presearch->researching;
475 }
476 science_report_store_set(store, &iter, next);
477
478 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
479 }
480
481 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_goals));
483
484 /* Update the tech goal. */
485 gtk_label_set_text(preport->goal_label,
486 get_science_goal_text(presearch->tech_goal));
487
488 /* Collect all techs which are reachable in next 10 steps. */
491 && TECH_KNOWN != presearch->inventions[i].state
492 && (i == presearch->tech_goal
493 || 10 >= presearch->inventions[i].num_required_techs)) {
495 }
497
498 if (sorting_list != NULL) {
499 if (A_UNSET == presearch->tech_goal) {
502 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
503 }
504
505 /* Sort the list, append it to the store. */
507 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
508 tech = GPOINTER_TO_INT(item->data);
510 science_report_store_set(store, &iter, tech);
511 if (tech == presearch->tech_goal) {
512 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
513 }
514 }
515
516 /* Free. */
518 } else {
519 /* No reachable normal techs. Can we select Future Tech? */
520 Tech_type_id goal;
521
523
525 goal = A_FUTURE;
526 } else {
527 goal = A_UNSET;
528 }
529
530 science_report_store_set(store, &iter, goal);
531 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
532 }
533
534 /* Re-enable callbacks. */
536}
537
538/************************************************************************/
542 gpointer data)
543{
544 Tech_type_id tech;
545 char *tech_name;
546
547 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
548 return;
549 }
550
553 } else if (can_client_issue_orders()) {
555 }
556
557 free(tech_name);
558 /* Revert, or we will not be in sync with the server. */
561}
562
563/************************************************************************/
567 gpointer data)
568{
569 struct science_report *preport = (struct science_report *) data;
570
572}
573
574/************************************************************************/
578{
579 Tech_type_id tech;
580 char *tech_name;
581
582 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
583 return;
584 }
585
588 } else if (can_client_issue_orders()) {
590 }
591
592 free(tech_name);
593 /* Revert, or we will not be in sync with the server. */
595 (client_player())->tech_goal);
596}
597
598/************************************************************************/
602{
603 GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w;
604 GtkSizeGroup *group;
605 GtkListStore *store;
606 GtkCellRenderer *renderer;
607
609
611 /* TRANS: Research report title */
612 gui_dialog_set_title(preport->shell, _("Research"));
613
614 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
616
618
619 w = gtk_label_new(NULL);
621 preport->main_label = GTK_LABEL(w);
622
623 /* Current research target line. */
624 frame = gtk_frame_new(_("Researching"));
626
630
633
634 store = science_report_store_new();
637 g_object_unref(G_OBJECT(store));
638 renderer = gtk_cell_renderer_text_new();
645 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
646 preport->reachable_techs = GTK_COMBO_BOX(w);
647
651 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
653 preport->progress_bar = GTK_PROGRESS_BAR(w);
654
655 /* Research goal line. */
656 frame = gtk_frame_new( _("Goal"));
658
662
663 store = science_report_store_new();
666 g_object_unref(G_OBJECT(store));
667 renderer = gtk_cell_renderer_text_new();
671 renderer = gtk_cell_renderer_text_new();
678 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
679 preport->reachable_goals = GTK_COMBO_BOX(w);
680
681 w = gtk_label_new(NULL);
683 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
685 preport->goal_label = GTK_LABEL(w);
686
687 /* Toggle "Show All" button. */
688 /* TRANS: As in 'Show all (even not reachable) techs'. */
695 preport->button_show_all = show_all_button;
696
697 /* Science diagram. */
702
707 preport->drawing_area = GTK_DRAWING_AREA(w);
708
712 g_object_unref(group);
713
714 /* This must be _after_ the dialog is drawn to really center it ... */
716}
717
718/************************************************************************/
722{
724
726 fc_assert(NULL == preport->shell);
727
728 memset(preport, 0, sizeof(*preport));
729}
730
731/************************************************************************/
735{
737
738 if (NULL == science_report.shell) {
740 }
741
742 if (NULL != presearch
743 && A_UNSET == presearch->tech_goal
744 && A_UNSET == presearch->researching) {
746 } else {
748 }
749
750 if (raise) {
752 }
753}
754
755/************************************************************************/
765
766/************************************************************************/
775
776/************************************************************************/
785
786
787/****************************************************************************
788 ECONOMY REPORT DIALOG
789****************************************************************************/
790struct economy_report {
791 struct gui_dialog *shell;
794};
795
797
803
804/* Those values must match the functions economy_report_store_new() and
805 * economy_report_column_name(). */
821
822/************************************************************************/
826{
828 GDK_TYPE_PIXBUF, /* ERD_COL_SPRITE */
829 G_TYPE_STRING, /* ERD_COL_NAME */
830 G_TYPE_INT, /* ERD_COL_REDUNDANT */
831 G_TYPE_INT, /* ERD_COL_COUNT */
832 G_TYPE_INT, /* ERD_COL_COST */
833 G_TYPE_INT, /* ERD_COL_TOTAL_COST */
834 G_TYPE_STRING, /* ERD_COL_EMPTY */
835 G_TYPE_BOOLEAN, /* ERD_COL_IS_IMPROVEMENT */
836 G_TYPE_INT, /* ERD_COL_UNI_KIND */
837 G_TYPE_INT); /* ERD_COL_UNI_VALUE_ID */
838}
839
840/************************************************************************/
843static const char *
845{
846 switch (col) {
847 case ERD_COL_SPRITE:
848 /* TRANS: Image header */
849 return _("Type");
850 case ERD_COL_NAME:
851 return Q_("?Building or Unit type:Name");
853 return _("Redundant");
854 case ERD_COL_COUNT:
855 return _("Count");
856 case ERD_COL_COST:
857 return _("Cost");
859 /* TRANS: Upkeep total, count*cost. */
860 return _("U Total");
861 case ERD_COL_EMPTY:
862 /* Empty space for scrollbar*/
863 return " ";
865 case ERD_COL_CID:
866 case ERD_COL_NUM:
867 break; /* No more columns will be displayed after reaching this */
868 }
869
870 return NULL;
871}
872
873/************************************************************************/
877{
878 GtkTreeSelection *selection;
879 GtkTreeModel *model;
880 GtkListStore *store;
882 GdkPixbuf *pix;
886 char buf[256];
887 cid selected;
888
890
891 /* Save the selection. */
892 selection = gtk_tree_view_get_selection(preport->tree_view);
893 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
894 gtk_tree_model_get(model, &iter, ERD_COL_CID, &selected, -1);
895 } else {
896 selected = -1;
897 }
898
899 model = gtk_tree_view_get_model(preport->tree_view);
900 store = GTK_LIST_STORE(model);
902
903 /* Buildings. */
905 &building_total, &tax);
906 for (i = 0; i < entries_used; i++) {
908 struct impr_type *pimprove = pentry->type;
909 struct sprite *sprite = get_building_sprite(tileset, pimprove);
910 cid id = cid_encode_building(pimprove);
911
914 gtk_list_store_set(store, &iter,
915 ERD_COL_SPRITE, pix,
917 ERD_COL_REDUNDANT, pentry->redundant,
918 ERD_COL_COUNT, pentry->count,
919 ERD_COL_COST, pentry->cost,
920 ERD_COL_TOTAL_COST, pentry->total_cost,
921 ERD_COL_EMPTY, " ",
923 ERD_COL_CID, id,
924 -1);
926 if (selected == id) {
927 /* Restore the selection. */
929 }
930 }
931
932 /* Units. */
934 for (i = 0; i < entries_used; i++) {
935 struct unit_entry *pentry = unit_entries + i;
936 struct unit_type *putype = pentry->type;
941
944 gtk_list_store_set(store, &iter,
945 ERD_COL_SPRITE, pix,
948 ERD_COL_COUNT, pentry->count,
949 ERD_COL_COST, pentry->cost,
950 ERD_COL_TOTAL_COST, pentry->total_cost,
951 ERD_COL_EMPTY, " ",
953 ERD_COL_CID, id,
954 -1);
956 if (selected == id) {
957 /* Restore the selection. */
959 }
960 }
961
962 /* Update the label. */
963 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
966}
967
968/************************************************************************/
971static void economy_report_command_callback(struct gui_dialog *pdialog,
972 int response,
973 gpointer data)
974{
975 struct economy_report *preport = data;
977 GtkTreeModel *model;
980 struct universal selected;
981 cid id;
982 char buf[256] = "";
983
984 switch (response) {
986 case ERD_RES_SELL_ALL:
988 break;
989 default:
990 gui_dialog_destroy(pdialog);
991 return;
992 }
993
995 || !gtk_tree_selection_get_selected(selection, &model, &iter)) {
996 return;
997 }
998
999 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1000 selected = cid_decode(id);
1001
1002 switch (selected.kind) {
1003 case VUT_IMPROVEMENT:
1004 {
1005 const struct impr_type *pimprove = selected.value.building;
1006
1007 if (can_sell_building(pimprove)
1008 && (ERD_RES_SELL_ALL == response
1009 || (ERD_RES_SELL_REDUNDANT == response))) {
1010 bool redundant = (ERD_RES_SELL_REDUNDANT == response);
1011 gint count;
1012
1013 gtk_tree_model_get(model, &iter,
1014 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
1015 &count, -1);
1016 if (count == 0) {
1017 break;
1018 }
1023 redundant
1024 /* TRANS: %s is an improvement */
1025 ? _("Do you really wish to sell "
1026 "every redundant %s (%d total)?")
1027 /* TRANS: %s is an improvement */
1028 : _("Do you really wish to sell "
1029 "every %s (%d total)?"),
1031 count);
1033 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1034
1036 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1037 }
1039 }
1040 }
1041 break;
1042 case VUT_UTYPE:
1043 {
1044 if (ERD_RES_DISBAND_UNITS == response) {
1045 const struct unit_type *putype = selected.value.utype;
1046 gint count;
1047
1048 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1049
1054 /* TRANS: %s is a unit */
1055 _("Do you really wish to disband "
1056 "every %s (%d total)?"),
1058 count);
1060 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1061
1063 disband_all_units(putype, FALSE, buf, sizeof(buf));
1064 }
1066 }
1067 }
1068 break;
1069 default:
1070 log_error("Not supported type: %d.", selected.kind);
1071 }
1072
1073 if ('\0' != buf[0]) {
1076 "%s", buf);
1079 NULL);
1080 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1082 }
1083}
1084
1085/************************************************************************/
1089 gpointer data)
1090{
1091 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1092 GtkTreeModel *model;
1094
1096 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1097 struct universal selected;
1098 cid id;
1099
1100 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1101 selected = cid_decode(id);
1102 switch (selected.kind) {
1103 case VUT_IMPROVEMENT:
1104 {
1105 bool can_sell = can_sell_building(selected.value.building);
1106 gint redundant;
1107
1108 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1109
1111 can_sell && redundant > 0);
1114 FALSE);
1115 }
1116 return;
1117 case VUT_UTYPE:
1119 FALSE);
1122 TRUE);
1123 return;
1124 default:
1125 log_error("Not supported type: %d.", selected.kind);
1126 break;
1127 }
1128 }
1129
1133}
1134
1135/************************************************************************/
1139{
1140 GtkWidget *view, *sw, *label, *button;
1141 GtkListStore *store;
1142 GtkTreeSelection *selection;
1143 const char *title;
1145
1147
1149 gui_dialog_set_title(preport->shell, _("Economy"));
1150
1157
1158 store = economy_report_store_new();
1161 gtk_widget_add_css_class(GTK_WIDGET(view), "large-pixbufs");
1162 g_object_unref(store);
1163 gtk_widget_set_name(view, "small_font");
1166 preport->tree_view = GTK_TREE_VIEW(view);
1167
1169 g_signal_connect(selection, "changed",
1171
1172 for (i = 0; (title = economy_report_column_name(i)); i++) {
1173 GtkCellRenderer *renderer;
1176
1177 if (GDK_TYPE_PIXBUF == type) {
1178 renderer = gtk_cell_renderer_pixbuf_new();
1180 "pixbuf", i, NULL);
1181#if 0
1182 } else if (G_TYPE_BOOLEAN == type) {
1183 renderer = gtk_cell_renderer_toggle_new();
1185 "active", i, NULL);
1186#endif
1187 } else {
1188 bool is_redundant = (i == ERD_COL_REDUNDANT);
1189
1190 renderer = gtk_cell_renderer_text_new();
1191 if (is_redundant) {
1192 /* Special treatment: hide "Redundant" column for units */
1194 "text", i,
1195 "visible",
1197 NULL);
1198 } else {
1200 "text", i, NULL);
1201 }
1202 }
1203
1204 if (i > 1) {
1205 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1207 }
1208
1210 }
1211
1212 label = gtk_label_new(NULL);
1215 gtk_widget_set_margin_end(label, 5);
1216 gtk_widget_set_margin_top(label, 5);
1218 preport->label = GTK_LABEL(label);
1219
1220 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1222
1223 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1226
1227 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1230
1231 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1234
1237
1238 gui_dialog_set_default_size(preport->shell, -1, 350);
1240
1242
1244}
1245
1246/************************************************************************/
1250{
1252
1254 fc_assert(NULL == preport->shell);
1255
1256 memset(preport, 0, sizeof(*preport));
1257}
1258
1259/************************************************************************/
1273
1274/************************************************************************/
1283
1284/************************************************************************/
1293
1294
1295/****************************************************************************
1296 UNITS REPORT DIALOG
1297****************************************************************************/
1298struct units_report {
1299 struct gui_dialog *shell;
1301};
1302
1303static struct units_report units_report = { NULL, NULL };
1304
1309
1310/* Those values must match the order of unit_report_columns[]. */
1330
1331static const struct {
1333 const char *title;
1334 const char *tooltip;
1337} unit_report_columns[] = {
1338 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1339 NULL, FALSE, -1 },
1340 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1341 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1342 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1344 /* TRANS: "In progress" abbreviation. */
1345 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1346 N_("In progress"), TRUE, -1 },
1347 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1348 NULL, TRUE, -1 },
1349 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1350 N_("Total shield upkeep"), TRUE, -1 },
1351 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1352 N_("Total food upkeep"), TRUE, -1 },
1353 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1354 N_("Total gold upkeep"), TRUE, -1 },
1355 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1356 " ", TRUE, -1 },
1357
1358 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1359 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1360 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1361 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1363
1364/************************************************************************/
1368{
1369 int i;
1371
1373
1374 for (i = 0; i < URD_COL_NUM; i++) {
1375 cols[i] = unit_report_columns[i].type;
1376 }
1377
1379}
1380
1381/************************************************************************/
1385{
1386 struct urd_info {
1387 int active_count;
1388 int building_count;
1389 int upkeep[O_LAST];
1390 };
1391
1393 struct urd_info unit_totals;
1394 struct urd_info *info;
1395 int total_upgradable_count = 0;
1396 GtkTreeSelection *selection;
1397 GtkTreeModel *model;
1398 GtkListStore *store;
1400 Unit_type_id selected, utype_id;
1401
1403
1404 memset(unit_array, '\0', sizeof(unit_array));
1405 memset(&unit_totals, '\0', sizeof(unit_totals));
1406
1407 /* Count units. */
1408 players_iterate(pplayer) {
1409 if (client_has_player() && pplayer != client_player()) {
1410 continue;
1411 }
1412
1413 unit_list_iterate(pplayer->units, punit) {
1415
1416 if (0 != punit->homecity) {
1418 info->upkeep[o] += punit->upkeep[o];
1420 }
1421 info->active_count++;
1423 city_list_iterate(pplayer->cities, pcity) {
1424 if (VUT_UTYPE == pcity->production.kind) {
1425 int num_units;
1426 info = unit_array + utype_index(pcity->production.value.utype);
1427 /* Account for build slots in city */
1429 /* Unit is in progress even if it won't be done this turn */
1430 num_units = MAX(num_units, 1);
1431 info->building_count += num_units;
1432 }
1435
1436 /* Save selection. */
1437 selection = gtk_tree_view_get_selection(preport->tree_view);
1438 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1439 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1440 } else {
1441 selected = -1;
1442 }
1443
1444 /* Make the store. */
1445 model = gtk_tree_view_get_model(preport->tree_view);
1446 store = GTK_LIST_STORE(model);
1447 gtk_list_store_clear(store);
1448
1449 unit_type_iterate(utype) {
1450 bool upgradable;
1451
1452 utype_id = utype_index(utype);
1453 info = unit_array + utype_id;
1454
1455 if (0 == info->active_count && 0 == info->building_count) {
1456 continue; /* We don't need a row for this type. */
1457 }
1458
1460 && NULL != can_upgrade_unittype(client_player(), utype);
1461
1462 gtk_list_store_append(store, &iter);
1463 gtk_list_store_set(store, &iter,
1466 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1467 URD_COL_IN_PROGRESS, info->building_count,
1468 URD_COL_ACTIVE, info->active_count,
1469 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1470 URD_COL_FOOD, info->upkeep[O_FOOD],
1471 URD_COL_GOLD, info->upkeep[O_GOLD],
1472 URD_COL_EMPTY, " ",
1477 -1);
1478 if (selected == utype_id) {
1479 /* Restore the selection. */
1481 }
1482
1483 /* Update totals. */
1484 unit_totals.active_count += info->active_count;
1486 unit_totals.upkeep[o] += info->upkeep[o];
1488 unit_totals.building_count += info->building_count;
1489 if (upgradable) {
1490 total_upgradable_count += info->active_count;
1491 }
1493
1494 /* Add the total row. */
1495 gtk_list_store_append(store, &iter);
1496 gtk_list_store_set(store, &iter,
1497 URD_COL_UTYPE_NAME, _("Totals:"),
1498 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1500 URD_COL_IN_PROGRESS, unit_totals.building_count,
1501 URD_COL_ACTIVE, unit_totals.active_count,
1505 URD_COL_EMPTY, " ",
1510 -1);
1511 if (selected == U_LAST) {
1512 /* Restore the selection. */
1514 }
1515}
1516
1517/************************************************************************/
1521 gpointer data)
1522{
1523 struct units_report *preport = data;
1524 GtkTreeModel *model;
1525 GtkTreeIter it;
1526 int active_count;
1527 struct unit_type *utype = NULL;
1528
1529 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1530 int ut;
1531
1532 gtk_tree_model_get(model, &it,
1533 URD_COL_ACTIVE, &active_count,
1535 -1);
1536 if (0 < active_count) {
1537 utype = utype_by_number(ut);
1538 }
1539 }
1540
1541 if (NULL == utype) {
1543 FALSE);
1545 FALSE);
1546 } else {
1551 && NULL != can_upgrade_unittype(client_player(), utype)));
1552 }
1553}
1554
1555/************************************************************************/
1558static struct unit *find_nearest_unit(const struct unit_type *utype,
1559 struct tile *ptile)
1560{
1561 struct unit *best_candidate = NULL;
1562 int best_dist = FC_INFINITY, dist;
1563
1564 players_iterate(pplayer) {
1565 if (client_has_player() && pplayer != client_player()) {
1566 continue;
1567 }
1568
1569 unit_list_iterate(pplayer->units, punit) {
1570 if (utype == unit_type_get(punit)
1572 && 0 < punit->moves_left
1573 && !punit->done_moving
1574 && punit->ssa_controller == SSA_NONE) {
1575 dist = sq_map_distance(unit_tile(punit), ptile);
1576 if (dist < best_dist) {
1578 best_dist = dist;
1579 }
1580 }
1583
1584 return best_candidate;
1585}
1586
1587/************************************************************************/
1590static void units_report_command_callback(struct gui_dialog *pdialog,
1591 int response,
1592 gpointer data)
1593{
1594 struct units_report *preport = data;
1595 struct unit_type *utype = NULL;
1596 GtkTreeSelection *selection;
1597 GtkTreeModel *model;
1598 GtkTreeIter it;
1599
1600 switch (response) {
1601 case URD_RES_NEAREST:
1602 case URD_RES_UPGRADE:
1603 break;
1604 default:
1605 gui_dialog_destroy(pdialog);
1606 return;
1607 }
1608
1609 /* Nearest & upgrade commands. */
1610 selection = gtk_tree_view_get_selection(preport->tree_view);
1611 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1612 int ut;
1613
1614 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1615 utype = utype_by_number(ut);
1616 }
1617
1618 if (response == URD_RES_NEAREST) {
1619 struct tile *ptile;
1620 struct unit *punit;
1621
1622 ptile = get_center_tile_mapcanvas();
1623 if ((punit = find_nearest_unit(utype, ptile))) {
1625
1630 }
1631 }
1632 }
1633 } else if (can_client_issue_orders()) {
1635 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1636 char buf[1024];
1637 int price = unit_upgrade_price(client_player(), utype, upgrade);
1638
1639 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1640 "Treasury contains %d gold.",
1641 client_player()->economic.gold),
1642 client_player()->economic.gold);
1643
1648 /* TRANS: Last %s is pre-pluralised
1649 * "Treasury contains %d gold." */
1650 PL_("Upgrade as many %s to %s as possible "
1651 "for %d gold each?\n%s",
1652 "Upgrade as many %s to %s as possible "
1653 "for %d gold each?\n%s", price),
1655 utype_name_translation(upgrade),
1656 price, buf);
1658
1659 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1660
1663 }
1664
1666 }
1667}
1668
1669/************************************************************************/
1673{
1674 GtkWidget *view, *sw, *button;
1675 GtkListStore *store;
1676 GtkTreeSelection *selection;
1679
1681
1683 gui_dialog_set_title(preport->shell, _("Units"));
1684
1691
1692 store = units_report_store_new();
1695 g_object_unref(store);
1696 gtk_widget_set_name(view, "small_font");
1699 preport->tree_view = GTK_TREE_VIEW(view);
1700
1702 g_signal_connect(selection, "changed",
1704
1705 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1706 GtkCellRenderer *renderer;
1707
1708 if (strlen(unit_report_columns[i].title) > 0) {
1710
1714 }
1720 }
1722 } /* else add new renderer to previous TreeViewColumn */
1723
1724 fc_assert(col != NULL);
1726 renderer = gtk_cell_renderer_toggle_new();
1728 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1729 } else {
1730 renderer = gtk_cell_renderer_text_new();
1732 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1734 "weight", URD_COL_TEXT_WEIGHT);
1735 }
1736
1737 if (unit_report_columns[i].visible_col >= 0) {
1738 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1740 }
1741
1743 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1744 }
1745 }
1746
1747 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1749
1750 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1753
1754 button = gui_dialog_add_button(preport->shell, "edit-find",
1755 _("Find _Nearest"), URD_RES_NEAREST);
1757
1760
1761 gui_dialog_set_default_size(preport->shell, -1, 350);
1763
1766}
1767
1768/************************************************************************/
1772{
1774
1776 fc_assert(NULL == preport->shell);
1777
1778 memset(preport, 0, sizeof(*preport));
1779}
1780
1781/************************************************************************/
1795
1796/************************************************************************/
1806
1807/************************************************************************/
1816
1817
1818/****************************************************************************
1819 FINAL REPORT DIALOG
1820****************************************************************************/
1821struct endgame_report {
1822 struct gui_dialog *shell;
1825 int player_count;
1826 int players_received;
1827};
1828
1837
1839
1840/************************************************************************/
1843static const char *
1845{
1846 switch (col) {
1847 case FRD_COL_PLAYER:
1848 return _("Player\n");
1849 case FRD_COL_NATION:
1850 return _("Nation\n");
1851 case FRD_COL_SCORE:
1852 return _("Score\n");
1853 case FRD_COL_TOOLTIP:
1854 case FRD_COL_NUM:
1855 break;
1856 }
1857
1858 return NULL;
1859}
1860
1861/************************************************************************/
1865 const struct packet_endgame_report *packet)
1866{
1867 const size_t col_num = packet->category_num + FRD_COL_NUM;
1871 int i;
1872
1874
1875 /* Remove the old columns. */
1876 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1878 }
1879
1880 /* Create the new model. */
1885 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1887 }
1891
1892 /* Create the new columns. */
1893 for (i = 0; (guint)i < col_num; i++) {
1894 GtkCellRenderer *renderer;
1895 const char *title;
1896 const char *attribute;
1897
1898 if (GDK_TYPE_PIXBUF == col_types[i]) {
1899 renderer = gtk_cell_renderer_pixbuf_new();
1900 attribute = "pixbuf";
1901 } else {
1902 renderer = gtk_cell_renderer_text_new();
1903 attribute = "text";
1904 }
1905
1906 if (i < FRD_COL_NUM) {
1908 } else {
1909 title = packet->category_name[i - FRD_COL_NUM];
1910 }
1911
1912 if (title != NULL) {
1914 attribute, i, NULL);
1916 if (GDK_TYPE_PIXBUF != col_types[i]) {
1918 }
1919 }
1920 }
1921
1924
1925 preport->store = store;
1926 preport->player_count = packet->player_num;
1927 preport->players_received = 0;
1928}
1929
1930/************************************************************************/
1934{
1935 /* Fill the model with player stats. */
1937 const struct player *pplayer = player_by_number(packet->player_id);
1939 int i;
1940
1943 FRD_COL_PLAYER, player_name(pplayer),
1945 FRD_COL_SCORE, packet->score,
1946 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1947 -1);
1948 for (i = 0; i < packet->category_num; i++) {
1950 i + FRD_COL_NUM, packet->category_score[i],
1951 -1);
1952 }
1953
1954 preport->players_received++;
1955
1956 if (preport->players_received == preport->player_count) {
1958 }
1959}
1960
1961/************************************************************************/
1965{
1966 GtkWidget *sw, *view;
1967
1969
1971 gui_dialog_set_title(preport->shell, _("Score"));
1972
1973 gui_dialog_set_default_size(preport->shell, 700, 420);
1974
1975 /* Setup the layout. */
1981
1983 gtk_widget_set_name(view, "small_font");
1984 gtk_widget_add_css_class(GTK_WIDGET(view), "large-pixbufs");
1986 preport->tree_view = GTK_TREE_VIEW(view);
1987
1988 if (preport->shell->type == GUI_DIALOG_TAB) {
1991 }
1992
1994}
1995
1996/************************************************************************/
bool action_ever_possible(action_id action)
Definition actions.c:7546
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:648
#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:73
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:77
int int id
Definition editgui_g.h:28
int Tech_type_id
Definition fc_types.h:237
int Unit_type_id
Definition fc_types.h:242
@ O_SHIELD
Definition fc_types.h:102
@ O_FOOD
Definition fc_types.h:102
@ O_GOLD
Definition fc_types.h:102
@ O_LAST
Definition fc_types.h:102
#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:1140
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1109
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:1334
const char * title
Definition repodlgs.c:1333
GType type
Definition repodlgs.c:1332
int visible_col
Definition repodlgs.c:1336
bool rightalign
Definition repodlgs.c:1335
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: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:795
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:1047
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:880
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1189
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1213
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:480
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:849
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
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:139
int upkeep[O_LAST]
Definition unit.h:149
enum unit_activity activity
Definition unit.h:158
int moves_left
Definition unit.h:151
struct unit::@84::@86 client
int homecity
Definition unit.h:147
bool done_moving
Definition unit.h:183
const struct unit_type * utype
Definition unit.h:140
enum unit_focus_status focus_status
Definition unit.h:216
enum server_side_agent ssa_controller
Definition unit.h:174
GtkTreeView * tree_view
Definition repodlgs.c:1281
struct gui_dialog * shell
Definition repodlgs.c:1280
enum universals_n kind
Definition fc_types.h:609
universals_u value
Definition fc_types.h:608
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:2207
const char * get_science_target_text(double *percent)
Definition text.c:874
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:920
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:7040
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7780
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:7062
const struct unit_type * utype
Definition fc_types.h:554
const struct impr_type * building
Definition fc_types.h:547
#define unit_tile(_pu)
Definition unit.h:406
@ 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:1707
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:1564
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1735
#define unit_type_iterate(_p)
Definition unittype.h:860
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:867