Freeciv-3.2
Loading...
Searching...
No Matches
repodlgs.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "fc_types.h" /* LINE_BREAK */
34#include "game.h"
35#include "government.h"
36#include "packets.h"
37#include "research.h"
38#include "tech.h"
39#include "unitlist.h"
40
41/* client */
42#include "chatline_common.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "control.h"
46#include "mapview_common.h"
47#include "options.h"
48#include "packhand_gen.h"
49#include "control.h"
50#include "reqtree.h"
51#include "text.h"
52
53/* client/gui-gtk-3.22 */
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****************************************************************************/
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);
92 cairo_t *cr,
93 gpointer data);
94static GtkWidget *science_diagram_new(void);
95static void science_diagram_data(GtkWidget *widget, bool show_all);
101 gpointer data);
103 gpointer data);
104static void science_report_goal_callback(GtkComboBox *combo, gpointer data);
105static void science_report_init(struct science_report *preport);
106static void science_report_free(struct science_report *preport);
107
108static struct science_report science_report = { NULL, };
110
111/* Those values must match the function science_report_store_new(). */
115
116 /* Not visible. */
117 SRD_COL_ID, /* Tech_type_id */
118
121
122/************************************************************************/
126{
128 G_TYPE_STRING, /* SRD_COL_NAME */
129 G_TYPE_INT, /* SRD_COL_STEPS */
130 G_TYPE_INT); /* SRD_COL_ID */
131}
132
133/************************************************************************/
136static inline void science_report_store_set(GtkListStore *store,
138 Tech_type_id tech)
139{
140 const struct research *presearch = research_get(client_player());
141
147 SRD_COL_ID, tech,
148 -1);
149}
150
151/************************************************************************/
155 Tech_type_id *tech,
156 char **name)
157{
159
161 || !gtk_combo_box_get_active_iter(combo, &iter)) {
162 return FALSE;
163 }
164
167 SRD_COL_ID, tech,
168 -1);
169 return TRUE;
170}
171
172/************************************************************************/
176 Tech_type_id tech)
177{
178 ITree iter;
180
184 if (iter_tech == tech) {
188 return;
189 }
190 }
191 log_error("%s(): Tech %d not found in the combo.", __FUNCTION__, tech);
192}
193
194/************************************************************************/
199{
200 const struct research *presearch = research_get(client_player());
201 struct reqtree *reqtree = g_object_get_data(G_OBJECT(widget), "reqtree");
203
204 if (tech == A_NONE) {
205 return TRUE;
206 }
207
208 if (event->button == 3) {
209 /* RMB: get help */
211 tech),
212 HELP_TECH);
213 } else {
214 if (event->button == 1 && can_client_issue_orders()) {
215 /* LMB: set research or research goal */
217 tech)) {
220 break;
221 case TECH_UNKNOWN:
223 break;
224 case TECH_KNOWN:
225 break;
226 }
227 }
228 }
229 return TRUE;
230}
231
232/************************************************************************/
265
266/************************************************************************/
286
287/************************************************************************/
290static void science_diagram_data(GtkWidget *widget, bool show_all)
291{
292 struct reqtree *reqtree;
293 int width, height;
294
295 if (can_conn_edit(&client.conn)) {
296 /* Show all techs in editor mode, not only currently reachable ones */
298 } else {
299 /* Show only at some point reachable techs */
300 reqtree = create_reqtree(client_player(), show_all);
301 }
302
307}
308
309/************************************************************************/
341
342/************************************************************************/
346{
347 Tech_type_id researching;
348
350
353 preport->button_show_all)));
354
355 if (client_has_player()) {
356 researching = research_get(client_player())->researching;
357 } else {
358 researching = A_UNSET;
359 }
360 science_diagram_center(GTK_WIDGET(preport->drawing_area), researching);
361
363}
364
365/************************************************************************/
379
380/************************************************************************/
384{
385 GtkListStore *store;
389 const char *text;
390 double pct;
391 Tech_type_id tech;
393
396
397 /* Disable callbacks. */
399
401
403
404 /* Update the progress bar. */
406 gtk_progress_bar_set_text(preport->progress_bar, text);
408 /* Work around GTK+ refresh bug? */
410
411 /* Update reachable techs. */
412 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
415
416 /* Collect all techs which are reachable in the next step. */
418 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
420 }
422
423 if (sorting_list != NULL) {
424 if (A_UNSET == presearch->researching
425 || is_future_tech(presearch->researching)) {
427 science_report_store_set(store, &iter, presearch->researching);
428 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
429 }
430
431 /* Sort the list, append it to the store. */
433 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
434 tech = GPOINTER_TO_INT(item->data);
436 science_report_store_set(store, &iter, tech);
437 if (tech == presearch->researching) {
438 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
439 }
440 }
441
442 /* Free, re-init. */
445 } else {
446 /* No reachable normal techs. Can we select Future Tech? */
447 Tech_type_id next;
448
451 next = A_FUTURE;
452 } else {
453 next = presearch->researching;
454 }
455 science_report_store_set(store, &iter, next);
456
457 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
458 }
459
460 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_goals));
462
463 /* Update the tech goal. */
464 gtk_label_set_text(preport->goal_label,
465 get_science_goal_text(presearch->tech_goal));
466
467 /* Collect all techs which are reachable in next 10 steps. */
470 && TECH_KNOWN != presearch->inventions[i].state
471 && (i == presearch->tech_goal
472 || 10 >= presearch->inventions[i].num_required_techs)) {
474 }
476
477 if (sorting_list != NULL) {
478 if (A_UNSET == presearch->tech_goal) {
481 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
482 }
483
484 /* Sort the list, append it to the store. */
486 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
487 tech = GPOINTER_TO_INT(item->data);
489 science_report_store_set(store, &iter, tech);
490 if (tech == presearch->tech_goal) {
491 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
492 }
493 }
494
495 /* Free. */
497 } else {
498 /* No reachable normal techs. Can we select Future Tech? */
499 Tech_type_id goal;
500
502
504 goal = A_FUTURE;
505 } else {
506 goal = A_UNSET;
507 }
508
509 science_report_store_set(store, &iter, goal);
510 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
511 }
512
513 /* Re-enable callbacks. */
515}
516
517/************************************************************************/
521 gpointer data)
522{
523 Tech_type_id tech;
524 char *tech_name;
525
526 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
527 return;
528 }
529
532 } else if (can_client_issue_orders()) {
534 }
535
536 free(tech_name);
537 /* Revert, or we will not be in sync with the server. */
540}
541
542/************************************************************************/
546 gpointer data)
547{
548 struct science_report *preport = (struct science_report *) data;
549
551}
552
553/************************************************************************/
557{
558 Tech_type_id tech;
559 char *tech_name;
560
561 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
562 return;
563 }
564
567 } else if (can_client_issue_orders()) {
569 }
570
571 free(tech_name);
572 /* Revert, or we will not be in sync with the server. */
574 (client_player())->tech_goal);
575}
576
577/************************************************************************/
581{
582 GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w;
583 GtkSizeGroup *group;
584 GtkContainer *vbox;
585 GtkListStore *store;
586 GtkCellRenderer *renderer;
587
589
591 /* TRANS: Research report title */
592 gui_dialog_set_title(preport->shell, _("Research"));
593
594 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
597
598 vbox = GTK_CONTAINER(preport->shell->vbox);
600
601 w = gtk_label_new(NULL);
602 gtk_container_add(vbox, w);
603 preport->main_label = GTK_LABEL(w);
604
605 /* Current research target line. */
606 frame = gtk_frame_new(_("Researching"));
607 gtk_container_add(vbox, frame);
608
612
615
616 store = science_report_store_new();
619 g_object_unref(G_OBJECT(store));
620 renderer = gtk_cell_renderer_text_new();
627 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
628 preport->reachable_techs = GTK_COMBO_BOX(w);
629
633 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
635 preport->progress_bar = GTK_PROGRESS_BAR(w);
636
637 /* Research goal line. */
638 frame = gtk_frame_new( _("Goal"));
639 gtk_container_add(vbox, frame);
640
644
645 store = science_report_store_new();
648 g_object_unref(G_OBJECT(store));
649 renderer = gtk_cell_renderer_text_new();
653 renderer = gtk_cell_renderer_text_new();
660 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
661 preport->reachable_goals = GTK_COMBO_BOX(w);
662
663 w = gtk_label_new(NULL);
665 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
667 preport->goal_label = GTK_LABEL(w);
668
669 /* Toggle "Show All" button. */
670 /* TRANS: As in 'Show all (even not reachable) techs'. */
677 preport->button_show_all = show_all_button;
678
679 /* Science diagram. */
683 gtk_container_add(vbox, sw);
684
689 preport->drawing_area = GTK_LAYOUT(w);
690
694 g_object_unref(group);
695
696 /* This must be _after_ the dialog is drawn to really center it ... */
698}
699
700/************************************************************************/
704{
706
708 fc_assert(NULL == preport->shell);
709
710 memset(preport, 0, sizeof(*preport));
711}
712
713/************************************************************************/
717{
719
720 if (NULL == science_report.shell) {
722 }
723
724 if (NULL != presearch
725 && A_UNSET == presearch->tech_goal
726 && A_UNSET == presearch->researching) {
728 } else {
730 }
731
732 if (raise) {
734 }
735}
736
737/************************************************************************/
747
748/************************************************************************/
757
758/************************************************************************/
767
768
769/****************************************************************************
770 ECONOMY REPORT DIALOG
771****************************************************************************/
777
779
785
786/* Those values must match the functions economy_report_store_new() and
787 * economy_report_column_name(). */
803
804/************************************************************************/
808{
810 GDK_TYPE_PIXBUF, /* ERD_COL_SPRITE */
811 G_TYPE_STRING, /* ERD_COL_NAME */
812 G_TYPE_INT, /* ERD_COL_REDUNDANT */
813 G_TYPE_INT, /* ERD_COL_COUNT */
814 G_TYPE_INT, /* ERD_COL_COST */
815 G_TYPE_INT, /* ERD_COL_TOTAL_COST */
816 G_TYPE_STRING, /* ERD_COL_EMPTY */
817 G_TYPE_BOOLEAN, /* ERD_COL_IS_IMPROVEMENT */
818 G_TYPE_INT, /* ERD_COL_UNI_KIND */
819 G_TYPE_INT); /* ERD_COL_UNI_VALUE_ID */
820}
821
822/************************************************************************/
825static const char *
827{
828 switch (col) {
829 case ERD_COL_SPRITE:
830 /* TRANS: Image header */
831 return _("Type");
832 case ERD_COL_NAME:
833 return Q_("?Building or Unit type:Name");
835 return _("Redundant");
836 case ERD_COL_COUNT:
837 return _("Count");
838 case ERD_COL_COST:
839 return _("Cost");
841 /* TRANS: Upkeep total, count*cost. */
842 return _("U Total");
843 case ERD_COL_EMPTY:
844 /* empty space for scrollbar*/
845 return " ";
847 case ERD_COL_CID:
848 case ERD_COL_NUM:
849 break; /* no more columns will be displayed after reaching this */
850 }
851
852 return NULL;
853}
854
855/************************************************************************/
859{
860 GtkTreeSelection *selection;
861 GtkTreeModel *model;
862 GtkListStore *store;
864 GdkPixbuf *pix;
868 char buf[256];
869 cid selected;
870
872
873 /* Save the selection. */
874 selection = gtk_tree_view_get_selection(preport->tree_view);
875 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
876 gtk_tree_model_get(model, &iter, ERD_COL_CID, &selected, -1);
877 } else {
878 selected = -1;
879 }
880
881 model = gtk_tree_view_get_model(preport->tree_view);
882 store = GTK_LIST_STORE(model);
884
885 /* Buildings. */
887 &building_total, &tax);
888 for (i = 0; i < entries_used; i++) {
890 struct impr_type *pimprove = pentry->type;
891 struct sprite *sprite = get_building_sprite(tileset, pimprove);
892 cid id = cid_encode_building(pimprove);
893
896 gtk_list_store_set(store, &iter,
897 ERD_COL_SPRITE, pix,
899 ERD_COL_REDUNDANT, pentry->redundant,
900 ERD_COL_COUNT, pentry->count,
901 ERD_COL_COST, pentry->cost,
902 ERD_COL_TOTAL_COST, pentry->total_cost,
903 ERD_COL_EMPTY, " ",
905 ERD_COL_CID, id,
906 -1);
908 if (selected == id) {
909 /* Restore the selection. */
911 }
912 }
913
914 /* Units. */
916 for (i = 0; i < entries_used; i++) {
917 struct unit_entry *pentry = unit_entries + i;
918 struct unit_type *putype = pentry->type;
923
926 gtk_list_store_set(store, &iter,
927 ERD_COL_SPRITE, pix,
930 ERD_COL_COUNT, pentry->count,
931 ERD_COL_COST, pentry->cost,
932 ERD_COL_TOTAL_COST, pentry->total_cost,
933 ERD_COL_EMPTY, " ",
935 ERD_COL_CID, id,
936 -1);
938 if (selected == id) {
939 /* Restore the selection. */
941 }
942 }
943
944 /* Update the label. */
945 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
948}
949
950/************************************************************************/
953static void economy_report_command_callback(struct gui_dialog *pdialog,
954 int response,
955 gpointer data)
956{
957 struct economy_report *preport = data;
959 GtkTreeModel *model;
962 struct universal selected;
963 cid id;
964 char buf[256] = "";
965
966 switch (response) {
968 case ERD_RES_SELL_ALL:
970 break;
971 default:
972 gui_dialog_destroy(pdialog);
973 return;
974 }
975
977 || !gtk_tree_selection_get_selected(selection, &model, &iter)) {
978 return;
979 }
980
981 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
982 selected = cid_decode(id);
983
984 switch (selected.kind) {
985 case VUT_IMPROVEMENT:
986 {
987 const struct impr_type *pimprove = selected.value.building;
988
989 if (can_sell_building(pimprove)
990 && (ERD_RES_SELL_ALL == response
991 || (ERD_RES_SELL_REDUNDANT == response))) {
992 bool redundant = (ERD_RES_SELL_REDUNDANT == response);
993 gint count;
994 gtk_tree_model_get(model, &iter,
995 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
996 &count, -1);
997 if (count == 0) {
998 break;
999 }
1004 redundant
1005 /* TRANS: %s is an improvement */
1006 ? _("Do you really wish to sell "
1007 "every redundant %s (%d total)?")
1008 /* TRANS: %s is an improvement */
1009 : _("Do you really wish to sell "
1010 "every %s (%d total)?"),
1012 count);
1014 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1015
1017 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1018 }
1020 }
1021 }
1022 break;
1023 case VUT_UTYPE:
1024 {
1025 if (ERD_RES_DISBAND_UNITS == response) {
1026 const struct unit_type *putype = selected.value.utype;
1027 gint count;
1028 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1029
1034 /* TRANS: %s is a unit */
1035 _("Do you really wish to disband "
1036 "every %s (%d total)?"),
1038 count);
1040 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1041
1043 disband_all_units(putype, FALSE, buf, sizeof(buf));
1044 }
1046 }
1047 }
1048 break;
1049 default:
1050 log_error("Not supported type: %d.", selected.kind);
1051 }
1052
1053 if ('\0' != buf[0]) {
1056 "%s", buf);
1059 NULL);
1060 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1062 }
1063}
1064
1065/************************************************************************/
1069 gpointer data)
1070{
1071 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1072 GtkTreeModel *model;
1074
1076 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1077 struct universal selected;
1078 cid id;
1079
1080 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1081 selected = cid_decode(id);
1082 switch (selected.kind) {
1083 case VUT_IMPROVEMENT:
1084 {
1085 bool can_sell = can_sell_building(selected.value.building);
1086 gint redundant;
1087 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1088
1090 can_sell && redundant > 0);
1093 FALSE);
1094 }
1095 return;
1096 case VUT_UTYPE:
1098 FALSE);
1101 TRUE);
1102 return;
1103 default:
1104 log_error("Not supported type: %d.", selected.kind);
1105 break;
1106 }
1107 }
1108
1112}
1113
1114/************************************************************************/
1118{
1119 GtkWidget *view, *sw, *label, *button;
1120 GtkListStore *store;
1121 GtkTreeSelection *selection;
1122 GtkContainer *vbox;
1123 const char *title;
1125
1127
1129 gui_dialog_set_title(preport->shell, _("Economy"));
1130 vbox = GTK_CONTAINER(preport->shell->vbox);
1131
1139
1140 store = economy_report_store_new();
1143 g_object_unref(store);
1144 gtk_widget_set_name(view, "small_font");
1147 preport->tree_view = GTK_TREE_VIEW(view);
1148
1150 g_signal_connect(selection, "changed",
1152
1153 for (i = 0; (title = economy_report_column_name(i)); i++) {
1154 GtkCellRenderer *renderer;
1157
1158 if (GDK_TYPE_PIXBUF == type) {
1159 renderer = gtk_cell_renderer_pixbuf_new();
1161 "pixbuf", i, NULL);
1162#if 0
1163 } else if (G_TYPE_BOOLEAN == type) {
1164 renderer = gtk_cell_renderer_toggle_new();
1166 "active", i, NULL);
1167#endif
1168 } else {
1169 bool is_redundant = (i == ERD_COL_REDUNDANT);
1170 renderer = gtk_cell_renderer_text_new();
1171 if (is_redundant) {
1172 /* Special treatment: hide "Redundant" column for units */
1174 "text", i,
1175 "visible",
1177 NULL);
1178 } else {
1180 "text", i, NULL);
1181 }
1182 }
1183
1184 if (i > 1) {
1185 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1187 }
1188
1190 }
1191
1192 label = gtk_label_new(NULL);
1193 gtk_container_add(vbox, label);
1195 gtk_widget_set_margin_end(label, 5);
1196 gtk_widget_set_margin_top(label, 5);
1198 preport->label = GTK_LABEL(label);
1199
1200 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1202
1203 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1206
1207 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1210
1211 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1214
1218
1219 gui_dialog_set_default_size(preport->shell, -1, 350);
1221
1223
1225}
1226
1227/************************************************************************/
1231{
1233
1235 fc_assert(NULL == preport->shell);
1236
1237 memset(preport, 0, sizeof(*preport));
1238}
1239
1240/************************************************************************/
1254
1255/************************************************************************/
1264
1265/************************************************************************/
1274
1275
1276/****************************************************************************
1277 UNITS REPORT DIALOG
1278****************************************************************************/
1283
1284static struct units_report units_report = { NULL, NULL };
1285
1290
1291/* Those values must match the order of unit_report_columns[]. */
1311
1312static const struct {
1314 const char *title;
1315 const char *tooltip;
1318} unit_report_columns[] = {
1319 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1320 NULL, FALSE, -1 },
1321 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1322 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1323 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1325 /* TRANS: "In progress" abbreviation. */
1326 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1327 N_("In progress"), TRUE, -1 },
1328 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1329 NULL, TRUE, -1 },
1330 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1331 N_("Total shield upkeep"), TRUE, -1 },
1332 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1333 N_("Total food upkeep"), TRUE, -1 },
1334 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1335 N_("Total gold upkeep"), TRUE, -1 },
1336 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1337 " ", TRUE, -1 },
1338
1339 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1340 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1341 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1342 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1344
1345/************************************************************************/
1349{
1350 int i;
1352
1354
1355 for (i = 0; i < URD_COL_NUM; i++) {
1356 cols[i] = unit_report_columns[i].type;
1357 }
1358
1360}
1361
1362/************************************************************************/
1366{
1367 struct urd_info {
1368 int active_count;
1369 int building_count;
1370 int upkeep[O_LAST];
1371 };
1372
1374 struct urd_info unit_totals;
1375 struct urd_info *info;
1376 int total_upgradable_count = 0;
1377 GtkTreeSelection *selection;
1378 GtkTreeModel *model;
1379 GtkListStore *store;
1381 Unit_type_id selected, utype_id;
1382
1384
1385 memset(unit_array, '\0', sizeof(unit_array));
1386 memset(&unit_totals, '\0', sizeof(unit_totals));
1387
1388 /* Count units. */
1389 players_iterate(pplayer) {
1390 if (client_has_player() && pplayer != client_player()) {
1391 continue;
1392 }
1393
1394 unit_list_iterate(pplayer->units, punit) {
1396
1397 if (0 != punit->homecity) {
1399 info->upkeep[o] += punit->upkeep[o];
1401 }
1402 info->active_count++;
1404 city_list_iterate(pplayer->cities, pcity) {
1405 if (VUT_UTYPE == pcity->production.kind) {
1406 int num_units;
1407 info = unit_array + utype_index(pcity->production.value.utype);
1408 /* Account for build slots in city */
1410 /* Unit is in progress even if it won't be done this turn */
1411 num_units = MAX(num_units, 1);
1412 info->building_count += num_units;
1413 }
1416
1417 /* Save selection. */
1418 selection = gtk_tree_view_get_selection(preport->tree_view);
1419 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1420 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1421 } else {
1422 selected = -1;
1423 }
1424
1425 /* Make the store. */
1426 model = gtk_tree_view_get_model(preport->tree_view);
1427 store = GTK_LIST_STORE(model);
1428 gtk_list_store_clear(store);
1429
1430 unit_type_iterate(utype) {
1431 bool upgradable;
1432
1433 utype_id = utype_index(utype);
1434 info = unit_array + utype_id;
1435
1436 if (0 == info->active_count && 0 == info->building_count) {
1437 continue; /* We don't need a row for this type. */
1438 }
1439
1441 && NULL != can_upgrade_unittype(client_player(), utype);
1442
1443 gtk_list_store_append(store, &iter);
1444 gtk_list_store_set(store, &iter,
1447 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1448 URD_COL_IN_PROGRESS, info->building_count,
1449 URD_COL_ACTIVE, info->active_count,
1450 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1451 URD_COL_FOOD, info->upkeep[O_FOOD],
1452 URD_COL_GOLD, info->upkeep[O_GOLD],
1453 URD_COL_EMPTY, " ",
1458 -1);
1459 if (selected == utype_id) {
1460 /* Restore the selection. */
1462 }
1463
1464 /* Update totals. */
1465 unit_totals.active_count += info->active_count;
1467 unit_totals.upkeep[o] += info->upkeep[o];
1469 unit_totals.building_count += info->building_count;
1470 if (upgradable) {
1471 total_upgradable_count += info->active_count;
1472 }
1474
1475 /* Add the total row. */
1476 gtk_list_store_append(store, &iter);
1477 gtk_list_store_set(store, &iter,
1478 URD_COL_UTYPE_NAME, _("Totals:"),
1479 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1481 URD_COL_IN_PROGRESS, unit_totals.building_count,
1482 URD_COL_ACTIVE, unit_totals.active_count,
1486 URD_COL_EMPTY, " ",
1491 -1);
1492 if (selected == U_LAST) {
1493 /* Restore the selection. */
1495 }
1496}
1497
1498/************************************************************************/
1502 gpointer data)
1503{
1504 struct units_report *preport = data;
1505 GtkTreeModel *model;
1506 GtkTreeIter it;
1507 int active_count;
1508 struct unit_type *utype = NULL;
1509
1510 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1511 int ut;
1512
1513 gtk_tree_model_get(model, &it,
1514 URD_COL_ACTIVE, &active_count,
1516 -1);
1517 if (0 < active_count) {
1518 utype = utype_by_number(ut);
1519 }
1520 }
1521
1522 if (NULL == utype) {
1524 FALSE);
1526 FALSE);
1527 } else {
1532 && NULL != can_upgrade_unittype(client_player(), utype)));
1533 }
1534}
1535
1536/************************************************************************/
1539static struct unit *find_nearest_unit(const struct unit_type *utype,
1540 struct tile *ptile)
1541{
1542 struct unit *best_candidate = NULL;
1543 int best_dist = FC_INFINITY, dist;
1544
1545 players_iterate(pplayer) {
1546 if (client_has_player() && pplayer != client_player()) {
1547 continue;
1548 }
1549
1550 unit_list_iterate(pplayer->units, punit) {
1551 if (utype == unit_type_get(punit)
1553 && 0 < punit->moves_left
1554 && !punit->done_moving
1555 && punit->ssa_controller == SSA_NONE) {
1556 dist = sq_map_distance(unit_tile(punit), ptile);
1557 if (dist < best_dist) {
1559 best_dist = dist;
1560 }
1561 }
1564
1565 return best_candidate;
1566}
1567
1568/************************************************************************/
1571static void units_report_command_callback(struct gui_dialog *pdialog,
1572 int response,
1573 gpointer data)
1574{
1575 struct units_report *preport = data;
1576 struct unit_type *utype = NULL;
1577 GtkTreeSelection *selection;
1578 GtkTreeModel *model;
1579 GtkTreeIter it;
1580
1581 switch (response) {
1582 case URD_RES_NEAREST:
1583 case URD_RES_UPGRADE:
1584 break;
1585 default:
1586 gui_dialog_destroy(pdialog);
1587 return;
1588 }
1589
1590 /* Nearest & upgrade commands. */
1591 selection = gtk_tree_view_get_selection(preport->tree_view);
1592 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1593 int ut;
1594
1595 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1596 utype = utype_by_number(ut);
1597 }
1598
1599 if (response == URD_RES_NEAREST) {
1600 struct tile *ptile;
1601 struct unit *punit;
1602
1603 ptile = get_center_tile_mapcanvas();
1604 if ((punit = find_nearest_unit(utype, ptile))) {
1606
1611 }
1612 }
1613 }
1614 } else if (can_client_issue_orders()) {
1616 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1617 char buf[1024];
1618 int price = unit_upgrade_price(client_player(), utype, upgrade);
1619
1620 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1621 "Treasury contains %d gold.",
1622 client_player()->economic.gold),
1623 client_player()->economic.gold);
1624
1629 /* TRANS: Last %s is pre-pluralised
1630 * "Treasury contains %d gold." */
1631 PL_("Upgrade as many %s to %s as possible "
1632 "for %d gold each?\n%s",
1633 "Upgrade as many %s to %s as possible "
1634 "for %d gold each?\n%s", price),
1636 utype_name_translation(upgrade),
1637 price, buf);
1639
1640 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1641
1644 }
1645
1647 }
1648}
1649
1650/************************************************************************/
1654{
1655 GtkWidget *view, *sw, *button;
1656 GtkListStore *store;
1657 GtkTreeSelection *selection;
1658 GtkContainer *vbox;
1661
1663
1665 gui_dialog_set_title(preport->shell, _("Units"));
1666 vbox = GTK_CONTAINER(preport->shell->vbox);
1667
1675
1676 store = units_report_store_new();
1679 g_object_unref(store);
1680 gtk_widget_set_name(view, "small_font");
1683 preport->tree_view = GTK_TREE_VIEW(view);
1684
1686 g_signal_connect(selection, "changed",
1688
1689 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1690 GtkCellRenderer *renderer;
1691
1692 if (strlen(unit_report_columns[i].title) > 0) {
1697 }
1698 gtk_widget_show(header);
1703 }
1705 } /* else add new renderer to previous TreeViewColumn */
1706
1707 fc_assert(col != NULL);
1709 renderer = gtk_cell_renderer_toggle_new();
1711 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1712 } else {
1713 renderer = gtk_cell_renderer_text_new();
1715 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1717 "weight", URD_COL_TEXT_WEIGHT);
1718 }
1719
1720 if (unit_report_columns[i].visible_col >= 0) {
1721 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1723 }
1724
1726 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1727 }
1728 }
1729
1730 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1732
1733 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1736
1737 button = gui_dialog_add_button(preport->shell, "edit-find",
1738 _("Find _Nearest"), URD_RES_NEAREST);
1740
1744
1745 gui_dialog_set_default_size(preport->shell, -1, 350);
1747
1750}
1751
1752/************************************************************************/
1756{
1758
1760 fc_assert(NULL == preport->shell);
1761
1762 memset(preport, 0, sizeof(*preport));
1763}
1764
1765/************************************************************************/
1779
1780/************************************************************************/
1790
1791/************************************************************************/
1800
1801
1802/****************************************************************************
1803 FINAL REPORT DIALOG
1804****************************************************************************/
1812
1821
1823
1824/************************************************************************/
1827static const char *
1829{
1830 switch (col) {
1831 case FRD_COL_PLAYER:
1832 return _("Player\n");
1833 case FRD_COL_NATION:
1834 return _("Nation\n");
1835 case FRD_COL_SCORE:
1836 return _("Score\n");
1837 case FRD_COL_TOOLTIP:
1838 case FRD_COL_NUM:
1839 break;
1840 }
1841
1842 return NULL;
1843}
1844
1845/************************************************************************/
1849 const struct packet_endgame_report *packet)
1850{
1851 const size_t col_num = packet->category_num + FRD_COL_NUM;
1855 int i;
1856
1858
1859 /* Remove the old columns. */
1860 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1862 }
1863
1864 /* Create the new model. */
1869 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1871 }
1875
1876 /* Create the new columns. */
1877 for (i = 0; (guint)i < col_num; i++) {
1878 GtkCellRenderer *renderer;
1879 const char *title;
1880 const char *attribute;
1881
1882 if (GDK_TYPE_PIXBUF == col_types[i]) {
1883 renderer = gtk_cell_renderer_pixbuf_new();
1884 attribute = "pixbuf";
1885 } else {
1886 renderer = gtk_cell_renderer_text_new();
1887 attribute = "text";
1888 }
1889
1890 if (i < FRD_COL_NUM) {
1892 } else {
1893 title = packet->category_name[i - FRD_COL_NUM];
1894 }
1895
1896 if (title != NULL) {
1898 attribute, i, NULL);
1900 if (GDK_TYPE_PIXBUF != col_types[i]) {
1902 }
1903 }
1904 }
1905
1908
1909 preport->store = store;
1910 preport->player_count = packet->player_num;
1911 preport->players_received = 0;
1912}
1913
1914/************************************************************************/
1918{
1919 /* Fill the model with player stats. */
1921 const struct player *pplayer = player_by_number(packet->player_id);
1923 int i;
1924
1927 FRD_COL_PLAYER, player_name(pplayer),
1929 FRD_COL_SCORE, packet->score,
1930 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1931 -1);
1932 for (i = 0; i < packet->category_num; i++) {
1934 i + FRD_COL_NUM, packet->category_score[i],
1935 -1);
1936 }
1937
1938 preport->players_received++;
1939
1940 if (preport->players_received == preport->player_count) {
1942 }
1943}
1944
1945/************************************************************************/
1949{
1950 GtkWidget *sw, *view;
1951
1953
1955 gui_dialog_set_title(preport->shell, _("Score"));
1956
1957 gui_dialog_set_default_size(preport->shell, 700, 420);
1958
1959 /* Setup the layout. */
1965 gtk_container_add(GTK_CONTAINER(preport->shell->vbox), sw);
1966
1968 gtk_widget_set_name(view, "small_font");
1970 preport->tree_view = GTK_TREE_VIEW(view);
1971
1972 if (preport->shell->type == GUI_DIALOG_TAB) {
1975 }
1976
1978}
1979
1980/************************************************************************/
bool action_ever_possible(action_id action)
Definition actions.c:8092
int entries_used
Definition agents.c:77
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:747
#define city_list_iterate(citylist, pcity)
Definition city.h:508
#define output_type_iterate(output)
Definition city.h:845
#define city_list_iterate_end
Definition city.h:510
#define output_type_iterate_end
Definition city.h:851
bool client_is_global_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:504
struct universal cid_decode(cid id)
Definition climisc.c:525
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
int cid
Definition climisc.h:31
char * incite_cost
Definition comments.c:75
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:636
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
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 gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:734
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:888
void itree_next(ITree *it)
Definition gui_stuff.c:144
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:760
GtkWidget * gui_dialog_get_toplevel(struct gui_dialog *dlg)
Definition gui_stuff.c:787
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
@ GUI_DIALOG_TAB
Definition gui_stuff.h:62
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
static struct endgame_report endgame_report
Definition repodlgs.c:1822
static void units_report_init(struct units_report *preport)
Definition repodlgs.c:1653
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
static GtkListStore * units_report_store_new(void)
Definition repodlgs.c:1348
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
static void science_report_store_set(GtkListStore *store, GtkTreeIter *iter, Tech_type_id tech)
Definition repodlgs.c:136
static void economy_report_init(struct economy_report *preport)
Definition repodlgs.c:1117
static void science_report_update(struct science_report *preport)
Definition repodlgs.c:383
static void units_report_update(struct units_report *preport)
Definition repodlgs.c:1365
static bool science_report_combo_get_active(GtkComboBox *combo, Tech_type_id *tech, char **name)
Definition repodlgs.c:154
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
Definition repodlgs.c:312
units_report_response
Definition repodlgs.c:1286
@ URD_RES_UPGRADE
Definition repodlgs.c:1288
@ URD_RES_NEAREST
Definition repodlgs.c:1287
static void endgame_report_update(struct endgame_report *preport, const struct packet_endgame_report *packet)
Definition repodlgs.c:1848
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
const char * tooltip
Definition repodlgs.c:1315
static const struct @158 unit_report_columns[]
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
Definition repodlgs.c:235
static gboolean science_diagram_button_release_callback(GtkWidget *widget, GdkEventButton *event, gpointer data)
Definition repodlgs.c:197
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
const char * tooltip
Definition repodlgs.c:1344
const char * title
Definition repodlgs.c:1343
GType type
Definition repodlgs.c:1342
int visible_col
Definition repodlgs.c:1346
bool rightalign
Definition repodlgs.c:1345
@ HELP_TECH
Definition helpdlg_g.h:21
bool can_sell_building(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:641
struct tile * get_center_tile_mapcanvas(void)
void center_tile_mapcanvas(const struct tile *ptile)
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:741
struct player * player_by_number(const int player_id)
Definition player.c:849
const char * player_name(const struct player *pplayer)
Definition player.c:895
#define players_iterate_end
Definition player.h:537
#define players_iterate(_pplayer)
Definition player.h:532
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
endgame_report_dialog_player
Definition repodlgs_g.h:33
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Definition reqtree.c:1036
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:870
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1176
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1199
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:473
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:839
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
bool research_future_next(const struct research *presearch)
Definition research.c:1362
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
#define ARRAY_SIZE(x)
Definition shared.h:85
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
cairo_t * drawable
Definition canvas.h:24
struct connection conn
Definition client_main.h:96
GtkLabel * label
Definition repodlgs.c:775
GtkTreeView * tree_view
Definition repodlgs.c:774
struct gui_dialog * shell
Definition repodlgs.c:773
GtkListStore * store
Definition repodlgs.c:1808
GtkTreeView * tree_view
Definition repodlgs.c:1807
struct gui_dialog * shell
Definition repodlgs.c:1806
Definition climisc.h:82
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:85
Tech_type_id researching
Definition research.h:52
struct gui_dialog * shell
Definition repodlgs.c:70
GtkProgressBar * progress_bar
Definition repodlgs.c:75
GtkComboBox * reachable_techs
Definition repodlgs.c:71
GtkComboBox * reachable_goals
Definition repodlgs.c:72
GtkLabel * goal_label
Definition repodlgs.c:76
GtkLabel * main_label
Definition repodlgs.c:74
GtkWidget * button_show_all
Definition repodlgs.c:73
GtkLayout * drawing_area
Definition repodlgs.c:77
Definition tile.h:50
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@81::@83 client
int homecity
Definition unit.h:146
bool done_moving
Definition unit.h:181
const struct unit_type * utype
Definition unit.h:139
enum unit_focus_status focus_status
Definition unit.h:214
enum server_side_agent ssa_controller
Definition unit.h:172
GtkTreeView * tree_view
Definition repodlgs.c:1281
struct gui_dialog * shell
Definition repodlgs.c:1280
enum universals_n kind
Definition fc_types.h:902
universals_u value
Definition fc_types.h:901
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:473
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
#define A_FUTURE
Definition tech.h:46
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
#define advance_index_iterate_max_end
Definition tech.h:258
static Tech_type_id advance_count(void)
Definition tech.h:170
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2126
const char * get_science_target_text(double *percent)
Definition text.c:820
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6783
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7514
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6805
const struct unit_type * utype
Definition fc_types.h:721
const struct impr_type * building
Definition fc_types.h:714
#define unit_tile(_pu)
Definition unit.h:397
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
#define unit_type_iterate(_p)
Definition unittype.h:855
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:862