Freeciv-3.1
Loading...
Searching...
No Matches
helpdlg.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 <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include <math.h> /* sqrt */
22
23#include <gtk/gtk.h>
24
25/* utility */
26#include "fcintl.h"
27#include "mem.h"
28#include "shared.h"
29#include "support.h"
30
31/* common */
32#include "city.h"
33#include "game.h"
34#include "government.h"
35#include "movement.h"
36#include "specialist.h"
37#include "tech.h"
38#include "unit.h"
39#include "map.h"
40#include "research.h"
41#include "version.h"
42
43/* client */
44#include "client_main.h"
45#include "climisc.h"
46#include "helpdata.h"
47#include "options.h"
48#include "tilespec.h"
49
50/* client/gui-gtk-3.0 */
51#include "colors.h"
52#include "graphics.h"
53#include "gui_main.h"
54#include "gui_stuff.h"
55
56#include "helpdlg.h"
57
58#define TECH_TREE_DEPTH 20
59
60/*
61 * Globals.
62 */
63static GtkWidget *help_dialog_shell;
64static GtkWidget *help_view_sw;
65
66static GtkWidget *help_view;
67
68static GtkWidget *help_frame;
69static GtkTextBuffer *help_text;
70static GtkWidget *help_text_sw;
71static GtkWidget *help_vbox;
72static GtkWidget *help_tile;
73static GtkWidget *help_box;
74static GtkWidget *help_itable;
75static GtkWidget *help_wtable;
76static GtkWidget *help_utable;
77static GtkWidget *help_ttable;
78static GtkWidget *help_etable;
79static GtkWidget *help_tree;
80static GtkTreeStore *tstore;
81
82static GtkWidget *help_tree_sw;
83static GtkWidget *help_tree_expand;
84static GtkWidget *help_tree_collapse;
85static GtkWidget *help_tree_buttons_hbox;
86static GtkWidget *help_ilabel[6];
87static GtkWidget *help_wlabel[6];
88static GtkWidget *help_ulabel[5][5];
89static GtkWidget *help_tlabel[2][5];
90static GtkWidget *help_elabel[6];
91
92static bool help_advances[A_LAST];
93
94static GPtrArray *help_history;
96
98{
100 union {
102 const struct requirement *req;
103 } u;
104};
105
106static const char *help_ilabel_name[6] =
107{ N_("Base Cost:"), NULL, N_("Upkeep:"), NULL, N_("Requirement:"), NULL };
109
110static const char *help_wlabel_name[6] =
111{ N_("Base Cost:"), NULL, N_("Requirement:"), NULL, N_("Obsolete by:"), NULL };
113
115
116static const char *help_ulabel_name[5][5] =
117{
118 { N_("Cost:"), NULL, NULL, N_("Attack:"), NULL },
119 { N_("Defense:"), NULL, NULL, N_("Move:"), NULL },
120 { N_("Firepower:"), NULL, NULL, N_("Hitpoints:"), NULL },
121 { N_("Basic Upkeep:"), NULL, NULL, N_("Vision:"), NULL },
122 { N_("Requirement:"), NULL, NULL, N_("Obsolete by:"), NULL }
123};
124
125static const char *help_tlabel_name[2][5] =
126{
127 { N_("Move/Defense:"), NULL, NULL, N_("Food/Res/Trade:"), NULL },
128 { N_("Resources:"), NULL, NULL, NULL, NULL }
129};
130
131static const char *help_elabel_name[6] =
132/* TRANS: Label for build cost for extras in help. Will be followed by
133 * something like "3 MP" (where MP = Movement Points) */
134{ N_("Build:"), NULL,
135/* TRANS: Extra conflicts in help. Will be followed by a list of extras
136 * that can't be built on the same tile as this one. */
137 N_("Conflicts with:"), NULL,
138/* TRANS: Extra bonus in help. Will be followed by food/production/trade
139 * stats like "0/0/+1", "0/+50%/0" */
140 N_("Bonus (F/P/T):"), NULL };
141
142#define REQ_LABEL_NONE _("?tech:None")
143#define REQ_LABEL_NEVER _("(Never)")
144
145static void create_help_dialog(void);
146static void help_update_dialog(const struct help_item *pitem);
147
148static void select_help_item_string(const char *item,
149 enum help_page_type htype);
150static void help_command_update(void);
151static void help_command_callback(GtkWidget *w, gint response_id);
152
153/**********************************************************************/
168
169/**********************************************************************/
172static void set_title_topic(char *topic)
173{
174 if (strcmp(topic, _(HELP_ABOUT_ITEM)) == 0) {
175 gtk_frame_set_label(GTK_FRAME(help_frame), freeciv_name_version());
176 } else {
177 gtk_frame_set_label(GTK_FRAME(help_frame), topic);
178 }
179 return;
180}
181
182/**********************************************************************/
186{
187 if (help_dialog_shell) {
188 gtk_widget_destroy(help_dialog_shell);
189 }
190}
191
192/**********************************************************************/
195void popup_help_dialog_typed(const char *item, enum help_page_type htype)
196{
197 if (!help_dialog_shell) {
200 GTK_WINDOW(help_dialog_shell), 10, 10);
201 }
202 gtk_window_present(GTK_WINDOW(help_dialog_shell));
203
205}
206
207/**********************************************************************/
215
216/**********************************************************************/
225static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
226{
227 const struct research *presearch;
228 int bg;
229 int turns_to_tech;
230 bool original;
231 GtkTreeIter l;
232 GValue value = { 0, };
233 enum tech_state state;
234
235 if (advance_required(tech, AR_ONE) == A_LAST
236 && advance_required(tech, AR_TWO) == A_LAST) {
237 bg = COLOR_REQTREE_UNKNOWN;
238
239 gtk_tree_store_append(tstore, &l, parent);
240 help_advances[tech] = TRUE;
241
242 g_value_init(&value, G_TYPE_STRING);
243 g_value_set_static_string(&value, _("Removed"));
244 gtk_tree_store_set_value(tstore, &l, 0, &value);
245 g_value_unset(&value);
246
247 gtk_tree_store_set(tstore, &l,
248 1, -1,
249 2, tech,
250 3, &get_color(tileset, bg)->color
251 -1);
252 return;
253 }
254
255 presearch = research_get(client_player());
256
257 state = research_invention_state(presearch, tech);
258 if (tech_state_is_valid(state)) {
259 switch (state) {
260 case TECH_UNKNOWN:
261 bg = COLOR_REQTREE_UNKNOWN;
262 break;
263 case TECH_KNOWN:
264 bg = COLOR_REQTREE_KNOWN;
265 break;
266 case TECH_PREREQS_KNOWN:
267 bg = COLOR_REQTREE_PREREQS_KNOWN;
268 break;
269 }
270 } else {
271 bg = COLOR_REQTREE_BACKGROUND;
272 }
273 turns_to_tech = research_goal_unknown_techs(presearch, tech);
274
275 /* l is the original in the tree. */
276 original = !help_advances[tech];
277
278 gtk_tree_store_append(tstore, &l, parent);
279 help_advances[tech] = TRUE;
280
281 g_value_init(&value, G_TYPE_STRING);
282 g_value_set_static_string(&value,
284 tech));
285 gtk_tree_store_set_value(tstore, &l, 0, &value);
286 g_value_unset(&value);
287
288 gtk_tree_store_set(tstore, &l,
289 1, turns_to_tech,
290 2, tech,
291 3, &get_color(tileset, bg)->color,
292 -1);
293
294 if (--levels <= 0)
295 return;
296
297 if (original) {
298 /* only add children to orginals */
299 if (advance_required(tech, AR_ONE) != A_NONE)
300 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
301 if (advance_required(tech, AR_TWO) != A_NONE)
302 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
303 }
304 return;
305}
306
307/**********************************************************************/
311 GtkTreePath *path,
312 GtkTreeViewColumn *col,
313 gpointer data)
314{
315 GtkTreeIter it;
316 gint tech;
317
318 gtk_tree_model_get_iter(GTK_TREE_MODEL(tstore), &it, path);
319 gtk_tree_model_get(GTK_TREE_MODEL(tstore), &it, 2, &tech, -1);
321 HELP_TECH);
322}
323
324/**********************************************************************/
327static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
328{
329 gtk_tree_view_expand_all(GTK_TREE_VIEW(data));
330}
331
332/**********************************************************************/
335static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
336{
337 gtk_tree_view_collapse_all(GTK_TREE_VIEW(data));
338}
339
340/**********************************************************************/
343static void help_hyperlink_callback(GtkWidget *w)
344{
345 const char *s;
346 struct help_page_selection *select;
348
349 s = gtk_label_get_text(GTK_LABEL(w));
350 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w), "page_type"));
351
352 switch (select->type) {
353 case HPAGE_SRC_ENUM:
354 type = select->u.page;
355 break;
356 case HPAGE_SRC_REQ:
358 break;
359 }
360
361 if (type == HELP_LAST) {
362 return;
363 }
364
365 /* FIXME: May be able to skip, or may need to modify, advances[A_NONE]
366 below, depending on which i18n is done elsewhere.
367 */
368 if (strcmp(s, REQ_LABEL_NEVER) != 0
372 }
373}
374
375/**********************************************************************/
378static GtkWidget *help_hyperlink_new(GtkWidget *label,
379 struct help_page_selection *select)
380{
381 GtkWidget *button;
382
383 button = gtk_button_new();
384 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
385 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
386 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
387 gtk_widget_set_name(label, "help_link");
388 gtk_container_add(GTK_CONTAINER(button), label);
389 gtk_widget_show(button);
390 g_signal_connect_swapped(button, "clicked",
391 G_CALLBACK(help_hyperlink_callback), label);
392 g_object_set_data(G_OBJECT(label), "page_type", select);
393
394 return button;
395}
396
397/**********************************************************************/
400static GtkWidget *help_hyperlink_new_page(GtkWidget *label,
401 enum help_page_type page)
402{
403 return help_hyperlink_new(label, &(page_selections[page]));
404}
405
406/**********************************************************************/
409static GtkWidget *help_slink_new(const gchar *txt,
410 struct help_page_selection *select)
411{
412 GtkWidget *button, *label;
413
414 label = gtk_label_new(txt);
415 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
416 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
417 button = help_hyperlink_new(label, select);
418
419 return button;
420}
421
422/**********************************************************************/
425static GtkWidget *help_slink_new_page(const gchar *txt,
426 enum help_page_type page)
427{
428 return help_slink_new(txt, &(page_selections[page]));
429}
430
431/**********************************************************************/
434static void help_box_hide(void)
435{
436 gtk_widget_hide(help_box);
437
438 gtk_widget_hide(help_tile);
439
440 gtk_widget_hide(help_itable);
441 gtk_widget_hide(help_wtable);
442 gtk_widget_hide(help_utable);
443 gtk_widget_hide(help_ttable);
444 gtk_widget_hide(help_etable);
445
446 gtk_widget_hide(help_tile); /* FIXME: twice? */
447
448 gtk_widget_hide(help_vbox);
449 gtk_widget_hide(help_text_sw);
450
451 gtk_widget_hide(help_tree_sw);
452 gtk_widget_hide(help_tree_buttons_hbox);
453}
454
455/**********************************************************************/
458static void help_destroy_callback(GtkWidget *w, gpointer data)
459{
460 g_ptr_array_free(help_history, TRUE);
461 help_dialog_shell = NULL;
462}
463
464/**********************************************************************/
467static void activated_topic(GtkTreeView *view, gpointer data)
468{
469 GtkTreePath *path;
470 GtkTreeViewColumn *col;
471 GtkTreeModel *model;
472 GtkTreeIter it;
473 struct help_item *pitem;
474
475 model = gtk_tree_view_get_model(view);
476
477 gtk_tree_view_get_cursor(view, &path, &col);
478 gtk_tree_model_get_iter(model, &it, path);
479 gtk_tree_path_free(path);
480
481 if (!path) {
482 return;
483 }
484
485 gtk_tree_model_get(model, &it, 1, &pitem, -1);
486
487 if (help_history_pos >= 0
488 && g_ptr_array_index(help_history, help_history_pos)
489 == (gpointer) pitem) {
490 return;
491 }
492
493 help_update_dialog(pitem);
494
495 /* add to history. */
496 if (help_history_pos < help_history->len - 1) {
497 g_ptr_array_set_size(help_history, help_history_pos + 1);
498 }
500
501 g_ptr_array_add(help_history, (gpointer)pitem);
503}
504
505/**********************************************************************/
508static void create_help_dialog(void)
509{
510 GtkWidget *hbox;
511 GtkWidget *button;
512 GtkWidget *text;
513 int i, j;
514 GtkCellRenderer *rend;
515 GtkTreeViewColumn *col;
516 GArray *array;
517 GtkTreeStore *store;
518 GtkTreeSelection *selection;
519
520 help_history = g_ptr_array_new();
521 help_history_pos = -1;
522
523 help_dialog_shell = gtk_dialog_new_with_buttons(_("Freeciv Help Browser"),
524 NULL,
525 0,
526 GTK_STOCK_GO_BACK,
527 1,
528 GTK_STOCK_GO_FORWARD,
529 2,
530 GTK_STOCK_CLOSE,
531 GTK_RESPONSE_CLOSE,
532 NULL);
534 gtk_dialog_set_default_response(GTK_DIALOG(help_dialog_shell),
535 GTK_RESPONSE_CLOSE);
536 gtk_widget_set_name(help_dialog_shell, "Freeciv");
537
538 g_signal_connect(help_dialog_shell, "response",
539 G_CALLBACK(help_command_callback), NULL);
540 g_signal_connect(help_dialog_shell, "destroy",
541 G_CALLBACK(help_destroy_callback), NULL);
542
543 hbox = gtk_grid_new();
544 gtk_grid_set_column_spacing(GTK_GRID(hbox), 5);
545 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))), hbox);
546 gtk_widget_show(hbox);
547
548 /* build tree store. */
549 store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
550
551 array = g_array_new(FALSE, FALSE, sizeof(GtkTreeIter));
552 help_items_iterate(pitem) {
553 GtkTreeIter *it, *parent;
554 const char *s;
555 int depth;
556
557 for (s = pitem->topic; *s == ' '; s++) {
558 /* nothing */
559 }
560 depth = s - pitem->topic;
561
562 array = g_array_set_size(array, depth+1);
563
564 if (depth > 0) {
565 parent = &g_array_index(array, GtkTreeIter, depth-1);
566 } else {
567 parent = NULL;
568 }
569
570 it = &g_array_index(array, GtkTreeIter, depth);
571 gtk_tree_store_append(store, it, parent);
572
573 gtk_tree_store_set(store, it, 0, pitem->topic, 1, pitem, -1);
575
576
577 /* create tree view. */
578 help_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
579 g_object_unref(store);
580 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(help_view));
581 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(help_view), FALSE);
582
583 g_signal_connect(help_view, "cursor-changed",
584 G_CALLBACK(activated_topic), NULL);
585
586 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(help_view));
587 gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
588
589 rend = gtk_cell_renderer_text_new();
590 col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", 0, NULL);
591 gtk_tree_view_append_column(GTK_TREE_VIEW(help_view), col);
592
593 help_view_sw = gtk_scrolled_window_new(NULL, NULL);
594 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_view_sw),
595 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
596 gtk_widget_set_size_request(help_view_sw, 190, -1);
597 gtk_container_add(GTK_CONTAINER(help_view_sw), help_view);
598 gtk_widget_show(help_view);
599 gtk_container_add(GTK_CONTAINER(hbox), help_view_sw);
600 gtk_widget_show(help_view_sw);
601
602 help_frame = gtk_frame_new("");
603 gtk_container_add(GTK_CONTAINER(hbox), help_frame);
604 gtk_widget_set_size_request(help_frame, 520, 350);
605 gtk_widget_show(help_frame);
606
607 help_box = gtk_grid_new();
608 gtk_grid_set_row_spacing(GTK_GRID(help_box), 5);
609 gtk_orientable_set_orientation(GTK_ORIENTABLE(help_box),
610 GTK_ORIENTATION_VERTICAL);
611 gtk_container_add(GTK_CONTAINER(help_frame), help_box);
612
613 help_tile = gtk_image_new();
614
615 gtk_container_add(GTK_CONTAINER(help_box), help_tile);
616
617 help_itable = gtk_grid_new();
618 gtk_container_add(GTK_CONTAINER(help_box), help_itable);
619
620 for (i = 0; i < 6; i++) {
621 help_ilabel[i] =
622 gtk_label_new(help_ilabel_name[i] != NULL ? _(help_ilabel_name[i]) : "");
623 gtk_widget_set_hexpand(help_ilabel[i], TRUE);
624
625 if (i == 5) {
627 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
628 } else {
629 gtk_grid_attach(GTK_GRID(help_itable), help_ilabel[i], i, 0, 1, 1);
630 gtk_widget_set_name(help_ilabel[i], "help_label");
631 }
632
633 gtk_widget_show(help_ilabel[i]);
634 }
635
636 help_wtable = gtk_grid_new();
637 gtk_container_add(GTK_CONTAINER(help_box), help_wtable);
638
639 for (i = 0; i < 6; i++) {
640 help_wlabel[i] =
641 gtk_label_new(help_wlabel_name[i] ? _(help_wlabel_name[i]) : "");
642 gtk_widget_set_hexpand(help_wlabel[i], TRUE);
643
644 if (i == 3 || i == 5) {
646 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
647 } else {
648 gtk_grid_attach(GTK_GRID(help_wtable), help_wlabel[i], i, 0, 1, 1);
649 gtk_widget_set_name(help_wlabel[i], "help_label");
650 }
651
652 gtk_widget_show(help_wlabel[i]);
653 }
654
655 help_utable = gtk_grid_new();
656 gtk_container_add(GTK_CONTAINER(help_box), help_utable);
657
658 for (i = 0; i < 5; i++) {
659 for (j = 0; j < 5; j++) {
660 help_ulabel[j][i] =
661 gtk_label_new(help_ulabel_name[j][i] ? _(help_ulabel_name[j][i]) : "");
662 gtk_widget_set_hexpand(help_ulabel[j][i], TRUE);
663
664 if (j == 4 && (i == 1 || i == 4)) {
665 if (i == 1) {
667 } else {
669 }
670
671 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
672 } else {
673 gtk_grid_attach(GTK_GRID(help_utable), help_ulabel[j][i],
674 i, j, 1, 1);
675 gtk_widget_set_name(help_ulabel[j][i], "help_label");
676 }
677 gtk_widget_show(help_ulabel[j][i]);
678 }
679 }
680
681 help_ttable = gtk_grid_new();
682 gtk_container_add(GTK_CONTAINER(help_box), help_ttable);
683
684 for (j = 0; j < 2; j++) {
685 for (i = 0; i < 5; i++) {
686 help_tlabel[j][i] =
687 gtk_label_new(help_tlabel_name[j][i] ? _(help_tlabel_name[j][i]) : "");
688 gtk_widget_set_hexpand(help_tlabel[j][i], TRUE);
689 gtk_widget_set_name(help_tlabel[j][i], "help_label");
690
691 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
692 if (j == 1 && i == 1) {
693 /* Extra wide cell for terrain specials */
694 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
695 i, j, 4, 1);
696 gtk_widget_show(help_tlabel[j][i]);
697 break; /* skip rest of row */
698 } else {
699 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
700 i, j, 1, 1);
701 gtk_widget_show(help_tlabel[j][i]);
702 }
703 }
704 }
705
706 help_etable = gtk_grid_new();
707 gtk_container_add(GTK_CONTAINER(help_box), help_etable);
708
709 for (i = 0; i < 6; i++) {
710 help_elabel[i] =
711 gtk_label_new(help_elabel_name[i] ? _(help_elabel_name[i]) : "");
712 gtk_widget_set_hexpand(help_elabel[i], TRUE);
713 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
714 gtk_widget_set_name(help_elabel[i], "help_label");
715 gtk_widget_show(help_elabel[i]);
716 }
717
718 help_vbox = gtk_grid_new();
719 gtk_grid_set_row_spacing(GTK_GRID(help_vbox), 1);
720 gtk_orientable_set_orientation(GTK_ORIENTABLE(help_vbox),
721 GTK_ORIENTATION_VERTICAL);
722 gtk_container_set_border_width(GTK_CONTAINER(help_vbox), 5);
723 gtk_container_add(GTK_CONTAINER(help_box), help_vbox);
724
725 text = gtk_text_view_new();
726 gtk_widget_set_hexpand(text, TRUE);
727 gtk_widget_set_vexpand(text, TRUE);
728 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
729 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
730 gtk_container_set_border_width(GTK_CONTAINER(text), 5);
731 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
732 gtk_widget_set_name(text, "help_text");
733 help_text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
734 gtk_widget_show(text);
735
736 help_text_sw = gtk_scrolled_window_new(NULL, NULL);
737 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_text_sw),
738 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
739 gtk_container_add(GTK_CONTAINER(help_text_sw), text);
740 gtk_container_add(GTK_CONTAINER(help_box), help_text_sw);
741
742 /* build tech store. */
743 tstore = gtk_tree_store_new(4,
744 G_TYPE_STRING, /* tech name */
745 G_TYPE_INT, /* turns to tech */
746 G_TYPE_INT, /* tech id */
747 GDK_TYPE_RGBA); /* color */
748 help_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tstore));
749 gtk_widget_set_hexpand(help_tree, TRUE);
750 gtk_widget_set_vexpand(help_tree, TRUE);
751 g_object_unref(tstore);
752 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(help_tree), FALSE);
753
754 g_signal_connect(help_tree, "row_activated",
755 G_CALLBACK(help_tech_tree_activated_callback), NULL);
756
757
758 col = gtk_tree_view_column_new();
759
760 rend = gtk_cell_renderer_text_new();
761 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, NULL);
762 gtk_tree_view_column_pack_start(col, rend, TRUE);
763 gtk_tree_view_column_set_attributes(col, rend,
764 "text", 0,
765 "background-rgba", 3,
766 NULL);
767 rend = gtk_cell_renderer_text_new();
768 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
769 gtk_tree_view_column_pack_start(col, rend, FALSE);
770 gtk_tree_view_column_set_attributes(col, rend,
771 "text", 1,
772 "background-rgba", 3,
773 NULL);
774
775 gtk_tree_view_append_column(GTK_TREE_VIEW(help_tree), col);
776
777
778 help_tree_sw = gtk_scrolled_window_new(NULL, NULL);
779 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_tree_sw),
780 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
781 gtk_container_add(GTK_CONTAINER(help_tree_sw), help_tree);
782 gtk_widget_show(help_tree);
783 gtk_container_add(GTK_CONTAINER(help_box), help_tree_sw);
784
786 gtk_button_new_with_label(_("Expand All"));
787 help_tree_collapse = gtk_button_new_with_label(_("Collapse All"));
788
789 g_signal_connect(help_tree_expand, "clicked",
791 g_signal_connect(help_tree_collapse, "clicked",
793
794 help_tree_buttons_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
795 gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_expand);
796 gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_collapse);
797 gtk_container_add(GTK_CONTAINER(help_box), help_tree_buttons_hbox);
798 gtk_widget_show_all(help_tree_buttons_hbox);
799}
800
801/**********************************************************************/
804static void set_help_tile_from_sprite(struct sprite *spr)
805{
806 if (spr == NULL) {
807 return;
808 }
809
810 gtk_image_set_from_surface(GTK_IMAGE(help_tile), spr->surface);
811 gtk_widget_show(help_tile);
812}
813
814/**********************************************************************/
817static void set_help_tile_from_terrain(struct terrain *pterr)
818{
820 cairo_t *cr;
821 int i;
822
823 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
826
827 cr = cairo_create(canvas.surface);
828 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
829 cairo_paint(cr);
830 cairo_destroy(cr);
831
832 for (i = 0; i < 3; i++) {
833 struct drawn_sprite sprs[80];
835 i, pterr);
836
837 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
838 }
839
840 gtk_image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
841 gtk_widget_show(help_tile);
842 cairo_surface_destroy(canvas.surface);
843}
844
845/**********************************************************************/
848static void set_help_tile_from_extra(const struct extra_type *pextra)
849{
851 cairo_t *cr;
852 struct drawn_sprite sprs[80];
853 int count;
854
855 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
858
859 cr = cairo_create(canvas.surface);
860 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
861 cairo_paint(cr);
862 cairo_destroy(cr);
863
864 count = fill_basic_extra_sprite_array(tileset, sprs, pextra);
865
866 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
867
868 gtk_image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
869 gtk_widget_show(help_tile);
870 cairo_surface_destroy(canvas.surface);
871}
872
873/**********************************************************************/
876static void help_update_improvement(const struct help_item *pitem,
877 char *title)
878{
879 char buf[8192];
881
882 if (imp && !is_great_wonder(imp)) {
884 char req_buf[512];
885
886 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
887 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), buf);
888 sprintf(buf, "%d", imp->upkeep);
889 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf);
890
891 /* FIXME: this should show ranges, negated reqs, and all the
892 * MAX_NUM_REQS reqs.
893 * Currently it's limited to 1 req but this code is partially prepared
894 * to be extended. Remember MAX_NUM_REQS is a compile-time
895 * definition. */
896 help_impr_req.u.req = NULL;
897 requirement_vector_iterate(&imp->reqs, preq) {
898 if (!preq->present) {
899 continue;
900 }
901 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
902 help_impr_req.u.req = preq;
903 break;
905 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), req);
906/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
907 } else {
908 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), "0");
909 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), "0");
910 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), REQ_LABEL_NEVER);
911/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3);*/
912 }
913
915
916 gtk_widget_show(help_itable);
917
918 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
919 gtk_text_buffer_set_text(help_text, buf, -1);
920 gtk_widget_show(help_text_sw);
921}
922
923/**********************************************************************/
926static void help_update_wonder(const struct help_item *pitem,
927 char *title)
928{
929 char buf[8192];
931
932 if (imp && is_great_wonder(imp)) {
933 int i;
934 char req_buf[512];
935
936 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
937 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf);
938
939 /* FIXME: this should show ranges, negated reqs, and all the
940 * MAX_NUM_REQS reqs.
941 * Currently it's limited to 1 req but this code is partially prepared
942 * to be extended. Remember MAX_NUM_REQS is a compile-time
943 * definition. */
944 i = 0;
945 help_wndr_req.u.req = NULL;
946 requirement_vector_iterate(&imp->reqs, preq) {
947 if (!preq->present) {
948 continue;
949 }
950 gtk_label_set_text(GTK_LABEL(help_wlabel[3 + i]),
951 universal_name_translation(&preq->source,
952 req_buf, sizeof(req_buf)));
953 help_wndr_req.u.req = preq;
954 i++;
955 break;
957
958 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), REQ_LABEL_NEVER);
960 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
961 gtk_label_set_text(GTK_LABEL(help_wlabel[5]),
963 (pobs->source.value.advance));
964
965 break;
966 }
968
969/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
970 } else {
971 /* can't find wonder */
972 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), "0");
973 gtk_label_set_text(GTK_LABEL(help_wlabel[3]), REQ_LABEL_NEVER);
974 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
975/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
976 }
977
979
980 gtk_widget_show(help_wtable);
981
982 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
983 gtk_text_buffer_set_text(help_text, buf, -1);
984 gtk_widget_show(help_text_sw);
985}
986
987/**********************************************************************/
990static void help_update_unit_type(const struct help_item *pitem,
991 char *title)
992{
993 char buf[8192];
995
996 if (utype) {
997 sprintf(buf, "%d", utype_build_shield_cost_base(utype));
998 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), buf);
999 sprintf(buf, "%d", utype->attack_strength);
1000 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), buf);
1001 sprintf(buf, "%d", utype->defense_strength);
1002 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), buf);
1003 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1004 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), buf);
1005 sprintf(buf, "%d", utype->firepower);
1006 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), buf);
1007 sprintf(buf, "%d", utype->hp);
1008 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), buf);
1009 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]),
1011 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1012 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), buf);
1013 if (A_NEVER == utype->require_advance) {
1014 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1015 } else {
1016 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
1018 }
1019/* create_tech_tree(help_improvement_tree, 0, advance_number(utype->require_advance), 3);*/
1020 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1021 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1022 } else {
1023 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]),
1025 }
1026
1027 helptext_unit(buf, sizeof(buf), client.conn.playing, pitem->text, utype);
1028
1029 gtk_text_buffer_set_text(help_text, buf, -1);
1030 gtk_widget_show(help_text_sw);
1031
1033 direction8_invalid()));
1034 } else {
1035 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), "0");
1036 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), "0");
1037 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), "0");
1038 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), "0");
1039 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), "0");
1040 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), "0");
1041 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]), "0");
1042 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), "0");
1043
1044 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1045/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3);*/
1046 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1047
1048 gtk_text_buffer_set_text(help_text, buf, -1);
1049 gtk_widget_show(help_text_sw);
1050 }
1051 gtk_widget_show(help_utable);
1052}
1053
1054/**********************************************************************/
1057static char *fc_chomp(char *str, size_t len)
1058{
1059 gchar *i;
1060
1061 if (!str || !*str)
1062 return str;
1063
1064 i = str + len;
1065 for (i = g_utf8_find_prev_char(str, i);
1066 (i && g_unichar_isspace(g_utf8_get_char(i)));
1067 i = g_utf8_find_prev_char(str, i)) {
1068 *i = '\0';
1069 }
1070 return str;
1071}
1072
1073/**********************************************************************/
1076static void help_update_tech(const struct help_item *pitem, char *title)
1077{
1078 int i, j;
1079 GtkWidget *w, *hbox;
1080 char buf[8192];
1081 struct advance *padvance = advance_by_translated_name(title);
1082
1083 if (padvance && !is_future_tech(i = advance_number(padvance))) {
1084 GtkTextBuffer *txt;
1085 size_t len;
1086
1087 gtk_container_foreach(GTK_CONTAINER(help_vbox), (GtkCallback)gtk_widget_destroy, NULL);
1088
1089 for (j = 0; j < ARRAY_SIZE(help_advances); j++) {
1090 help_advances[j] = FALSE;
1091 }
1092 gtk_tree_store_clear(tstore);
1094 gtk_widget_show(help_tree_sw);
1095 gtk_widget_show(help_tree_buttons_hbox);
1096
1097 helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i);
1098 len = strlen(buf);
1099 fc_chomp(buf, len);
1100
1102
1103 w = gtk_text_view_new();
1104 gtk_widget_set_hexpand(w, TRUE);
1105 gtk_widget_set_vexpand(w, TRUE);
1106 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(w), FALSE);
1107 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(w), GTK_WRAP_WORD);
1108 gtk_widget_set_name(w, "help_text");
1109 gtk_container_set_border_width(GTK_CONTAINER(w), 5);
1110 gtk_text_view_set_editable(GTK_TEXT_VIEW(w), FALSE);
1111 gtk_container_add(GTK_CONTAINER(help_vbox), w);
1112 gtk_widget_show(w);
1113
1114 txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
1115 if (txt) {
1116 gtk_text_buffer_set_text(txt, buf, -1);
1117 }
1118
1119 w = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
1120 g_object_set(w, "margin", 5, NULL);
1121 gtk_widget_set_hexpand(w, TRUE);
1122 gtk_widget_set_vexpand(w, TRUE);
1123 gtk_container_add(GTK_CONTAINER(help_vbox), w);
1124 gtk_widget_show(w);
1125
1126 governments_iterate(pgov) {
1127 /* FIXME: need a more general mechanism for this, since this
1128 * helptext needs to be shown in all possible req source types. */
1129 requirement_vector_iterate(&pgov->reqs, preq) {
1130 if (VUT_ADVANCE == preq->source.kind
1131 && preq->source.value.advance == padvance) {
1132 hbox = gtk_grid_new();
1133 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1134 w = gtk_label_new(_("Allows"));
1135 gtk_container_add(GTK_CONTAINER(hbox), w);
1138 gtk_container_add(GTK_CONTAINER(hbox), w);
1139 gtk_widget_show_all(hbox);
1140 }
1143
1144 improvement_iterate(pimprove) {
1145 if (valid_improvement(pimprove)) {
1146 requirement_vector_iterate(&pimprove->reqs, preq) {
1147 if (VUT_ADVANCE == preq->source.kind
1148 && preq->source.value.advance == padvance) {
1149 hbox = gtk_grid_new();
1150 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1151 w = gtk_label_new(_("Allows"));
1152 gtk_container_add(GTK_CONTAINER(hbox), w);
1154 is_great_wonder(pimprove)
1155 ? HELP_WONDER
1157 gtk_container_add(GTK_CONTAINER(hbox), w);
1158 gtk_widget_show_all(hbox);
1159 }
1161 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1162 if (pobs->source.kind == VUT_ADVANCE
1163 && pobs->source.value.advance == padvance
1164 && pobs->present) {
1165 hbox = gtk_grid_new();
1166 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1167 w = gtk_label_new(_("Obsoletes"));
1168 gtk_container_add(GTK_CONTAINER(hbox), w);
1170 is_great_wonder(pimprove)
1171 ? HELP_WONDER
1173 gtk_container_add(GTK_CONTAINER(hbox), w);
1174 gtk_widget_show_all(hbox);
1175 }
1177 }
1179
1180 unit_type_iterate(punittype) {
1181 if (padvance != punittype->require_advance) {
1182 continue;
1183 }
1184 hbox = gtk_grid_new();
1185 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1186 w = gtk_label_new(_("Allows"));
1187 gtk_container_add(GTK_CONTAINER(hbox), w);
1189 gtk_container_add(GTK_CONTAINER(hbox), w);
1190 gtk_widget_show_all(hbox);
1192
1193 advance_iterate(A_NONE, ptest) {
1194 if (padvance == advance_requires(ptest, AR_ONE)) {
1196 hbox = gtk_grid_new();
1197 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1198 w = gtk_label_new(_("Allows"));
1199 gtk_container_add(GTK_CONTAINER(hbox), w);
1201 gtk_container_add(GTK_CONTAINER(hbox), w);
1202 gtk_widget_show_all(hbox);
1203 } else {
1204 hbox = gtk_grid_new();
1205 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1206 w = gtk_label_new(_("Allows"));
1207 gtk_container_add(GTK_CONTAINER(hbox), w);
1209 gtk_container_add(GTK_CONTAINER(hbox), w);
1210 w = gtk_label_new(_("with"));
1211 gtk_container_add(GTK_CONTAINER(hbox), w);
1213 AR_TWO)),
1214 HELP_TECH);
1215 gtk_container_add(GTK_CONTAINER(hbox), w);
1216 w = gtk_label_new(Q_("?techhelp:"));
1217 gtk_container_add(GTK_CONTAINER(hbox), w);
1218 gtk_widget_show_all(hbox);
1219 }
1220 }
1221 if (padvance == advance_requires(ptest, AR_TWO)) {
1222 hbox = gtk_grid_new();
1223 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1224 w = gtk_label_new(_("Allows"));
1225 gtk_container_add(GTK_CONTAINER(hbox), w);
1227 gtk_container_add(GTK_CONTAINER(hbox), w);
1228 w = gtk_label_new(_("with"));
1229 gtk_container_add(GTK_CONTAINER(hbox), w);
1231 HELP_TECH);
1232 gtk_container_add(GTK_CONTAINER(hbox), w);
1233 w = gtk_label_new(Q_("?techhelp:"));
1234 gtk_container_add(GTK_CONTAINER(hbox), w);
1235 gtk_widget_show_all(hbox);
1236 }
1238 gtk_widget_show(help_vbox);
1239 }
1240}
1241
1242/**********************************************************************/
1245static void add_act_help_for_terrain(const char *act_label,
1246 const char *result_link_label,
1247 enum help_page_type result_link_type,
1248 const char *descr_label)
1249{
1250 GtkWidget *w;
1251 GtkWidget *hbox;
1252
1253 hbox = gtk_grid_new();
1254 gtk_container_add(GTK_CONTAINER(help_vbox), hbox);
1255 w = gtk_label_new(act_label);
1256 gtk_container_add(GTK_CONTAINER(hbox), w);
1257 w = help_slink_new_page(result_link_label, result_link_type);
1258 gtk_container_add(GTK_CONTAINER(hbox), w);
1259 w = gtk_label_new(descr_label);
1260 gtk_container_add(GTK_CONTAINER(hbox), w);
1261
1262 gtk_widget_show_all(hbox);
1263}
1264
1265/**********************************************************************/
1268static void help_extras_of_act_for_terrain(struct terrain *pterr,
1269 enum unit_activity act,
1270 char *label)
1271{
1272 enum extra_cause cause = activity_to_extra_cause(act);
1273
1274 extra_type_by_cause_iterate(cause, pextra) {
1275 if (pextra->buildable
1276 && requirement_fulfilled_by_terrain(pterr, &(pextra->reqs))) {
1279 helptext_extra_for_terrain_str(pextra, pterr,
1280 act));
1281 }
1283}
1284
1285/**********************************************************************/
1288static void help_update_terrain(const struct help_item *pitem,
1289 char *title)
1290{
1291 char buf[8192];
1292 struct terrain *pterrain = terrain_by_translated_name(title);
1293
1294 if (pterrain) {
1295 struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
1296
1298
1299 {
1300 /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
1301 int defbonus = pterrain->defense_bonus + 100;
1302 int frac = defbonus % 100;
1303
1304 if ((frac % 10) == 0) {
1305 frac /= 10;
1306 }
1307 sprintf(buf, "%d/%d.%d",
1308 pterrain->movement_cost, defbonus / 100, frac);
1309 }
1310 gtk_label_set_text(GTK_LABEL(help_tlabel[0][1]), buf);
1311
1312 sprintf(buf, "%d/%d/%d",
1313 pterrain->output[O_FOOD],
1314 pterrain->output[O_SHIELD],
1315 pterrain->output[O_TRADE]);
1316 gtk_label_set_text(GTK_LABEL(help_tlabel[0][4]), buf);
1317
1318 buf[0] = '\0';
1319 if (*(pterrain->resources)) {
1320 struct extra_type **r;
1321
1322 for (r = pterrain->resources; *r; r++) {
1323 /* TRANS: " Whales (2/1/2)," */
1324 sprintf (buf + strlen (buf), " %s (%d/%d/%d),",
1326 pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD],
1327 pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD],
1328 pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]);
1329 }
1330 buf[strlen (buf) - 1] = '.';
1331 } else {
1332 /* TRANS: "Resources: (none)" */
1333 sprintf (buf + strlen (buf), _("(none)"));
1334 }
1335 gtk_label_set_text(GTK_LABEL(help_tlabel[1][1]), buf);
1336
1337 gtk_container_foreach(GTK_CONTAINER(help_vbox), (GtkCallback)gtk_widget_destroy, NULL);
1338
1339 if (pterrain->cultivate_result != T_NONE
1340 && action_id_univs_not_blocking(ACTION_CULTIVATE,
1341 NULL, &for_terr)) {
1342 fc_snprintf(buf, sizeof(buf),
1343 PL_("%d turn", "%d turns", pterrain->cultivate_time),
1344 pterrain->cultivate_time);
1345 add_act_help_for_terrain(_("Cultivate Rslt/Time"),
1347 HELP_TERRAIN, buf);
1348 }
1349
1350 if (pterrain->plant_result != T_NONE
1351 && action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
1352 fc_snprintf(buf, sizeof(buf),
1353 PL_("%d turn", "%d turns", pterrain->plant_time),
1354 pterrain->plant_time);
1355 add_act_help_for_terrain(_("Plant Rslt/Time"),
1357 HELP_TERRAIN, buf);
1358 }
1359
1360 if (pterrain->transform_result != T_NONE
1361 && action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
1362 NULL, &for_terr)) {
1363 fc_snprintf(buf, sizeof(buf),
1364 PL_("%d turn", "%d turns", pterrain->transform_time),
1365 pterrain->transform_time);
1366 add_act_help_for_terrain(_("Trans. Rslt/Time"),
1368 HELP_TERRAIN, buf);
1369 }
1370
1371 if (action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
1372 help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE, _("Build as irrigation"));
1373 }
1374 if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
1375 help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE, _("Build as mine"));
1376 }
1377 if (pterrain->road_time != 0
1378 && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) {
1379 help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD, _("Build as road"));
1380 }
1381 if (pterrain->base_time != 0
1382 && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) {
1383 help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE, _("Build as base"));
1384 }
1385 gtk_widget_show(help_vbox);
1386 }
1387
1388 helptext_terrain(buf, sizeof(buf), client.conn.playing, pitem->text, pterrain);
1389
1390 gtk_text_buffer_set_text(help_text, buf, -1);
1391 gtk_widget_show(help_text_sw);
1392
1393 gtk_widget_show(help_ttable);
1394}
1395
1396/**********************************************************************/
1399static void help_update_extra(const struct help_item *pitem, char *title)
1400{
1401 char buf[8192];
1403
1404 buf[0] = '\0';
1405 if (pextra == NULL) {
1406 strcat(buf, pitem->text);
1407 } else {
1408 struct road_type *proad = extra_road_get(pextra);
1409 bool is_resource = is_extra_caused_by(pextra, EC_RESOURCE);
1410
1412
1413 /* Cost to build */
1414 if (pextra->buildable) {
1415 if (pextra->build_time != 0) {
1416 /* TRANS: "MP" = movement points */
1417 sprintf(buf, _("%d MP"), pextra->build_time);
1418 } else {
1419 /* TRANS: Build time depends on terrain. */
1420 sprintf(buf, _("Terrain specific"));
1421 }
1422 } else {
1423 sprintf(buf, "-");
1424 }
1425 gtk_label_set_text(GTK_LABEL(help_elabel[1]), buf);
1426 /* Conflicting extras */
1427 buf[0] = '\0';
1428 if (is_resource) {
1429 /* TRANS: (Resource extra) Conflicts with: */
1430 strcat(buf, _("Other Resources"));
1431 }
1432 extra_type_iterate(pextra2) {
1433 if (!can_extras_coexist(pextra, pextra2)
1434 && (!is_resource || !is_extra_caused_by(pextra2, EC_RESOURCE))) {
1435 if (buf[0] != '\0') {
1436 strcat(buf, "/");
1437 }
1438 strcat(buf, extra_name_translation(pextra2));
1439 }
1441 /* TRANS: "Conflicts with: (none)" (extras) */
1442 gtk_label_set_text(GTK_LABEL(help_elabel[3]), buf[0] ? buf : _("(none)"));
1443
1444 /* Bonus */
1445 if (proad != NULL) {
1446 const char *bonus = NULL;
1447
1449 if (proad->tile_incr[o] > 0) {
1450 /* TRANS: Road bonus depends on terrain. */
1451 bonus = _("Terrain specific");
1452 break;
1453 }
1455 if (!bonus) {
1456 bonus = helptext_road_bonus_str(NULL, proad);
1457 }
1458 if (!bonus) {
1459 /* TRANS: No output bonus from a road */
1460 bonus = Q_("?bonus:None");
1461 }
1462 gtk_label_set_text(GTK_LABEL(help_elabel[5]), bonus);
1463 } else {
1464 gtk_label_set_text(GTK_LABEL(help_elabel[5]), Q_("?bonus:None"));
1465 }
1466
1467 helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra);
1468 }
1469 gtk_widget_show(help_etable);
1470
1471 gtk_text_buffer_set_text(help_text, buf, -1);
1472 gtk_widget_show(help_text_sw);
1473}
1474
1475/**********************************************************************/
1478static void help_update_goods(const struct help_item *pitem,
1479 char *title)
1480{
1481 char buf[8192];
1482 struct goods_type *pgood = goods_by_translated_name(title);
1483
1484 if (!pgood) {
1485 strcat(buf, pitem->text);
1486 } else {
1487 helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
1488 pgood);
1489 }
1490
1491 gtk_text_buffer_set_text(help_text, buf, -1);
1492 gtk_widget_show(help_text_sw);
1493}
1494
1495/**********************************************************************/
1498static void help_update_specialist(const struct help_item *pitem,
1499 char *title)
1500{
1501 char buf[8192];
1503
1504 if (!pspec) {
1505 strcat(buf, pitem->text);
1506 } else {
1507 helptext_specialist(buf, sizeof(buf), client.conn.playing, pitem->text,
1508 pspec);
1509 }
1510
1511 gtk_text_buffer_set_text(help_text, buf, -1);
1512 gtk_widget_show(help_text_sw);
1513}
1514
1515/**********************************************************************/
1518static void help_update_government(const struct help_item *pitem,
1519 char *title)
1520{
1521 char buf[8192];
1523
1524 if (!gov) {
1525 strcat(buf, pitem->text);
1526 } else {
1527 helptext_government(buf, sizeof(buf), client.conn.playing, pitem->text, gov);
1528 }
1529
1530 gtk_text_buffer_set_text(help_text, buf, -1);
1531 gtk_widget_show(help_text_sw);
1532}
1533
1534/**********************************************************************/
1537static void help_update_nation(const struct help_item *pitem, char *title,
1538 struct nation_type *pnation)
1539{
1540 char buf[4096];
1541
1542 if (!pnation) {
1543 strcat(buf, pitem->text);
1544 } else {
1545 helptext_nation(buf, sizeof(buf), pnation, pitem->text);
1546
1548 }
1549
1550 gtk_text_buffer_set_text(help_text, buf, -1);
1551 gtk_widget_show(help_text_sw);
1552}
1553
1554/**********************************************************************/
1557static void help_update_dialog(const struct help_item *pitem)
1558{
1559 char *top;
1560
1561 /* figure out what kind of item is required for pitem ingo */
1562
1563 for (top = pitem->topic; *top == ' '; top++) {
1564 /* nothing */
1565 }
1566
1567 help_box_hide();
1568 gtk_text_buffer_set_text(help_text, "", -1);
1569
1570 switch (pitem->type) {
1571 case HELP_IMPROVEMENT:
1572 help_update_improvement(pitem, top);
1573 break;
1574 case HELP_WONDER:
1575 help_update_wonder(pitem, top);
1576 break;
1577 case HELP_UNIT:
1578 help_update_unit_type(pitem, top);
1579 break;
1580 case HELP_TECH:
1581 help_update_tech(pitem, top);
1582 break;
1583 case HELP_TERRAIN:
1584 help_update_terrain(pitem, top);
1585 break;
1586 case HELP_EXTRA:
1587 help_update_extra(pitem, top);
1588 break;
1589 case HELP_GOODS:
1590 help_update_goods(pitem, top);
1591 break;
1592 case HELP_SPECIALIST:
1593 help_update_specialist(pitem, top);
1594 break;
1595 case HELP_GOVERNMENT:
1596 help_update_government(pitem, top);
1597 break;
1598 case HELP_NATIONS:
1600 break;
1601 case HELP_TEXT:
1602 default:
1603 /* it was a pure text item */
1604 gtk_text_buffer_set_text(help_text, pitem->text, -1);
1605 gtk_widget_show(help_text_sw);
1606 break;
1607 }
1608 set_title_topic(pitem->topic);
1609
1610 gtk_widget_show(help_box);
1611}
1612
1613/**********************************************************************/
1616static void help_item_zoom(GtkTreePath *path)
1617{
1618 GtkTreeModel *model;
1619 GtkTreeIter it, child, item;
1620 GtkTreeSelection *selection;
1621
1622 model = gtk_tree_view_get_model(GTK_TREE_VIEW(help_view));
1623 gtk_tree_model_get_iter(model, &item, path);
1624
1625 for (child=item; gtk_tree_model_iter_parent(model, &it, &child); child=it) {
1626 GtkTreePath *it_path;
1627
1628 it_path = gtk_tree_model_get_path(model, &it);
1629 gtk_tree_view_expand_row(GTK_TREE_VIEW(help_view), it_path, TRUE);
1630 gtk_tree_path_free(it_path);
1631 }
1632
1633 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(help_view));
1634 gtk_tree_selection_select_iter(selection, &item);
1635 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(help_view), path, NULL,
1636 TRUE, 0.0, 0.0);
1637}
1638
1639/**********************************************************************/
1642static GtkTreePath *help_item_path(const struct help_item *pitem)
1643{
1644 GtkTreePath *path;
1645 bool next;
1646
1647 path = gtk_tree_path_new_first();
1648 next = FALSE;
1649 help_items_iterate(pitem2) {
1650 const char *s;
1651 int depth;
1652
1653 for (s = pitem2->topic; *s == ' '; s++) {
1654 /* nothing */
1655 }
1656 depth = s - pitem2->topic + 1;
1657
1658 while (depth < gtk_tree_path_get_depth(path)) {
1659 gtk_tree_path_up(path);
1660 gtk_tree_path_next(path);
1661 next = FALSE;
1662 }
1663 while (depth > gtk_tree_path_get_depth(path)) {
1664 gtk_tree_path_down(path);
1665 next = FALSE;
1666 }
1667
1668 if (next) {
1669 gtk_tree_path_next(path);
1670 }
1671
1672 if (pitem == pitem2)
1673 break;
1674
1675 next = TRUE;
1677
1678 return path;
1679}
1680
1681/**********************************************************************/
1684static void select_help_item_string(const char *item, enum help_page_type htype)
1685{
1686 const struct help_item *pitem;
1687 int idx;
1688 GtkTreePath *path;
1689 GtkTreeViewColumn *col;
1690
1691 if (!(pitem = get_help_item_spec(item, htype, &idx))) {
1692 return;
1693 }
1694
1695 path = help_item_path(pitem);
1696 help_item_zoom(path);
1697
1698 col = gtk_tree_view_get_column(GTK_TREE_VIEW(help_view), 0);
1699 gtk_tree_view_set_cursor(GTK_TREE_VIEW(help_view), path, col, FALSE);
1700 gtk_tree_path_free(path);
1701}
1702
1703/**********************************************************************/
1706static void help_command_update(void)
1707{
1708 GtkDialog *dialog = GTK_DIALOG(help_dialog_shell);
1709
1710 if (help_history_pos < 0) {
1711 gtk_dialog_set_response_sensitive(dialog, 1, FALSE);
1712 gtk_dialog_set_response_sensitive(dialog, 2, FALSE);
1713 } else {
1714 gtk_dialog_set_response_sensitive(dialog, 1, TRUE);
1715 gtk_dialog_set_response_sensitive(dialog, 2, TRUE);
1716
1717 if (help_history_pos == 0) {
1718 gtk_dialog_set_response_sensitive(dialog, 1, FALSE);
1719 }
1720 if (help_history_pos >= help_history->len - 1) {
1721 gtk_dialog_set_response_sensitive(dialog, 2, FALSE);
1722 }
1723 }
1724}
1725
1726/**********************************************************************/
1729static void help_command_callback(GtkWidget *w, gint response_id)
1730{
1731 GtkTreePath *path;
1732 const struct help_item *pitem;
1733
1734 if (response_id == 1) {
1735 if (help_history_pos > 0) {
1737
1738 pitem = g_ptr_array_index(help_history, help_history_pos);
1739 path = help_item_path(pitem);
1740 help_item_zoom(path);
1741 help_update_dialog(pitem);
1743 }
1744 } else if (response_id == 2) {
1745 if (help_history_pos < help_history->len - 1) {
1747
1748 pitem = g_ptr_array_index(help_history, help_history_pos);
1749 path = help_item_path(pitem);
1750 help_item_zoom(path);
1751 help_update_dialog(pitem);
1753 }
1754 } else {
1755 gtk_widget_destroy(help_dialog_shell);
1756 }
1757}
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:962
#define str
Definition astring.c:76
#define output_type_iterate(output)
Definition city.h:821
#define output_type_iterate_end
Definition city.h:827
struct civclient client
#define client_player()
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
struct extra_type * extra_type_by_translated_name(const char *name)
Definition extras.c:227
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1028
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:952
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
#define extra_type_iterate(_p)
Definition extras.h:291
#define extra_type_iterate_end
Definition extras.h:297
#define is_extra_caused_by(e, c)
Definition extras.h:196
#define extra_road_get(_e_)
Definition extras.h:185
#define extra_type_by_cause_iterate_end
Definition extras.h:315
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
@ O_SHIELD
Definition fc_types.h:91
@ O_FOOD
Definition fc_types.h:91
@ O_TRADE
Definition fc_types.h:91
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#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
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
struct government * government_by_translated_name(const char *name)
Definition government.c:39
#define governments_iterate(NAME_pgov)
Definition government.h:121
#define governments_iterate_end
Definition government.h:124
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
GtkWidget * toplevel
Definition gui_main.c:124
void set_relative_window_position(GtkWindow *ref, GtkWindow *w, int px, int py)
Definition gui_stuff.c:58
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
static GtkWidget * help_tree_sw
Definition helpdlg.c:82
static void set_title_topic(char *topic)
Definition helpdlg.c:172
static void activated_topic(GtkTreeView *view, gpointer data)
Definition helpdlg.c:467
static GtkWidget * help_tree
Definition helpdlg.c:79
static GtkWidget * help_tree_expand
Definition helpdlg.c:83
static GtkWidget * help_ulabel[5][5]
Definition helpdlg.c:88
static void help_update_specialist(const struct help_item *pitem, char *title)
Definition helpdlg.c:1498
static void help_hyperlink_callback(GtkWidget *w)
Definition helpdlg.c:343
static GtkWidget * help_elabel[6]
Definition helpdlg.c:90
static GtkWidget * help_etable
Definition helpdlg.c:78
static void help_destroy_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:458
static void set_help_tile_from_extra(const struct extra_type *pextra)
Definition helpdlg.c:848
static GtkWidget * help_frame
Definition helpdlg.c:68
static void help_tech_tree_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition helpdlg.c:310
static void help_update_tech(const struct help_item *pitem, char *title)
Definition helpdlg.c:1076
static void help_item_zoom(GtkTreePath *path)
Definition helpdlg.c:1616
static GtkWidget * help_slink_new_page(const gchar *txt, enum help_page_type page)
Definition helpdlg.c:425
static GtkWidget * help_tlabel[2][5]
Definition helpdlg.c:89
static GtkTreePath * help_item_path(const struct help_item *pitem)
Definition helpdlg.c:1642
static GtkWidget * help_tree_collapse
Definition helpdlg.c:84
static void help_update_nation(const struct help_item *pitem, char *title, struct nation_type *pnation)
Definition helpdlg.c:1537
static void create_help_dialog(void)
Definition helpdlg.c:508
static GtkTextBuffer * help_text
Definition helpdlg.c:69
static void help_update_wonder(const struct help_item *pitem, char *title)
Definition helpdlg.c:926
static GtkWidget * help_hyperlink_new_page(GtkWidget *label, enum help_page_type page)
Definition helpdlg.c:400
static GtkWidget * help_dialog_shell
Definition helpdlg.c:63
static GtkWidget * help_text_sw
Definition helpdlg.c:70
static GPtrArray * help_history
Definition helpdlg.c:94
static const char * help_elabel_name[6]
Definition helpdlg.c:131
static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
Definition helpdlg.c:225
static void help_update_extra(const struct help_item *pitem, char *title)
Definition helpdlg.c:1399
static GtkWidget * help_ilabel[6]
Definition helpdlg.c:86
static void set_help_tile_from_sprite(struct sprite *spr)
Definition helpdlg.c:804
static const char * help_wlabel_name[6]
Definition helpdlg.c:110
static const char * help_ulabel_name[5][5]
Definition helpdlg.c:116
static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:335
static void set_help_tile_from_terrain(struct terrain *pterr)
Definition helpdlg.c:817
static GtkWidget * help_view
Definition helpdlg.c:66
static void help_update_goods(const struct help_item *pitem, char *title)
Definition helpdlg.c:1478
void help_system_init(void)
Definition helpdlg.c:156
static void help_box_hide(void)
Definition helpdlg.c:434
static void help_update_unit_type(const struct help_item *pitem, char *title)
Definition helpdlg.c:990
void popdown_help_dialog(void)
Definition helpdlg.c:185
static void help_update_terrain(const struct help_item *pitem, char *title)
Definition helpdlg.c:1288
static void help_update_dialog(const struct help_item *pitem)
Definition helpdlg.c:1557
static char * fc_chomp(char *str, size_t len)
Definition helpdlg.c:1057
void popup_help_dialog_string(const char *item)
Definition helpdlg.c:211
static int help_history_pos
Definition helpdlg.c:95
static struct help_page_selection help_wndr_req
Definition helpdlg.c:112
static GtkWidget * help_wlabel[6]
Definition helpdlg.c:87
static GtkWidget * help_box
Definition helpdlg.c:73
static void help_extras_of_act_for_terrain(struct terrain *pterr, enum unit_activity act, char *label)
Definition helpdlg.c:1268
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:195
#define REQ_LABEL_NEVER
Definition helpdlg.c:143
static void help_command_update(void)
Definition helpdlg.c:1706
static struct help_page_selection page_selections[HELP_LAST]
Definition helpdlg.c:114
#define TECH_TREE_DEPTH
Definition helpdlg.c:58
static const char * help_tlabel_name[2][5]
Definition helpdlg.c:125
static struct help_page_selection help_impr_req
Definition helpdlg.c:108
#define REQ_LABEL_NONE
Definition helpdlg.c:142
static GtkWidget * help_wtable
Definition helpdlg.c:75
static GtkWidget * help_slink_new(const gchar *txt, struct help_page_selection *select)
Definition helpdlg.c:409
static GtkWidget * help_vbox
Definition helpdlg.c:71
static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:327
static GtkWidget * help_tile
Definition helpdlg.c:72
static GtkWidget * help_hyperlink_new(GtkWidget *label, struct help_page_selection *select)
Definition helpdlg.c:378
static void help_update_government(const struct help_item *pitem, char *title)
Definition helpdlg.c:1518
static GtkWidget * help_ttable
Definition helpdlg.c:77
static void help_update_improvement(const struct help_item *pitem, char *title)
Definition helpdlg.c:876
static const char * help_ilabel_name[6]
Definition helpdlg.c:106
static GtkWidget * help_tree_buttons_hbox
Definition helpdlg.c:85
static GtkWidget * help_view_sw
Definition helpdlg.c:64
static void select_help_item_string(const char *item, enum help_page_type htype)
Definition helpdlg.c:1684
static bool help_advances[A_LAST]
Definition helpdlg.c:92
static GtkWidget * help_utable
Definition helpdlg.c:76
static GtkWidget * help_itable
Definition helpdlg.c:74
static GtkTreeStore * tstore
Definition helpdlg.c:80
static void add_act_help_for_terrain(const char *act_label, const char *result_link_label, enum help_page_type result_link_type, const char *descr_label)
Definition helpdlg.c:1245
static void help_command_callback(GtkWidget *w, gint response_id)
Definition helpdlg.c:1729
const char * title
Definition repodlgs.c:1313
GType type
Definition repodlgs.c:1312
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4175
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3115
enum help_page_type help_type_by_requirement(const struct requirement *req)
Definition helpdata.c:5037
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
Definition helpdata.c:3619
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
Definition helpdata.c:4094
const char * helptext_road_bonus_str(const struct terrain *pterrain, const struct road_type *proad)
Definition helpdata.c:3455
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Definition helpdata.c:4834
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
Definition helpdata.c:3585
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
Definition helpdata.c:4140
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
Definition helpdata.c:1223
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1316
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
Definition helpdata.c:3338
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype)
Definition helpdata.c:1763
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:4871
#define help_items_iterate(pitem)
Definition helpdata.h:70
#define help_items_iterate_end
Definition helpdata.h:74
#define HELP_ABOUT_ITEM
help_page_type
Definition helpdlg_g.h:20
@ HELP_ANY
Definition helpdlg_g.h:20
@ HELP_TERRAIN
Definition helpdlg_g.h:21
@ HELP_EXTRA
Definition helpdlg_g.h:21
@ HELP_NATIONS
Definition helpdlg_g.h:23
@ HELP_LAST
Definition helpdlg_g.h:24
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_UNIT
Definition helpdlg_g.h:20
@ HELP_SPECIALIST
Definition helpdlg_g.h:22
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
@ HELP_GOODS
Definition helpdlg_g.h:22
@ HELP_WONDER
Definition helpdlg_g.h:21
@ HELP_TECH
Definition helpdlg_g.h:21
@ HELP_TEXT
Definition helpdlg_g.h:20
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
int impr_base_build_shield_cost(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
struct impr_type * improvement_by_translated_name(const char *name)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:105
int len
Definition packhand.c:125
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
#define requirement_fulfilled_by_terrain(_ter_, _rqs_)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:747
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
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:130
cairo_surface_t * surface
Definition canvas.h:22
struct connection conn
Definition client_main.h:96
Definition colors.h:20
struct player * playing
Definition connection.h:156
bool buildable
Definition extras.h:112
int build_time
Definition extras.h:114
char * topic
Definition helpdata.h:26
enum help_page_type type
Definition helpdata.h:27
char * text
Definition helpdata.h:26
enum help_page_selection::@152 type
enum help_page_type page
Definition helpdlg.c:101
const struct requirement * req
Definition helpdlg.c:102
union help_page_selection::@153 u
struct requirement_vector obsolete_by
Definition improvement.h:76
struct requirement_vector reqs
Definition improvement.h:75
Definition climisc.h:82
int tile_incr[O_LAST]
Definition road.h:81
cairo_surface_t * surface
Definition sprite.h:23
struct terrain * cultivate_result
Definition terrain.h:203
struct extra_type ** resources
Definition terrain.h:197
int road_time
Definition terrain.h:201
int plant_time
Definition terrain.h:207
struct terrain * plant_result
Definition terrain.h:206
int defense_bonus
Definition terrain.h:193
int cultivate_time
Definition terrain.h:204
int movement_cost
Definition terrain.h:192
int output[O_LAST]
Definition terrain.h:195
int transform_time
Definition terrain.h:218
struct terrain * transform_result
Definition terrain.h:217
int base_time
Definition terrain.h:200
int defense_strength
Definition unittype.h:496
int firepower
Definition unittype.h:506
const struct unit_type * obsoleted_by
Definition unittype.h:510
int vision_radius_sq
Definition unittype.h:503
int move_rate
Definition unittype.h:497
struct advance * require_advance
Definition unittype.h:500
int attack_strength
Definition unittype.h:495
enum universals_n kind
Definition fc_types.h:758
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
struct advance * advance_by_translated_name(const char *name)
Definition tech.c:185
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
Definition tech.c:136
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Definition tech.c:121
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define A_NEVER
Definition tech.h:51
@ AR_TWO
Definition tech.h:112
@ AR_ONE
Definition tech.h:111
#define advance_iterate(_start, _p)
Definition tech.h:264
#define A_NONE
Definition tech.h:43
#define advance_iterate_end
Definition tech.h:270
#define A_LAST
Definition tech.h:45
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:190
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
#define T_NONE
Definition terrain.h:56
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
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:6897
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:6864
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6467
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6485
struct goods_type * goods_by_translated_name(const char *name)
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1520
struct unit_type * unit_type_by_translated_name(const char *name)
Definition unittype.c:1804
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
#define unit_type_iterate(_p)
Definition unittype.h:841
#define unit_type_iterate_end
Definition unittype.h:848
#define U_NOT_OBSOLETED
Definition unittype.h:509
const char * freeciv_name_version(void)
Definition version.c:35