Freeciv-3.2
Loading...
Searching...
No Matches
repodlgs.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/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 gtk_tree_model_get(model, &iter,
1013 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
1014 &count, -1);
1015 if (count == 0) {
1016 break;
1017 }
1022 redundant
1023 /* TRANS: %s is an improvement */
1024 ? _("Do you really wish to sell "
1025 "every redundant %s (%d total)?")
1026 /* TRANS: %s is an improvement */
1027 : _("Do you really wish to sell "
1028 "every %s (%d total)?"),
1030 count);
1032 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1033
1035 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1036 }
1038 }
1039 }
1040 break;
1041 case VUT_UTYPE:
1042 {
1043 if (ERD_RES_DISBAND_UNITS == response) {
1044 const struct unit_type *putype = selected.value.utype;
1045 gint count;
1046
1047 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1048
1053 /* TRANS: %s is a unit */
1054 _("Do you really wish to disband "
1055 "every %s (%d total)?"),
1057 count);
1059 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1060
1062 disband_all_units(putype, FALSE, buf, sizeof(buf));
1063 }
1065 }
1066 }
1067 break;
1068 default:
1069 log_error("Not supported type: %d.", selected.kind);
1070 }
1071
1072 if ('\0' != buf[0]) {
1075 "%s", buf);
1078 NULL);
1079 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1081 }
1082}
1083
1084/************************************************************************/
1088 gpointer data)
1089{
1090 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1091 GtkTreeModel *model;
1093
1095 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1096 struct universal selected;
1097 cid id;
1098
1099 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1100 selected = cid_decode(id);
1101 switch (selected.kind) {
1102 case VUT_IMPROVEMENT:
1103 {
1104 bool can_sell = can_sell_building(selected.value.building);
1105 gint redundant;
1106 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1107
1109 can_sell && redundant > 0);
1112 FALSE);
1113 }
1114 return;
1115 case VUT_UTYPE:
1117 FALSE);
1120 TRUE);
1121 return;
1122 default:
1123 log_error("Not supported type: %d.", selected.kind);
1124 break;
1125 }
1126 }
1127
1131}
1132
1133/************************************************************************/
1137{
1138 GtkWidget *view, *sw, *label, *button;
1139 GtkListStore *store;
1140 GtkTreeSelection *selection;
1141 const char *title;
1143
1145
1147 gui_dialog_set_title(preport->shell, _("Economy"));
1148
1155
1156 store = economy_report_store_new();
1159 gtk_widget_add_css_class(GTK_WIDGET(view), "large-pixbufs");
1160 g_object_unref(store);
1161 gtk_widget_set_name(view, "small_font");
1164 preport->tree_view = GTK_TREE_VIEW(view);
1165
1167 g_signal_connect(selection, "changed",
1169
1170 for (i = 0; (title = economy_report_column_name(i)); i++) {
1171 GtkCellRenderer *renderer;
1174
1175 if (GDK_TYPE_PIXBUF == type) {
1176 renderer = gtk_cell_renderer_pixbuf_new();
1178 "pixbuf", i, NULL);
1179#if 0
1180 } else if (G_TYPE_BOOLEAN == type) {
1181 renderer = gtk_cell_renderer_toggle_new();
1183 "active", i, NULL);
1184#endif
1185 } else {
1186 bool is_redundant = (i == ERD_COL_REDUNDANT);
1187 renderer = gtk_cell_renderer_text_new();
1188 if (is_redundant) {
1189 /* Special treatment: hide "Redundant" column for units */
1191 "text", i,
1192 "visible",
1194 NULL);
1195 } else {
1197 "text", i, NULL);
1198 }
1199 }
1200
1201 if (i > 1) {
1202 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1204 }
1205
1207 }
1208
1209 label = gtk_label_new(NULL);
1212 gtk_widget_set_margin_end(label, 5);
1213 gtk_widget_set_margin_top(label, 5);
1215 preport->label = GTK_LABEL(label);
1216
1217 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1219
1220 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1223
1224 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1227
1228 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1231
1234
1235 gui_dialog_set_default_size(preport->shell, -1, 350);
1237
1239
1241}
1242
1243/************************************************************************/
1247{
1249
1251 fc_assert(NULL == preport->shell);
1252
1253 memset(preport, 0, sizeof(*preport));
1254}
1255
1256/************************************************************************/
1270
1271/************************************************************************/
1280
1281/************************************************************************/
1290
1291
1292/****************************************************************************
1293 UNITS REPORT DIALOG
1294****************************************************************************/
1295struct units_report {
1296 struct gui_dialog *shell;
1298};
1299
1300static struct units_report units_report = { NULL, NULL };
1301
1306
1307/* Those values must match the order of unit_report_columns[]. */
1327
1328static const struct {
1330 const char *title;
1331 const char *tooltip;
1334} unit_report_columns[] = {
1335 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1336 NULL, FALSE, -1 },
1337 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1338 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1339 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1341 /* TRANS: "In progress" abbreviation. */
1342 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1343 N_("In progress"), TRUE, -1 },
1344 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1345 NULL, TRUE, -1 },
1346 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1347 N_("Total shield upkeep"), TRUE, -1 },
1348 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1349 N_("Total food upkeep"), TRUE, -1 },
1350 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1351 N_("Total gold upkeep"), TRUE, -1 },
1352 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1353 " ", TRUE, -1 },
1354
1355 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1356 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1357 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1358 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1360
1361/************************************************************************/
1365{
1366 int i;
1368
1370
1371 for (i = 0; i < URD_COL_NUM; i++) {
1372 cols[i] = unit_report_columns[i].type;
1373 }
1374
1376}
1377
1378/************************************************************************/
1382{
1383 struct urd_info {
1384 int active_count;
1385 int building_count;
1386 int upkeep[O_LAST];
1387 };
1388
1390 struct urd_info unit_totals;
1391 struct urd_info *info;
1392 int total_upgradable_count = 0;
1393 GtkTreeSelection *selection;
1394 GtkTreeModel *model;
1395 GtkListStore *store;
1397 Unit_type_id selected, utype_id;
1398
1400
1401 memset(unit_array, '\0', sizeof(unit_array));
1402 memset(&unit_totals, '\0', sizeof(unit_totals));
1403
1404 /* Count units. */
1405 players_iterate(pplayer) {
1406 if (client_has_player() && pplayer != client_player()) {
1407 continue;
1408 }
1409
1410 unit_list_iterate(pplayer->units, punit) {
1412
1413 if (0 != punit->homecity) {
1415 info->upkeep[o] += punit->upkeep[o];
1417 }
1418 info->active_count++;
1420 city_list_iterate(pplayer->cities, pcity) {
1421 if (VUT_UTYPE == pcity->production.kind) {
1422 int num_units;
1423 info = unit_array + utype_index(pcity->production.value.utype);
1424 /* Account for build slots in city */
1426 /* Unit is in progress even if it won't be done this turn */
1427 num_units = MAX(num_units, 1);
1428 info->building_count += num_units;
1429 }
1432
1433 /* Save selection. */
1434 selection = gtk_tree_view_get_selection(preport->tree_view);
1435 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1436 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1437 } else {
1438 selected = -1;
1439 }
1440
1441 /* Make the store. */
1442 model = gtk_tree_view_get_model(preport->tree_view);
1443 store = GTK_LIST_STORE(model);
1444 gtk_list_store_clear(store);
1445
1446 unit_type_iterate(utype) {
1447 bool upgradable;
1448
1449 utype_id = utype_index(utype);
1450 info = unit_array + utype_id;
1451
1452 if (0 == info->active_count && 0 == info->building_count) {
1453 continue; /* We don't need a row for this type. */
1454 }
1455
1457 && NULL != can_upgrade_unittype(client_player(), utype);
1458
1459 gtk_list_store_append(store, &iter);
1460 gtk_list_store_set(store, &iter,
1463 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1464 URD_COL_IN_PROGRESS, info->building_count,
1465 URD_COL_ACTIVE, info->active_count,
1466 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1467 URD_COL_FOOD, info->upkeep[O_FOOD],
1468 URD_COL_GOLD, info->upkeep[O_GOLD],
1469 URD_COL_EMPTY, " ",
1474 -1);
1475 if (selected == utype_id) {
1476 /* Restore the selection. */
1478 }
1479
1480 /* Update totals. */
1481 unit_totals.active_count += info->active_count;
1483 unit_totals.upkeep[o] += info->upkeep[o];
1485 unit_totals.building_count += info->building_count;
1486 if (upgradable) {
1487 total_upgradable_count += info->active_count;
1488 }
1490
1491 /* Add the total row. */
1492 gtk_list_store_append(store, &iter);
1493 gtk_list_store_set(store, &iter,
1494 URD_COL_UTYPE_NAME, _("Totals:"),
1495 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1497 URD_COL_IN_PROGRESS, unit_totals.building_count,
1498 URD_COL_ACTIVE, unit_totals.active_count,
1502 URD_COL_EMPTY, " ",
1507 -1);
1508 if (selected == U_LAST) {
1509 /* Restore the selection. */
1511 }
1512}
1513
1514/************************************************************************/
1518 gpointer data)
1519{
1520 struct units_report *preport = data;
1521 GtkTreeModel *model;
1522 GtkTreeIter it;
1523 int active_count;
1524 struct unit_type *utype = NULL;
1525
1526 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1527 int ut;
1528
1529 gtk_tree_model_get(model, &it,
1530 URD_COL_ACTIVE, &active_count,
1532 -1);
1533 if (0 < active_count) {
1534 utype = utype_by_number(ut);
1535 }
1536 }
1537
1538 if (NULL == utype) {
1540 FALSE);
1542 FALSE);
1543 } else {
1548 && NULL != can_upgrade_unittype(client_player(), utype)));
1549 }
1550}
1551
1552/************************************************************************/
1555static struct unit *find_nearest_unit(const struct unit_type *utype,
1556 struct tile *ptile)
1557{
1558 struct unit *best_candidate = NULL;
1559 int best_dist = FC_INFINITY, dist;
1560
1561 players_iterate(pplayer) {
1562 if (client_has_player() && pplayer != client_player()) {
1563 continue;
1564 }
1565
1566 unit_list_iterate(pplayer->units, punit) {
1567 if (utype == unit_type_get(punit)
1569 && 0 < punit->moves_left
1570 && !punit->done_moving
1571 && punit->ssa_controller == SSA_NONE) {
1572 dist = sq_map_distance(unit_tile(punit), ptile);
1573 if (dist < best_dist) {
1575 best_dist = dist;
1576 }
1577 }
1580
1581 return best_candidate;
1582}
1583
1584/************************************************************************/
1587static void units_report_command_callback(struct gui_dialog *pdialog,
1588 int response,
1589 gpointer data)
1590{
1591 struct units_report *preport = data;
1592 struct unit_type *utype = NULL;
1593 GtkTreeSelection *selection;
1594 GtkTreeModel *model;
1595 GtkTreeIter it;
1596
1597 switch (response) {
1598 case URD_RES_NEAREST:
1599 case URD_RES_UPGRADE:
1600 break;
1601 default:
1602 gui_dialog_destroy(pdialog);
1603 return;
1604 }
1605
1606 /* Nearest & upgrade commands. */
1607 selection = gtk_tree_view_get_selection(preport->tree_view);
1608 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1609 int ut;
1610
1611 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1612 utype = utype_by_number(ut);
1613 }
1614
1615 if (response == URD_RES_NEAREST) {
1616 struct tile *ptile;
1617 struct unit *punit;
1618
1619 ptile = get_center_tile_mapcanvas();
1620 if ((punit = find_nearest_unit(utype, ptile))) {
1622
1627 }
1628 }
1629 }
1630 } else if (can_client_issue_orders()) {
1632 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1633 char buf[1024];
1634 int price = unit_upgrade_price(client_player(), utype, upgrade);
1635
1636 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1637 "Treasury contains %d gold.",
1638 client_player()->economic.gold),
1639 client_player()->economic.gold);
1640
1645 /* TRANS: Last %s is pre-pluralised
1646 * "Treasury contains %d gold." */
1647 PL_("Upgrade as many %s to %s as possible "
1648 "for %d gold each?\n%s",
1649 "Upgrade as many %s to %s as possible "
1650 "for %d gold each?\n%s", price),
1652 utype_name_translation(upgrade),
1653 price, buf);
1655
1656 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1657
1660 }
1661
1663 }
1664}
1665
1666/************************************************************************/
1670{
1671 GtkWidget *view, *sw, *button;
1672 GtkListStore *store;
1673 GtkTreeSelection *selection;
1676
1678
1680 gui_dialog_set_title(preport->shell, _("Units"));
1681
1688
1689 store = units_report_store_new();
1692 g_object_unref(store);
1693 gtk_widget_set_name(view, "small_font");
1696 preport->tree_view = GTK_TREE_VIEW(view);
1697
1699 g_signal_connect(selection, "changed",
1701
1702 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1703 GtkCellRenderer *renderer;
1704
1705 if (strlen(unit_report_columns[i].title) > 0) {
1707
1711 }
1717 }
1719 } /* else add new renderer to previous TreeViewColumn */
1720
1721 fc_assert(col != NULL);
1723 renderer = gtk_cell_renderer_toggle_new();
1725 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1726 } else {
1727 renderer = gtk_cell_renderer_text_new();
1729 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1731 "weight", URD_COL_TEXT_WEIGHT);
1732 }
1733
1734 if (unit_report_columns[i].visible_col >= 0) {
1735 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1737 }
1738
1740 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1741 }
1742 }
1743
1744 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1746
1747 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1750
1751 button = gui_dialog_add_button(preport->shell, "edit-find",
1752 _("Find _Nearest"), URD_RES_NEAREST);
1754
1757
1758 gui_dialog_set_default_size(preport->shell, -1, 350);
1760
1763}
1764
1765/************************************************************************/
1769{
1771
1773 fc_assert(NULL == preport->shell);
1774
1775 memset(preport, 0, sizeof(*preport));
1776}
1777
1778/************************************************************************/
1792
1793/************************************************************************/
1803
1804/************************************************************************/
1813
1814
1815/****************************************************************************
1816 FINAL REPORT DIALOG
1817****************************************************************************/
1818struct endgame_report {
1819 struct gui_dialog *shell;
1822 int player_count;
1823 int players_received;
1824};
1825
1834
1836
1837/************************************************************************/
1840static const char *
1842{
1843 switch (col) {
1844 case FRD_COL_PLAYER:
1845 return _("Player\n");
1846 case FRD_COL_NATION:
1847 return _("Nation\n");
1848 case FRD_COL_SCORE:
1849 return _("Score\n");
1850 case FRD_COL_TOOLTIP:
1851 case FRD_COL_NUM:
1852 break;
1853 }
1854
1855 return NULL;
1856}
1857
1858/************************************************************************/
1862 const struct packet_endgame_report *packet)
1863{
1864 const size_t col_num = packet->category_num + FRD_COL_NUM;
1868 int i;
1869
1871
1872 /* Remove the old columns. */
1873 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1875 }
1876
1877 /* Create the new model. */
1882 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1884 }
1888
1889 /* Create the new columns. */
1890 for (i = 0; (guint)i < col_num; i++) {
1891 GtkCellRenderer *renderer;
1892 const char *title;
1893 const char *attribute;
1894
1895 if (GDK_TYPE_PIXBUF == col_types[i]) {
1896 renderer = gtk_cell_renderer_pixbuf_new();
1897 attribute = "pixbuf";
1898 } else {
1899 renderer = gtk_cell_renderer_text_new();
1900 attribute = "text";
1901 }
1902
1903 if (i < FRD_COL_NUM) {
1905 } else {
1906 title = packet->category_name[i - FRD_COL_NUM];
1907 }
1908
1909 if (title != NULL) {
1911 attribute, i, NULL);
1913 if (GDK_TYPE_PIXBUF != col_types[i]) {
1915 }
1916 }
1917 }
1918
1921
1922 preport->store = store;
1923 preport->player_count = packet->player_num;
1924 preport->players_received = 0;
1925}
1926
1927/************************************************************************/
1931{
1932 /* Fill the model with player stats. */
1934 const struct player *pplayer = player_by_number(packet->player_id);
1936 int i;
1937
1940 FRD_COL_PLAYER, player_name(pplayer),
1942 FRD_COL_SCORE, packet->score,
1943 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1944 -1);
1945 for (i = 0; i < packet->category_num; i++) {
1947 i + FRD_COL_NUM, packet->category_score[i],
1948 -1);
1949 }
1950
1951 preport->players_received++;
1952
1953 if (preport->players_received == preport->player_count) {
1955 }
1956}
1957
1958/************************************************************************/
1962{
1963 GtkWidget *sw, *view;
1964
1966
1968 gui_dialog_set_title(preport->shell, _("Score"));
1969
1970 gui_dialog_set_default_size(preport->shell, 700, 420);
1971
1972 /* Setup the layout. */
1978
1980 gtk_widget_set_name(view, "small_font");
1981 gtk_widget_add_css_class(GTK_WIDGET(view), "large-pixbufs");
1983 preport->tree_view = GTK_TREE_VIEW(view);
1984
1985 if (preport->shell->type == GUI_DIALOG_TAB) {
1988 }
1989
1991}
1992
1993/************************************************************************/
bool action_ever_possible(action_id action)
Definition actions.c:8092
int entries_used
Definition agents.c:77
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:747
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define output_type_iterate(output)
Definition city.h:845
#define city_list_iterate_end
Definition city.h:510
#define output_type_iterate_end
Definition city.h:851
bool client_is_global_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:504
struct universal cid_decode(cid id)
Definition climisc.c:525
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:75
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
void unit_focus_set_and_select(struct unit *punit)
Definition control.c: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
int int id
Definition editgui_g.h:28
int Tech_type_id
Definition fc_types.h:377
int Unit_type_id
Definition fc_types.h:382
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_GOLD
Definition fc_types.h:101
@ O_LAST
Definition fc_types.h:101
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * top_notebook
Definition gui_main.c:129
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:888
void itree_next(ITree *it)
Definition gui_stuff.c:144
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:760
GtkWidget * gui_dialog_get_toplevel(struct gui_dialog *dlg)
Definition gui_stuff.c:787
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
@ GUI_DIALOG_TAB
Definition gui_stuff.h:62
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:197
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
static struct endgame_report endgame_report
Definition repodlgs.c:1822
static void units_report_init(struct units_report *preport)
Definition repodlgs.c:1653
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
static GtkListStore * units_report_store_new(void)
Definition repodlgs.c:1348
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
static void science_report_store_set(GtkListStore *store, GtkTreeIter *iter, Tech_type_id tech)
Definition repodlgs.c:136
static void economy_report_init(struct economy_report *preport)
Definition repodlgs.c:1117
static void science_report_update(struct science_report *preport)
Definition repodlgs.c:383
static void units_report_update(struct units_report *preport)
Definition repodlgs.c:1365
static bool science_report_combo_get_active(GtkComboBox *combo, Tech_type_id *tech, char **name)
Definition repodlgs.c:154
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
Definition repodlgs.c:312
units_report_response
Definition repodlgs.c:1286
@ URD_RES_UPGRADE
Definition repodlgs.c:1288
@ URD_RES_NEAREST
Definition repodlgs.c:1287
static void endgame_report_update(struct endgame_report *preport, const struct packet_endgame_report *packet)
Definition repodlgs.c:1848
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
const char * tooltip
Definition repodlgs.c:1315
static const struct @158 unit_report_columns[]
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
Definition repodlgs.c:235
static const char * endgame_report_column_name(enum endgame_report_columns col)
Definition repodlgs.c:1828
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
static void endgame_report_init(struct endgame_report *preport)
Definition repodlgs.c:1948
static void science_report_combo_set_active(GtkComboBox *combo, Tech_type_id tech)
Definition repodlgs.c:175
const char * title
Definition repodlgs.c:1314
static void science_diagram_data(GtkWidget *widget, bool show_all)
Definition repodlgs.c:290
static void science_report_free(struct science_report *preport)
Definition repodlgs.c:703
static bool science_report_no_combo_callback
Definition repodlgs.c:109
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
static void economy_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:953
GType type
Definition repodlgs.c:1313
static void units_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:1571
static void units_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1501
static void economy_report_update(struct economy_report *preport)
Definition repodlgs.c:858
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
units_report_columns
Definition repodlgs.c:1292
@ URD_COL_NUM
Definition repodlgs.c:1309
@ URD_COL_UPG_VISIBLE
Definition repodlgs.c:1305
@ URD_COL_ACTIVE
Definition repodlgs.c:1297
@ URD_COL_IN_PROGRESS
Definition repodlgs.c:1296
@ URD_COL_TEXT_WEIGHT
Definition repodlgs.c:1304
@ URD_COL_GOLD
Definition repodlgs.c:1300
@ URD_COL_UPGRADABLE
Definition repodlgs.c:1294
@ URD_COL_FOOD
Definition repodlgs.c:1299
@ URD_COL_N_UPGRADABLE
Definition repodlgs.c:1295
@ URD_COL_NUPG_VISIBLE
Definition repodlgs.c:1306
@ URD_COL_UTYPE_NAME
Definition repodlgs.c:1293
@ URD_COL_UTYPE_ID
Definition repodlgs.c:1307
@ URD_COL_SHIELD
Definition repodlgs.c:1298
@ URD_COL_EMPTY
Definition repodlgs.c:1301
science_report_columns
Definition repodlgs.c:112
@ SRD_COL_ID
Definition repodlgs.c:117
@ SRD_COL_NAME
Definition repodlgs.c:113
@ SRD_COL_NUM
Definition repodlgs.c:119
@ SRD_COL_STEPS
Definition repodlgs.c:114
static const char * economy_report_column_name(enum economy_report_columns col)
Definition repodlgs.c:826
static GtkWidget * science_diagram_new(void)
Definition repodlgs.c:270
int visible_col
Definition repodlgs.c:1317
static void science_report_show_all_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:545
economy_report_columns
Definition repodlgs.c:788
@ ERD_COL_NUM
Definition repodlgs.c:801
@ ERD_COL_SPRITE
Definition repodlgs.c:789
@ ERD_COL_IS_IMPROVEMENT
Definition repodlgs.c:798
@ ERD_COL_CID
Definition repodlgs.c:799
@ ERD_COL_NAME
Definition repodlgs.c:790
@ ERD_COL_EMPTY
Definition repodlgs.c:795
@ ERD_COL_REDUNDANT
Definition repodlgs.c:791
@ ERD_COL_TOTAL_COST
Definition repodlgs.c:794
@ ERD_COL_COUNT
Definition repodlgs.c:792
@ ERD_COL_COST
Definition repodlgs.c:793
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
bool rightalign
Definition repodlgs.c:1316
static GtkListStore * economy_report_store_new(void)
Definition repodlgs.c:807
static struct unit * find_nearest_unit(const struct unit_type *utype, struct tile *ptile)
Definition repodlgs.c:1539
endgame_report_columns
Definition repodlgs.c:1813
@ FRD_COL_NUM
Definition repodlgs.c:1819
@ FRD_COL_TOOLTIP
Definition repodlgs.c:1817
@ FRD_COL_NATION
Definition repodlgs.c:1815
@ FRD_COL_PLAYER
Definition repodlgs.c:1814
@ FRD_COL_SCORE
Definition repodlgs.c:1816
economy_report_response
Definition repodlgs.c:780
@ ERD_RES_SELL_REDUNDANT
Definition repodlgs.c:781
@ ERD_RES_SELL_ALL
Definition repodlgs.c:782
@ ERD_RES_DISBAND_UNITS
Definition repodlgs.c:783
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
static void economy_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1068
static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:556
static void economy_report_free(struct economy_report *preport)
Definition repodlgs.c:1230
static void science_report_init(struct science_report *preport)
Definition repodlgs.c:580
static void science_report_current_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:520
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
static void units_report_free(struct units_report *preport)
Definition repodlgs.c:1755
static GtkListStore * science_report_store_new(void)
Definition repodlgs.c:125
static void science_report_redraw(struct science_report *preport)
Definition repodlgs.c:345
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1139
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1108
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:1331
const char * title
Definition repodlgs.c:1330
GType type
Definition repodlgs.c:1329
int visible_col
Definition repodlgs.c:1333
bool rightalign
Definition repodlgs.c:1332
static gboolean science_diagram_right_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:238
@ HELP_TECH
Definition helpdlg_g.h:21
bool can_sell_building(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:641
struct tile * get_center_tile_mapcanvas(void)
void center_tile_mapcanvas(const struct tile *ptile)
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:747
struct player * player_by_number(const int player_id)
Definition player.c:849
const char * player_name(const struct player *pplayer)
Definition player.c:895
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
endgame_report_dialog_player
Definition repodlgs_g.h:33
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Definition reqtree.c:1038
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:872
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1180
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1203
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:475
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:841
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
bool research_future_next(const struct research *presearch)
Definition research.c:1362
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
#define ARRAY_SIZE(x)
Definition shared.h:85
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
cairo_t * drawable
Definition canvas.h:24
struct connection conn
Definition client_main.h:96
GtkLabel * label
Definition repodlgs.c:775
GtkTreeView * tree_view
Definition repodlgs.c:774
struct gui_dialog * shell
Definition repodlgs.c:773
GtkListStore * store
Definition repodlgs.c:1808
GtkTreeView * tree_view
Definition repodlgs.c:1807
struct gui_dialog * shell
Definition repodlgs.c:1806
Definition climisc.h:82
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:85
Tech_type_id researching
Definition research.h:52
struct gui_dialog * shell
Definition repodlgs.c:70
GtkProgressBar * progress_bar
Definition repodlgs.c:75
GtkComboBox * reachable_techs
Definition repodlgs.c:71
GtkComboBox * reachable_goals
Definition repodlgs.c:72
GtkDrawingArea * drawing_area
Definition repodlgs.c:77
GtkLabel * goal_label
Definition repodlgs.c:76
GtkLabel * main_label
Definition repodlgs.c:74
GtkWidget * button_show_all
Definition repodlgs.c:73
Definition tile.h:50
Definition unit.h:137
int upkeep[O_LAST]
Definition unit.h:147
enum unit_activity activity
Definition unit.h:156
int moves_left
Definition unit.h:149
struct unit::@81::@83 client
int homecity
Definition unit.h:145
bool done_moving
Definition unit.h:180
const struct unit_type * utype
Definition unit.h:138
enum unit_focus_status focus_status
Definition unit.h:213
enum server_side_agent ssa_controller
Definition unit.h:171
GtkTreeView * tree_view
Definition repodlgs.c:1281
struct gui_dialog * shell
Definition repodlgs.c:1280
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:473
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
#define A_FUTURE
Definition tech.h:46
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2158
const char * get_science_target_text(double *percent)
Definition text.c:826
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:872
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6798
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7529
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6820
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
#define unit_tile(_pu)
Definition unit.h:396
@ FOCUS_AVAIL
Definition unit.h:52
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862