Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-gtk-3.22/repodlgs.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
repodlgs.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <math.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23#include <gtk/gtk.h>
24#include <gdk/gdkkeysyms.h>
25
26/* utility */
27#include "fcintl.h"
28#include "log.h"
29#include "shared.h"
30#include "support.h"
31
32/* common */
33#include "fc_types.h" /* LINE_BREAK */
34#include "game.h"
35#include "government.h"
36#include "packets.h"
37#include "research.h"
38#include "tech.h"
39#include "unitlist.h"
40
41/* client */
42#include "chatline_common.h"
43#include "client_main.h"
44#include "climisc.h"
45#include "control.h"
46#include "mapview_common.h"
47#include "options.h"
48#include "packhand_gen.h"
49#include "control.h"
50#include "reqtree.h"
51#include "text.h"
52
53/* client/gui-gtk-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****************************************************************************/
69 struct 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 GtkLayout *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_button_release_callback(GtkWidget *widget,
90 GdkEventButton *event, gpointer data);
91static gboolean science_diagram_update(GtkWidget *widget,
92 cairo_t *cr,
93 gpointer data);
94static GtkWidget *science_diagram_new(void);
95static void science_diagram_data(GtkWidget *widget, bool show_all);
96static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech);
97static void science_report_redraw(struct science_report *preport);
98static gint cmp_func(gconstpointer a_p, gconstpointer b_p);
99static void science_report_update(struct science_report *preport);
100static void science_report_current_callback(GtkComboBox *combo,
101 gpointer data);
102static void science_report_show_all_callback(GtkComboBox *combo,
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
108 static struct science_report science_report = { NULL, };
109 static bool science_report_no_combo_callback = FALSE;
110
111/* Those values must match the function science_report_store_new(). */
112 enum science_report_columns {
113 SRD_COL_NAME,
114 SRD_COL_STEPS,
115
116 /* Not visible. */
117 SRD_COL_ID, /* Tech_type_id */
118
119 SRD_COL_NUM
120};
121
122/************************************************************************/
125 static GtkListStore *science_report_store_new(void)
126{
127 return gtk_list_store_new(SRD_COL_NUM,
128 G_TYPE_STRING, /* SRD_COL_NAME */
129 G_TYPE_INT, /* SRD_COL_STEPS */
130 G_TYPE_INT); /* SRD_COL_ID */
131}
132
133/************************************************************************/
136 static inline void science_report_store_set(GtkListStore *store,
137 GtkTreeIter *iter,
138 Tech_type_id tech)
139{
140 const struct research *presearch = research_get(client_player());
141
142 gtk_list_store_set(store, iter,
143 SRD_COL_NAME,
144 research_advance_name_translation(presearch, tech),
145 SRD_COL_STEPS,
146 research_goal_unknown_techs(presearch, tech),
147 SRD_COL_ID, tech,
148 -1);
149}
150
151/************************************************************************/
154 static bool science_report_combo_get_active(GtkComboBox *combo,
155 Tech_type_id *tech,
156 char **name)
157{
158 GtkTreeIter iter;
159
160 if (science_report_no_combo_callback
161 || !gtk_combo_box_get_active_iter(combo, &iter)) {
162 return FALSE;
163 }
164
165 gtk_tree_model_get(gtk_combo_box_get_model(combo), &iter,
166 SRD_COL_NAME, name,
167 SRD_COL_ID, tech,
168 -1);
169 return TRUE;
170}
171
172/************************************************************************/
175 static void science_report_combo_set_active(GtkComboBox *combo,
176 Tech_type_id tech)
177{
178 ITree iter;
179 Tech_type_id iter_tech;
180
181 for (itree_begin(gtk_combo_box_get_model(combo), &iter);
182 !itree_end(&iter); itree_next(&iter)) {
183 itree_get(&iter, SRD_COL_ID, &iter_tech, -1);
184 if (iter_tech == tech) {
185 science_report_no_combo_callback = TRUE;
186 gtk_combo_box_set_active_iter(combo, &iter.it);
187 science_report_no_combo_callback = FALSE;
188 return;
189 }
190 }
191 log_error("%s(): Tech %d not found in the combo.", __FUNCTION__, tech);
192}
193
194/************************************************************************/
197 static gboolean science_diagram_button_release_callback(GtkWidget *widget,
198 GdkEventButton *event, gpointer data)
199{
200 const struct research *presearch = research_get(client_player());
201 struct reqtree *reqtree = g_object_get_data(G_OBJECT(widget), "reqtree");
202 Tech_type_id tech = get_tech_on_reqtree(reqtree, event->x, event->y);
203
204 if (tech == A_NONE) {
205 return TRUE;
206 }
207
208 if (event->button == 3) {
209 /* RMB: get help */
210 popup_help_dialog_typed(research_advance_name_translation(presearch,
211 tech),
212 HELP_TECH);
213 } else {
214 if (event->button == 1 && can_client_issue_orders()) {
215 /* LMB: set research or research goal */
216 switch (research_invention_state(research_get(client_player()),
217 tech)) {
218 case TECH_PREREQS_KNOWN:
219 dsend_packet_player_research(&client.conn, tech);
220 break;
221 case TECH_UNKNOWN:
222 dsend_packet_player_tech_goal(&client.conn, tech);
223 break;
224 case TECH_KNOWN:
225 break;
226 }
227 }
228 }
229 return TRUE;
230}
231
232/************************************************************************/
235 static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
236{
237 /* FIXME: this currently redraws everything! */
238 struct canvas canvas = FC_STATIC_CANVAS_INIT;
239 struct reqtree *reqtree = g_object_get_data(G_OBJECT(widget), "reqtree");
240 int width, height;
241 GtkAdjustment *hadjustment;
242 GtkAdjustment *vadjustment;
243 gint hadjustment_value;
244 gint vadjustment_value;
245
246 if (!tileset_is_fully_loaded()) {
247 return TRUE;
248 }
249
250 hadjustment = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(widget));
251 vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(widget));
252
253 hadjustment_value = (gint)gtk_adjustment_get_value(hadjustment);
254 vadjustment_value = (gint)gtk_adjustment_get_value(vadjustment);
255
256 cairo_translate(cr, -hadjustment_value, -vadjustment_value);
257
258 canvas.drawable = cr;
259
260 get_reqtree_dimensions(reqtree, &width, &height);
261 draw_reqtree(reqtree, &canvas, 0, 0, 0, 0, width, height);
262
263 return TRUE;
264}
265
266/************************************************************************/
270 static GtkWidget *science_diagram_new(void)
271{
272 GtkWidget *diagram;
273
274 diagram = gtk_layout_new(NULL, NULL);
275 gtk_widget_add_events(diagram,
276 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
277 | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK);
278 g_signal_connect(diagram, "draw",
279 G_CALLBACK(science_diagram_update), NULL);
280 g_signal_connect(diagram, "button-release-event",
281 G_CALLBACK(science_diagram_button_release_callback),
282 NULL);
283
284 return diagram;
285}
286
287/************************************************************************/
290 static 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 */
297 reqtree = create_reqtree(NULL, TRUE);
298 } else {
299 /* Show only at some point reachable techs */
300 reqtree = create_reqtree(client_player(), show_all);
301 }
302
303 get_reqtree_dimensions(reqtree, &width, &height);
304 gtk_layout_set_size(GTK_LAYOUT(widget), width, height);
305 g_object_set_data_full(G_OBJECT(widget), "reqtree", reqtree,
306 (GDestroyNotify) destroy_reqtree);
307}
308
309/************************************************************************/
312 static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
313{
314 GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(gtk_widget_get_parent(diagram));
315 struct reqtree *reqtree;
316 int x, y, width, height;
317
318 if (!GTK_IS_SCROLLED_WINDOW(sw)) {
319 return;
320 }
321
322 reqtree = g_object_get_data(G_OBJECT(diagram), "reqtree");
323 get_reqtree_dimensions(reqtree, &width, &height);
324 if (find_tech_on_reqtree(reqtree, tech, &x, &y, NULL, NULL)) {
325 GtkAdjustment *adjust = NULL;
326 gdouble value;
327
328 adjust = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(sw));
329 value = (gtk_adjustment_get_lower(adjust)
330 + gtk_adjustment_get_upper(adjust)
331 - gtk_adjustment_get_page_size(adjust)) / width * x;
332 gtk_adjustment_set_value(adjust, value);
333
334 adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw));
335 value = (gtk_adjustment_get_lower(adjust)
336 + gtk_adjustment_get_upper(adjust)
337 - gtk_adjustment_get_page_size(adjust)) / height * y;
338 gtk_adjustment_set_value(adjust, value);
339 }
340}
341
342/************************************************************************/
345 static void science_report_redraw(struct science_report *preport)
346{
347 Tech_type_id researching;
348
349 fc_assert_ret(NULL != preport);
350
351 science_diagram_data(GTK_WIDGET(preport->drawing_area),
352 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
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
362 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
363}
364
365/************************************************************************/
368 static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
369{
370 const gchar *a_str, *b_str;
371 gint a = GPOINTER_TO_INT(a_p), b = GPOINTER_TO_INT(b_p);
372 const struct research *presearch = research_get(client_player());
373
374 a_str = research_advance_name_translation(presearch, a);
375 b_str = research_advance_name_translation(presearch, b);
376
377 return fc_strcoll(a_str, b_str);
378}
379
380/************************************************************************/
383 static void science_report_update(struct science_report *preport)
384{
385 GtkListStore *store;
386 GtkTreeIter iter;
387 GList *sorting_list, *item;
388 struct research *presearch = research_get(client_player());
389 const char *text;
390 double pct;
391 Tech_type_id tech;
392 Tech_type_id ac = advance_count();
393
394 fc_assert_ret(NULL != preport);
395 fc_assert_ret(NULL != presearch);
396
397 /* Disable callbacks. */
398 science_report_no_combo_callback = TRUE;
399
400 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
401
402 gtk_label_set_text(preport->main_label, science_dialog_text());
403
404 /* Update the progress bar. */
405 text = get_science_target_text(&pct);
406 gtk_progress_bar_set_text(preport->progress_bar, text);
407 gtk_progress_bar_set_fraction(preport->progress_bar, pct);
408 /* Work around GTK+ refresh bug? */
409 gtk_widget_queue_resize(GTK_WIDGET(preport->progress_bar));
410
411 /* Update reachable techs. */
412 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
413 gtk_list_store_clear(store);
414 sorting_list = NULL;
415
416 /* Collect all techs which are reachable in the next step. */
417 advance_index_iterate_max(A_FIRST, i, ac) {
418 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
419 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
420 }
421 } advance_index_iterate_max_end;
422
423 if (sorting_list != NULL) {
424 if (A_UNSET == presearch->researching
425 || is_future_tech(presearch->researching)) {
426 gtk_list_store_append(store, &iter);
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. */
432 sorting_list = g_list_sort(sorting_list, cmp_func);
433 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
434 tech = GPOINTER_TO_INT(item->data);
435 gtk_list_store_append(store, &iter);
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. */
443 g_list_free(sorting_list);
444 sorting_list = NULL;
445 } else {
446 /* No reachable normal techs. Can we select Future Tech? */
447 Tech_type_id next;
448
449 gtk_list_store_append(store, &iter);
450 if (research_future_next(presearch)) {
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));
461 gtk_list_store_clear(store);
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. */
468 advance_index_iterate_max(A_FIRST, i, ac) {
469 if (research_invention_reachable(presearch, i)
470 && TECH_KNOWN != presearch->inventions[i].state
471 && (i == presearch->tech_goal
472 || 10 >= presearch->inventions[i].num_required_techs)) {
473 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
474 }
475 } advance_index_iterate_max_end;
476
477 if (sorting_list != NULL) {
478 if (A_UNSET == presearch->tech_goal) {
479 gtk_list_store_append(store, &iter);
480 science_report_store_set(store, &iter, A_UNSET);
481 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
482 }
483
484 /* Sort the list, append it to the store. */
485 sorting_list = g_list_sort(sorting_list, cmp_func);
486 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
487 tech = GPOINTER_TO_INT(item->data);
488 gtk_list_store_append(store, &iter);
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. */
496 g_list_free(sorting_list);
497 } else {
498 /* No reachable normal techs. Can we select Future Tech? */
499 Tech_type_id goal;
500
501 gtk_list_store_append(store, &iter);
502
503 if (research_future_next(presearch)) {
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. */
514 science_report_no_combo_callback = FALSE;
515}
516
517/************************************************************************/
520 static void science_report_current_callback(GtkComboBox *combo,
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
530 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data))) {
531 popup_help_dialog_typed(tech_name, HELP_TECH);
532 } else if (can_client_issue_orders()) {
533 dsend_packet_player_research(&client.conn, tech);
534 }
535
536 free(tech_name);
537 /* Revert, or we will not be in sync with the server. */
538 science_report_combo_set_active(combo, research_get
539 (client_player())->researching);
540}
541
542/************************************************************************/
545 static void science_report_show_all_callback(GtkComboBox *combo,
546 gpointer data)
547{
548 struct science_report *preport = (struct science_report *) data;
549
550 science_report_redraw(preport);
551}
552
553/************************************************************************/
556 static void science_report_goal_callback(GtkComboBox *combo, 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_toggle_button_get_active(GTK_TOGGLE_BUTTON(data))) {
566 popup_help_dialog_typed(tech_name, HELP_TECH);
567 } else if (can_client_issue_orders()) {
568 dsend_packet_player_tech_goal(&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())->tech_goal);
575}
576
577/************************************************************************/
580 static void science_report_init(struct science_report *preport)
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
588 fc_assert_ret(NULL != preport);
589
590 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
591 /* TRANS: Research report title */
592 gui_dialog_set_title(preport->shell, _("Research"));
593
594 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
595 GTK_RESPONSE_CLOSE);
596 gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
597
598 vbox = GTK_CONTAINER(preport->shell->vbox);
599 group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
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
609 table = gtk_grid_new();
610 gtk_grid_set_column_spacing(GTK_GRID(table), 4);
611 gtk_container_add(GTK_CONTAINER(frame), table);
612
613 help_button = gtk_check_button_new_with_label(_("Help"));
614 gtk_grid_attach(GTK_GRID(table), help_button, 5, 0, 1, 1);
615
616 store = science_report_store_new();
617 w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
618 gtk_size_group_add_widget(group, w);
619 g_object_unref(G_OBJECT(store));
620 renderer = gtk_cell_renderer_text_new();
621 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), renderer, TRUE);
622 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
623 SRD_COL_NAME, NULL);
624 gtk_widget_set_sensitive(w, can_client_issue_orders());
625 g_signal_connect(w, "changed", G_CALLBACK(science_report_current_callback),
626 help_button);
627 gtk_grid_attach(GTK_GRID(table), w, 0, 0, 1, 1);
628 preport->reachable_techs = GTK_COMBO_BOX(w);
629
630 w = gtk_progress_bar_new();
631 gtk_widget_set_hexpand(w, TRUE);
632 gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(w), TRUE);
633 gtk_grid_attach(GTK_GRID(table), w, 2, 0, 1, 1);
634 gtk_widget_set_size_request(w, -1, 25);
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
641 table = gtk_grid_new();
642 gtk_grid_set_column_spacing(GTK_GRID(table), 4);
643 gtk_container_add(GTK_CONTAINER(frame),table);
644
645 store = science_report_store_new();
646 w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
647 gtk_size_group_add_widget(group, w);
648 g_object_unref(G_OBJECT(store));
649 renderer = gtk_cell_renderer_text_new();
650 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), renderer, TRUE);
651 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
652 SRD_COL_NAME, NULL);
653 renderer = gtk_cell_renderer_text_new();
654 gtk_cell_layout_pack_end(GTK_CELL_LAYOUT(w), renderer, FALSE);
655 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), renderer, "text",
656 SRD_COL_STEPS, NULL);
657 gtk_widget_set_sensitive(w, can_client_issue_orders());
658 g_signal_connect(w, "changed", G_CALLBACK(science_report_goal_callback),
659 help_button);
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);
664 gtk_widget_set_hexpand(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->goal_label = GTK_LABEL(w);
668
669 /* Toggle "Show All" button. */
670 /* TRANS: As in 'Show all (even not reachable) techs'. */
671 show_all_button = gtk_toggle_button_new_with_label(_("Show all"));
672 gtk_grid_attach(GTK_GRID(table), show_all_button, 5, 0, 1, 1);
673 g_signal_connect(show_all_button, "toggled",
674 G_CALLBACK(science_report_show_all_callback), preport);
675 gtk_widget_set_sensitive(show_all_button, can_client_issue_orders()
676 && !client_is_global_observer());
677 preport->button_show_all = show_all_button;
678
679 /* Science diagram. */
680 sw = gtk_scrolled_window_new(NULL, NULL);
681 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
682 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
683 gtk_container_add(vbox, sw);
684
685 w = science_diagram_new();
686 gtk_widget_set_hexpand(w, TRUE);
687 gtk_widget_set_vexpand(w, TRUE);
688 gtk_container_add(GTK_CONTAINER(sw), w);
689 preport->drawing_area = GTK_LAYOUT(w);
690
691 science_report_update(preport);
692 gui_dialog_show_all(preport->shell);
693 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
694 g_object_unref(group);
695
696 /* This must be _after_ the dialog is drawn to really center it ... */
697 science_report_redraw(preport);
698}
699
700/************************************************************************/
703 static void science_report_free(struct science_report *preport)
704{
705 fc_assert_ret(NULL != preport);
706
707 gui_dialog_destroy(preport->shell);
708 fc_assert(NULL == preport->shell);
709
710 memset(preport, 0, sizeof(*preport));
711}
712
713/************************************************************************/
716 void science_report_dialog_popup(bool raise)
717{
718 struct research *presearch = research_get(client_player());
719
720 if (NULL == science_report.shell) {
721 science_report_init(&science_report);
722 }
723
724 if (NULL != presearch
725 && A_UNSET == presearch->tech_goal
726 && A_UNSET == presearch->researching) {
727 gui_dialog_alert(science_report.shell);
728 } else {
729 gui_dialog_present(science_report.shell);
730 }
731
732 if (raise) {
733 gui_dialog_raise(science_report.shell);
734 }
735}
736
737/************************************************************************/
740 void science_report_dialog_popdown(void)
741{
742 if (NULL != science_report.shell) {
743 science_report_free(&science_report);
744 fc_assert(NULL == science_report.shell);
745 }
746}
747
748/************************************************************************/
751 void real_science_report_dialog_update(void *unused)
752{
753 if (NULL != science_report.shell) {
754 science_report_update(&science_report);
755 }
756}
757
758/************************************************************************/
761 void science_report_dialog_redraw(void)
762{
763 if (NULL != science_report.shell) {
764 science_report_redraw(&science_report);
765 }
766}
767
768
769/****************************************************************************
770 ECONOMY REPORT DIALOG
771****************************************************************************/
772 struct economy_report {
773 struct gui_dialog *shell;
774 GtkTreeView *tree_view;
775 GtkLabel *label;
776};
777
778 static struct economy_report economy_report = { NULL, NULL, NULL };
779
780 enum economy_report_response {
781 ERD_RES_SELL_REDUNDANT = 1,
782 ERD_RES_SELL_ALL,
783 ERD_RES_DISBAND_UNITS
784};
785
786/* Those values must match the functions economy_report_store_new() and
787 * economy_report_column_name(). */
788 enum economy_report_columns {
789 ERD_COL_SPRITE,
790 ERD_COL_NAME,
791 ERD_COL_REDUNDANT,
792 ERD_COL_COUNT,
793 ERD_COL_COST,
794 ERD_COL_TOTAL_COST,
795 ERD_COL_EMPTY, /* will make an empty space for scroll bar */
796
797 /* Not visible. */
798 ERD_COL_IS_IMPROVEMENT,
799 ERD_COL_CID,
800
801 ERD_COL_NUM
802};
803
804/************************************************************************/
807 static GtkListStore *economy_report_store_new(void)
808{
809 return gtk_list_store_new(ERD_COL_NUM,
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 *
826economy_report_column_name(enum economy_report_columns col)
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");
834 case ERD_COL_REDUNDANT:
835 return _("Redundant");
836 case ERD_COL_COUNT:
837 return _("Count");
838 case ERD_COL_COST:
839 return _("Cost");
840 case ERD_COL_TOTAL_COST:
841 /* TRANS: Upkeep total, count*cost. */
842 return _("U Total");
843 case ERD_COL_EMPTY:
844 /* empty space for scrollbar*/
845 return " ";
846 case ERD_COL_IS_IMPROVEMENT:
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/************************************************************************/
858 static void economy_report_update(struct economy_report *preport)
859{
860 GtkTreeSelection *selection;
861 GtkTreeModel *model;
862 GtkListStore *store;
863 GtkTreeIter iter;
864 GdkPixbuf *pix;
865 struct improvement_entry building_entries[B_LAST];
866 struct unit_entry unit_entries[U_LAST];
867 int entries_used, building_total, unit_total, tax, i;
868 char buf[256];
869 cid selected;
870
871 fc_assert_ret(NULL != preport);
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);
883 gtk_list_store_clear(store);
884
885 /* Buildings. */
886 get_economy_report_data(building_entries, &entries_used,
887 &building_total, &tax);
888 for (i = 0; i < entries_used; i++) {
889 struct improvement_entry *pentry = building_entries + 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
894 pix = sprite_get_pixbuf(sprite);
895 gtk_list_store_append(store, &iter);
896 gtk_list_store_set(store, &iter,
897 ERD_COL_SPRITE, pix,
898 ERD_COL_NAME, improvement_name_translation(pimprove),
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, " ",
904 ERD_COL_IS_IMPROVEMENT, TRUE,
905 ERD_COL_CID, id,
906 -1);
907 g_object_unref(G_OBJECT(pix));
908 if (selected == id) {
909 /* Restore the selection. */
910 gtk_tree_selection_select_iter(selection, &iter);
911 }
912 }
913
914 /* Units. */
915 get_economy_report_units_data(unit_entries, &entries_used, &unit_total);
916 for (i = 0; i < entries_used; i++) {
917 struct unit_entry *pentry = unit_entries + i;
918 struct unit_type *putype = pentry->type;
919 struct sprite *sprite = get_unittype_sprite(tileset, putype,
920 ACTIVITY_LAST,
921 direction8_invalid());
922 cid id = cid_encode_unit(putype);
923
924 pix = sprite_get_pixbuf(sprite);
925 gtk_list_store_append(store, &iter);
926 gtk_list_store_set(store, &iter,
927 ERD_COL_SPRITE, pix,
928 ERD_COL_NAME, utype_name_translation(putype),
929 ERD_COL_REDUNDANT, 0,
930 ERD_COL_COUNT, pentry->count,
931 ERD_COL_COST, pentry->cost,
932 ERD_COL_TOTAL_COST, pentry->total_cost,
933 ERD_COL_EMPTY, " ",
934 ERD_COL_IS_IMPROVEMENT, FALSE,
935 ERD_COL_CID, id,
936 -1);
937 g_object_unref(G_OBJECT(pix));
938 if (selected == id) {
939 /* Restore the selection. */
940 gtk_tree_selection_select_iter(selection, &iter);
941 }
942 }
943
944 /* Update the label. */
945 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
946 tax, building_total + unit_total);
947 gtk_label_set_text(preport->label, buf);
948}
949
950/************************************************************************/
953 static void economy_report_command_callback(struct gui_dialog *pdialog,
954 int response,
955 gpointer data)
956{
957 struct economy_report *preport = data;
958 GtkTreeSelection *selection = gtk_tree_view_get_selection(preport->tree_view);
959 GtkTreeModel *model;
960 GtkTreeIter iter;
961 GtkWidget *shell;
962 struct universal selected;
963 cid id;
964 char buf[256] = "";
965
966 switch (response) {
967 case ERD_RES_SELL_REDUNDANT:
968 case ERD_RES_SELL_ALL:
969 case ERD_RES_DISBAND_UNITS:
970 break;
971 default:
972 gui_dialog_destroy(pdialog);
973 return;
974 }
975
976 if (!can_client_issue_orders()
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 }
1000 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL
1001 | GTK_DIALOG_DESTROY_WITH_PARENT,
1002 GTK_MESSAGE_QUESTION,
1003 GTK_BUTTONS_YES_NO,
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)?"),
1011 improvement_name_translation(pimprove),
1012 count);
1013 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1014 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1015
1016 if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(shell))) {
1017 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1018 }
1019 gtk_widget_destroy(shell);
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
1030 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL
1031 | GTK_DIALOG_DESTROY_WITH_PARENT,
1032 GTK_MESSAGE_QUESTION,
1033 GTK_BUTTONS_YES_NO,
1034 /* TRANS: %s is a unit */
1035 _("Do you really wish to disband "
1036 "every %s (%d total)?"),
1037 utype_name_translation(putype),
1038 count);
1039 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1040 gtk_window_set_title(GTK_WINDOW(shell), _("Disband Units"));
1041
1042 if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(shell))) {
1043 disband_all_units(putype, FALSE, buf, sizeof(buf));
1044 }
1045 gtk_widget_destroy(shell);
1046 }
1047 }
1048 break;
1049 default:
1050 log_error("Not supported type: %d.", selected.kind);
1051 }
1052
1053 if ('\0' != buf[0]) {
1054 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
1055 GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
1056 "%s", buf);
1057 setup_dialog(shell, gui_dialog_get_toplevel(pdialog));
1058 g_signal_connect(shell, "response", G_CALLBACK(gtk_widget_destroy),
1059 NULL);
1060 gtk_window_set_title(GTK_WINDOW(shell), _("Sell-Off: Results"));
1061 gtk_window_present(GTK_WINDOW(shell));
1062 }
1063}
1064
1065/************************************************************************/
1068 static void economy_report_selection_callback(GtkTreeSelection *selection,
1069 gpointer data)
1070{
1071 struct gui_dialog *pdialog = ((struct economy_report *)data)->shell;
1072 GtkTreeModel *model;
1073 GtkTreeIter iter;
1074
1075 if (can_client_issue_orders()
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
1089 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT,
1090 can_sell && redundant > 0);
1091 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, can_sell);
1092 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS,
1093 FALSE);
1094 }
1095 return;
1096 case VUT_UTYPE:
1097 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT,
1098 FALSE);
1099 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, FALSE);
1100 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS,
1101 TRUE);
1102 return;
1103 default:
1104 log_error("Not supported type: %d.", selected.kind);
1105 break;
1106 }
1107 }
1108
1109 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_REDUNDANT, FALSE);
1110 gui_dialog_set_response_sensitive(pdialog, ERD_RES_SELL_ALL, FALSE);
1111 gui_dialog_set_response_sensitive(pdialog, ERD_RES_DISBAND_UNITS, FALSE);
1112}
1113
1114/************************************************************************/
1117 static void economy_report_init(struct economy_report *preport)
1118{
1119 GtkWidget *view, *sw, *label, *button;
1120 GtkListStore *store;
1121 GtkTreeSelection *selection;
1122 GtkContainer *vbox;
1123 const char *title;
1124 enum economy_report_columns i;
1125
1126 fc_assert_ret(NULL != preport);
1127
1128 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE);
1129 gui_dialog_set_title(preport->shell, _("Economy"));
1130 vbox = GTK_CONTAINER(preport->shell->vbox);
1131
1132 sw = gtk_scrolled_window_new(NULL, NULL);
1133 gtk_widget_set_halign(sw, GTK_ALIGN_CENTER);
1134 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1135 GTK_SHADOW_ETCHED_IN);
1136 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1137 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1138 gtk_container_add(GTK_CONTAINER(vbox), sw);
1139
1140 store = economy_report_store_new();
1141 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1142 gtk_widget_set_vexpand(view, TRUE);
1143 g_object_unref(store);
1144 gtk_widget_set_name(view, "small_font");
1145 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
1146 gtk_container_add(GTK_CONTAINER(sw), view);
1147 preport->tree_view = GTK_TREE_VIEW(view);
1148
1149 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1150 g_signal_connect(selection, "changed",
1151 G_CALLBACK(economy_report_selection_callback), preport);
1152
1153 for (i = 0; (title = economy_report_column_name(i)); i++) {
1154 GtkCellRenderer *renderer;
1155 GtkTreeViewColumn *col;
1156 GType type = gtk_tree_model_get_column_type(GTK_TREE_MODEL(store), i);
1157
1158 if (GDK_TYPE_PIXBUF == type) {
1159 renderer = gtk_cell_renderer_pixbuf_new();
1160 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1161 "pixbuf", i, NULL);
1162#if 0
1163 } else if (G_TYPE_BOOLEAN == type) {
1164 renderer = gtk_cell_renderer_toggle_new();
1165 col = gtk_tree_view_column_new_with_attributes(title, renderer,
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 */
1173 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1174 "text", i,
1175 "visible",
1176 ERD_COL_IS_IMPROVEMENT,
1177 NULL);
1178 } else {
1179 col = gtk_tree_view_column_new_with_attributes(title, renderer,
1180 "text", i, NULL);
1181 }
1182 }
1183
1184 if (i > 1) {
1185 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1186 gtk_tree_view_column_set_alignment(col, 1.0);
1187 }
1188
1189 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1190 }
1191
1192 label = gtk_label_new(NULL);
1193 gtk_container_add(vbox, label);
1194 gtk_widget_set_margin_start(label, 5);
1195 gtk_widget_set_margin_end(label, 5);
1196 gtk_widget_set_margin_top(label, 5);
1197 gtk_widget_set_margin_bottom(label, 5);
1198 preport->label = GTK_LABEL(label);
1199
1200 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1201 GTK_RESPONSE_CLOSE);
1202
1203 button = gui_dialog_add_button(preport->shell, NULL, _("_Disband"),
1204 ERD_RES_DISBAND_UNITS);
1205 gtk_widget_set_sensitive(button, FALSE);
1206
1207 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _All"),
1208 ERD_RES_SELL_ALL);
1209 gtk_widget_set_sensitive(button, FALSE);
1210
1211 button = gui_dialog_add_button(preport->shell, NULL, _("Sell _Redundant"),
1212 ERD_RES_SELL_REDUNDANT);
1213 gtk_widget_set_sensitive(button, FALSE);
1214
1215 gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
1216 gui_dialog_response_set_callback(preport->shell,
1217 economy_report_command_callback);
1218
1219 gui_dialog_set_default_size(preport->shell, -1, 350);
1220 gui_dialog_show_all(preport->shell);
1221
1222 economy_report_update(preport);
1223
1224 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1225}
1226
1227/************************************************************************/
1230 static void economy_report_free(struct economy_report *preport)
1231{
1232 fc_assert_ret(NULL != preport);
1233
1234 gui_dialog_destroy(preport->shell);
1235 fc_assert(NULL == preport->shell);
1236
1237 memset(preport, 0, sizeof(*preport));
1238}
1239
1240/************************************************************************/
1243 void economy_report_dialog_popup(bool raise)
1244{
1245 if (NULL == economy_report.shell) {
1246 economy_report_init(&economy_report);
1247 }
1248
1249 gui_dialog_present(economy_report.shell);
1250 if (raise) {
1251 gui_dialog_raise(economy_report.shell);
1252 }
1253}
1254
1255/************************************************************************/
1258 void economy_report_dialog_popdown(void)
1259{
1260 if (NULL != economy_report.shell) {
1261 economy_report_free(&economy_report);
1262 }
1263}
1264
1265/************************************************************************/
1268 void real_economy_report_dialog_update(void *unused)
1269{
1270 if (NULL != economy_report.shell) {
1271 economy_report_update(&economy_report);
1272 }
1273}
1274
1275
1276/****************************************************************************
1277 UNITS REPORT DIALOG
1278****************************************************************************/
1279 struct units_report {
1280 struct gui_dialog *shell;
1281 GtkTreeView *tree_view;
1282};
1283
1284 static struct units_report units_report = { NULL, NULL };
1285
1286 enum units_report_response {
1287 URD_RES_NEAREST = 1,
1288 URD_RES_UPGRADE
1289};
1290
1291/* Those values must match the order of unit_report_columns[]. */
1292 enum units_report_columns {
1293 URD_COL_UTYPE_NAME,
1294 URD_COL_UPGRADABLE,
1295 URD_COL_N_UPGRADABLE,
1296 URD_COL_IN_PROGRESS,
1297 URD_COL_ACTIVE,
1298 URD_COL_SHIELD,
1299 URD_COL_FOOD,
1300 URD_COL_GOLD,
1301 URD_COL_EMPTY, /* empty space for scrollbar */
1302
1303 /* Not visible. */
1304 URD_COL_TEXT_WEIGHT,
1305 URD_COL_UPG_VISIBLE,
1306 URD_COL_NUPG_VISIBLE,
1307 URD_COL_UTYPE_ID,
1308
1309 URD_COL_NUM
1310};
1311
1312static const struct {
1313 GType type;
1314 const char *title;
1315 const char *tooltip;
1316 bool rightalign;
1317 int visible_col;
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 */,
1324 NULL, TRUE, URD_COL_NUPG_VISIBLE },
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 /* ... */ }
1343};
1344
1345/************************************************************************/
1348 static GtkListStore *units_report_store_new(void)
1349{
1350 int i;
1351 GType cols[URD_COL_NUM];
1352
1353 fc_assert(ARRAY_SIZE(unit_report_columns) == URD_COL_NUM);
1354
1355 for (i = 0; i < URD_COL_NUM; i++) {
1356 cols[i] = unit_report_columns[i].type;
1357 }
1358
1359 return gtk_list_store_newv(URD_COL_NUM, cols);
1360}
1361
1362/************************************************************************/
1365 static void units_report_update(struct units_report *preport)
1366{
1367 struct urd_info {
1368 int active_count;
1369 int building_count;
1370 int upkeep[O_LAST];
1371 };
1372
1373 struct urd_info unit_array[utype_count()];
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;
1380 GtkTreeIter iter;
1381 Unit_type_id selected, utype_id;
1382
1383 fc_assert_ret(NULL != preport);
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) {
1395 info = unit_array + utype_index(unit_type_get(punit));
1396
1397 if (0 != punit->homecity) {
1398 output_type_iterate(o) {
1399 info->upkeep[o] += punit->upkeep[o];
1400 } output_type_iterate_end;
1401 }
1402 info->active_count++;
1403 } unit_list_iterate_end;
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 */
1409 (void) city_production_build_units(pcity, TRUE, &num_units);
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 }
1414 } city_list_iterate_end;
1415 } players_iterate_end;
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
1440 upgradable = client_has_player()
1441 && NULL != can_upgrade_unittype(client_player(), utype);
1442
1443 gtk_list_store_append(store, &iter);
1444 gtk_list_store_set(store, &iter,
1445 URD_COL_UTYPE_NAME, utype_name_translation(utype),
1446 URD_COL_UPGRADABLE, upgradable,
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, " ",
1454 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
1455 URD_COL_UPG_VISIBLE, TRUE,
1456 URD_COL_NUPG_VISIBLE, FALSE,
1457 URD_COL_UTYPE_ID, utype_id,
1458 -1);
1459 if (selected == utype_id) {
1460 /* Restore the selection. */
1461 gtk_tree_selection_select_iter(selection, &iter);
1462 }
1463
1464 /* Update totals. */
1465 unit_totals.active_count += info->active_count;
1466 output_type_iterate(o) {
1467 unit_totals.upkeep[o] += info->upkeep[o];
1468 } output_type_iterate_end;
1469 unit_totals.building_count += info->building_count;
1470 if (upgradable) {
1471 total_upgradable_count += info->active_count;
1472 }
1473 } unit_type_iterate_end;
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 */
1480 URD_COL_N_UPGRADABLE, total_upgradable_count,
1481 URD_COL_IN_PROGRESS, unit_totals.building_count,
1482 URD_COL_ACTIVE, unit_totals.active_count,
1483 URD_COL_SHIELD, unit_totals.upkeep[O_SHIELD],
1484 URD_COL_FOOD, unit_totals.upkeep[O_FOOD],
1485 URD_COL_GOLD, unit_totals.upkeep[O_GOLD],
1486 URD_COL_EMPTY, " ",
1487 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_BOLD,
1488 URD_COL_UPG_VISIBLE, FALSE,
1489 URD_COL_NUPG_VISIBLE, TRUE,
1490 URD_COL_UTYPE_ID, U_LAST,
1491 -1);
1492 if (selected == U_LAST) {
1493 /* Restore the selection. */
1494 gtk_tree_selection_select_iter(selection, &iter);
1495 }
1496}
1497
1498/************************************************************************/
1501 static void units_report_selection_callback(GtkTreeSelection *selection,
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,
1515 URD_COL_UTYPE_ID, &ut,
1516 -1);
1517 if (0 < active_count) {
1518 utype = utype_by_number(ut);
1519 }
1520 }
1521
1522 if (NULL == utype) {
1523 gui_dialog_set_response_sensitive(preport->shell, URD_RES_NEAREST,
1524 FALSE);
1525 gui_dialog_set_response_sensitive(preport->shell, URD_RES_UPGRADE,
1526 FALSE);
1527 } else {
1528 gui_dialog_set_response_sensitive(preport->shell, URD_RES_NEAREST, TRUE);
1529 gui_dialog_set_response_sensitive(preport->shell, URD_RES_UPGRADE,
1530 (can_client_issue_orders()
1531 && action_ever_possible(ACTION_UPGRADE_UNIT)
1532 && NULL != can_upgrade_unittype(client_player(), utype)));
1533 }
1534}
1535
1536/************************************************************************/
1539 static 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)
1552 && FOCUS_AVAIL == punit->client.focus_status
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) {
1558 best_candidate = punit;
1559 best_dist = dist;
1560 }
1561 }
1562 } unit_list_iterate_end;
1563 } players_iterate_end;
1564
1565 return best_candidate;
1566}
1567
1568/************************************************************************/
1571 static 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))) {
1605 center_tile_mapcanvas(unit_tile(punit));
1606
1607 if (ACTIVITY_IDLE == punit->activity
1608 || ACTIVITY_SENTRY == punit->activity) {
1609 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
1610 unit_focus_set_and_select(punit);
1611 }
1612 }
1613 }
1614 } else if (can_client_issue_orders()) {
1615 GtkWidget *shell;
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
1625 shell = gtk_message_dialog_new(NULL,
1626 GTK_DIALOG_MODAL
1627 | GTK_DIALOG_DESTROY_WITH_PARENT,
1628 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
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),
1635 utype_name_translation(utype),
1636 utype_name_translation(upgrade),
1637 price, buf);
1638 setup_dialog(shell, gui_dialog_get_toplevel(preport->shell));
1639
1640 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1641
1642 if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(shell))) {
1643 dsend_packet_unit_type_upgrade(&client.conn, utype_number(utype));
1644 }
1645
1646 gtk_widget_destroy(shell);
1647 }
1648}
1649
1650/************************************************************************/
1653 static void units_report_init(struct units_report *preport)
1654{
1655 GtkWidget *view, *sw, *button;
1656 GtkListStore *store;
1657 GtkTreeSelection *selection;
1658 GtkContainer *vbox;
1659 GtkTreeViewColumn *col = NULL;
1660 enum units_report_columns i;
1661
1662 fc_assert_ret(NULL != preport);
1663
1664 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE);
1665 gui_dialog_set_title(preport->shell, _("Units"));
1666 vbox = GTK_CONTAINER(preport->shell->vbox);
1667
1668 sw = gtk_scrolled_window_new(NULL,NULL);
1669 gtk_widget_set_halign(sw, GTK_ALIGN_CENTER);
1670 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1671 GTK_SHADOW_ETCHED_IN);
1672 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1673 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1674 gtk_container_add(GTK_CONTAINER(vbox), sw);
1675
1676 store = units_report_store_new();
1677 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1678 gtk_widget_set_vexpand(view, TRUE);
1679 g_object_unref(store);
1680 gtk_widget_set_name(view, "small_font");
1681 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
1682 gtk_container_add(GTK_CONTAINER(sw), view);
1683 preport->tree_view = GTK_TREE_VIEW(view);
1684
1685 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1686 g_signal_connect(selection, "changed",
1687 G_CALLBACK(units_report_selection_callback), preport);
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) {
1693 GtkWidget *header = gtk_label_new(Q_(unit_report_columns[i].title));
1694 if (unit_report_columns[i].tooltip) {
1695 gtk_widget_set_tooltip_text(header,
1696 Q_(unit_report_columns[i].tooltip));
1697 }
1698 gtk_widget_show(header);
1699 col = gtk_tree_view_column_new();
1700 gtk_tree_view_column_set_widget(col, header);
1701 if (unit_report_columns[i].rightalign) {
1702 gtk_tree_view_column_set_alignment(col, 1.0);
1703 }
1704 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1705 } /* else add new renderer to previous TreeViewColumn */
1706
1707 fc_assert(col != NULL);
1708 if (G_TYPE_BOOLEAN == unit_report_columns[i].type) {
1709 renderer = gtk_cell_renderer_toggle_new();
1710 gtk_tree_view_column_pack_start(col, renderer, FALSE);
1711 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1712 } else {
1713 renderer = gtk_cell_renderer_text_new();
1714 gtk_tree_view_column_pack_start(col, renderer, TRUE);
1715 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1716 gtk_tree_view_column_add_attribute(col, renderer,
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",
1722 unit_report_columns[i].visible_col);
1723 }
1724
1725 if (unit_report_columns[i].rightalign) {
1726 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1727 }
1728 }
1729
1730 gui_dialog_add_button(preport->shell, "window-close", _("_Close"),
1731 GTK_RESPONSE_CLOSE);
1732
1733 button = gui_dialog_add_button(preport->shell, NULL, _("_Upgrade"),
1734 URD_RES_UPGRADE);
1735 gtk_widget_set_sensitive(button, FALSE);
1736
1737 button = gui_dialog_add_button(preport->shell, "edit-find",
1738 _("Find _Nearest"), URD_RES_NEAREST);
1739 gtk_widget_set_sensitive(button, FALSE);
1740
1741 gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
1742 gui_dialog_response_set_callback(preport->shell,
1743 units_report_command_callback);
1744
1745 gui_dialog_set_default_size(preport->shell, -1, 350);
1746 gui_dialog_show_all(preport->shell);
1747
1748 units_report_update(preport);
1749 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1750}
1751
1752/************************************************************************/
1755 static void units_report_free(struct units_report *preport)
1756{
1757 fc_assert_ret(NULL != preport);
1758
1759 gui_dialog_destroy(preport->shell);
1760 fc_assert(NULL == preport->shell);
1761
1762 memset(preport, 0, sizeof(*preport));
1763}
1764
1765/************************************************************************/
1768 void units_report_dialog_popup(bool raise)
1769{
1770 if (NULL == units_report.shell) {
1771 units_report_init(&units_report);
1772 }
1773
1774 gui_dialog_present(units_report.shell);
1775 if (raise) {
1776 gui_dialog_raise(units_report.shell);
1777 }
1778}
1779
1780/************************************************************************/
1783 void units_report_dialog_popdown(void)
1784{
1785 if (NULL != units_report.shell) {
1786 units_report_free(&units_report);
1787 fc_assert(NULL == units_report.shell);
1788 }
1789}
1790
1791/************************************************************************/
1794 void real_units_report_dialog_update(void *unused)
1795{
1796 if (NULL != units_report.shell) {
1797 units_report_update(&units_report);
1798 }
1799}
1800
1801
1802/****************************************************************************
1803 FINAL REPORT DIALOG
1804****************************************************************************/
1805 struct endgame_report {
1806 struct gui_dialog *shell;
1807 GtkTreeView *tree_view;
1808 GtkListStore *store;
1809 int player_count;
1810 int players_received;
1811};
1812
1813 enum endgame_report_columns {
1814 FRD_COL_PLAYER,
1815 FRD_COL_NATION,
1816 FRD_COL_SCORE,
1817 FRD_COL_TOOLTIP,
1818
1819 FRD_COL_NUM
1820};
1821
1822 static struct endgame_report endgame_report = { NULL, NULL };
1823
1824/************************************************************************/
1827static const char *
1828endgame_report_column_name(enum endgame_report_columns col)
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/************************************************************************/
1848 static void endgame_report_update(struct endgame_report *preport,
1849 const struct packet_endgame_report *packet)
1850{
1851 const size_t col_num = packet->category_num + FRD_COL_NUM;
1852 GType col_types[col_num];
1853 GtkListStore *store;
1854 GtkTreeViewColumn *col;
1855 int i;
1856
1857 fc_assert_ret(NULL != preport);
1858
1859 /* Remove the old columns. */
1860 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1861 gtk_tree_view_remove_column(preport->tree_view, col);
1862 }
1863
1864 /* Create the new model. */
1865 col_types[FRD_COL_PLAYER] = G_TYPE_STRING;
1866 col_types[FRD_COL_NATION] = GDK_TYPE_PIXBUF;
1867 col_types[FRD_COL_SCORE] = G_TYPE_INT;
1868 col_types[FRD_COL_TOOLTIP] = G_TYPE_STRING;
1869 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1870 col_types[i] = G_TYPE_INT;
1871 }
1872 store = gtk_list_store_newv(col_num, col_types);
1873 gtk_tree_view_set_model(preport->tree_view, GTK_TREE_MODEL(store));
1874 g_object_unref(G_OBJECT(store));
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) {
1891 title = endgame_report_column_name(i);
1892 } else {
1893 title = packet->category_name[i - FRD_COL_NUM];
1894 }
1895
1896 if (title != NULL) {
1897 col = gtk_tree_view_column_new_with_attributes(Q_(title), renderer,
1898 attribute, i, NULL);
1899 gtk_tree_view_append_column(preport->tree_view, col);
1900 if (GDK_TYPE_PIXBUF != col_types[i]) {
1901 gtk_tree_view_column_set_sort_column_id(col, i);
1902 }
1903 }
1904 }
1905
1906 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(preport->tree_view),
1907 FRD_COL_TOOLTIP);
1908
1909 preport->store = store;
1910 preport->player_count = packet->player_num;
1911 preport->players_received = 0;
1912}
1913
1914/************************************************************************/
1917 void endgame_report_dialog_player(const struct packet_endgame_player *packet)
1918{
1919 /* Fill the model with player stats. */
1920 struct endgame_report *preport = &endgame_report;
1921 const struct player *pplayer = player_by_number(packet->player_id);
1922 GtkTreeIter iter;
1923 int i;
1924
1925 gtk_list_store_append(preport->store, &iter);
1926 gtk_list_store_set(preport->store, &iter,
1927 FRD_COL_PLAYER, player_name(pplayer),
1928 FRD_COL_NATION, get_flag(nation_of_player(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++) {
1933 gtk_list_store_set(preport->store, &iter,
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) {
1941 gui_dialog_present(preport->shell);
1942 }
1943}
1944
1945/************************************************************************/
1948 static void endgame_report_init(struct endgame_report *preport)
1949{
1950 GtkWidget *sw, *view;
1951
1952 fc_assert_ret(NULL != preport);
1953
1954 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1955 gui_dialog_set_title(preport->shell, _("Score"));
1956
1957 gui_dialog_set_default_size(preport->shell, 700, 420);
1958
1959 /* Setup the layout. */
1960 sw = gtk_scrolled_window_new(NULL, NULL);
1961 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1962 GTK_SHADOW_ETCHED_IN);
1963 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1964 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1965 gtk_container_add(GTK_CONTAINER(preport->shell->vbox), sw);
1966
1967 view = gtk_tree_view_new();
1968 gtk_widget_set_name(view, "small_font");
1969 gtk_container_add(GTK_CONTAINER(sw), view);
1970 preport->tree_view = GTK_TREE_VIEW(view);
1971
1972 if (preport->shell->type == GUI_DIALOG_TAB) {
1973 gtk_widget_set_hexpand(GTK_WIDGET(view), TRUE);
1974 gtk_widget_set_vexpand(GTK_WIDGET(view), TRUE);
1975 }
1976
1977 gui_dialog_show_all(preport->shell);
1978}
1979
1980/************************************************************************/
1983 void endgame_report_dialog_start(const struct packet_endgame_report *packet)
1984{
1985 if (NULL == endgame_report.shell) {
1986 endgame_report_init(&endgame_report);
1987 }
1988 endgame_report_update(&endgame_report, packet);
1989}
action_ever_possible
bool action_ever_possible(action_id action)
Definition actions.c:7481
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:747
city_list_iterate
#define city_list_iterate(citylist, pcity)
Definition city.h:508
output_type_iterate
#define output_type_iterate(output)
Definition city.h:836
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:842
client_is_global_observer
bool client_is_global_observer(void)
Definition client_main.c:1353
client
struct civclient client
Definition client_main.c:153
can_client_issue_orders
bool can_client_issue_orders(void)
Definition client_main.c:1272
client_has_player
bool client_has_player(void)
Definition client_main.c:1372
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:504
cid_decode
struct universal cid_decode(cid id)
Definition climisc.c:525
cid_encode_unit
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:492
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
event
enum event_type event
Definition events.c:81
fc_types.h
Tech_type_id
int Tech_type_id
Definition fc_types.h:381
Unit_type_id
int Unit_type_id
Definition fc_types.h:386
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
gui_dialog_set_default_response
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:734
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
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
unit_report_columns
static const struct @158 unit_report_columns[]
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
science_diagram_button_release_callback
static gboolean science_diagram_button_release_callback(GtkWidget *widget, GdkEventButton *event, gpointer data)
Definition repodlgs.c:197
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
gui_stuff.h
tooltip
const char * tooltip
Definition repodlgs.c:1347
title
const char * title
Definition repodlgs.c:1346
type
GType type
Definition repodlgs.c:1345
visible_col
int visible_col
Definition repodlgs.c:1349
rightalign
bool rightalign
Definition repodlgs.c:1348
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:647
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:31903
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:31709
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:37301
packhand_gen.h
science_dialog_text
const char * science_dialog_text(void)
Definition text.c:754
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:539
players_iterate
#define players_iterate(_pplayer)
Definition player.h:534
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:1045
get_reqtree_dimensions
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:878
get_tech_on_reqtree
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1185
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:1209
destroy_reqtree
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:478
create_reqtree
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:847
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:1370
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:93
packet_endgame_player::category_num
int category_num
Definition packets_gen.h:94
packet_endgame_player::player_id
int player_id
Definition packets_gen.h:95
packet_endgame_player::category_score
int category_score[32]
Definition packets_gen.h:97
packet_endgame_player::score
int score
Definition packets_gen.h:96
packet_endgame_report
Definition packets_gen.h:87
packet_endgame_report::category_name
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:89
packet_endgame_report::category_num
int category_num
Definition packets_gen.h:88
packet_endgame_report::player_num
int player_num
Definition packets_gen.h:90
player
Definition player.h:249
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::drawing_area
GtkLayout * drawing_area
Definition repodlgs.c:77
science_report::reachable_techs
GtkComboBox * reachable_techs
Definition repodlgs.c:71
science_report::reachable_goals
GtkComboBox * reachable_goals
Definition repodlgs.c:72
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:482
unit_entry
Definition repodlgs_common.h:34
unit_type
Definition unittype.h:507
unit
Definition unit.h:140
unit::upkeep
int upkeep[O_LAST]
Definition unit.h:150
unit::activity
enum unit_activity activity
Definition unit.h:159
unit::moves_left
int moves_left
Definition unit.h:152
unit::client
struct unit::@81::@83 client
unit::homecity
int homecity
Definition unit.h:148
unit::done_moving
bool done_moving
Definition unit.h:184
unit::utype
const struct unit_type * utype
Definition unit.h:141
unit::focus_status
enum unit_focus_status focus_status
Definition unit.h:217
unit::ssa_controller
enum server_side_agent ssa_controller
Definition unit.h:175
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:878
universal::kind
enum universals_n kind
Definition fc_types.h:880
universal::value
universals_u value
Definition fc_types.h:879
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:960
fc_strcoll
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:471
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:253
advance_index_iterate_max_end
#define advance_index_iterate_max_end
Definition tech.h:259
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:2139
get_science_target_text
const char * get_science_target_text(double *percent)
Definition text.c:833
get_science_goal_text
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:879
text.h
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6822
tileset_is_fully_loaded
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7557
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:6844
universals_u::utype
const struct unit_type * utype
Definition fc_types.h:698
universals_u::building
const struct impr_type * building
Definition fc_types.h:691
unit_tile
#define unit_tile(_pu)
Definition unit.h:397
FOCUS_AVAIL
@ FOCUS_AVAIL
Definition unit.h:54
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:859
U_LAST
#define U_LAST
Definition unittype.h:40
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:866