Freeciv-3.1
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.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****************************************************************************/
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
108static struct science_report science_report = { NULL, };
110
111/* Those values must match the function science_report_store_new(). */
115
116 /* Not visible. */
117 SRD_COL_ID, /* Tech_type_id */
118
121
122/************************************************************************/
125static 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/************************************************************************/
136static 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,
144 research_advance_name_translation(presearch, tech),
146 research_goal_unknown_techs(presearch, tech),
147 SRD_COL_ID, tech,
148 -1);
149}
150
151/************************************************************************/
154static bool science_report_combo_get_active(GtkComboBox *combo,
155 Tech_type_id *tech,
156 char **name)
157{
158 GtkTreeIter iter;
159
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,
167 SRD_COL_ID, tech,
168 -1);
169 return TRUE;
170}
171
172/************************************************************************/
175static 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) {
186 gtk_combo_box_set_active_iter(combo, &iter.it);
188 return;
189 }
190 }
191 log_error("%s(): Tech %d not found in the combo.", __FUNCTION__, tech);
192}
193
194/************************************************************************/
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");
203
204 if (tech == A_NONE) {
205 return TRUE;
206 }
207
208 if (event->button == 3) {
209 /* RMB: get help */
211 tech),
212 HELP_TECH);
213 } else {
214 if (event->button == 1 && can_client_issue_orders()) {
215 /* LMB: set research or research goal */
217 tech)) {
218 case TECH_PREREQS_KNOWN:
220 break;
221 case TECH_UNKNOWN:
223 break;
224 case TECH_KNOWN:
225 break;
226 }
227 }
228 }
229 return TRUE;
230}
231
232/************************************************************************/
235static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
236{
237 /* FIXME: this currently redraws everything! */
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
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
261 draw_reqtree(reqtree, &canvas, 0, 0, 0, 0, width, height);
262
263 return TRUE;
264}
265
266/************************************************************************/
270static 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",
282 NULL);
283
284 return diagram;
285}
286
287/************************************************************************/
290static void science_diagram_data(GtkWidget *widget, bool show_all)
291{
292 struct reqtree *reqtree;
293 int width, height;
294
295 if (can_conn_edit(&client.conn)) {
296 /* Show all techs in editor mode, not only currently reachable ones */
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
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/************************************************************************/
312static 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");
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 gtk_adjustment_value_changed(adjust);
334
335 adjust = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw));
336 value = (gtk_adjustment_get_lower(adjust)
337 + gtk_adjustment_get_upper(adjust)
338 - gtk_adjustment_get_page_size(adjust)) / height * y;
339 gtk_adjustment_set_value(adjust, value);
340 gtk_adjustment_value_changed(adjust);
341 }
342}
343
344/************************************************************************/
347static void science_report_redraw(struct science_report *preport)
348{
349 Tech_type_id researching;
350
351 fc_assert_ret(NULL != preport);
352
353 science_diagram_data(GTK_WIDGET(preport->drawing_area),
354 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
355 preport->button_show_all)));
356
357 if (client_has_player()) {
358 researching = research_get(client_player())->researching;
359 } else {
360 researching = A_UNSET;
361 }
362 science_diagram_center(GTK_WIDGET(preport->drawing_area), researching);
363
364 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
365}
366
367/************************************************************************/
370static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
371{
372 const gchar *a_str, *b_str;
373 gint a = GPOINTER_TO_INT(a_p), b = GPOINTER_TO_INT(b_p);
374 const struct research *presearch = research_get(client_player());
375
376 a_str = research_advance_name_translation(presearch, a);
377 b_str = research_advance_name_translation(presearch, b);
378
379 return fc_strcoll(a_str, b_str);
380}
381
382/************************************************************************/
385static void science_report_update(struct science_report *preport)
386{
387 GtkListStore *store;
388 GtkTreeIter iter;
389 GList *sorting_list, *item;
390 struct research *presearch = research_get(client_player());
391 const char *text;
392 double pct;
393 Tech_type_id tech;
394
395 fc_assert_ret(NULL != preport);
396 fc_assert_ret(NULL != presearch);
397
398 /* Disable callbacks. */
400
401 gtk_widget_queue_draw(GTK_WIDGET(preport->drawing_area));
402
403 gtk_label_set_text(preport->main_label, science_dialog_text());
404
405 /* Update the progress bar. */
406 text = get_science_target_text(&pct);
407 gtk_progress_bar_set_text(preport->progress_bar, text);
408 gtk_progress_bar_set_fraction(preport->progress_bar, pct);
409 /* Work around GTK+ refresh bug? */
410 gtk_widget_queue_resize(GTK_WIDGET(preport->progress_bar));
411
412 /* Update reachable techs. */
413 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_techs));
414 gtk_list_store_clear(store);
415 sorting_list = NULL;
416
417 /* Collect all techs which are reachable in the next step. */
419 if (TECH_PREREQS_KNOWN == presearch->inventions[i].state) {
420 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
421 }
423
424 if (sorting_list != NULL) {
425 if (A_UNSET == presearch->researching
426 || is_future_tech(presearch->researching)) {
427 gtk_list_store_append(store, &iter);
428 science_report_store_set(store, &iter, presearch->researching);
429 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
430 }
431
432 /* Sort the list, append it to the store. */
433 sorting_list = g_list_sort(sorting_list, cmp_func);
434 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
435 tech = GPOINTER_TO_INT(item->data);
436 gtk_list_store_append(store, &iter);
437 science_report_store_set(store, &iter, tech);
438 if (tech == presearch->researching) {
439 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
440 }
441 }
442
443 /* Free, re-init. */
444 g_list_free(sorting_list);
445 sorting_list = NULL;
446 } else {
447 /* No reachable normal techs. Can we select Future Tech? */
448 Tech_type_id next;
449
450 gtk_list_store_append(store, &iter);
451 if (research_future_next(presearch)) {
452 next = A_FUTURE;
453 } else {
454 next = presearch->researching;
455 }
456 science_report_store_set(store, &iter, next);
457
458 gtk_combo_box_set_active_iter(preport->reachable_techs, &iter);
459 }
460
461 store = GTK_LIST_STORE(gtk_combo_box_get_model(preport->reachable_goals));
462 gtk_list_store_clear(store);
463
464 /* Update the tech goal. */
465 gtk_label_set_text(preport->goal_label,
466 get_science_goal_text(presearch->tech_goal));
467
468 /* Collect all techs which are reachable in next 10 steps. */
470 if (research_invention_reachable(presearch, i)
471 && TECH_KNOWN != presearch->inventions[i].state
472 && (i == presearch->tech_goal
473 || 10 >= presearch->inventions[i].num_required_techs)) {
474 sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
475 }
477
478 if (sorting_list != NULL) {
479 if (A_UNSET == presearch->tech_goal) {
480 gtk_list_store_append(store, &iter);
481 science_report_store_set(store, &iter, A_UNSET);
482 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
483 }
484
485 /* Sort the list, append it to the store. */
486 sorting_list = g_list_sort(sorting_list, cmp_func);
487 for (item = sorting_list; NULL != item; item = g_list_next(item)) {
488 tech = GPOINTER_TO_INT(item->data);
489 gtk_list_store_append(store, &iter);
490 science_report_store_set(store, &iter, tech);
491 if (tech == presearch->tech_goal) {
492 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
493 }
494 }
495
496 /* Free. */
497 g_list_free(sorting_list);
498 } else {
499 /* No reachable normal techs. Can we select Future Tech? */
500 Tech_type_id goal;
501
502 gtk_list_store_append(store, &iter);
503
504 if (research_future_next(presearch)) {
505 goal = A_FUTURE;
506 } else {
507 goal = A_UNSET;
508 }
509
510 science_report_store_set(store, &iter, goal);
511 gtk_combo_box_set_active_iter(preport->reachable_goals, &iter);
512 }
513
514 /* Re-enable callbacks. */
516}
517
518/************************************************************************/
521static void science_report_current_callback(GtkComboBox *combo,
522 gpointer data)
523{
524 Tech_type_id tech;
525 char *tech_name;
526
527 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
528 return;
529 }
530
531 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data))) {
533 } else if (can_client_issue_orders()) {
535 }
536
537 free(tech_name);
538 /* Revert, or we will not be in sync with the server. */
541}
542
543/************************************************************************/
546static void science_report_show_all_callback(GtkComboBox *combo,
547 gpointer data)
548{
549 struct science_report *preport = (struct science_report *) data;
550
551 science_report_redraw(preport);
552}
553
554/************************************************************************/
557static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
558{
559 Tech_type_id tech;
560 char *tech_name;
561
562 if (!science_report_combo_get_active(combo, &tech, &tech_name)) {
563 return;
564 }
565
566 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data))) {
568 } else if (can_client_issue_orders()) {
570 }
571
572 free(tech_name);
573 /* Revert, or we will not be in sync with the server. */
575 (client_player())->tech_goal);
576}
577
578/************************************************************************/
581static void science_report_init(struct science_report *preport)
582{
583 GtkWidget *frame, *table, *help_button, *show_all_button, *sw, *w;
584 GtkSizeGroup *group;
585 GtkContainer *vbox;
586 GtkListStore *store;
587 GtkCellRenderer *renderer;
588
589 fc_assert_ret(NULL != preport);
590
591 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
592 /* TRANS: Research report title */
593 gui_dialog_set_title(preport->shell, _("Research"));
594
595 gui_dialog_add_button(preport->shell, GTK_STOCK_CLOSE, 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()
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
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/************************************************************************/
703static 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/************************************************************************/
717{
718 struct research *presearch = research_get(client_player());
719
720 if (NULL == science_report.shell) {
722 }
723
724 if (NULL != presearch
725 && A_UNSET == presearch->tech_goal
726 && A_UNSET == presearch->researching) {
728 } else {
730 }
731
732 if (raise) {
734 }
735}
736
737/************************************************************************/
747
748/************************************************************************/
752{
753 if (NULL != science_report.shell) {
755 }
756}
757
758/************************************************************************/
762{
763 if (NULL != science_report.shell) {
765 }
766}
767
768
769/****************************************************************************
770 ECONOMY REPORT DIALOG
771****************************************************************************/
774 GtkTreeView *tree_view;
775 GtkLabel *label;
776};
777
778static struct economy_report economy_report = { NULL, NULL, NULL };
779
785
786/* Those values must match the functions economy_report_store_new() and
787 * economy_report_column_name(). */
803
804/************************************************************************/
807static 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 *
827{
828 switch (col) {
829 case ERD_COL_SPRITE:
830 /* TRANS: Image header */
831 return _("Type");
832 case ERD_COL_NAME:
833 return Q_("?Building or Unit type:Name");
835 return _("Redundant");
836 case ERD_COL_COUNT:
837 return _("Count");
838 case ERD_COL_COST:
839 return _("Cost");
841 /* TRANS: Upkeep total, count*cost. */
842 return _("U Total");
843 case ERD_COL_EMPTY:
844 /* empty space for scrollbar*/
845 return " ";
847 case ERD_COL_CID:
848 case ERD_COL_NUM:
849 break; /* no more columns will be displayed after reaching this */
850 }
851
852 return NULL;
853}
854
855/************************************************************************/
858static 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
895 gtk_list_store_append(store, &iter);
896 gtk_list_store_set(store, &iter,
897 ERD_COL_SPRITE, pix,
900 ERD_COL_COUNT, pentry->count,
901 ERD_COL_COST, pentry->cost,
903 ERD_COL_EMPTY, " ",
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 direction8_invalid());
921 cid id = cid_encode_unit(putype);
922
924 gtk_list_store_append(store, &iter);
925 gtk_list_store_set(store, &iter,
926 ERD_COL_SPRITE, pix,
929 ERD_COL_COUNT, pentry->count,
930 ERD_COL_COST, pentry->cost,
932 ERD_COL_EMPTY, " ",
934 ERD_COL_CID, id,
935 -1);
936 g_object_unref(G_OBJECT(pix));
937 if (selected == id) {
938 /* Restore the selection. */
939 gtk_tree_selection_select_iter(selection, &iter);
940 }
941 }
942
943 /* Update the label. */
944 fc_snprintf(buf, sizeof(buf), _("Income: %d Total Costs: %d"),
945 tax, building_total + unit_total);
946 gtk_label_set_text(preport->label, buf);
947}
948
949/************************************************************************/
952static void economy_report_command_callback(struct gui_dialog *pdialog,
953 int response,
954 gpointer data)
955{
956 struct economy_report *preport = data;
957 GtkTreeSelection *selection = gtk_tree_view_get_selection(preport->tree_view);
958 GtkTreeModel *model;
959 GtkTreeIter iter;
960 GtkWidget *shell;
961 struct universal selected;
962 cid id;
963 char buf[256] = "";
964
965 switch (response) {
967 case ERD_RES_SELL_ALL:
969 break;
970 default:
971 gui_dialog_destroy(pdialog);
972 return;
973 }
974
976 || !gtk_tree_selection_get_selected(selection, &model, &iter)) {
977 return;
978 }
979
980 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
981 selected = cid_decode(id);
982
983 switch (selected.kind) {
984 case VUT_IMPROVEMENT:
985 {
986 const struct impr_type *pimprove = selected.value.building;
987
988 if (can_sell_building(pimprove)
989 && (ERD_RES_SELL_ALL == response
990 || (ERD_RES_SELL_REDUNDANT == response))) {
991 bool redundant = (ERD_RES_SELL_REDUNDANT == response);
992 gint count;
993 gtk_tree_model_get(model, &iter,
994 redundant ? ERD_COL_REDUNDANT : ERD_COL_COUNT,
995 &count, -1);
996 if (count == 0) {
997 break;
998 }
999 shell = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL
1000 | GTK_DIALOG_DESTROY_WITH_PARENT,
1001 GTK_MESSAGE_QUESTION,
1002 GTK_BUTTONS_YES_NO,
1003 redundant
1004 /* TRANS: %s is an improvement */
1005 ? _("Do you really wish to sell "
1006 "every redundant %s (%d total)?")
1007 /* TRANS: %s is an improvement */
1008 : _("Do you really wish to sell "
1009 "every %s (%d total)?"),
1011 count);
1013 gtk_window_set_title(GTK_WINDOW(shell), _("Sell Improvements"));
1014
1015 if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(shell))) {
1016 sell_all_improvements(pimprove, redundant, buf, sizeof(buf));
1017 }
1018 gtk_widget_destroy(shell);
1019 }
1020 }
1021 break;
1022 case VUT_UTYPE:
1023 {
1024 if (ERD_RES_DISBAND_UNITS == response) {
1025 const struct unit_type *putype = selected.value.utype;
1026 gint count;
1027
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);
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);
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/************************************************************************/
1068static 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
1076 && gtk_tree_selection_get_selected(selection, &model, &iter)) {
1077 struct universal selected;
1078 cid id;
1079
1080 gtk_tree_model_get(model, &iter, ERD_COL_CID, &id, -1);
1081 selected = cid_decode(id);
1082 switch (selected.kind) {
1083 case VUT_IMPROVEMENT:
1084 {
1085 bool can_sell = can_sell_building(selected.value.building);
1086 gint redundant;
1087 gtk_tree_model_get(model, &iter, ERD_COL_REDUNDANT, &redundant, -1);
1088
1090 can_sell && redundant > 0);
1093 FALSE);
1094 }
1095 return;
1096 case VUT_UTYPE:
1098 FALSE);
1101 TRUE);
1102 return;
1103 default:
1104 log_error("Not supported type: %d.", selected.kind);
1105 break;
1106 }
1107 }
1108
1112}
1113
1114/************************************************************************/
1117static 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;
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",
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_left(label, 5);
1195 gtk_widget_set_margin_right(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, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
1201
1202 button = gui_dialog_add_button(preport->shell, _("_Disband"),
1204 gtk_widget_set_sensitive(button, FALSE);
1205
1206 button = gui_dialog_add_button(preport->shell, _("Sell _All"),
1208 gtk_widget_set_sensitive(button, FALSE);
1209
1210 button = gui_dialog_add_button(preport->shell, _("Sell _Redundant"),
1212 gtk_widget_set_sensitive(button, FALSE);
1213
1214 gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
1217
1218 gui_dialog_set_default_size(preport->shell, -1, 350);
1219 gui_dialog_show_all(preport->shell);
1220
1221 economy_report_update(preport);
1222
1223 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1224}
1225
1226/************************************************************************/
1229static void economy_report_free(struct economy_report *preport)
1230{
1231 fc_assert_ret(NULL != preport);
1232
1233 gui_dialog_destroy(preport->shell);
1234 fc_assert(NULL == preport->shell);
1235
1236 memset(preport, 0, sizeof(*preport));
1237}
1238
1239/************************************************************************/
1243{
1244 if (NULL == economy_report.shell) {
1246 }
1247
1249 if (raise) {
1251 }
1252}
1253
1254/************************************************************************/
1258{
1259 if (NULL != economy_report.shell) {
1261 }
1262}
1263
1264/************************************************************************/
1268{
1269 if (NULL != economy_report.shell) {
1271 }
1272}
1273
1274
1275/****************************************************************************
1276 UNITS REPORT DIALOG
1277****************************************************************************/
1280 GtkTreeView *tree_view;
1281};
1282
1283static struct units_report units_report = { NULL, NULL };
1284
1289
1290/* Those values must match the order of unit_report_columns[]. */
1310
1311static const struct {
1312 GType type;
1313 const char *title;
1314 const char *tooltip;
1317} unit_report_columns[] = {
1318 { /* URD_COL_UTYPE_NAME */ G_TYPE_STRING, N_("Unit Type"),
1319 NULL, FALSE, -1 },
1320 { /* URD_COL_UPGRADABLE */ G_TYPE_BOOLEAN, N_("?Upgradable unit [short]:U"),
1321 N_("Upgradable"), TRUE, URD_COL_UPG_VISIBLE },
1322 { /* URD_COL_N_UPGRADABLE */ G_TYPE_INT, "" /* merge with previous col */,
1323 NULL, TRUE, URD_COL_NUPG_VISIBLE },
1324 /* TRANS: "In progress" abbreviation. */
1325 { /* URD_COL_IN_PROGRESS */ G_TYPE_INT, N_("In-Prog"),
1326 N_("In progress"), TRUE, -1 },
1327 { /* URD_COL_ACTIVE */ G_TYPE_INT, N_("Active"),
1328 NULL, TRUE, -1 },
1329 { /* URD_COL_SHIELD */ G_TYPE_INT, N_("Shield"),
1330 N_("Total shield upkeep"), TRUE, -1 },
1331 { /* URD_COL_FOOD */ G_TYPE_INT, N_("Food"),
1332 N_("Total food upkeep"), TRUE, -1 },
1333 { /* URD_COL_GOLD */ G_TYPE_INT, N_("Gold"),
1334 N_("Total gold upkeep"), TRUE, -1 },
1335 { /* URD_COL_EMPTY */ G_TYPE_STRING, " ",
1336 " ", TRUE, -1 },
1337
1338 { /* URD_COL_TEXT_WEIGHT */ G_TYPE_INT, NULL /* ... */ },
1339 { /* URD_COL_UPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1340 { /* URD_COL_NUPG_VISIBLE */ G_TYPE_BOOLEAN, NULL /* ... */ },
1341 { /* URD_COL_UTYPE_ID */ G_TYPE_INT, NULL /* ... */ }
1343
1344/************************************************************************/
1347static GtkListStore *units_report_store_new(void)
1348{
1349 int i;
1350 GType cols[URD_COL_NUM];
1352
1353 for (i=0; i<URD_COL_NUM; i++) {
1354 cols[i] = unit_report_columns[i].type;
1355 }
1356
1357 return gtk_list_store_newv(URD_COL_NUM, cols);
1358}
1359
1360/************************************************************************/
1363static void units_report_update(struct units_report *preport)
1364{
1365 struct urd_info {
1366 int active_count;
1367 int building_count;
1368 int upkeep[O_LAST];
1369 };
1370
1371 struct urd_info unit_array[utype_count()];
1372 struct urd_info unit_totals;
1373 struct urd_info *info;
1374 int total_upgradable_count = 0;
1375 GtkTreeSelection *selection;
1376 GtkTreeModel *model;
1377 GtkListStore *store;
1378 GtkTreeIter iter;
1379 Unit_type_id selected, utype_id;
1380
1381 fc_assert_ret(NULL != preport);
1382
1383 memset(unit_array, '\0', sizeof(unit_array));
1384 memset(&unit_totals, '\0', sizeof(unit_totals));
1385
1386 /* Count units. */
1387 players_iterate(pplayer) {
1388 if (client_has_player() && pplayer != client_player()) {
1389 continue;
1390 }
1391
1392 unit_list_iterate(pplayer->units, punit) {
1393 info = unit_array + utype_index(unit_type_get(punit));
1394
1395 if (0 != punit->homecity) {
1397 info->upkeep[o] += punit->upkeep[o];
1399 }
1400 info->active_count++;
1402 city_list_iterate(pplayer->cities, pcity) {
1403 if (VUT_UTYPE == pcity->production.kind) {
1404 int num_units;
1405 info = unit_array + utype_index(pcity->production.value.utype);
1406 /* Account for build slots in city */
1407 (void) city_production_build_units(pcity, TRUE, &num_units);
1408 /* Unit is in progress even if it won't be done this turn */
1409 num_units = MAX(num_units, 1);
1410 info->building_count += num_units;
1411 }
1414
1415 /* Save selection. */
1416 selection = gtk_tree_view_get_selection(preport->tree_view);
1417 if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
1418 gtk_tree_model_get(model, &iter, URD_COL_UTYPE_ID, &selected, -1);
1419 } else {
1420 selected = -1;
1421 }
1422
1423 /* Make the store. */
1424 model = gtk_tree_view_get_model(preport->tree_view);
1425 store = GTK_LIST_STORE(model);
1426 gtk_list_store_clear(store);
1427
1428 unit_type_iterate(utype) {
1429 bool upgradable;
1430
1431 utype_id = utype_index(utype);
1432 info = unit_array + utype_id;
1433
1434 if (0 == info->active_count && 0 == info->building_count) {
1435 continue; /* We don't need a row for this type. */
1436 }
1437
1438 upgradable = client_has_player()
1439 && NULL != can_upgrade_unittype(client_player(), utype);
1440
1441 gtk_list_store_append(store, &iter);
1442 gtk_list_store_set(store, &iter,
1444 URD_COL_UPGRADABLE, upgradable,
1445 URD_COL_N_UPGRADABLE, 0, /* never displayed */
1446 URD_COL_IN_PROGRESS, info->building_count,
1447 URD_COL_ACTIVE, info->active_count,
1448 URD_COL_SHIELD, info->upkeep[O_SHIELD],
1449 URD_COL_FOOD, info->upkeep[O_FOOD],
1450 URD_COL_GOLD, info->upkeep[O_GOLD],
1451 URD_COL_EMPTY, " ",
1452 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_NORMAL,
1455 URD_COL_UTYPE_ID, utype_id,
1456 -1);
1457 if (selected == utype_id) {
1458 /* Restore the selection. */
1459 gtk_tree_selection_select_iter(selection, &iter);
1460 }
1461
1462 /* Update totals. */
1463 unit_totals.active_count += info->active_count;
1465 unit_totals.upkeep[o] += info->upkeep[o];
1467 unit_totals.building_count += info->building_count;
1468 if (upgradable) {
1469 total_upgradable_count += info->active_count;
1470 }
1472
1473 /* Add the total row. */
1474 gtk_list_store_append(store, &iter);
1475 gtk_list_store_set(store, &iter,
1476 URD_COL_UTYPE_NAME, _("Totals:"),
1477 URD_COL_UPGRADABLE, FALSE, /* never displayed */
1478 URD_COL_N_UPGRADABLE, total_upgradable_count,
1479 URD_COL_IN_PROGRESS, unit_totals.building_count,
1480 URD_COL_ACTIVE, unit_totals.active_count,
1481 URD_COL_SHIELD, unit_totals.upkeep[O_SHIELD],
1482 URD_COL_FOOD, unit_totals.upkeep[O_FOOD],
1483 URD_COL_GOLD, unit_totals.upkeep[O_GOLD],
1484 URD_COL_EMPTY, " ",
1485 URD_COL_TEXT_WEIGHT, PANGO_WEIGHT_BOLD,
1489 -1);
1490 if (selected == U_LAST) {
1491 /* Restore the selection. */
1492 gtk_tree_selection_select_iter(selection, &iter);
1493 }
1494}
1495
1496/************************************************************************/
1499static void units_report_selection_callback(GtkTreeSelection *selection,
1500 gpointer data)
1501{
1502 struct units_report *preport = data;
1503 GtkTreeModel *model;
1504 GtkTreeIter it;
1505 int active_count;
1506 struct unit_type *utype = NULL;
1507
1508 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1509 int ut;
1510
1511 gtk_tree_model_get(model, &it,
1512 URD_COL_ACTIVE, &active_count,
1513 URD_COL_UTYPE_ID, &ut,
1514 -1);
1515 if (0 < active_count) {
1516 utype = utype_by_number(ut);
1517 }
1518 }
1519
1520 if (NULL == utype) {
1522 FALSE);
1524 FALSE);
1525 } else {
1529 && action_ever_possible(ACTION_UPGRADE_UNIT)
1530 && NULL != can_upgrade_unittype(client_player(), utype)));
1531 }
1532}
1533
1534/************************************************************************/
1537static struct unit *find_nearest_unit(const struct unit_type *utype,
1538 struct tile *ptile)
1539{
1540 struct unit *best_candidate = NULL;
1541 int best_dist = FC_INFINITY, dist;
1542
1543 players_iterate(pplayer) {
1544 if (client_has_player() && pplayer != client_player()) {
1545 continue;
1546 }
1547
1548 unit_list_iterate(pplayer->units, punit) {
1549 if (utype == unit_type_get(punit)
1551 && 0 < punit->moves_left
1552 && !punit->done_moving
1553 && punit->ssa_controller == SSA_NONE) {
1554 dist = sq_map_distance(unit_tile(punit), ptile);
1555 if (dist < best_dist) {
1556 best_candidate = punit;
1557 best_dist = dist;
1558 }
1559 }
1562
1563 return best_candidate;
1564}
1565
1566/************************************************************************/
1569static void units_report_command_callback(struct gui_dialog *pdialog,
1570 int response,
1571 gpointer data)
1572{
1573 struct units_report *preport = data;
1574 struct unit_type *utype = NULL;
1575 GtkTreeSelection *selection;
1576 GtkTreeModel *model;
1577 GtkTreeIter it;
1578
1579 switch (response) {
1580 case URD_RES_NEAREST:
1581 case URD_RES_UPGRADE:
1582 break;
1583 default:
1584 gui_dialog_destroy(pdialog);
1585 return;
1586 }
1587
1588 /* Nearest & upgrade commands. */
1589 selection = gtk_tree_view_get_selection(preport->tree_view);
1590 if (gtk_tree_selection_get_selected(selection, &model, &it)) {
1591 int ut;
1592
1593 gtk_tree_model_get(model, &it, URD_COL_UTYPE_ID, &ut, -1);
1594 utype = utype_by_number(ut);
1595 }
1596
1597 if (response == URD_RES_NEAREST) {
1598 struct tile *ptile;
1599 struct unit *punit;
1600
1601 ptile = get_center_tile_mapcanvas();
1602 if ((punit = find_nearest_unit(utype, ptile))) {
1604
1605 if (ACTIVITY_IDLE == punit->activity
1606 || ACTIVITY_SENTRY == punit->activity) {
1607 if (can_unit_do_activity_client(punit, ACTIVITY_IDLE)) {
1609 }
1610 }
1611 }
1612 } else if (can_client_issue_orders()) {
1613 GtkWidget *shell;
1614 const struct unit_type *upgrade = can_upgrade_unittype(client_player(), utype);
1615 char buf[1024];
1616 int price = unit_upgrade_price(client_player(), utype, upgrade);
1617
1618 fc_snprintf(buf, ARRAY_SIZE(buf), PL_("Treasury contains %d gold.",
1619 "Treasury contains %d gold.",
1620 client_player()->economic.gold),
1621 client_player()->economic.gold);
1622
1623 shell = gtk_message_dialog_new(NULL,
1624 GTK_DIALOG_MODAL
1625 | GTK_DIALOG_DESTROY_WITH_PARENT,
1626 GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
1627 /* TRANS: Last %s is pre-pluralised
1628 * "Treasury contains %d gold." */
1629 PL_("Upgrade as many %s to %s as possible "
1630 "for %d gold each?\n%s",
1631 "Upgrade as many %s to %s as possible "
1632 "for %d gold each?\n%s", price),
1634 utype_name_translation(upgrade),
1635 price, buf);
1637
1638 gtk_window_set_title(GTK_WINDOW(shell), _("Upgrade Obsolete Units"));
1639
1640 if (GTK_RESPONSE_YES == gtk_dialog_run(GTK_DIALOG(shell))) {
1642 }
1643
1644 gtk_widget_destroy(shell);
1645 }
1646}
1647
1648/************************************************************************/
1651static void units_report_init(struct units_report *preport)
1652{
1653 GtkWidget *view, *sw, *button;
1654 GtkListStore *store;
1655 GtkTreeSelection *selection;
1656 GtkContainer *vbox;
1657 GtkTreeViewColumn *col = NULL;
1658 enum units_report_columns i;
1659
1660 fc_assert_ret(NULL != preport);
1661
1662 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), preport, TRUE);
1663 gui_dialog_set_title(preport->shell, _("Units"));
1664 vbox = GTK_CONTAINER(preport->shell->vbox);
1665
1666 sw = gtk_scrolled_window_new(NULL,NULL);
1667 gtk_widget_set_halign(sw, GTK_ALIGN_CENTER);
1668 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1669 GTK_SHADOW_ETCHED_IN);
1670 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1671 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1672 gtk_container_add(GTK_CONTAINER(vbox), sw);
1673
1674 store = units_report_store_new();
1675 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1676 gtk_widget_set_vexpand(view, TRUE);
1677 g_object_unref(store);
1678 gtk_widget_set_name(view, "small_font");
1679 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(view));
1680 gtk_container_add(GTK_CONTAINER(sw), view);
1681 preport->tree_view = GTK_TREE_VIEW(view);
1682
1683 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1684 g_signal_connect(selection, "changed",
1685 G_CALLBACK(units_report_selection_callback), preport);
1686
1687 for (i = 0; unit_report_columns[i].title != NULL; i++) {
1688 GtkCellRenderer *renderer;
1689
1690 if (strlen(unit_report_columns[i].title) > 0) {
1691 GtkWidget *header = gtk_label_new(Q_(unit_report_columns[i].title));
1693 gtk_widget_set_tooltip_text(header,
1695 }
1696 gtk_widget_show(header);
1697 col = gtk_tree_view_column_new();
1698 gtk_tree_view_column_set_widget(col, header);
1700 gtk_tree_view_column_set_alignment(col, 1.0);
1701 }
1702 gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
1703 } /* else add new renderer to previous TreeViewColumn */
1704
1705 fc_assert(col != NULL);
1706 if (G_TYPE_BOOLEAN == unit_report_columns[i].type) {
1707 renderer = gtk_cell_renderer_toggle_new();
1708 gtk_tree_view_column_pack_start(col, renderer, FALSE);
1709 gtk_tree_view_column_add_attribute(col, renderer, "active", i);
1710 } else {
1711 renderer = gtk_cell_renderer_text_new();
1712 gtk_tree_view_column_pack_start(col, renderer, TRUE);
1713 gtk_tree_view_column_add_attribute(col, renderer, "text", i);
1714 gtk_tree_view_column_add_attribute(col, renderer,
1715 "weight", URD_COL_TEXT_WEIGHT);
1716 }
1717
1718 if (unit_report_columns[i].visible_col >= 0) {
1719 gtk_tree_view_column_add_attribute(col, renderer, "visible",
1721 }
1722
1724 g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
1725 }
1726 }
1727
1728 gui_dialog_add_button(preport->shell, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
1729
1730 button = gui_dialog_add_button(preport->shell, _("_Upgrade"),
1732 gtk_widget_set_sensitive(button, FALSE);
1733
1734 button = gui_dialog_add_stockbutton(preport->shell, GTK_STOCK_FIND,
1735 _("Find _Nearest"), URD_RES_NEAREST);
1736 gtk_widget_set_sensitive(button, FALSE);
1737
1738 gui_dialog_set_default_response(preport->shell, GTK_RESPONSE_CLOSE);
1741
1742 gui_dialog_set_default_size(preport->shell, -1, 350);
1743 gui_dialog_show_all(preport->shell);
1744
1745 units_report_update(preport);
1746 gtk_tree_view_focus(GTK_TREE_VIEW(view));
1747}
1748
1749/************************************************************************/
1752static void units_report_free(struct units_report *preport)
1753{
1754 fc_assert_ret(NULL != preport);
1755
1756 gui_dialog_destroy(preport->shell);
1757 fc_assert(NULL == preport->shell);
1758
1759 memset(preport, 0, sizeof(*preport));
1760}
1761
1762/************************************************************************/
1766{
1767 if (NULL == units_report.shell) {
1769 }
1770
1772 if (raise) {
1774 }
1775}
1776
1777/************************************************************************/
1781{
1782 if (NULL != units_report.shell) {
1784 fc_assert(NULL == units_report.shell);
1785 }
1786}
1787
1788/************************************************************************/
1792{
1793 if (NULL != units_report.shell) {
1795 }
1796}
1797
1798
1799/****************************************************************************
1800 FINAL REPORT DIALOG
1801****************************************************************************/
1804 GtkTreeView *tree_view;
1805 GtkListStore *store;
1808};
1809
1818
1819static struct endgame_report endgame_report = { NULL, NULL };
1820
1821/************************************************************************/
1824static const char *
1826{
1827 switch (col) {
1828 case FRD_COL_PLAYER:
1829 return _("Player\n");
1830 case FRD_COL_NATION:
1831 return _("Nation\n");
1832 case FRD_COL_SCORE:
1833 return _("Score\n");
1834 case FRD_COL_TOOLTIP:
1835 case FRD_COL_NUM:
1836 break;
1837 }
1838
1839 return NULL;
1840}
1841
1842/************************************************************************/
1845static void endgame_report_update(struct endgame_report *preport,
1846 const struct packet_endgame_report *packet)
1847{
1848 const size_t col_num = packet->category_num + FRD_COL_NUM;
1849 GType col_types[col_num];
1850 GtkListStore *store;
1851 GtkTreeViewColumn *col;
1852 int i;
1853
1854 fc_assert_ret(NULL != preport);
1855
1856 /* Remove the old columns. */
1857 while ((col = gtk_tree_view_get_column(preport->tree_view, 0))) {
1858 gtk_tree_view_remove_column(preport->tree_view, col);
1859 }
1860
1861 /* Create the new model. */
1862 col_types[FRD_COL_PLAYER] = G_TYPE_STRING;
1863 col_types[FRD_COL_NATION] = GDK_TYPE_PIXBUF;
1864 col_types[FRD_COL_SCORE] = G_TYPE_INT;
1865 col_types[FRD_COL_TOOLTIP] = G_TYPE_STRING;
1866 for (i = FRD_COL_NUM; (guint)i < col_num; i++) {
1867 col_types[i] = G_TYPE_INT;
1868 }
1869 store = gtk_list_store_newv(col_num, col_types);
1870 gtk_tree_view_set_model(preport->tree_view, GTK_TREE_MODEL(store));
1871 g_object_unref(G_OBJECT(store));
1872
1873 /* Create the new columns. */
1874 for (i = 0; (guint)i < col_num; i++) {
1875 GtkCellRenderer *renderer;
1876 const char *title;
1877 const char *attribute;
1878
1879 if (GDK_TYPE_PIXBUF == col_types[i]) {
1880 renderer = gtk_cell_renderer_pixbuf_new();
1881 attribute = "pixbuf";
1882 } else {
1883 renderer = gtk_cell_renderer_text_new();
1884 attribute = "text";
1885 }
1886
1887 if (i < FRD_COL_NUM) {
1889 } else {
1890 title = packet->category_name[i - FRD_COL_NUM];
1891 }
1892
1893 if (title != NULL) {
1894 col = gtk_tree_view_column_new_with_attributes(Q_(title), renderer,
1895 attribute, i, NULL);
1896 gtk_tree_view_append_column(preport->tree_view, col);
1897 if (GDK_TYPE_PIXBUF != col_types[i]) {
1898 gtk_tree_view_column_set_sort_column_id(col, i);
1899 }
1900 }
1901 }
1902
1903 gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(preport->tree_view),
1905
1906 preport->store = store;
1907 preport->player_count = packet->player_num;
1908 preport->players_received = 0;
1909}
1910
1911/************************************************************************/
1915{
1916 /* Fill the model with player stats. */
1917 struct endgame_report *preport = &endgame_report;
1918 const struct player *pplayer = player_by_number(packet->player_id);
1919 GtkTreeIter iter;
1920 int i;
1921
1922 gtk_list_store_append(preport->store, &iter);
1923 gtk_list_store_set(preport->store, &iter,
1924 FRD_COL_PLAYER, player_name(pplayer),
1926 FRD_COL_SCORE, packet->score,
1927 FRD_COL_TOOLTIP, score_tooltip(pplayer, packet->score),
1928 -1);
1929 for (i = 0; i < packet->category_num; i++) {
1930 gtk_list_store_set(preport->store, &iter,
1931 i + FRD_COL_NUM, packet->category_score[i],
1932 -1);
1933 }
1934
1935 preport->players_received++;
1936
1937 if (preport->players_received == preport->player_count) {
1938 gui_dialog_present(preport->shell);
1939 }
1940}
1941
1942/************************************************************************/
1945static void endgame_report_init(struct endgame_report *preport)
1946{
1947 GtkWidget *sw, *view;
1948
1949 fc_assert_ret(NULL != preport);
1950
1951 gui_dialog_new(&preport->shell, GTK_NOTEBOOK(top_notebook), NULL, TRUE);
1952 gui_dialog_set_title(preport->shell, _("Score"));
1953
1954 gui_dialog_set_default_size(preport->shell, 700, 420);
1955
1956 /* Setup the layout. */
1957 sw = gtk_scrolled_window_new(NULL, NULL);
1958 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
1959 GTK_SHADOW_ETCHED_IN);
1960 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
1961 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
1962 gtk_container_add(GTK_CONTAINER(preport->shell->vbox), sw);
1963
1964 view = gtk_tree_view_new();
1965 gtk_widget_set_name(view, "small_font");
1966 gtk_container_add(GTK_CONTAINER(sw), view);
1967 preport->tree_view = GTK_TREE_VIEW(view);
1968
1969 if (preport->shell->type == GUI_DIALOG_TAB) {
1970 gtk_widget_set_hexpand(GTK_WIDGET(view), TRUE);
1971 gtk_widget_set_vexpand(GTK_WIDGET(view), TRUE);
1972 }
1973
1974 gui_dialog_show_all(preport->shell);
1975}
1976
1977/************************************************************************/
1981{
1982 if (NULL == endgame_report.shell) {
1984 }
1986}
bool action_ever_possible(action_id action)
Definition actions.c:9305
int entries_used
Definition agents.c:74
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
bool city_production_build_units(const struct city *pcity, bool add_production, int *num_units)
Definition city.c:732
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define output_type_iterate(output)
Definition city.h:821
#define city_list_iterate_end
Definition city.h:490
#define output_type_iterate_end
Definition city.h:827
bool client_is_global_observer(void)
struct civclient client
bool can_client_issue_orders(void)
bool client_has_player(void)
#define client_player()
cid cid_encode_building(const struct impr_type *pimprove)
Definition climisc.c:498
struct universal cid_decode(cid id)
Definition climisc.c:519
cid cid_encode_unit(const struct unit_type *punittype)
Definition climisc.c:486
int cid
Definition climisc.h:31
bool can_conn_edit(const struct connection *pconn)
Definition connection.c:510
void unit_focus_set_and_select(struct unit *punit)
Definition control.c:637
#define can_unit_do_activity_client(_punit_, _act_)
Definition control.h:40
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
int int id
Definition editgui_g.h:28
enum event_type event
Definition events.c:81
int Tech_type_id
Definition fc_types.h:347
int Unit_type_id
Definition fc_types.h:352
@ O_SHIELD
Definition fc_types.h:91
@ O_FOOD
Definition fc_types.h:91
@ O_GOLD
Definition fc_types.h:91
@ O_LAST
Definition fc_types.h:91
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
GtkWidget * top_notebook
Definition gui_main.c:128
void gtk_tree_view_focus(GtkTreeView *view)
Definition gui_stuff.c:230
void gui_dialog_destroy(struct gui_dialog *dlg)
Definition gui_stuff.c:951
void gui_dialog_present(struct gui_dialog *dlg)
Definition gui_stuff.c:834
void gui_dialog_set_default_response(struct gui_dialog *dlg, int response)
Definition gui_stuff.c:733
void itree_get(ITree *it,...)
Definition gui_stuff.c:158
void gui_dialog_raise(struct gui_dialog *dlg)
Definition gui_stuff.c:864
void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gpointer user_data, bool check_top)
Definition gui_stuff.c:504
void gui_dialog_response_set_callback(struct gui_dialog *dlg, GUI_DIALOG_RESPONSE_FUN fun)
Definition gui_stuff.c:985
void itree_begin(GtkTreeModel *model, ITree *it)
Definition gui_stuff.c:121
GtkWidget * gui_dialog_add_button(struct gui_dialog *dlg, const char *text, int response)
Definition gui_stuff.c:706
GtkWidget * gui_dialog_add_stockbutton(struct gui_dialog *dlg, const char *stock, const char *text, int response)
Definition gui_stuff.c:690
void gui_dialog_show_all(struct gui_dialog *dlg)
Definition gui_stuff.c:794
void gui_dialog_set_title(struct gui_dialog *dlg, const char *title)
Definition gui_stuff.c:932
void gui_dialog_set_default_size(struct gui_dialog *dlg, int width, int height)
Definition gui_stuff.c:916
void gui_dialog_alert(struct gui_dialog *dlg)
Definition gui_stuff.c:887
void itree_next(ITree *it)
Definition gui_stuff.c:138
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
void gui_dialog_set_response_sensitive(struct gui_dialog *dlg, int response, bool setting)
Definition gui_stuff.c:759
GtkWidget * gui_dialog_get_toplevel(struct gui_dialog *dlg)
Definition gui_stuff.c:786
gboolean itree_end(ITree *it)
Definition gui_stuff.c:130
@ GUI_DIALOG_TAB
Definition gui_stuff.h:61
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:195
static struct gui_dialog * shell
Definition messagedlg.c:39
GdkPixbuf * get_flag(const struct nation_type *nation)
Definition plrdlg.c:609
static struct endgame_report endgame_report
Definition repodlgs.c:1819
static void units_report_init(struct units_report *preport)
Definition repodlgs.c:1651
void units_report_dialog_popdown(void)
Definition repodlgs.c:1780
static GtkListStore * units_report_store_new(void)
Definition repodlgs.c:1347
void science_report_dialog_popup(bool raise)
Definition repodlgs.c:716
static void science_report_store_set(GtkListStore *store, GtkTreeIter *iter, Tech_type_id tech)
Definition repodlgs.c:136
static void economy_report_init(struct economy_report *preport)
Definition repodlgs.c:1117
static void science_report_update(struct science_report *preport)
Definition repodlgs.c:385
static void units_report_update(struct units_report *preport)
Definition repodlgs.c:1363
static bool science_report_combo_get_active(GtkComboBox *combo, Tech_type_id *tech, char **name)
Definition repodlgs.c:154
void endgame_report_dialog_start(const struct packet_endgame_report *packet)
Definition repodlgs.c:1980
static void science_diagram_center(GtkWidget *diagram, Tech_type_id tech)
Definition repodlgs.c:312
units_report_response
Definition repodlgs.c:1285
@ URD_RES_UPGRADE
Definition repodlgs.c:1287
@ URD_RES_NEAREST
Definition repodlgs.c:1286
static void endgame_report_update(struct endgame_report *preport, const struct packet_endgame_report *packet)
Definition repodlgs.c:1845
void real_units_report_dialog_update(void *unused)
Definition repodlgs.c:1791
void real_economy_report_dialog_update(void *unused)
Definition repodlgs.c:1267
const char * tooltip
Definition repodlgs.c:1314
void economy_report_dialog_popdown(void)
Definition repodlgs.c:1257
static gboolean science_diagram_update(GtkWidget *widget, cairo_t *cr, gpointer data)
Definition repodlgs.c:235
static gboolean science_diagram_button_release_callback(GtkWidget *widget, GdkEventButton *event, gpointer data)
Definition repodlgs.c:197
static const char * endgame_report_column_name(enum endgame_report_columns col)
Definition repodlgs.c:1825
void economy_report_dialog_popup(bool raise)
Definition repodlgs.c:1242
static void endgame_report_init(struct endgame_report *preport)
Definition repodlgs.c:1945
static void science_report_combo_set_active(GtkComboBox *combo, Tech_type_id tech)
Definition repodlgs.c:175
const char * title
Definition repodlgs.c:1313
static void science_diagram_data(GtkWidget *widget, bool show_all)
Definition repodlgs.c:290
static void science_report_free(struct science_report *preport)
Definition repodlgs.c:703
static bool science_report_no_combo_callback
Definition repodlgs.c:109
static const struct @155 unit_report_columns[]
void units_report_dialog_popup(bool raise)
Definition repodlgs.c:1765
static void economy_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:952
GType type
Definition repodlgs.c:1312
static void units_report_command_callback(struct gui_dialog *pdialog, int response, gpointer data)
Definition repodlgs.c:1569
static void units_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1499
static void economy_report_update(struct economy_report *preport)
Definition repodlgs.c:858
void science_report_dialog_redraw(void)
Definition repodlgs.c:761
units_report_columns
Definition repodlgs.c:1291
@ URD_COL_NUM
Definition repodlgs.c:1308
@ URD_COL_UPG_VISIBLE
Definition repodlgs.c:1304
@ URD_COL_ACTIVE
Definition repodlgs.c:1296
@ URD_COL_IN_PROGRESS
Definition repodlgs.c:1295
@ URD_COL_TEXT_WEIGHT
Definition repodlgs.c:1303
@ URD_COL_GOLD
Definition repodlgs.c:1299
@ URD_COL_UPGRADABLE
Definition repodlgs.c:1293
@ URD_COL_FOOD
Definition repodlgs.c:1298
@ URD_COL_N_UPGRADABLE
Definition repodlgs.c:1294
@ URD_COL_NUPG_VISIBLE
Definition repodlgs.c:1305
@ URD_COL_UTYPE_NAME
Definition repodlgs.c:1292
@ URD_COL_UTYPE_ID
Definition repodlgs.c:1306
@ URD_COL_SHIELD
Definition repodlgs.c:1297
@ URD_COL_EMPTY
Definition repodlgs.c:1300
science_report_columns
Definition repodlgs.c:112
@ SRD_COL_ID
Definition repodlgs.c:117
@ SRD_COL_NAME
Definition repodlgs.c:113
@ SRD_COL_NUM
Definition repodlgs.c:119
@ SRD_COL_STEPS
Definition repodlgs.c:114
static const char * economy_report_column_name(enum economy_report_columns col)
Definition repodlgs.c:826
static GtkWidget * science_diagram_new(void)
Definition repodlgs.c:270
int visible_col
Definition repodlgs.c:1316
static void science_report_show_all_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:546
economy_report_columns
Definition repodlgs.c:788
@ ERD_COL_NUM
Definition repodlgs.c:801
@ ERD_COL_SPRITE
Definition repodlgs.c:789
@ ERD_COL_IS_IMPROVEMENT
Definition repodlgs.c:798
@ ERD_COL_CID
Definition repodlgs.c:799
@ ERD_COL_NAME
Definition repodlgs.c:790
@ ERD_COL_EMPTY
Definition repodlgs.c:795
@ ERD_COL_REDUNDANT
Definition repodlgs.c:791
@ ERD_COL_TOTAL_COST
Definition repodlgs.c:794
@ ERD_COL_COUNT
Definition repodlgs.c:792
@ ERD_COL_COST
Definition repodlgs.c:793
void science_report_dialog_popdown(void)
Definition repodlgs.c:740
bool rightalign
Definition repodlgs.c:1315
static GtkListStore * economy_report_store_new(void)
Definition repodlgs.c:807
static struct unit * find_nearest_unit(const struct unit_type *utype, struct tile *ptile)
Definition repodlgs.c:1537
endgame_report_columns
Definition repodlgs.c:1810
@ FRD_COL_NUM
Definition repodlgs.c:1816
@ FRD_COL_TOOLTIP
Definition repodlgs.c:1814
@ FRD_COL_NATION
Definition repodlgs.c:1812
@ FRD_COL_PLAYER
Definition repodlgs.c:1811
@ FRD_COL_SCORE
Definition repodlgs.c:1813
economy_report_response
Definition repodlgs.c:780
@ ERD_RES_SELL_REDUNDANT
Definition repodlgs.c:781
@ ERD_RES_SELL_ALL
Definition repodlgs.c:782
@ ERD_RES_DISBAND_UNITS
Definition repodlgs.c:783
static gint cmp_func(gconstpointer a_p, gconstpointer b_p)
Definition repodlgs.c:370
static void economy_report_selection_callback(GtkTreeSelection *selection, gpointer data)
Definition repodlgs.c:1068
static void science_report_goal_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:557
static void economy_report_free(struct economy_report *preport)
Definition repodlgs.c:1229
static void science_report_init(struct science_report *preport)
Definition repodlgs.c:581
static void science_report_current_callback(GtkComboBox *combo, gpointer data)
Definition repodlgs.c:521
void real_science_report_dialog_update(void *unused)
Definition repodlgs.c:751
static void units_report_free(struct units_report *preport)
Definition repodlgs.c:1752
static GtkListStore * science_report_store_new(void)
Definition repodlgs.c:125
static void science_report_redraw(struct science_report *preport)
Definition repodlgs.c:347
GdkPixbuf * sprite_get_pixbuf(struct sprite *sprite)
Definition sprite.c:402
const char * tooltip
Definition repodlgs.c:1342
const char * title
Definition repodlgs.c:1341
GType type
Definition repodlgs.c:1340
int visible_col
Definition repodlgs.c:1344
bool rightalign
Definition repodlgs.c:1343
@ HELP_TECH
Definition helpdlg_g.h:21
bool can_sell_building(const struct impr_type *pimprove)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert(condition)
Definition log.h:176
#define log_error(message,...)
Definition log.h:103
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
Definition map.c:639
struct tile * get_center_tile_mapcanvas(void)
void center_tile_mapcanvas(const struct tile *ptile)
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
int dsend_packet_player_research(struct connection *pc, int tech)
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
const char * science_dialog_text(void)
Definition text.c:774
struct player * player_by_number(const int player_id)
Definition player.c:840
const char * player_name(const struct player *pplayer)
Definition player.c:886
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
void get_economy_report_units_data(struct unit_entry *entries, int *num_entries_used, int *total_cost)
void get_economy_report_data(struct improvement_entry *entries, int *num_entries_used, int *total_cost, int *total_income)
void sell_all_improvements(const struct impr_type *pimprove, bool redundant_only, char *message, size_t message_sz)
void disband_all_units(const struct unit_type *punittype, bool in_cities_only, char *message, size_t message_sz)
endgame_report_dialog_player
Definition repodlgs_g.h:33
void draw_reqtree(struct reqtree *tree, struct canvas *pcanvas, int canvas_x, int canvas_y, int tt_x, int tt_y, int w, int h)
Definition reqtree.c:1033
void get_reqtree_dimensions(struct reqtree *reqtree, int *width, int *height)
Definition reqtree.c:867
Tech_type_id get_tech_on_reqtree(struct reqtree *tree, int x, int y)
Definition reqtree.c:1170
bool find_tech_on_reqtree(struct reqtree *tree, Tech_type_id tech, int *x, int *y, int *w, int *h)
Definition reqtree.c:1193
void destroy_reqtree(struct reqtree *tree)
Definition reqtree.c:470
struct reqtree * create_reqtree(struct player *pplayer, bool show_all)
Definition reqtree.c:836
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:747
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:665
bool research_future_next(const struct research *presearch)
Definition research.c:1335
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
struct research * research_get(const struct player *pplayer)
Definition research.c:126
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
#define ARRAY_SIZE(x)
Definition shared.h:85
#define FC_INFINITY
Definition shared.h:36
#define MAX(x, y)
Definition shared.h:54
GtkTreeIter it
Definition gui_stuff.h:34
cairo_t * drawable
Definition canvas.h:23
struct connection conn
Definition client_main.h:96
GtkLabel * label
Definition repodlgs.c:775
GtkTreeView * tree_view
Definition repodlgs.c:774
struct gui_dialog * shell
Definition repodlgs.c:773
GtkListStore * store
Definition repodlgs.c:1805
GtkTreeView * tree_view
Definition repodlgs.c:1804
struct gui_dialog * shell
Definition repodlgs.c:1803
GtkWidget * vbox
Definition gui_stuff.h:71
enum gui_dialog_type type
Definition gui_stuff.h:76
int cost
struct impr_type * type
int total_cost
int count
int redundant
Definition climisc.h:82
char category_name[32][MAX_LEN_NAME]
Definition packets_gen.h:90
enum tech_state state
Definition research.h:73
Tech_type_id researching
Definition research.h:52
Tech_type_id tech_goal
Definition research.h:85
struct research::research_invention inventions[A_ARRAY_SIZE]
struct gui_dialog * shell
Definition repodlgs.c:70
GtkLayout * drawing_area
Definition repodlgs.c:77
GtkProgressBar * progress_bar
Definition repodlgs.c:75
GtkComboBox * reachable_techs
Definition repodlgs.c:71
GtkComboBox * reachable_goals
Definition repodlgs.c:72
GtkLabel * goal_label
Definition repodlgs.c:76
GtkLabel * main_label
Definition repodlgs.c:74
GtkWidget * button_show_all
Definition repodlgs.c:73
Definition tile.h:49
int total_cost
struct unit_type * type
int count
int cost
Definition unit.h:138
int upkeep[O_LAST]
Definition unit.h:148
enum unit_activity activity
Definition unit.h:157
int moves_left
Definition unit.h:150
struct unit::@80::@82 client
int homecity
Definition unit.h:146
bool done_moving
Definition unit.h:181
const struct unit_type * utype
Definition unit.h:139
enum unit_focus_status focus_status
Definition unit.h:211
enum server_side_agent ssa_controller
Definition unit.h:172
GtkTreeView * tree_view
Definition repodlgs.c:1280
struct gui_dialog * shell
Definition repodlgs.c:1279
enum universals_n kind
Definition fc_types.h:758
universals_u value
Definition fc_types.h:757
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
int fc_strcoll(const char *str0, const char *str1)
Definition support.c:472
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
#define A_FUTURE
Definition tech.h:46
#define advance_index_iterate_end
Definition tech.h:248
#define A_FIRST
Definition tech.h:44
#define A_NONE
Definition tech.h:43
#define A_UNSET
Definition tech.h:48
#define advance_index_iterate(_start, _index)
Definition tech.h:244
const char * score_tooltip(const struct player *pplayer, int score)
Definition text.c:2157
const char * get_science_target_text(double *percent)
Definition text.c:853
const char * get_science_goal_text(Tech_type_id goal)
Definition text.c:899
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6494
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6516
bool tileset_is_fully_loaded(void)
Definition tilespec.c:7203
const struct unit_type * utype
Definition fc_types.h:604
const struct impr_type * building
Definition fc_types.h:598
#define unit_tile(_pu)
Definition unit.h:395
@ FOCUS_AVAIL
Definition unit.h:53
#define unit_list_iterate(unitlist, punit)
Definition unitlist.h:31
#define unit_list_iterate_end
Definition unitlist.h:33
const struct unit_type * unit_type_get(const struct unit *punit)
Definition unittype.c:123
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Definition unittype.c:1755
Unit_type_id utype_count(void)
Definition unittype.c:80
struct unit_type * utype_by_number(const Unit_type_id id)
Definition unittype.c:112
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
int unit_upgrade_price(const struct player *pplayer, const struct unit_type *from, const struct unit_type *to)
Definition unittype.c:1783
#define unit_type_iterate(_p)
Definition unittype.h:841
#define U_LAST
Definition unittype.h:40
#define unit_type_iterate_end
Definition unittype.h:848