Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-gtk-4.0/repodlgs.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
repodlgs.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "fc_types.h" /* LINE_BREAK */
34#include "game.h"
35#include "government.h"
36#include "packets.h"
37#include "research.h"
38#include "tech.h"
39#include "unitlist.h"
40
41/* client */
42#include "chatline_common.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "control.h"
46#include "mapview_common.h"
47#include "options.h"
48#include "packhand_gen.h"
49#include "control.h"
50#include "reqtree.h"
51#include "text.h"
52
53/* client/gui-gtk-4.0 */
54#include "canvas.h"
55#include "cityrep.h"
56#include "dialogs.h"
57#include "gui_main.h"
58#include "gui_stuff.h"
59#include "helpdlg.h"
60#include "plrdlg.h"
61#include "sprite.h"
62
63#include "repodlgs.h"
64
65
66/****************************************************************************
67 RESEARCH REPORT DIALOG
68****************************************************************************/
69struct science_report {
70 struct gui_dialog *shell;
71 GtkComboBox *reachable_techs;
72 GtkComboBox *reachable_goals;
73 GtkWidget *button_show_all;
74 GtkLabel *main_label; /* Gets science_dialog_text(). */
75 GtkProgressBar *progress_bar;
76 GtkLabel *goal_label;
77 GtkDrawingArea *drawing_area;
78};
79
80static GtkListStore *science_report_store_new(void);
81static inline void science_report_store_set(GtkListStore *store,
82 GtkTreeIter *iter,
83 Tech_type_id tech);
84static bool science_report_combo_get_active(GtkComboBox *combo,
85 Tech_type_id *tech,
86 char **name);
87static void science_report_combo_set_active(GtkComboBox *combo,
88 Tech_type_id tech);
89static gboolean science_diagram_left_button_up(GtkGestureClick *gesture,
90 int n_press,
91 double x, double y);
92static gboolean science_diagram_right_button_up(GtkGestureClick *gesture,
93 int n_press,
94 double x, double y);
95
96static void science_diagram_update(GtkDrawingArea *widget, cairo_t *cr,
97 int width, int height, gpointer data);
98static GtkWidget *science_diagram_new(void);
99static void science_diagram_data(GtkWidget *widget, bool show_all);
100static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech);
101static void science_report_redraw(struct science_report *preport);
102static gint cmp_func(gconstpointer a_p, gconstpointer b_p);
103static void science_report_update(struct science_report *preport);
104static void science_report_current_callback(GtkComboBox *combo,
105 gpointer data);
106static void science_report_show_all_callback(GtkComboBox *combo,
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
112 static struct science_report science_report = { NULL, };
113 static bool science_report_no_combo_callback = FALSE;
114
115/* Those values must match the function science_report_store_new(). */
116 enum science_report_columns {
117 SRD_COL_NAME,
118 SRD_COL_STEPS,
119
120 /* Not visible. */
121 SRD_COL_ID, /* Tech_type_id */
122
123 SRD_COL_NUM
124};
125
126/************************************************************************/
129 static GtkListStore *science_report_store_new(void)
130{
131 return gtk_list_store_new(SRD_COL_NUM,
132 G_TYPE_STRING, /* SRD_COL_NAME */
133 G_TYPE_INT, /* SRD_COL_STEPS */
134 G_TYPE_INT); /* SRD_COL_ID */
135}
136
137/************************************************************************/
140 static inline void science_report_store_set(GtkListStore *store,
141 GtkTreeIter *iter,
142 Tech_type_id tech)
143{
144 const struct research *presearch = research_get(client_player());
145
146 gtk_list_store_set(store, iter,
147 SRD_COL_NAME,
148 research_advance_name_translation(presearch, tech),
149 SRD_COL_STEPS,
150 research_goal_unknown_techs(presearch, tech),
151 SRD_COL_ID, tech,
152 -1);
153}
154
155/************************************************************************/
158 static bool science_report_combo_get_active(GtkComboBox *combo,
159 Tech_type_id *tech,
160 char **name)
161{
162 GtkTreeIter iter;
163
164 if (science_report_no_combo_callback
165 || !gtk_combo_box_get_active_iter(combo, &iter)) {
166 return FALSE;
167 }
168
169 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter,
170 SRD_COL_NAME, name,
171 SRD_COL_ID, tech,
172 -1);
173
174 return TRUE;
175}
176
177/************************************************************************/
180 static void science_report_combo_set_active(GtkComboBox *combo,
181 Tech_type_id tech)
182{
183 ITree iter;
184 Tech_type_id iter_tech;
185
186 for (itree_begin(gtk_combo_box_get_model(combo), &iter);
187 !itree_end(&iter); itree_next(&iter)) {
188 itree_get(&iter, SRD_COL_ID, &iter_tech, -1);
189 if (iter_tech == tech) {
190 science_report_no_combo_callback = TRUE;
191 gtk_combo_box_set_active_iter(combo, &iter.it);
192 science_report_no_combo_callback = FALSE;
193 return;
194 }
195 }
196 log_error("%s(): Tech %d not found in the combo.", __FUNCTION__, tech);
197}
198
199/************************************************************************/
202 static gboolean science_diagram_left_button_up(GtkGestureClick *gesture,
203 int n_press,
204 double x, double y)
205{
206 GtkEventController *controller = GTK_EVENT_CONTROLLER(gesture);
207 GtkWidget *w = gtk_event_controller_get_widget(controller);
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
217 if (can_client_issue_orders()) {
218 /* Set research or research goal */
219 switch (research_invention_state(research_get(client_player()),
220 tech)) {
221 case TECH_PREREQS_KNOWN:
222 dsend_packet_player_research(&client.conn, tech);
223 break;
224 case TECH_UNKNOWN:
225 dsend_packet_player_tech_goal(&client.conn, tech);
226 break;
227 case TECH_KNOWN:
228 break;
229 }
230 }
231
232 return TRUE;
233}
234
235/************************************************************************/
238 static gboolean science_diagram_right_button_up(GtkGestureClick *gesture,
239 int n_press,
240 double x, double y)
241{
242 const struct research *presearch;
243 GtkEventController *controller = GTK_EVENT_CONTROLLER(gesture);
244 GtkWidget *w = gtk_event_controller_get_widget(controller);
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
254 presearch = research_get(client_player());
255
256 /* Open help */
257 popup_help_dialog_typed(research_advance_name_translation(presearch,
258 tech),
259 HELP_TECH);
260
261 return TRUE;
262}
263
264/************************************************************************/
267 static void science_diagram_update(GtkDrawingArea *widget, cairo_t *cr,
268 int width, int height, gpointer data)
269{
270 /* FIXME: this currently redraws everything! */
271 struct canvas canvas = FC_STATIC_CANVAS_INIT;
272 struct reqtree *reqtree = g_object_get_data(G_OBJECT(widget), "reqtree");
273 int rtwidth, rtheight;
274 GtkAdjustment *hadjustment;
275 GtkAdjustment *vadjustment;
276 gint hadjustment_value;
277 gint vadjustment_value;
278 GtkViewport *vp;
279
280 if (!tileset_is_fully_loaded()) {
281 return;
282 }
283
284 get_reqtree_dimensions(reqtree, &rtwidth, &rtheight);
285 gtk_widget_set_size_request(GTK_WIDGET(widget), rtwidth, rtheight);
286
287 vp = GTK_VIEWPORT(gtk_widget_get_parent(GTK_WIDGET(widget)));
288 hadjustment = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(vp));
289 vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vp));
290
291 hadjustment_value = (gint)gtk_adjustment_get_value(hadjustment);
292 vadjustment_value = (gint)gtk_adjustment_get_value(vadjustment);
293
294 cairo_translate(cr, -hadjustment_value, -vadjustment_value);
295
296 canvas.drawable = cr;
297
298 draw_reqtree(reqtree, &canvas, 0, 0, 0, 0, rtwidth, rtheight);
299}
300
301/************************************************************************/
305 static GtkWidget *science_diagram_new(void)
306{
307 GtkWidget *diagram;
308 GtkEventController *controller;
309 GtkGesture *gesture;
310
311 diagram = gtk_drawing_area_new();
312 gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(diagram),
313 science_diagram_update, NULL, NULL);
314
315 controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
316 g_signal_connect(controller, "released",
317 G_CALLBACK(science_diagram_left_button_up), NULL);
318 gtk_widget_add_controller(diagram, controller);
319 gesture = gtk_gesture_click_new();
320 gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
321 controller = GTK_EVENT_CONTROLLER(gesture);
322 g_signal_connect(controller, "released",
323 G_CALLBACK(science_diagram_right_button_up), NULL);
324 gtk_widget_add_controller(diagram, controller);
325
326 return diagram;
327}
328
329/************************************************************************/
332 static void science_diagram_data(GtkWidget *widget, bool show_all)
333{
334 struct reqtree *reqtree;
335
336 if (can_conn_edit(&client.conn)) {
337 /* Show all techs in editor mode, not only currently reachable ones */
338 reqtree = create_reqtree(NULL, TRUE);
339 } else {
340 /* Show only at some point reachable techs */
341 reqtree = create_reqtree(client_player(), show_all);
342 }
343
344 g_object_set_data_full(G_OBJECT(widget), "reqtree", reqtree,
345 (GDestroyNotify) destroy_reqtree);
346}
347
348/************************************************************************/
351 static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
352{
353 GtkViewport *vp = GTK_VIEWPORT(gtk_widget_get_parent(diagram));
354 struct reqtree *reqtree;
355 int x, y, width, height;
356
357 reqtree = g_object_get_data(G_OBJECT(diagram), "reqtree");
358 get_reqtree_dimensions(reqtree, &width, &height);
359 if (find_tech_on_reqtree(reqtree, tech, &x, &y, NULL, NULL)) {
360 GtkAdjustment *adjust = NULL;
361 gdouble value;
362
363 adjust = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(vp));
364 value = (gtk_adjustment_get_lower(adjust)
365 + gtk_adjustment_get_upper(adjust)
366 - gtk_adjustment_get_page_size(adjust)) / width * x;
367 gtk_adjustment_set_value(adjust, value);
368
369 adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vp));
370 value = (gtk_adjustment_get_lower(adjust)
371 + gtk_adjustment_get_upper(adjust)
372 - gtk_adjustment_get_page_size(adjust)) / height * y;
373 gtk_adjustment_set_value(adjust, value);
374 }
375}
376
377/************************************************************************/
380 static void science_report_redraw(struct science_report *preport)
381{
382 Tech_type_id researching;
383
384 fc_assert_ret(NULL != preport);
385
386 science_diagram_data(GTK_WIDGET(preport->drawing_area),
387 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
388 preport->button_show_all)));
389
390 if (client_has_player()) {
391 researching = research_get(client_player())->researching;
392 } else {
393 researching = A_UNSET;
394 }
395 science_diagram_center(GTK_WIDGET(preport->drawing_area), researching);
396
397 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
398}
399
400/************************************************************************/
403 static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
404{
405 const gchar *a_str, *b_str;
406 gint a = GPOINTER_TO_INT(a_p), b = GPOINTER_TO_INT(b_p);
407 const struct research *presearch = research_get(client_player());
408
409 a_str = research_advance_name_translation(presearch, a);
410 b_str = research_advance_name_translation(presearch, b);
411
412 return fc_strcoll(a_str, b_str);
413}
414
415/************************************************************************/
418 static void science_report_update(struct science_report *preport)
419{
420 GtkListStore *store;
421 GtkTreeIter iter;
422 GList *sorting_list, *item;
423 struct research *presearch = research_get(client_player());
424 const char *text;
425 double pct;
426 Tech_type_id tech;
427 Tech_type_id ac = advance_count();
428
429 fc_assert_ret(NULL != preport);
430 fc_assert_ret(NULL != presearch);
431
432 /* Disable callbacks. */
433 science_report_no_combo_callback = TRUE;
434
435 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
436
437 gtk_label_set_text(preport->main_label, science_dialog_text());
438
439 /* Update the progress bar. */
440 text = get_science_target_text(&pct);
441 gtk_progress_bar_set_text(preport->progress_bar, text);
442 gtk_progress_bar_set_fraction(preport->progress_bar, pct);
443 /* Work around GTK refresh bug? */
444 gtk_widget_queue_resize(GTK_WIDGET(preport->progress_bar));
445
446 /* Update reachable techs. */
447 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
448 gtk_list_store_clear(store);
449 sorting_list = NULL;
450
451 /* Collect all techs which are reachable in the next step. */
452 advance_index_iterate_max(A_FIRST, i, ac) {
453 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
454 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
455 }
456 } advance_index_iterate_max_end;
457
458 if (sorting_list != NULL) {
459 if (A_UNSET == presearch->researching
460 || is_future_tech(presearch->researching)) {
461 gtk_list_store_append(store, &iter);
462 science_report_store_set(store, &iter, presearch->researching);
463 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
464 }
465
466 /* Sort the list, append it to the store. */
467 sorting_list = g_list_sort(sorting_list, cmp_func);
468 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
469 tech = GPOINTER_TO_INT(item->data);
470 gtk_list_store_append(store, &iter);
471 science_report_store_set(store, &iter, tech);
472 if (tech == presearch->researching) {
473 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
474 }
475 }
476
477 /* Free, re-init. */
478 g_list_free(sorting_list);
479 sorting_list = NULL;
480 } else {
481 /* No reachable normal techs. Can we select Future Tech? */
482 Tech_type_id next;
483
484 gtk_list_store_append(store, &iter);
485 if (research_future_next(presearch)) {
486 next = A_FUTURE;
487 } else {
488 next = presearch->researching;
489 }
490 science_report_store_set(store, &iter, next);
491
492 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
493 }
494
495 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_goals));
496 gtk_list_store_clear(store);
497
498 /* Update the tech goal. */
499 gtk_label_set_text(preport->goal_label,
500 get_science_goal_text(presearch->tech_goal));
501
502 /* Collect all techs which are reachable in next 10 steps. */
503 advance_index_iterate_max(A_FIRST, i, ac) {
504 if (research_invention_reachable(presearch, i)
505 && TECH_KNOWN != presearch->inventions[i].state
506 && (i == presearch->tech_goal
507 || 10 >= presearch->inventions[i].num_required_techs)) {
508 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
509 }
510 } advance_index_iterate_max_end;
511
512 if (sorting_list != NULL) {
513 if (A_UNSET == presearch->tech_goal) {
514 gtk_list_store_append(store, &iter);
515 science_report_store_set(store, &iter, A_UNSET);
516 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
517 }
518
519 /* Sort the list, append it to the store. */
520 sorting_list = g_list_sort(sorting_list, cmp_func);
521 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
522 tech = GPOINTER_TO_INT(item->data);
523 gtk_list_store_append(store, &iter);
524 science_report_store_set(store, &iter, tech);
525 if (tech == presearch->tech_goal) {
526 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
527 }
528 }
529
530 /* Free. */
531 g_list_free(sorting_list);
532 } else {
533 /* No reachable normal techs. Can we select Future Tech? */
534 Tech_type_id goal;
535
536 gtk_list_store_append(store, &iter);
537
538 if (research_future_next(presearch)) {
539 goal = A_FUTURE;
540 } else {
541 goal = A_UNSET;
542 }
543
544 science_report_store_set(store, &iter, goal);
545 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
546 }
547
548 /* Re-enable callbacks. */
549 science_report_no_combo_callback = FALSE;
550}
551
552/************************************************************************/
555 static void science_report_current_callback(GtkComboBox *combo,
556 gpointer data)
557{
558 Tech_type_id tech;
559 char *tech_name;
560
561 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
562 return;
563 }
564
565 if (gtk_check_button_get_active(GTK_CHECK_BUTTON(data))) {
566 popup_help_dialog_typed(tech_name, HELP_TECH);
567 } else if (can_client_issue_orders()) {
568 dsend_packet_player_research(&client.conn, tech);
569 }
570
571 free(tech_name);
572 /* Revert, or we will not be in sync with the server. */
573 science_report_combo_set_active(combo, research_get
574 (client_player())->researching);
575}
576
577/************************************************************************/
580 static void science_report_show_all_callback(GtkComboBox *combo,
581 gpointer data)
582{
583 struct science_report *preport = (struct science_report *) data;
584
585 science_report_redraw(preport);
586}
587
588/************************************************************************/
591 static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
592{
593 Tech_type_id tech;
594 char *tech_name;
595
596 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
597 return;
598 }
599
600 if (gtk_check_button_get_active(GTK_CHECK_BUTTON(data))) {
601 popup_help_dialog_typed(tech_name, HELP_TECH);
602 } else if (can_client_issue_orders()) {
603 dsend_packet_player_tech_goal(&client.conn, tech);
604 }
605
606 free(tech_name);
607 /* Revert, or we will not be in sync with the server. */
608 science_report_combo_set_active(combo, research_get
609 (client_player())->tech_goal);
610}
611
612/************************************************************************/
615 static void science_report_init(struct science_report *preport)
616{
617 GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w;
618 GtkSizeGroup *group;
619 GtkListStore *store;
620 GtkCellRenderer *renderer;
621
622 fc_assert_ret(NULL != preport);
623
624 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
625 /* TRANS: Research report title */
626 gui_dialog_set_title(preport->shell, _("Research"));
627
628 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
629 GTK_RESPONSE_CLOSE);
630
631 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
632
633 w = gtk_label_new(NULL);
634 gui_dialog_add_content_widget(preport->shell, w);
635 preport->main_label = GTK_LABEL(w);
636
637 /* Current research target line. */
638 frame = gtk_frame_new(_("Researching"));
639 gui_dialog_add_content_widget(preport->shell, frame);
640
641 table = gtk_grid_new();
642 gtk_grid_set_column_spacing(GTK_GRID(table), 4);
643 gtk_frame_set_child(GTK_FRAME(frame), table);
644
645 help_button = gtk_check_button_new_with_label(_("Help"));
646 gtk_grid_attach(GTK_GRID(table), help_button, 5, 0, 1, 1);
647
648 store = science_report_store_new();
649 w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
650 gtk_size_group_add_widget(group, w);
651 g_object_unref(G_OBJECT(store));
652 renderer = gtk_cell_renderer_text_new();
653 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), renderer, TRUE);
654 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
655 SRD_COL_NAME, NULL);
656 gtk_widget_set_sensitive(w, can_client_issue_orders());
657 g_signal_connect(w, "changed", G_CALLBACK(science_report_current_callback),
658 help_button);
659 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
660 preport->reachable_techs = GTK_COMBO_BOX(w);
661
662 w = gtk_progress_bar_new();
663 gtk_widget_set_hexpand(w, TRUE);
664 gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(w), TRUE);
665 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
666 gtk_widget_set_size_request(w, -1, 25);
667 preport->progress_bar = GTK_PROGRESS_BAR(w);
668
669 /* Research goal line. */
670 frame = gtk_frame_new( _("Goal"));
671 gui_dialog_add_content_widget(preport->shell, frame);
672
673 table = gtk_grid_new();
674 gtk_grid_set_column_spacing(GTK_GRID(table), 4);
675 gtk_frame_set_child(GTK_FRAME(frame), table);
676
677 store = science_report_store_new();
678 w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
679 gtk_size_group_add_widget(group, w);
680 g_object_unref(G_OBJECT(store));
681 renderer = gtk_cell_renderer_text_new();
682 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), renderer, TRUE);
683 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
684 SRD_COL_NAME, NULL);
685 renderer = gtk_cell_renderer_text_new();
686 gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(w), renderer, FALSE);
687 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
688 SRD_COL_STEPS, NULL);
689 gtk_widget_set_sensitive(w, can_client_issue_orders());
690 g_signal_connect(w, "changed", G_CALLBACK(science_report_goal_callback),
691 help_button);
692 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
693 preport->reachable_goals = GTK_COMBO_BOX(w);
694
695 w = gtk_label_new(NULL);
696 gtk_widget_set_hexpand(w, TRUE);
697 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
698 gtk_widget_set_size_request(w, -1, 25);
699 preport->goal_label = GTK_LABEL(w);
700
701 /* Toggle "Show All" button. */
702 /* TRANS: As in 'Show all (even not reachable) techs'. */
703 show_all_button = gtk_toggle_button_new_with_label(_("Show all"));
704 gtk_grid_attach(GTK_GRID(table), show_all_button, 5, 0, 1, 1);
705 g_signal_connect(show_all_button, "toggled",
706 G_CALLBACK(science_report_show_all_callback), preport);
707 gtk_widget_set_sensitive(show_all_button, can_client_issue_orders()
708 && !client_is_global_observer());
709 preport->button_show_all = show_all_button;
710
711 /* Science diagram. */
712 sw = gtk_scrolled_window_new();
713 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
714 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
715 gui_dialog_add_content_widget(preport->shell, sw);
716
717 w = science_diagram_new();
718 gtk_widget_set_hexpand(w, TRUE);
719 gtk_widget_set_vexpand(w, TRUE);
720 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), w);
721 preport->drawing_area = GTK_DRAWING_AREA(w);
722
723 science_report_update(preport);
724 gui_dialog_show_all(preport->shell);
725 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
726 g_object_unref(group);
727
728 /* This must be _after_ the dialog is drawn to really center it ... */
729 science_report_redraw(preport);
730}
731
732/************************************************************************/
735 static void science_report_free(struct science_report *preport)
736{
737 fc_assert_ret(NULL != preport);
738
739 gui_dialog_destroy(preport->shell);
740 fc_assert(NULL == preport->shell);
741
742 memset(preport, 0, sizeof(*preport));
743}
744
745/************************************************************************/
748 void science_report_dialog_popup(bool raise)
749{
750 struct research *presearch = research_get(client_player());
751
752 if (NULL == science_report.shell) {
753 science_report_init(&science_report);
754 }
755
756 if (NULL != presearch
757 && A_UNSET == presearch->tech_goal
758 && A_UNSET == presearch->researching) {
759 gui_dialog_alert(science_report.shell);
760 } else {
761 gui_dialog_present(science_report.shell);
762 }
763
764 if (raise) {
765 gui_dialog_raise(science_report.shell);
766 }
767}
768
769/************************************************************************/
772 void science_report_dialog_popdown(void)
773{
774 if (NULL != science_report.shell) {
775 science_report_free(&science_report);
776 fc_assert(NULL == science_report.shell);
777 }
778}
779
780/************************************************************************/
783 void real_science_report_dialog_update(void *unused)
784{
785 if (NULL != science_report.shell) {
786 science_report_update(&science_report);
787 }
788}
789
790/************************************************************************/
793 void science_report_dialog_redraw(void)
794{
795 if (NULL != science_report.shell) {
796 science_report_redraw(&science_report);
797 }
798}
799
800
801/****************************************************************************
802 ECONOMY REPORT DIALOG
803****************************************************************************/
804struct economy_report {
805 struct gui_dialog *shell;
806 GtkTreeView *tree_view;
807 GtkLabel *label;
808};
809
810 static struct economy_report economy_report = { NULL, NULL, NULL };
811
812 enum economy_report_response {
813 ERD_RES_SELL_REDUNDANT = 1,
814 ERD_RES_SELL_ALL,
815 ERD_RES_DISBAND_UNITS
816};
817
818/* Those values must match the functions economy_report_store_new() and
819 * economy_report_column_name(). */
820 enum economy_report_columns {
821 ERD_COL_SPRITE,
822 ERD_COL_NAME,
823 ERD_COL_REDUNDANT,
824 ERD_COL_COUNT,
825 ERD_COL_COST,
826 ERD_COL_TOTAL_COST,
827 ERD_COL_EMPTY, /* will make an empty space for scroll bar */
828
829 /* Not visible. */
830 ERD_COL_IS_IMPROVEMENT,
831 ERD_COL_CID,
832
833 ERD_COL_NUM
834};
835
836/************************************************************************/
839 static GtkListStore *economy_report_store_new(void)
840{
841 return gtk_list_store_new(ERD_COL_NUM,
842 GDK_TYPE_PIXBUF, /* ERD_COL_SPRITE */
843 G_TYPE_STRING, /* ERD_COL_NAME */
844 G_TYPE_INT, /* ERD_COL_REDUNDANT */
845 G_TYPE_INT, /* ERD_COL_COUNT */
846 G_TYPE_INT, /* ERD_COL_COST */
847 G_TYPE_INT, /* ERD_COL_TOTAL_COST */
848 G_TYPE_STRING, /* ERD_COL_EMPTY */
849 G_TYPE_BOOLEAN, /* ERD_COL_IS_IMPROVEMENT */
850 G_TYPE_INT, /* ERD_COL_UNI_KIND */
851 G_TYPE_INT); /* ERD_COL_UNI_VALUE_ID */
852}
853
854/************************************************************************/
857static const char *
858 economy_report_column_name(enum economy_report_columns col)
859{
860 switch (col) {
861 case ERD_COL_SPRITE:
862 /* TRANS: Image header */
863 return _("Type");
864 case ERD_COL_NAME:
865 return Q_("?Building or Unit type:Name");
866 case ERD_COL_REDUNDANT:
867 return _("Redundant");
868 case ERD_COL_COUNT:
869 return _("Count");
870 case ERD_COL_COST:
871 return _("Cost");
872 case ERD_COL_TOTAL_COST:
873 /* TRANS: Upkeep total, count*cost. */
874 return _("U Total");
875 case ERD_COL_EMPTY:
876 /* empty space for scrollbar*/
877 return " ";
878 case ERD_COL_IS_IMPROVEMENT:
879 case ERD_COL_CID:
880 case ERD_COL_NUM:
881 break; /* no more columns will be displayed after reaching this */
882 }
883
884 return NULL;
885}
886
887/************************************************************************/
890 static void economy_report_update(struct economy_report *preport)
891{
892 GtkTreeSelection *selection;
893 GtkTreeModel *model;
894 GtkListStore *store;
895 GtkTreeIter iter;
896 GdkPixbuf *pix;
897 struct improvement_entry building_entries[B_LAST];
898 struct unit_entry unit_entries[U_LAST];
899 int entries_used, building_total, unit_total, tax, i;
900 char buf[256];
901 cid selected;
902
903 fc_assert_ret(NULL != preport);
904
905 /* Save the selection. */
906 selection = gtk_tree_view_get_selection(preport->tree_view);
907 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
908 gtk_tree_model_get(model, &iter, ERD_COL_CID, &selected, -1);
909 } else {
910 selected = -1;
911 }
912
913 model = gtk_tree_view_get_model(preport->tree_view);
914 store = GTK_LIST_STORE(model);
915 gtk_list_store_clear(store);
916
917 /* Buildings. */
918 get_economy_report_data(building_entries, &entries_used,
919 &building_total, &tax);
920 for (i = 0; i < entries_used; i++) {
921 struct improvement_entry *pentry = building_entries + i;
922 struct impr_type *pimprove = pentry->type;
923 struct sprite *sprite = get_building_sprite(tileset, pimprove);
924 cid id = cid_encode_building(pimprove);
925
926 pix = sprite_get_pixbuf(sprite);
927 gtk_list_store_append(store, &iter);
928 gtk_list_store_set(store, &iter,
929 ERD_COL_SPRITE, pix,
930 ERD_COL_NAME, improvement_name_translation(pimprove),
931 ERD_COL_REDUNDANT, pentry->redundant,
932 ERD_COL_COUNT, pentry->count,
933 ERD_COL_COST, pentry->cost,
934 ERD_COL_TOTAL_COST, pentry->total_cost,
935 ERD_COL_EMPTY, " ",
936 ERD_COL_IS_IMPROVEMENT, TRUE,
937 ERD_COL_CID, id,
938 -1);
939 g_object_unref(G_OBJECT(pix));
940 if (selected == id) {
941 /* Restore the selection. */
942 gtk_tree_selection_select_iter(selection, &iter);
943 }
944 }
945
946 /* Units. */
947 get_economy_report_units_data(unit_entries, &entries_used, &unit_total);
948 for (i = 0; i < entries_used; i++) {
949 struct unit_entry *pentry = unit_entries + i;
950 struct unit_type *putype = pentry->type;
951 struct sprite *sprite = get_unittype_sprite(tileset, putype,
952 ACTIVITY_LAST,
953 direction8_invalid());
954 cid id = cid_encode_unit(putype);
955
956 pix = sprite_get_pixbuf(sprite);
957 gtk_list_store_append(store, &iter);
958 gtk_list_store_set(store, &iter,
959 ERD_COL_SPRITE, pix,
960 ERD_COL_NAME, utype_name_translation(putype),
961 ERD_COL_REDUNDANT, 0,
962 ERD_COL_COUNT, pentry->count,
963 ERD_COL_COST, pentry->cost,
964 ERD_COL_TOTAL_COST, pentry->total_cost,
965 ERD_COL_EMPTY, " ",
966 ERD_COL_IS_IMPROVEMENT, FALSE,
967 ERD_COL_CID, id,
968 -1);
969 g_object_unref(G_OBJECT(pix));
970 if (selected == id) {
971 /* Restore the selection. */
972 gtk_tree_selection_select_iter(selection, &iter);
973 }
974 }
975
976 /* Update the label. */
977 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
978 tax, building_total + unit_total);
979 gtk_label_set_text(preport->label, buf);
980}
981
982/************************************************************************/
985 static void economy_report_command_callback(struct gui_dialog *pdialog,
986 int response,
987 gpointer data)
988{
989 struct economy_report *preport = data;
990 GtkTreeSelection *selection = gtk_tree_view_get_selection(preport->tree_view);
991 GtkTreeModel *model;
992 GtkTreeIter iter;
993 GtkWidget *shell;
994 struct universal selected;
995 cid id;
996 char buf[256] = "";
997
998 switch (response) {
999 case ERD_RES_SELL_REDUNDANT:
1000 case ERD_RES_SELL_ALL:
1001 case ERD_RES_DISBAND_UNITS:
1002 break;
1003 default:
1004 gui_dialog_destroy(pdialog);
1005 return;
1006 }
1007
1008 if (!can_client_issue_orders()
1009 || !gtk_tree_selection_get_selected(selection, &model, &iter)) {
1010 return;
1011 }
1012
1013 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1014 selected = cid_decode(id);
1015
1016 switch (selected.kind) {
1017 case VUT_IMPROVEMENT:
1018 {
1019 const struct impr_type *pimprove = selected.value.building;
1020
1021 if (can_sell_building(pimprove)
1022 && (ERD_RES_SELL_ALL == response
1023 || (ERD_RES_SELL_REDUNDANT == response))) {
1024 bool redundant = (ERD_RES_SELL_REDUNDANT == response);
1025 gint count;
1026 gtk_tree_model_get(model, &iter,
1027 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
1028 &count, -1);
1029 if (count == 0) {
1030 break;
1031 }
1032 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL
1033 | GTK_DIALOG_DESTROY_WITH_PARENT,
1034 GTK_MESSAGE_QUESTION,
1035 GTK_BUTTONS_YES_NO,
1036 redundant
1037 /* TRANS: %s is an improvement */
1038 ? _("Do you really wish to sell "
1039 "every redundant %s (%d total)?")
1040 /* TRANS: %s is an improvement */
1041 : _("Do you really wish to sell "
1042 "every %s (%d total)?"),
1043 improvement_name_translation(pimprove),
1044 count);
1045 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1046 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1047
1048 if (GTK_RESPONSE_YES == blocking_dialog(shell)) {
1049 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1050 }
1051 gtk_window_destroy(GTK_WINDOW(shell));
1052 }
1053 }
1054 break;
1055 case VUT_UTYPE:
1056 {
1057 if (ERD_RES_DISBAND_UNITS == response) {
1058 const struct unit_type *putype = selected.value.utype;
1059 gint count;
1060
1061 gtk_tree_model_get(model, &iter, ERD_COL_COUNT, &count, -1);
1062
1063 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL
1064 | GTK_DIALOG_DESTROY_WITH_PARENT,
1065 GTK_MESSAGE_QUESTION,
1066 GTK_BUTTONS_YES_NO,
1067 /* TRANS: %s is a unit */
1068 _("Do you really wish to disband "
1069 "every %s (%d total)?"),
1070 utype_name_translation(putype),
1071 count);
1072 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1073 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1074
1075 if (GTK_RESPONSE_YES == blocking_dialog(shell)) {
1076 disband_all_units(putype, FALSE, buf, sizeof(buf));
1077 }
1078 gtk_window_destroy(GTK_WINDOW(shell));
1079 }
1080 }
1081 break;
1082 default:
1083 log_error("Not supported type: %d.", selected.kind);
1084 }
1085
1086 if ('\0' != buf[0]) {
1087 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
1088 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
1089 "%s", buf);
1090 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1091 g_signal_connect(shell, "response", G_CALLBACK(gtk_window_destroy),
1092 NULL);
1093 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1094 gtk_window_present(GTK_WINDOW(shell));
1095 }
1096}
1097
1098/************************************************************************/
1101 static void economy_report_selection_callback(GtkTreeSelection *selection,
1102 gpointer data)
1103{
1104 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1105 GtkTreeModel *model;
1106 GtkTreeIter iter;
1107
1108 if (can_client_issue_orders()
1109 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1110 struct universal selected;
1111 cid id;
1112
1113 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1114 selected = cid_decode(id);
1115 switch (selected.kind) {
1116 case VUT_IMPROVEMENT:
1117 {
1118 bool can_sell = can_sell_building(selected.value.building);
1119 gint redundant;
1120 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1121
1122 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT,
1123 can_sell && redundant > 0);
1124 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, can_sell);
1125 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS,
1126 FALSE);
1127 }
1128 return;
1129 case VUT_UTYPE:
1130 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT,
1131 FALSE);
1132 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, FALSE);
1133 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS,
1134 TRUE);
1135 return;
1136 default:
1137 log_error("Not supported type: %d.", selected.kind);
1138 break;
1139 }
1140 }
1141
1142 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT, FALSE);
1143 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, FALSE);
1144 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS, FALSE);
1145}
1146
1147/************************************************************************/
1150 static void economy_report_init(struct economy_report *preport)
1151{
1152 GtkWidget *view, *sw, *label, *button;
1153 GtkListStore *store;
1154 GtkTreeSelection *selection;
1155 const char *title;
1156 enum economy_report_columns i;
1157
1158 fc_assert_ret(NULL != preport);
1159
1160 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE);
1161 gui_dialog_set_title(preport->shell, _("Economy"));
1162
1163 sw = gtk_scrolled_window_new();
1164 gtk_widget_set_halign(sw, GTK_ALIGN_CENTER);
1165 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1166 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1167 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1168 gui_dialog_add_content_widget(preport->shell, sw);
1169
1170 store = economy_report_store_new();
1171 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1172 gtk_widget_set_vexpand(view, TRUE);
1173 g_object_unref(store);
1174 gtk_widget_set_name(view, "small_font");
1175 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
1176 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view);
1177 preport->tree_view = GTK_TREE_VIEW(view);
1178
1179 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1180 g_signal_connect(selection, "changed",
1181 G_CALLBACK(economy_report_selection_callback), preport);
1182
1183 for (i = 0; (title = economy_report_column_name(i)); i++) {
1184 GtkCellRenderer *renderer;
1185 GtkTreeViewColumn *col;
1186 GType type = gtk_tree_model_get_column_type(GTK_TREE_MODEL(store), i);
1187
1188 if (GDK_TYPE_PIXBUF == type) {
1189 renderer = gtk_cell_renderer_pixbuf_new();
1190 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1191 "pixbuf", i, NULL);
1192#if 0
1193 } else if (G_TYPE_BOOLEAN == type) {
1194 renderer = gtk_cell_renderer_toggle_new();
1195 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1196 "active", i, NULL);
1197#endif
1198 } else {
1199 bool is_redundant = (i == ERD_COL_REDUNDANT);
1200 renderer = gtk_cell_renderer_text_new();
1201 if (is_redundant) {
1202 /* Special treatment: hide "Redundant" column for units */
1203 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1204 "text", i,
1205 "visible",
1206 ERD_COL_IS_IMPROVEMENT,
1207 NULL);
1208 } else {
1209 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1210 "text", i, NULL);
1211 }
1212 }
1213
1214 if (i > 1) {
1215 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1216 gtk_tree_view_column_set_alignment(col, 1.0);
1217 }
1218
1219 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1220 }
1221
1222 label = gtk_label_new(NULL);
1223 gui_dialog_add_content_widget(preport->shell, label);
1224 gtk_widget_set_margin_start(label, 5);
1225 gtk_widget_set_margin_end(label, 5);
1226 gtk_widget_set_margin_top(label, 5);
1227 gtk_widget_set_margin_bottom(label, 5);
1228 preport->label = GTK_LABEL(label);
1229
1230 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1231 GTK_RESPONSE_CLOSE);
1232
1233 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1234 ERD_RES_DISBAND_UNITS);
1235 gtk_widget_set_sensitive(button, FALSE);
1236
1237 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1238 ERD_RES_SELL_ALL);
1239 gtk_widget_set_sensitive(button, FALSE);
1240
1241 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1242 ERD_RES_SELL_REDUNDANT);
1243 gtk_widget_set_sensitive(button, FALSE);
1244
1245 gui_dialog_response_set_callback(preport->shell,
1246 economy_report_command_callback);
1247
1248 gui_dialog_set_default_size(preport->shell, -1, 350);
1249 gui_dialog_show_all(preport->shell);
1250
1251 economy_report_update(preport);
1252
1253 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1254}
1255
1256/************************************************************************/
1259 static void economy_report_free(struct economy_report *preport)
1260{
1261 fc_assert_ret(NULL != preport);
1262
1263 gui_dialog_destroy(preport->shell);
1264 fc_assert(NULL == preport->shell);
1265
1266 memset(preport, 0, sizeof(*preport));
1267}
1268
1269/************************************************************************/
1272 void economy_report_dialog_popup(bool raise)
1273{
1274 if (NULL == economy_report.shell) {
1275 economy_report_init(&economy_report);
1276 }
1277
1278 gui_dialog_present(economy_report.shell);
1279 if (raise) {
1280 gui_dialog_raise(economy_report.shell);
1281 }
1282}
1283
1284/************************************************************************/
1287 void economy_report_dialog_popdown(void)
1288{
1289 if (NULL != economy_report.shell) {
1290 economy_report_free(&economy_report);
1291 }
1292}
1293
1294/************************************************************************/
1297 void real_economy_report_dialog_update(void *unused)
1298{
1299 if (NULL != economy_report.shell) {
1300 economy_report_update(&economy_report);
1301 }
1302}
1303
1304
1305/****************************************************************************
1306 UNITS REPORT DIALOG
1307****************************************************************************/
1308struct units_report {
1309 struct gui_dialog *shell;
1310 GtkTreeView *tree_view;
1311};
1312
1313 static struct units_report units_report = { NULL, NULL };
1314
1315 enum units_report_response {
1316 URD_RES_NEAREST = 1,
1317 URD_RES_UPGRADE
1318};
1319
1320/* Those values must match the order of unit_report_columns[]. */
1321 enum units_report_columns {
1322 URD_COL_UTYPE_NAME,
1323 URD_COL_UPGRADABLE,
1324 URD_COL_N_UPGRADABLE,
1325 URD_COL_IN_PROGRESS,
1326 URD_COL_ACTIVE,
1327 URD_COL_SHIELD,
1328 URD_COL_FOOD,
1329 URD_COL_GOLD,
1330 URD_COL_EMPTY, /* empty space for scrollbar */
1331
1332 /* Not visible. */
1333 URD_COL_TEXT_WEIGHT,
1334 URD_COL_UPG_VISIBLE,
1335 URD_COL_NUPG_VISIBLE,
1336 URD_COL_UTYPE_ID,
1337
1338 URD_COL_NUM
1339};
1340
1341static const struct {
1342 GType type;
1343 const char *title;
1344 const char *tooltip;
1345 bool rightalign;
1346 int visible_col;
1347} unit_report_columns[] = {
1348 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1349 NULL, FALSE, -1 },
1350 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1351 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1352 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1353 NULL, TRUE, URD_COL_NUPG_VISIBLE },
1354 /* TRANS: "In progress" abbreviation. */
1355 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1356 N_("In progress"), TRUE, -1 },
1357 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1358 NULL, TRUE, -1 },
1359 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1360 N_("Total shield upkeep"), TRUE, -1 },
1361 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1362 N_("Total food upkeep"), TRUE, -1 },
1363 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1364 N_("Total gold upkeep"), TRUE, -1 },
1365 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1366 " ", TRUE, -1 },
1367
1368 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1369 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1370 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1371 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1372};
1373
1374/************************************************************************/
1377 static GtkListStore *units_report_store_new(void)
1378{
1379 int i;
1380 GType cols[URD_COL_NUM];
1381
1382 fc_assert(ARRAY_SIZE(unit_report_columns) == URD_COL_NUM);
1383
1384 for (i = 0; i < URD_COL_NUM; i++) {
1385 cols[i] = unit_report_columns[i].type;
1386 }
1387
1388 return gtk_list_store_newv(URD_COL_NUM, cols);
1389}
1390
1391/************************************************************************/
1394 static void units_report_update(struct units_report *preport)
1395{
1396 struct urd_info {
1397 int active_count;
1398 int building_count;
1399 int upkeep[O_LAST];
1400 };
1401
1402 struct urd_info unit_array[utype_count()];
1403 struct urd_info unit_totals;
1404 struct urd_info *info;
1405 int total_upgradable_count = 0;
1406 GtkTreeSelection *selection;
1407 GtkTreeModel *model;
1408 GtkListStore *store;
1409 GtkTreeIter iter;
1410 Unit_type_id selected, utype_id;
1411
1412 fc_assert_ret(NULL != preport);
1413
1414 memset(unit_array, '\0', sizeof(unit_array));
1415 memset(&unit_totals, '\0', sizeof(unit_totals));
1416
1417 /* Count units. */
1418 players_iterate(pplayer) {
1419 if (client_has_player() && pplayer != client_player()) {
1420 continue;
1421 }
1422
1423 unit_list_iterate(pplayer->units, punit) {
1424 info = unit_array + utype_index(unit_type_get(punit));
1425
1426 if (0 != punit->homecity) {
1427 output_type_iterate(o) {
1428 info->upkeep[o] += punit->upkeep[o];
1429 } output_type_iterate_end;
1430 }
1431 info->active_count++;
1432 } unit_list_iterate_end;
1433 city_list_iterate(pplayer->cities, pcity) {
1434 if (VUT_UTYPE == pcity->production.kind) {
1435 int num_units;
1436 info = unit_array + utype_index(pcity->production.value.utype);
1437 /* Account for build slots in city */
1438 (void) city_production_build_units(pcity, TRUE, &num_units);
1439 /* Unit is in progress even if it won't be done this turn */
1440 num_units = MAX(num_units, 1);
1441 info->building_count += num_units;
1442 }
1443 } city_list_iterate_end;
1444 } players_iterate_end;
1445
1446 /* Save selection. */
1447 selection = gtk_tree_view_get_selection(preport->tree_view);
1448 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1449 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1450 } else {
1451 selected = -1;
1452 }
1453
1454 /* Make the store. */
1455 model = gtk_tree_view_get_model(preport->tree_view);
1456 store = GTK_LIST_STORE(model);
1457 gtk_list_store_clear(store);
1458
1459 unit_type_iterate(utype) {
1460 bool upgradable;
1461
1462 utype_id = utype_index(utype);
1463 info = unit_array + utype_id;
1464
1465 if (0 == info->active_count && 0 == info->building_count) {
1466 continue; /* We don't need a row for this type. */
1467 }
1468
1469 upgradable = client_has_player()
1470 && NULL != can_upgrade_unittype(client_player(), utype);
1471
1472 gtk_list_store_append(store, &iter);
1473 gtk_list_store_set(store, &iter,
1474 URD_COL_UTYPE_NAME, utype_name_translation(utype),
1475 URD_COL_UPGRADABLE, upgradable,
1476 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1477 URD_COL_IN_PROGRESS, info->building_count,
1478 URD_COL_ACTIVE, info->active_count,
1479 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1480 URD_COL_FOOD, info->upkeep[O_FOOD],
1481 URD_COL_GOLD, info->upkeep[O_GOLD],
1482 URD_COL_EMPTY, " ",
1483 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
1484 URD_COL_UPG_VISIBLE, TRUE,
1485 URD_COL_NUPG_VISIBLE, FALSE,
1486 URD_COL_UTYPE_ID, utype_id,
1487 -1);
1488 if (selected == utype_id) {
1489 /* Restore the selection. */
1490 gtk_tree_selection_select_iter(selection, &iter);
1491 }
1492
1493 /* Update totals. */
1494 unit_totals.active_count += info->active_count;
1495 output_type_iterate(o) {
1496 unit_totals.upkeep[o] += info->upkeep[o];
1497 } output_type_iterate_end;
1498 unit_totals.building_count += info->building_count;
1499 if (upgradable) {
1500 total_upgradable_count += info->active_count;
1501 }
1502 } unit_type_iterate_end;
1503
1504 /* Add the total row. */
1505 gtk_list_store_append(store, &iter);
1506 gtk_list_store_set(store, &iter,
1507 URD_COL_UTYPE_NAME, _("Totals:"),
1508 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1509 URD_COL_N_UPGRADABLE, total_upgradable_count,
1510 URD_COL_IN_PROGRESS, unit_totals.building_count,
1511 URD_COL_ACTIVE, unit_totals.active_count,
1512 URD_COL_SHIELD, unit_totals.upkeep[O_SHIELD],
1513 URD_COL_FOOD, unit_totals.upkeep[O_FOOD],
1514 URD_COL_GOLD, unit_totals.upkeep[O_GOLD],
1515 URD_COL_EMPTY, " ",
1516 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_BOLD,
1517 URD_COL_UPG_VISIBLE, FALSE,
1518 URD_COL_NUPG_VISIBLE, TRUE,
1519 URD_COL_UTYPE_ID, U_LAST,
1520 -1);
1521 if (selected == U_LAST) {
1522 /* Restore the selection. */
1523 gtk_tree_selection_select_iter(selection, &iter);
1524 }
1525}
1526
1527/************************************************************************/
1530 static void units_report_selection_callback(GtkTreeSelection *selection,
1531 gpointer data)
1532{
1533 struct units_report *preport = data;
1534 GtkTreeModel *model;
1535 GtkTreeIter it;
1536 int active_count;
1537 struct unit_type *utype = NULL;
1538
1539 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1540 int ut;
1541
1542 gtk_tree_model_get(model, &it,
1543 URD_COL_ACTIVE, &active_count,
1544 URD_COL_UTYPE_ID, &ut,
1545 -1);
1546 if (0 < active_count) {
1547 utype = utype_by_number(ut);
1548 }
1549 }
1550
1551 if (NULL == utype) {
1552 gui_dialog_set_response_sensitive(preport->shell, URD_RES_NEAREST,
1553 FALSE);
1554 gui_dialog_set_response_sensitive(preport->shell, URD_RES_UPGRADE,
1555 FALSE);
1556 } else {
1557 gui_dialog_set_response_sensitive(preport->shell, URD_RES_NEAREST, TRUE);
1558 gui_dialog_set_response_sensitive(preport->shell, URD_RES_UPGRADE,
1559 (can_client_issue_orders()
1560 && action_ever_possible(ACTION_UPGRADE_UNIT)
1561 && NULL != can_upgrade_unittype(client_player(), utype)));
1562 }
1563}
1564
1565/************************************************************************/
1568 static struct unit *find_nearest_unit(const struct unit_type *utype,
1569 struct tile *ptile)
1570{
1571 struct unit *best_candidate = NULL;
1572 int best_dist = FC_INFINITY, dist;
1573
1574 players_iterate(pplayer) {
1575 if (client_has_player() && pplayer != client_player()) {
1576 continue;
1577 }
1578
1579 unit_list_iterate(pplayer->units, punit) {
1580 if (utype == unit_type_get(punit)
1581 && FOCUS_AVAIL == punit->client.focus_status
1582 && 0 < punit->moves_left
1583 && !punit->done_moving
1584 && punit->ssa_controller == SSA_NONE) {
1585 dist = sq_map_distance(unit_tile(punit), ptile);
1586 if (dist < best_dist) {
1587 best_candidate = punit;
1588 best_dist = dist;
1589 }
1590 }
1591 } unit_list_iterate_end;
1592 } players_iterate_end;
1593
1594 return best_candidate;
1595}
1596
1597/************************************************************************/
1600 static void units_report_command_callback(struct gui_dialog *pdialog,
1601 int response,
1602 gpointer data)
1603{
1604 struct units_report *preport = data;
1605 struct unit_type *utype = NULL;
1606 GtkTreeSelection *selection;
1607 GtkTreeModel *model;
1608 GtkTreeIter it;
1609
1610 switch (response) {
1611 case URD_RES_NEAREST:
1612 case URD_RES_UPGRADE:
1613 break;
1614 default:
1615 gui_dialog_destroy(pdialog);
1616 return;
1617 }
1618
1619 /* Nearest & upgrade commands. */
1620 selection = gtk_tree_view_get_selection(preport->tree_view);
1621 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1622 int ut;
1623
1624 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1625 utype = utype_by_number(ut);
1626 }
1627
1628 if (response == URD_RES_NEAREST) {
1629 struct tile *ptile;
1630 struct unit *punit;
1631
1632 ptile = get_center_tile_mapcanvas();
1633 if ((punit = find_nearest_unit(utype, ptile))) {
1634 center_tile_mapcanvas(unit_tile(punit));
1635
1636 if (ACTIVITY_IDLE == punit->activity
1637 || ACTIVITY_SENTRY == punit->activity) {
1638 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
1639 unit_focus_set_and_select(punit);
1640 }
1641 }
1642 }
1643 } else if (can_client_issue_orders()) {
1644 GtkWidget *shell;
1645 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1646 char buf[1024];
1647 int price = unit_upgrade_price(client_player(), utype, upgrade);
1648
1649 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1650 "Treasury contains %d gold.",
1651 client_player()->economic.gold),
1652 client_player()->economic.gold);
1653
1654 shell = gtk_message_dialog_new(NULL,
1655 GTK_DIALOG_MODAL
1656 | GTK_DIALOG_DESTROY_WITH_PARENT,
1657 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
1658 /* TRANS: Last %s is pre-pluralised
1659 * "Treasury contains %d gold." */
1660 PL_("Upgrade as many %s to %s as possible "
1661 "for %d gold each?\n%s",
1662 "Upgrade as many %s to %s as possible "
1663 "for %d gold each?\n%s", price),
1664 utype_name_translation(utype),
1665 utype_name_translation(upgrade),
1666 price, buf);
1667 setup_dialog(shell, gui_dialog_get_toplevel(preport->shell));
1668
1669 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1670
1671 if (GTK_RESPONSE_YES == blocking_dialog(shell)) {
1672 dsend_packet_unit_type_upgrade(&client.conn, utype_number(utype));
1673 }
1674
1675 gtk_window_destroy(GTK_WINDOW(shell));
1676 }
1677}
1678
1679/************************************************************************/
1682 static void units_report_init(struct units_report *preport)
1683{
1684 GtkWidget *view, *sw, *button;
1685 GtkListStore *store;
1686 GtkTreeSelection *selection;
1687 GtkTreeViewColumn *col = NULL;
1688 enum units_report_columns i;
1689
1690 fc_assert_ret(NULL != preport);
1691
1692 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE);
1693 gui_dialog_set_title(preport->shell, _("Units"));
1694
1695 sw = gtk_scrolled_window_new();
1696 gtk_widget_set_halign(sw, GTK_ALIGN_CENTER);
1697 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1698 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1699 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1700 gui_dialog_add_content_widget(preport->shell, sw);
1701
1702 store = units_report_store_new();
1703 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1704 gtk_widget_set_vexpand(view, TRUE);
1705 g_object_unref(store);
1706 gtk_widget_set_name(view, "small_font");
1707 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
1708 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view);
1709 preport->tree_view = GTK_TREE_VIEW(view);
1710
1711 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1712 g_signal_connect(selection, "changed",
1713 G_CALLBACK(units_report_selection_callback), preport);
1714
1715 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1716 GtkCellRenderer *renderer;
1717
1718 if (strlen(unit_report_columns[i].title) > 0) {
1719 GtkWidget *header = gtk_label_new(Q_(unit_report_columns[i].title));
1720
1721 if (unit_report_columns[i].tooltip) {
1722 gtk_widget_set_tooltip_text(header,
1723 Q_(unit_report_columns[i].tooltip));
1724 }
1725 gtk_widget_set_visible(header, TRUE);
1726 col = gtk_tree_view_column_new();
1727 gtk_tree_view_column_set_widget(col, header);
1728 if (unit_report_columns[i].rightalign) {
1729 gtk_tree_view_column_set_alignment(col, 1.0);
1730 }
1731 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1732 } /* else add new renderer to previous TreeViewColumn */
1733
1734 fc_assert(col != NULL);
1735 if (G_TYPE_BOOLEAN == unit_report_columns[i].type) {
1736 renderer = gtk_cell_renderer_toggle_new();
1737 gtk_tree_view_column_pack_start(col, renderer, FALSE);
1738 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1739 } else {
1740 renderer = gtk_cell_renderer_text_new();
1741 gtk_tree_view_column_pack_start(col, renderer, TRUE);
1742 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1743 gtk_tree_view_column_add_attribute(col, renderer,
1744 "weight", URD_COL_TEXT_WEIGHT);
1745 }
1746
1747 if (unit_report_columns[i].visible_col >= 0) {
1748 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1749 unit_report_columns[i].visible_col);
1750 }
1751
1752 if (unit_report_columns[i].rightalign) {
1753 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1754 }
1755 }
1756
1757 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1758 GTK_RESPONSE_CLOSE);
1759
1760 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1761 URD_RES_UPGRADE);
1762 gtk_widget_set_sensitive(button, FALSE);
1763
1764 button = gui_dialog_add_button(preport->shell, "edit-find",
1765 _("Find _Nearest"), URD_RES_NEAREST);
1766 gtk_widget_set_sensitive(button, FALSE);
1767
1768 gui_dialog_response_set_callback(preport->shell,
1769 units_report_command_callback);
1770
1771 gui_dialog_set_default_size(preport->shell, -1, 350);
1772 gui_dialog_show_all(preport->shell);
1773
1774 units_report_update(preport);
1775 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1776}
1777
1778/************************************************************************/
1781 static void units_report_free(struct units_report *preport)
1782{
1783 fc_assert_ret(NULL != preport);
1784
1785 gui_dialog_destroy(preport->shell);
1786 fc_assert(NULL == preport->shell);
1787
1788 memset(preport, 0, sizeof(*preport));
1789}
1790
1791/************************************************************************/
1794 void units_report_dialog_popup(bool raise)
1795{
1796 if (NULL == units_report.shell) {
1797 units_report_init(&units_report);
1798 }
1799
1800 gui_dialog_present(units_report.shell);
1801 if (raise) {
1802 gui_dialog_raise(units_report.shell);
1803 }
1804}
1805
1806/************************************************************************/
1809 void units_report_dialog_popdown(void)
1810{
1811 if (NULL != units_report.shell) {
1812 units_report_free(&units_report);
1813 fc_assert(NULL == units_report.shell);
1814 }
1815}
1816
1817/************************************************************************/
1820 void real_units_report_dialog_update(void *unused)
1821{
1822 if (NULL != units_report.shell) {
1823 units_report_update(&units_report);
1824 }
1825}
1826
1827
1828/****************************************************************************
1829 FINAL REPORT DIALOG
1830****************************************************************************/
1831struct endgame_report {
1832 struct gui_dialog *shell;
1833 GtkTreeView *tree_view;
1834 GtkListStore *store;
1835 int player_count;
1836 int players_received;
1837};
1838
1839 enum endgame_report_columns {
1840 FRD_COL_PLAYER,
1841 FRD_COL_NATION,
1842 FRD_COL_SCORE,
1843 FRD_COL_TOOLTIP,
1844
1845 FRD_COL_NUM
1846};
1847
1848 static struct endgame_report endgame_report = { NULL, NULL };
1849
1850/************************************************************************/
1853static const char *
1854 endgame_report_column_name(enum endgame_report_columns col)
1855{
1856 switch (col) {
1857 case FRD_COL_PLAYER:
1858 return _("Player\n");
1859 case FRD_COL_NATION:
1860 return _("Nation\n");
1861 case FRD_COL_SCORE:
1862 return _("Score\n");
1863 case FRD_COL_TOOLTIP:
1864 case FRD_COL_NUM:
1865 break;
1866 }
1867
1868 return NULL;
1869}
1870
1871/************************************************************************/
1874 static void endgame_report_update(struct endgame_report *preport,
1875 const struct packet_endgame_report *packet)
1876{
1877 const size_t col_num = packet->category_num + FRD_COL_NUM;
1878 GType col_types[col_num];
1879 GtkListStore *store;
1880 GtkTreeViewColumn *col;
1881 int i;
1882
1883 fc_assert_ret(NULL != preport);
1884
1885 /* Remove the old columns. */
1886 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1887 gtk_tree_view_remove_column(preport->tree_view, col);
1888 }
1889
1890 /* Create the new model. */
1891 col_types[FRD_COL_PLAYER] = G_TYPE_STRING;
1892 col_types[FRD_COL_NATION] = GDK_TYPE_PIXBUF;
1893 col_types[FRD_COL_SCORE] = G_TYPE_INT;
1894 col_types[FRD_COL_TOOLTIP] = G_TYPE_STRING;
1895 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1896 col_types[i] = G_TYPE_INT;
1897 }
1898 store = gtk_list_store_newv(col_num, col_types);
1899 gtk_tree_view_set_model(preport->tree_view, GTK_TREE_MODEL(store));
1900 g_object_unref(G_OBJECT(store));
1901
1902 /* Create the new columns. */
1903 for (i = 0; (guint)i < col_num; i++) {
1904 GtkCellRenderer *renderer;
1905 const char *title;
1906 const char *attribute;
1907
1908 if (GDK_TYPE_PIXBUF == col_types[i]) {
1909 renderer = gtk_cell_renderer_pixbuf_new();
1910 attribute = "pixbuf";
1911 } else {
1912 renderer = gtk_cell_renderer_text_new();
1913 attribute = "text";
1914 }
1915
1916 if (i < FRD_COL_NUM) {
1917 title = endgame_report_column_name(i);
1918 } else {
1919 title = packet->category_name[i - FRD_COL_NUM];
1920 }
1921
1922 if (title != NULL) {
1923 col = gtk_tree_view_column_new_with_attributes(Q_(title), renderer,
1924 attribute, i, NULL);
1925 gtk_tree_view_append_column(preport->tree_view, col);
1926 if (GDK_TYPE_PIXBUF != col_types[i]) {
1927 gtk_tree_view_column_set_sort_column_id(col, i);
1928 }
1929 }
1930 }
1931
1932 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(preport->tree_view),
1933 FRD_COL_TOOLTIP);
1934
1935 preport->store = store;
1936 preport->player_count = packet->player_num;
1937 preport->players_received = 0;
1938}
1939
1940/************************************************************************/
1943 void endgame_report_dialog_player(const struct packet_endgame_player *packet)
1944{
1945 /* Fill the model with player stats. */
1946 struct endgame_report *preport = &endgame_report;
1947 const struct player *pplayer = player_by_number(packet->player_id);
1948 GtkTreeIter iter;
1949 int i;
1950
1951 gtk_list_store_append(preport->store, &iter);
1952 gtk_list_store_set(preport->store, &iter,
1953 FRD_COL_PLAYER, player_name(pplayer),
1954 FRD_COL_NATION, get_flag(nation_of_player(pplayer)),
1955 FRD_COL_SCORE, packet->score,
1956 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1957 -1);
1958 for (i = 0; i < packet->category_num; i++) {
1959 gtk_list_store_set(preport->store, &iter,
1960 i + FRD_COL_NUM, packet->category_score[i],
1961 -1);
1962 }
1963
1964 preport->players_received++;
1965
1966 if (preport->players_received == preport->player_count) {
1967 gui_dialog_present(preport->shell);
1968 }
1969}
1970
1971/************************************************************************/
1974 static void endgame_report_init(struct endgame_report *preport)
1975{
1976 GtkWidget *sw, *view;
1977
1978 fc_assert_ret(NULL != preport);
1979
1980 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1981 gui_dialog_set_title(preport->shell, _("Score"));
1982
1983 gui_dialog_set_default_size(preport->shell, 700, 420);
1984
1985 /* Setup the layout. */
1986 sw = gtk_scrolled_window_new();
1987 gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(sw), TRUE);
1988 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1989 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1990 gui_dialog_add_content_widget(preport->shell, sw);
1991
1992 view = gtk_tree_view_new();
1993 gtk_widget_set_name(view, "small_font");
1994 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view);
1995 preport->tree_view = GTK_TREE_VIEW(view);
1996
1997 if (preport->shell->type == GUI_DIALOG_TAB) {
1998 gtk_widget_set_hexpand(GTK_WIDGET(view), TRUE);
1999 gtk_widget_set_vexpand(GTK_WIDGET(view), TRUE);
2000 }
2001
2002 gui_dialog_show_all(preport->shell);
2003}
2004
2005/************************************************************************/
2008 void endgame_report_dialog_start(const struct packet_endgame_report *packet)
2009{
2010 if (NULL == endgame_report.shell) {
2011 endgame_report_init(&endgame_report);
2012 }
2013 endgame_report_update(&endgame_report, packet);
2014}
action_ever_possible
bool action_ever_possible(action_id action)
Definition actions.c:8081
entries_used
int entries_used
Definition agents.c:77
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
chatline_common.h
city_production_build_units
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:746
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
output_type_iterate
#define output_type_iterate(output)
Definition city.h:833
city_list_iterate_end
#define city_list_iterate_end
Definition city.h:510
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:839
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1345
client
struct civclient client
Definition client_main.c:150
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1264
client_has_player
bool client_has_player(void)
Definition client_main.c:1364
client_main.h
client_player
#define client_player()
Definition client_main.h:106
cid_encode_building
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:503
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:524
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:491
climisc.h
cid
int cid
Definition climisc.h:31
incite_cost
char * incite_cost
Definition comments.c:74
can_conn_edit
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:511
unit_focus_set_and_select
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:620
control.h
can_unit_do_activity_client
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:41
punit
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
id
int int id
Definition editgui_g.h:28
fc_types.h
Tech_type_id
int Tech_type_id
Definition fc_types.h:380
Unit_type_id
int Unit_type_id
Definition fc_types.h:385
O_SHIELD
@ O_SHIELD
Definition fc_types.h:101
O_FOOD
@ O_FOOD
Definition fc_types.h:101
O_GOLD
@ O_GOLD
Definition fc_types.h:101
O_LAST
@ O_LAST
Definition fc_types.h:101
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
N_
#define N_(String)
Definition fcintl.h:69
game.h
government.h
FC_STATIC_CANVAS_INIT
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
top_notebook
GtkWidget * top_notebook
Definition gui_main.c:129
gtk_tree_view_focus
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:236
gui_dialog_destroy
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:954
gui_dialog_present
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:835
itree_get
void itree_get(ITree *it,...)
Definition gui_stuff.c:164
gui_dialog_raise
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:865
gui_dialog_new
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:517
gui_dialog_response_set_callback
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:988
itree_begin
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:127
gui_dialog_show_all
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:795
gui_dialog_set_title
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:935
gui_dialog_set_default_size
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:919
gui_dialog_alert
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:888
itree_next
void itree_next(ITree *it)
Definition gui_stuff.c:144
gui_dialog_add_button
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *icon_name, const char *text, int response)
Definition gui_stuff.c:706
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
gui_dialog_set_response_sensitive
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:760
gui_dialog_get_toplevel
GtkWidget * gui_dialog_get_toplevel(struct gui_dialog *dlg)
Definition gui_stuff.c:787
itree_end
gboolean itree_end(ITree *it)
Definition gui_stuff.c:136
GUI_DIALOG_TAB
@ GUI_DIALOG_TAB
Definition gui_stuff.h:62
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
shell
static struct gui_dialog * shell
Definition messagedlg.c:39
get_flag
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:607
endgame_report
static struct endgame_report endgame_report
Definition repodlgs.c:1822
units_report_init
static void units_report_init(struct units_report *preport)
Definition repodlgs.c:1653
units_report_dialog_popdown
void units_report_dialog_popdown(void)
Definition repodlgs.c:1783
units_report_store_new
static GtkListStore * units_report_store_new(void)
Definition repodlgs.c:1348
science_report_dialog_popup
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
science_report_store_set
static void science_report_store_set(GtkListStore *store, GtkTreeIter *iter, Tech_type_id tech)
Definition repodlgs.c:136
economy_report_init
static void economy_report_init(struct economy_report *preport)
Definition repodlgs.c:1117
unit_report_columns
static const struct @157 unit_report_columns[]
science_report_update
static void science_report_update(struct science_report *preport)
Definition repodlgs.c:383
units_report_update
static void units_report_update(struct units_report *preport)
Definition repodlgs.c:1365
science_report_combo_get_active
static bool science_report_combo_get_active(GtkComboBox *combo, Tech_type_id *tech, char **name)
Definition repodlgs.c:154
endgame_report_dialog_start
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1983
science_diagram_center
static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
Definition repodlgs.c:312
units_report_response
units_report_response
Definition repodlgs.c:1286
URD_RES_UPGRADE
@ URD_RES_UPGRADE
Definition repodlgs.c:1288
URD_RES_NEAREST
@ URD_RES_NEAREST
Definition repodlgs.c:1287
endgame_report_update
static void endgame_report_update(struct endgame_report *preport, const struct packet_endgame_report *packet)
Definition repodlgs.c:1848
real_units_report_dialog_update
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1794
real_economy_report_dialog_update
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1268
tooltip
const char * tooltip
Definition repodlgs.c:1315
economy_report_dialog_popdown
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1258
science_diagram_update
static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
Definition repodlgs.c:235
endgame_report_column_name
static const char * endgame_report_column_name(enum endgame_report_columns col)
Definition repodlgs.c:1828
economy_report_dialog_popup
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1243
endgame_report_init
static void endgame_report_init(struct endgame_report *preport)
Definition repodlgs.c:1948
science_report_combo_set_active
static void science_report_combo_set_active(GtkComboBox *combo, Tech_type_id tech)
Definition repodlgs.c:175
title
const char * title
Definition repodlgs.c:1314
science_diagram_data
static void science_diagram_data(GtkWidget *widget, bool show_all)
Definition repodlgs.c:290
science_report_free
static void science_report_free(struct science_report *preport)
Definition repodlgs.c:703
science_report_no_combo_callback
static bool science_report_no_combo_callback
Definition repodlgs.c:109
units_report_dialog_popup
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1768
economy_report_command_callback
static void economy_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:953
type
GType type
Definition repodlgs.c:1313
units_report_command_callback
static void units_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:1571
units_report_selection_callback
static void units_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1501
economy_report_update
static void economy_report_update(struct economy_report *preport)
Definition repodlgs.c:858
science_report_dialog_redraw
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
units_report_columns
units_report_columns
Definition repodlgs.c:1292
URD_COL_NUM
@ URD_COL_NUM
Definition repodlgs.c:1309
URD_COL_UPG_VISIBLE
@ URD_COL_UPG_VISIBLE
Definition repodlgs.c:1305
URD_COL_ACTIVE
@ URD_COL_ACTIVE
Definition repodlgs.c:1297
URD_COL_IN_PROGRESS
@ URD_COL_IN_PROGRESS
Definition repodlgs.c:1296
URD_COL_TEXT_WEIGHT
@ URD_COL_TEXT_WEIGHT
Definition repodlgs.c:1304
URD_COL_GOLD
@ URD_COL_GOLD
Definition repodlgs.c:1300
URD_COL_UPGRADABLE
@ URD_COL_UPGRADABLE
Definition repodlgs.c:1294
URD_COL_FOOD
@ URD_COL_FOOD
Definition repodlgs.c:1299
URD_COL_N_UPGRADABLE
@ URD_COL_N_UPGRADABLE
Definition repodlgs.c:1295
URD_COL_NUPG_VISIBLE
@ URD_COL_NUPG_VISIBLE
Definition repodlgs.c:1306
URD_COL_UTYPE_NAME
@ URD_COL_UTYPE_NAME
Definition repodlgs.c:1293
URD_COL_UTYPE_ID
@ URD_COL_UTYPE_ID
Definition repodlgs.c:1307
URD_COL_SHIELD
@ URD_COL_SHIELD
Definition repodlgs.c:1298
URD_COL_EMPTY
@ URD_COL_EMPTY
Definition repodlgs.c:1301
science_report_columns
science_report_columns
Definition repodlgs.c:112
SRD_COL_ID
@ SRD_COL_ID
Definition repodlgs.c:117
SRD_COL_NAME
@ SRD_COL_NAME
Definition repodlgs.c:113
SRD_COL_NUM
@ SRD_COL_NUM
Definition repodlgs.c:119
SRD_COL_STEPS
@ SRD_COL_STEPS
Definition repodlgs.c:114
economy_report_column_name
static const char * economy_report_column_name(enum economy_report_columns col)
Definition repodlgs.c:826
science_diagram_new
static GtkWidget * science_diagram_new(void)
Definition repodlgs.c:270
visible_col
int visible_col
Definition repodlgs.c:1317
science_report_show_all_callback
static void science_report_show_all_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:545
economy_report_columns
economy_report_columns
Definition repodlgs.c:788
ERD_COL_NUM
@ ERD_COL_NUM
Definition repodlgs.c:801
ERD_COL_SPRITE
@ ERD_COL_SPRITE
Definition repodlgs.c:789
ERD_COL_IS_IMPROVEMENT
@ ERD_COL_IS_IMPROVEMENT
Definition repodlgs.c:798
ERD_COL_CID
@ ERD_COL_CID
Definition repodlgs.c:799
ERD_COL_NAME
@ ERD_COL_NAME
Definition repodlgs.c:790
ERD_COL_EMPTY
@ ERD_COL_EMPTY
Definition repodlgs.c:795
ERD_COL_REDUNDANT
@ ERD_COL_REDUNDANT
Definition repodlgs.c:791
ERD_COL_TOTAL_COST
@ ERD_COL_TOTAL_COST
Definition repodlgs.c:794
ERD_COL_COUNT
@ ERD_COL_COUNT
Definition repodlgs.c:792
ERD_COL_COST
@ ERD_COL_COST
Definition repodlgs.c:793
science_report_dialog_popdown
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
rightalign
bool rightalign
Definition repodlgs.c:1316
economy_report_store_new
static GtkListStore * economy_report_store_new(void)
Definition repodlgs.c:807
find_nearest_unit
static struct unit * find_nearest_unit(const struct unit_type *utype, struct tile *ptile)
Definition repodlgs.c:1539
endgame_report_columns
endgame_report_columns
Definition repodlgs.c:1813
FRD_COL_NUM
@ FRD_COL_NUM
Definition repodlgs.c:1819
FRD_COL_TOOLTIP
@ FRD_COL_TOOLTIP
Definition repodlgs.c:1817
FRD_COL_NATION
@ FRD_COL_NATION
Definition repodlgs.c:1815
FRD_COL_PLAYER
@ FRD_COL_PLAYER
Definition repodlgs.c:1814
FRD_COL_SCORE
@ FRD_COL_SCORE
Definition repodlgs.c:1816
economy_report_response
economy_report_response
Definition repodlgs.c:780
ERD_RES_SELL_REDUNDANT
@ ERD_RES_SELL_REDUNDANT
Definition repodlgs.c:781
ERD_RES_SELL_ALL
@ ERD_RES_SELL_ALL
Definition repodlgs.c:782
ERD_RES_DISBAND_UNITS
@ ERD_RES_DISBAND_UNITS
Definition repodlgs.c:783
cmp_func
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:368
economy_report_selection_callback
static void economy_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1068
science_report_goal_callback
static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:556
economy_report_free
static void economy_report_free(struct economy_report *preport)
Definition repodlgs.c:1230
science_report_init
static void science_report_init(struct science_report *preport)
Definition repodlgs.c:580
science_report_current_callback
static void science_report_current_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:520
real_science_report_dialog_update
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
units_report_free
static void units_report_free(struct units_report *preport)
Definition repodlgs.c:1755
science_report_store_new
static GtkListStore * science_report_store_new(void)
Definition repodlgs.c:125
science_report_redraw
static void science_report_redraw(struct science_report *preport)
Definition repodlgs.c:345
sprite_get_pixbuf
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
blocking_dialog
gint blocking_dialog(GtkWidget *dlg)
Definition gui_stuff.c:1135
gui_dialog_add_content_widget
void gui_dialog_add_content_widget(struct gui_dialog *dlg, GtkWidget *wdg)
Definition gui_stuff.c:1104
gui_stuff.h
science_diagram_left_button_up
static gboolean science_diagram_left_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:202
tooltip
const char * tooltip
Definition repodlgs.c:1344
title
const char * title
Definition repodlgs.c:1343
type
GType type
Definition repodlgs.c:1342
visible_col
int visible_col
Definition repodlgs.c:1346
rightalign
bool rightalign
Definition repodlgs.c:1345
science_diagram_right_button_up
static gboolean science_diagram_right_button_up(GtkGestureClick *gesture, int n_press, double x, double y)
Definition repodlgs.c:238
canvas.h
cityrep.h
dialogs.h
gui_main.h
helpdlg.h
plrdlg.h
repodlgs.h
sprite.h
HELP_TECH
@ HELP_TECH
Definition helpdlg_g.h:21
can_sell_building
bool can_sell_building(const struct impr_type *pimprove)
Definition improvement.c:1091
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:243
B_LAST
#define B_LAST
Definition improvement.h:42
name
const char * name
Definition inputfile.c:127
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
log_error
#define log_error(message,...)
Definition log.h:103
sq_map_distance
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:641
get_center_tile_mapcanvas
struct tile * get_center_tile_mapcanvas(void)
Definition mapview_common.c:1227
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
mapview_common.h
nation_of_player
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:444
options.h
packets.h
dsend_packet_player_tech_goal
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
Definition packets_gen.c:27308
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:27133
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:31811
packhand_gen.h
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:741
player_by_number
struct player * player_by_number(const int player_id)
Definition player.c:849
player_name
const char * player_name(const struct player *pplayer)
Definition player.c:895
players_iterate_end
#define players_iterate_end
Definition player.h:537
players_iterate
#define players_iterate(_pplayer)
Definition player.h:532
get_economy_report_units_data
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
Definition repodlgs_common.c:105
get_economy_report_data
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
Definition repodlgs_common.c:46
sell_all_improvements
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
Definition repodlgs_common.c:160
disband_all_units
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
Definition repodlgs_common.c:200
endgame_report_dialog_player
endgame_report_dialog_player
Definition repodlgs_g.h:33
draw_reqtree
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
get_reqtree_dimensions
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:870
get_tech_on_reqtree
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1176
find_tech_on_reqtree
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1199
destroy_reqtree
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:473
create_reqtree
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:839
reqtree.h
research_goal_unknown_techs
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
research_invention_reachable
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
research_future_next
bool research_future_next(const struct research *presearch)
Definition research.c:1362
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:128
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
research.h
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
FC_INFINITY
#define FC_INFINITY
Definition shared.h:36
MAX
#define MAX(x, y)
Definition shared.h:54
y
struct sprite int int y
Definition sprite_g.h:31
x
struct sprite int x
Definition sprite_g.h:31
ITree
Definition gui_stuff.h:32
canvas
Definition canvas.h:22
canvas::drawable
cairo_t * drawable
Definition canvas.h:24
civclient::conn
struct connection conn
Definition client_main.h:96
economy_report
Definition repodlgs.c:772
economy_report::label
GtkLabel * label
Definition repodlgs.c:775
economy_report::tree_view
GtkTreeView * tree_view
Definition repodlgs.c:774
economy_report::shell
struct gui_dialog * shell
Definition repodlgs.c:773
endgame_report
Definition repodlgs.c:1805
endgame_report::store
GtkListStore * store
Definition repodlgs.c:1808
endgame_report::tree_view
GtkTreeView * tree_view
Definition repodlgs.c:1807
endgame_report::shell
struct gui_dialog * shell
Definition repodlgs.c:1806
endgame_report::player_count
int player_count
Definition repodlgs.c:1809
endgame_report::players_received
int players_received
Definition repodlgs.c:1810
gui_dialog
Definition gui_stuff.h:70
impr_type
Definition improvement.h:50
improvement_entry
Definition repodlgs_common.h:28
item
Definition climisc.h:80
packet_endgame_player
Definition packets_gen.h:91
packet_endgame_player::category_num
int category_num
Definition packets_gen.h:92
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:93
packet_endgame_player::category_score
int category_score[32]
Definition packets_gen.h:95
packet_endgame_player::score
int score
Definition packets_gen.h:94
packet_endgame_report
Definition packets_gen.h:85
packet_endgame_report::category_name
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:87
packet_endgame_report::category_num
int category_num
Definition packets_gen.h:86
packet_endgame_report::player_num
int player_num
Definition packets_gen.h:88
player
Definition player.h:247
reqtree
Definition repodlgs.cpp:85
research
Definition research.h:39
research::researching
Tech_type_id researching
Definition research.h:52
science_report
Definition repodlgs.c:69
science_report::shell
struct gui_dialog * shell
Definition repodlgs.c:70
science_report::progress_bar
GtkProgressBar * progress_bar
Definition repodlgs.c:75
science_report::reachable_techs
GtkComboBox * reachable_techs
Definition repodlgs.c:71
science_report::reachable_goals
GtkComboBox * reachable_goals
Definition repodlgs.c:72
science_report::drawing_area
GtkDrawingArea * drawing_area
Definition repodlgs.c:77
science_report::goal_label
GtkLabel * goal_label
Definition repodlgs.c:76
science_report::main_label
GtkLabel * main_label
Definition repodlgs.c:74
science_report::button_show_all
GtkWidget * button_show_all
Definition repodlgs.c:73
sprite
Definition sprite.h:22
tile
Definition tile.h:50
tileset
Definition tilespec.c:481
unit_entry
Definition repodlgs_common.h:34
unit_type
Definition unittype.h:500
unit
Definition unit.h:138
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:148
unit::activity
enum unit_activity activity
Definition unit.h:157
unit::moves_left
int moves_left
Definition unit.h:150
unit::client
struct unit::@81::@83 client
unit::homecity
int homecity
Definition unit.h:146
unit::done_moving
bool done_moving
Definition unit.h:181
unit::utype
const struct unit_type * utype
Definition unit.h:139
unit::focus_status
enum unit_focus_status focus_status
Definition unit.h:214
unit::ssa_controller
enum server_side_agent ssa_controller
Definition unit.h:172
units_report
Definition repodlgs.c:1279
units_report::tree_view
GtkTreeView * tree_view
Definition repodlgs.c:1281
units_report::shell
struct gui_dialog * shell
Definition repodlgs.c:1280
universal
Definition fc_types.h:901
universal::kind
enum universals_n kind
Definition fc_types.h:903
universal::value
universals_u value
Definition fc_types.h:902
view
Definition mapview_common.h:36
widget
Definition widget.h:112
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
fc_strcoll
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:473
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
is_future_tech
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
tech.h
A_FUTURE
#define A_FUTURE
Definition tech.h:46
advance_index_iterate_max
#define advance_index_iterate_max(_start, _index, _max)
Definition tech.h:252
advance_index_iterate_max_end
#define advance_index_iterate_max_end
Definition tech.h:258
advance_count
static Tech_type_id advance_count(void)
Definition tech.h:170
A_FIRST
#define A_FIRST
Definition tech.h:44
A_NONE
#define A_NONE
Definition tech.h:43
A_UNSET
#define A_UNSET
Definition tech.h:48
score_tooltip
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2126
get_science_target_text
const char * get_science_target_text(double *percent)
Definition text.c:820
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:866
text.h
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6787
tileset_is_fully_loaded
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7518
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6809
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:724
universals_u::building
const struct impr_type * building
Definition fc_types.h:717
unit_tile
#define unit_tile(_pu)
Definition unit.h:390
FOCUS_AVAIL
@ FOCUS_AVAIL
Definition unit.h:53
unitlist.h
unit_list_iterate
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
unit_list_iterate_end
#define unit_list_iterate_end
Definition unitlist.h:33
unit_type_get
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
can_upgrade_unittype
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1703
utype_count
Unit_type_id utype_count(void)
Definition unittype.c:80
utype_by_number
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
unit_upgrade_price
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1731
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:852
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:859