Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-3.22/helpdlg.c Source File

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.22 */
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 */
63 static GtkWidget *help_dialog_shell;
64 static GtkWidget *help_view_sw;
65
66 static GtkWidget *help_view;
67
68 static GtkWidget *help_frame;
69 static GtkTextBuffer *help_text;
70 static GtkWidget *help_text_sw;
71 static GtkWidget *help_vbox;
72 static GtkWidget *help_tile;
73 static GtkWidget *help_box;
74 static GtkWidget *help_itable;
75 static GtkWidget *help_wtable;
76 static GtkWidget *help_utable;
77 static GtkWidget *help_ttable;
78 static GtkWidget *help_etable;
79 static GtkWidget *help_tree;
80 static GtkTreeStore *tstore;
81
82 static GtkWidget *help_tree_sw;
83 static GtkWidget *help_tree_expand;
84 static GtkWidget *help_tree_collapse;
85 static GtkWidget *help_tree_buttons_hbox;
86 static GtkWidget *help_ilabel[6];
87 static GtkWidget *help_wlabel[6];
88 static GtkWidget *help_ulabel[5][5];
89 static GtkWidget *help_tlabel[2][5];
90 static GtkWidget *help_elabel[6];
91
92 static bool help_advances[A_LAST];
93
94 static GPtrArray *help_history;
95 static int help_history_pos;
96
97struct help_page_selection
98{
99 enum { HPAGE_SRC_ENUM, HPAGE_SRC_REQ } type;
100 union {
101 enum help_page_type page;
102 const struct requirement *req;
103 } u;
104};
105
106 static const char *help_ilabel_name[6] =
107{ N_("Base Cost:"), NULL, N_("Upkeep:"), NULL, N_("Requirement:"), NULL };
108 static struct help_page_selection help_impr_req;
109
110 static const char *help_wlabel_name[6] =
111{ N_("Base Cost:"), NULL, N_("Requirement:"), NULL, N_("Obsolete by:"), NULL };
112 static struct help_page_selection help_wndr_req;
113
114 static struct help_page_selection page_selections[HELP_LAST];
115
116 static 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
125 static 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
131 static 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/**********************************************************************/
156 void help_system_init(void)
157{
158 enum help_page_type page;
159
160 for (page = 0; page < HELP_LAST; page++) {
161 page_selections[page].type = HPAGE_SRC_ENUM;
162 page_selections[page].u.page = page;
163 }
164
165 help_impr_req.type = HPAGE_SRC_REQ;
166 help_wndr_req.type = HPAGE_SRC_REQ;
167}
168
169/**********************************************************************/
172 static 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/**********************************************************************/
185 void popdown_help_dialog(void)
186{
187 if (help_dialog_shell) {
188 gtk_widget_destroy(help_dialog_shell);
189 }
190}
191
192/**********************************************************************/
195 void popup_help_dialog_typed(const char *item, enum help_page_type htype)
196{
197 if (!help_dialog_shell) {
198 create_help_dialog();
199 set_relative_window_position(GTK_WINDOW(toplevel),
200 GTK_WINDOW(help_dialog_shell), 10, 10);
201 }
202 gtk_window_present(GTK_WINDOW(help_dialog_shell));
203
204 select_help_item_string(item, htype);
205}
206
207/**********************************************************************/
211 void popup_help_dialog_string(const char *item)
212{
213 popup_help_dialog_typed(Q_(item), HELP_ANY);
214}
215
216/**********************************************************************/
225 static 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,
283 research_advance_name_translation(presearch,
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
298 if (original) {
299 /* only add children to orginals */
300 if (advance_required(tech, AR_ONE) != A_NONE)
301 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
302 if (advance_required(tech, AR_TWO) != A_NONE)
303 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
304 }
305 return;
306}
307
308/**********************************************************************/
311 static void help_tech_tree_activated_callback(GtkTreeView *view,
312 GtkTreePath *path,
313 GtkTreeViewColumn *col,
314 gpointer data)
315{
316 GtkTreeIter it;
317 gint tech;
318
319 gtk_tree_model_get_iter(GTK_TREE_MODEL(tstore), &it, path);
320 gtk_tree_model_get(GTK_TREE_MODEL(tstore), &it, 2, &tech, -1);
321 select_help_item_string(advance_name_translation(advance_by_number(tech)),
322 HELP_TECH);
323}
324
325/**********************************************************************/
328 static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
329{
330 gtk_tree_view_expand_all(GTK_TREE_VIEW(data));
331}
332
333/**********************************************************************/
336 static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
337{
338 gtk_tree_view_collapse_all(GTK_TREE_VIEW(data));
339}
340
341/**********************************************************************/
344 static void help_hyperlink_callback(GtkWidget *w)
345{
346 const char *s;
347 struct help_page_selection *select;
348 enum help_page_type type = HELP_LAST;
349
350 s = gtk_label_get_text(GTK_LABEL(w));
351 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w), "page_type"));
352
353 switch (select->type) {
354 case HPAGE_SRC_ENUM:
355 type = select->u.page;
356 break;
357 case HPAGE_SRC_REQ:
358 type = help_type_by_requirement(select->u.req);
359 break;
360 }
361
362 if (type == HELP_LAST) {
363 return;
364 }
365
366 /* FIXME: May be able to skip, or may need to modify, advances[A_NONE]
367 below, depending on which i18n is done elsewhere.
368 */
369 if (strcmp(s, REQ_LABEL_NEVER) != 0
370 && strcmp(s, skip_intl_qualifier_prefix(REQ_LABEL_NONE)) != 0
371 && strcmp(s, advance_name_translation(advance_by_number(A_NONE))) != 0) {
372 select_help_item_string(s, type);
373 }
374}
375
376/**********************************************************************/
379 static GtkWidget *help_hyperlink_new(GtkWidget *label,
380 struct help_page_selection *select)
381{
382 GtkWidget *button;
383
384 button = gtk_button_new();
385 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
386 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
387 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
388 gtk_widget_set_name(label, "help_link");
389 gtk_container_add(GTK_CONTAINER(button), label);
390 gtk_widget_show(button);
391 g_signal_connect_swapped(button, "clicked",
392 G_CALLBACK(help_hyperlink_callback), label);
393 g_object_set_data(G_OBJECT(label), "page_type", select);
394
395 return button;
396}
397
398/**********************************************************************/
401 static GtkWidget *help_hyperlink_new_page(GtkWidget *label,
402 enum help_page_type page)
403{
404 return help_hyperlink_new(label, &(page_selections[page]));
405}
406
407/**********************************************************************/
410 static GtkWidget *help_slink_new(const gchar *txt,
411 struct help_page_selection *select)
412{
413 GtkWidget *button, *label;
414
415 label = gtk_label_new(txt);
416 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
417 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
418 button = help_hyperlink_new(label, select);
419
420 return button;
421}
422
423/**********************************************************************/
426 static GtkWidget *help_slink_new_page(const gchar *txt,
427 enum help_page_type page)
428{
429 return help_slink_new(txt, &(page_selections[page]));
430}
431
432/**********************************************************************/
435 static void help_box_hide(void)
436{
437 gtk_widget_hide(help_box);
438
439 gtk_widget_hide(help_tile);
440
441 gtk_widget_hide(help_itable);
442 gtk_widget_hide(help_wtable);
443 gtk_widget_hide(help_utable);
444 gtk_widget_hide(help_ttable);
445 gtk_widget_hide(help_etable);
446
447 gtk_widget_hide(help_tile); /* FIXME: twice? */
448
449 gtk_widget_hide(help_vbox);
450 gtk_widget_hide(help_text_sw);
451
452 gtk_widget_hide(help_tree_sw);
453 gtk_widget_hide(help_tree_buttons_hbox);
454}
455
456/**********************************************************************/
459 static void help_destroy_callback(GtkWidget *w, gpointer data)
460{
461 g_ptr_array_free(help_history, TRUE);
462 help_dialog_shell = NULL;
463}
464
465/**********************************************************************/
468 static void activated_topic(GtkTreeView *view, gpointer data)
469{
470 GtkTreePath *path;
471 GtkTreeViewColumn *col;
472 GtkTreeModel *model;
473 GtkTreeIter it;
474 struct help_item *pitem;
475
476 model = gtk_tree_view_get_model(view);
477
478 gtk_tree_view_get_cursor(view, &path, &col);
479 gtk_tree_model_get_iter(model, &it, path);
480 gtk_tree_path_free(path);
481
482 if (!path) {
483 return;
484 }
485
486 gtk_tree_model_get(model, &it, 1, &pitem, -1);
487
488 if (help_history_pos >= 0
489 && g_ptr_array_index(help_history, help_history_pos) == (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 }
499 help_history_pos++;
500
501 g_ptr_array_add(help_history, (gpointer)pitem);
502 help_command_update();
503}
504
505/**********************************************************************/
508 static 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 _("_Back"),
527 1,
528 _("_Forward"),
529 2,
530 _("_Close"),
531 GTK_RESPONSE_CLOSE,
532 NULL);
533 setup_dialog(help_dialog_shell, toplevel);
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);
574 } help_items_iterate_end;
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 gtk_container_add(GTK_CONTAINER(help_box), help_tile);
615
616 help_itable = gtk_grid_new();
617 gtk_container_add(GTK_CONTAINER(help_box), help_itable);
618
619 for (i = 0; i < 6; i++) {
620 help_ilabel[i] =
621 gtk_label_new(help_ilabel_name[i] != NULL ? _(help_ilabel_name[i]) : "");
622 gtk_widget_set_hexpand(help_ilabel[i], TRUE);
623
624 if (i == 5) {
625 button = help_hyperlink_new(help_ilabel[i], &help_impr_req);
626 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
627 } else {
628 gtk_grid_attach(GTK_GRID(help_itable), help_ilabel[i], i, 0, 1, 1);
629 gtk_widget_set_name(help_ilabel[i], "help_label");
630 }
631
632 gtk_widget_show(help_ilabel[i]);
633 }
634
635 help_wtable = gtk_grid_new();
636 gtk_container_add(GTK_CONTAINER(help_box), help_wtable);
637
638 for (i = 0; i < 6; i++) {
639 help_wlabel[i] =
640 gtk_label_new(help_wlabel_name[i] ? _(help_wlabel_name[i]) : "");
641 gtk_widget_set_hexpand(help_wlabel[i], TRUE);
642
643 if (i == 3 || i == 5) {
644 button = help_hyperlink_new(help_wlabel[i], &help_wndr_req);
645 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
646 } else {
647 gtk_grid_attach(GTK_GRID(help_wtable), help_wlabel[i], i, 0, 1, 1);
648 gtk_widget_set_name(help_wlabel[i], "help_label");
649 }
650
651 gtk_widget_show(help_wlabel[i]);
652 }
653
654 help_utable = gtk_grid_new();
655 gtk_container_add(GTK_CONTAINER(help_box), help_utable);
656
657 for (i = 0; i < 5; i++) {
658 for (j = 0; j < 5; j++) {
659 help_ulabel[j][i] =
660 gtk_label_new(help_ulabel_name[j][i] ? _(help_ulabel_name[j][i]) : "");
661 gtk_widget_set_hexpand(help_ulabel[j][i], TRUE);
662
663 if (j == 4 && (i == 1 || i == 4)) {
664 if (i == 1) {
665 button = help_hyperlink_new_page(help_ulabel[j][i], HELP_TECH);
666 } else {
667 button = help_hyperlink_new_page(help_ulabel[j][i], HELP_UNIT);
668 }
669
670 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
671 } else {
672 gtk_grid_attach(GTK_GRID(help_utable), help_ulabel[j][i],
673 i, j, 1, 1);
674 gtk_widget_set_name(help_ulabel[j][i], "help_label");
675 }
676 gtk_widget_show(help_ulabel[j][i]);
677 }
678 }
679
680 help_ttable = gtk_grid_new();
681 gtk_container_add(GTK_CONTAINER(help_box), help_ttable);
682
683 for (j = 0; j < 2; j++) {
684 for (i = 0; i < 5; i++) {
685 help_tlabel[j][i] =
686 gtk_label_new(help_tlabel_name[j][i] ? _(help_tlabel_name[j][i]) : "");
687 gtk_widget_set_hexpand(help_tlabel[j][i], TRUE);
688 gtk_widget_set_name(help_tlabel[j][i], "help_label");
689
690 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
691 if (j == 1 && i == 1) {
692 /* Extra wide cell for terrain specials */
693 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
694 i, j, 4, 1);
695 gtk_widget_show(help_tlabel[j][i]);
696 break; /* skip rest of row */
697 } else {
698 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
699 i, j, 1, 1);
700 gtk_widget_show(help_tlabel[j][i]);
701 }
702 }
703 }
704
705 help_etable = gtk_grid_new();
706 gtk_container_add(GTK_CONTAINER(help_box), help_etable);
707
708 for (i = 0; i < 6; i++) {
709 help_elabel[i] =
710 gtk_label_new(help_elabel_name[i] ? _(help_elabel_name[i]) : "");
711 gtk_widget_set_hexpand(help_elabel[i], TRUE);
712 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
713 gtk_widget_set_name(help_elabel[i], "help_label");
714 gtk_widget_show(help_elabel[i]);
715 }
716
717 help_vbox = gtk_grid_new();
718 gtk_grid_set_row_spacing(GTK_GRID(help_vbox), 1);
719 gtk_orientable_set_orientation(GTK_ORIENTABLE(help_vbox),
720 GTK_ORIENTATION_VERTICAL);
721 gtk_container_set_border_width(GTK_CONTAINER(help_vbox), 5);
722 gtk_container_add(GTK_CONTAINER(help_box), help_vbox);
723
724 text = gtk_text_view_new();
725 gtk_widget_set_hexpand(text, TRUE);
726 gtk_widget_set_vexpand(text, TRUE);
727 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
728 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
729 gtk_container_set_border_width(GTK_CONTAINER(text), 5);
730 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
731 gtk_widget_set_name(text, "help_text");
732 help_text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
733 gtk_widget_show(text);
734
735 help_text_sw = gtk_scrolled_window_new(NULL, NULL);
736 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_text_sw),
737 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
738 gtk_container_add(GTK_CONTAINER(help_text_sw), text);
739 gtk_container_add(GTK_CONTAINER(help_box), help_text_sw);
740
741 /* build tech store. */
742 tstore = gtk_tree_store_new(4,
743 G_TYPE_STRING, /* tech name */
744 G_TYPE_INT, /* turns to tech */
745 G_TYPE_INT, /* tech id */
746 GDK_TYPE_RGBA); /* color */
747 help_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tstore));
748 gtk_widget_set_hexpand(help_tree, TRUE);
749 gtk_widget_set_vexpand(help_tree, TRUE);
750 g_object_unref(tstore);
751 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(help_tree), FALSE);
752
753 g_signal_connect(help_tree, "row_activated",
754 G_CALLBACK(help_tech_tree_activated_callback), NULL);
755
756
757 col = gtk_tree_view_column_new();
758
759 rend = gtk_cell_renderer_text_new();
760 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, NULL);
761 gtk_tree_view_column_pack_start(col, rend, TRUE);
762 gtk_tree_view_column_set_attributes(col, rend,
763 "text", 0,
764 "background-rgba", 3,
765 NULL);
766 rend = gtk_cell_renderer_text_new();
767 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
768 gtk_tree_view_column_pack_start(col, rend, FALSE);
769 gtk_tree_view_column_set_attributes(col, rend,
770 "text", 1,
771 "background-rgba", 3,
772 NULL);
773
774 gtk_tree_view_append_column(GTK_TREE_VIEW(help_tree), col);
775
776
777 help_tree_sw = gtk_scrolled_window_new(NULL, NULL);
778 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_tree_sw),
779 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
780 gtk_container_add(GTK_CONTAINER(help_tree_sw), help_tree);
781 gtk_widget_show(help_tree);
782 gtk_container_add(GTK_CONTAINER(help_box), help_tree_sw);
783
784 help_tree_expand =
785 gtk_button_new_with_label(_("Expand All"));
786 help_tree_collapse = gtk_button_new_with_label(_("Collapse All"));
787
788 g_signal_connect(help_tree_expand, "clicked",
789 G_CALLBACK(help_tech_tree_expand_callback), help_tree);
790 g_signal_connect(help_tree_collapse, "clicked",
791 G_CALLBACK(help_tech_tree_collapse_callback), help_tree);
792
793 help_tree_buttons_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
794 gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_expand);
795 gtk_container_add(GTK_CONTAINER(help_tree_buttons_hbox), help_tree_collapse);
796 gtk_container_add(GTK_CONTAINER(help_box), help_tree_buttons_hbox);
797 gtk_widget_show_all(help_tree_buttons_hbox);
798}
799
800/**********************************************************************/
803 static void set_help_tile_from_sprite(struct sprite *spr)
804{
805 if (spr == NULL) {
806 return;
807 }
808
809 gtk_image_set_from_surface(GTK_IMAGE(help_tile), spr->surface);
810 gtk_widget_show(help_tile);
811}
812
813/**********************************************************************/
816 static void set_help_tile_from_terrain(struct terrain *pterr)
817{
818 struct canvas canvas = FC_STATIC_CANVAS_INIT;
819 cairo_t *cr;
820 int i;
821
822 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
823 tileset_tile_width(tileset),
824 tileset_tile_height(tileset));
825
826 cr = cairo_create(canvas.surface);
827 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
828 cairo_paint(cr);
829 cairo_destroy(cr);
830
831 for (i = 0; i < 3; i++) {
832 struct drawn_sprite sprs[80];
833 int count = fill_basic_terrain_layer_sprite_array(tileset, sprs,
834 i, pterr);
835
836 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
837 }
838
839 gtk_image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
840 gtk_widget_show(help_tile);
841 cairo_surface_destroy(canvas.surface);
842}
843
844/**********************************************************************/
847 static void set_help_tile_from_extra(const struct extra_type *pextra)
848{
849 struct canvas canvas = FC_STATIC_CANVAS_INIT;
850 cairo_t *cr;
851 struct drawn_sprite sprs[80];
852 int count;
853
854 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
855 tileset_tile_width(tileset),
856 tileset_tile_height(tileset));
857
858 cr = cairo_create(canvas.surface);
859 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
860 cairo_paint(cr);
861 cairo_destroy(cr);
862
863 count = fill_basic_extra_sprite_array(tileset, sprs, pextra);
864
865 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
866
867 gtk_image_set_from_surface(GTK_IMAGE(help_tile), canvas.surface);
868 gtk_widget_show(help_tile);
869 cairo_surface_destroy(canvas.surface);
870}
871
872/**********************************************************************/
875 static void help_update_improvement(const struct help_item *pitem,
876 char *title)
877{
878 char buf[8192];
879 struct impr_type *imp = improvement_by_translated_name(title);
880
881 if (imp && !is_great_wonder(imp)) {
882 const char *req = skip_intl_qualifier_prefix(REQ_LABEL_NONE);
883 char req_buf[512];
884
885 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
886 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), buf);
887 sprintf(buf, "%d", imp->upkeep);
888 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf);
889
890 /* FIXME: this should show ranges, negated reqs, and all the
891 * MAX_NUM_REQS reqs.
892 * Currently it's limited to 1 req but this code is partially prepared
893 * to be extended. Remember MAX_NUM_REQS is a compile-time
894 * definition. */
895 help_impr_req.u.req = NULL;
896 requirement_vector_iterate(&imp->reqs, preq) {
897 if (!preq->present) {
898 continue;
899 }
900 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
901 help_impr_req.u.req = preq;
902 break;
903 } requirement_vector_iterate_end;
904 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), req);
905/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
906 } else {
907 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), "0");
908 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), "0");
909 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), REQ_LABEL_NEVER);
910/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3);*/
911 }
912
913 set_help_tile_from_sprite(get_building_sprite(tileset, imp));
914
915 gtk_widget_show(help_itable);
916
917 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
918 gtk_text_buffer_set_text(help_text, buf, -1);
919 gtk_widget_show(help_text_sw);
920}
921
922/**********************************************************************/
925 static void help_update_wonder(const struct help_item *pitem,
926 char *title)
927{
928 char buf[8192];
929 struct impr_type *imp = improvement_by_translated_name(title);
930
931 if (imp && is_great_wonder(imp)) {
932 int i;
933 char req_buf[512];
934
935 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
936 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf);
937
938 /* FIXME: this should show ranges, negated reqs, and all the
939 * MAX_NUM_REQS reqs.
940 * Currently it's limited to 1 req but this code is partially prepared
941 * to be extended. Remember MAX_NUM_REQS is a compile-time
942 * definition. */
943 i = 0;
944 help_wndr_req.u.req = NULL;
945 requirement_vector_iterate(&imp->reqs, preq) {
946 if (!preq->present) {
947 continue;
948 }
949 gtk_label_set_text(GTK_LABEL(help_wlabel[3 + i]),
950 universal_name_translation(&preq->source,
951 req_buf, sizeof(req_buf)));
952 help_wndr_req.u.req = preq;
953 i++;
954 break;
955 } requirement_vector_iterate_end;
956
957 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), REQ_LABEL_NEVER);
958 requirement_vector_iterate(&imp->obsolete_by, pobs) {
959 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
960 gtk_label_set_text(GTK_LABEL(help_wlabel[5]),
961 advance_name_translation
962 (pobs->source.value.advance));
963
964 break;
965 }
966 } requirement_vector_iterate_end;
967
968/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
969 } else {
970 /* can't find wonder */
971 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), "0");
972 gtk_label_set_text(GTK_LABEL(help_wlabel[3]), REQ_LABEL_NEVER);
973 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
974/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
975 }
976
977 set_help_tile_from_sprite(get_building_sprite(tileset, imp));
978
979 gtk_widget_show(help_wtable);
980
981 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
982 gtk_text_buffer_set_text(help_text, buf, -1);
983 gtk_widget_show(help_text_sw);
984}
985
986/**********************************************************************/
989 static void help_update_unit_type(const struct help_item *pitem,
990 char *title)
991{
992 char buf[8192];
993 struct unit_type *utype = unit_type_by_translated_name(title);
994
995 if (utype) {
996 sprintf(buf, "%d", utype_build_shield_cost_base(utype));
997 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), buf);
998 sprintf(buf, "%d", utype->attack_strength);
999 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), buf);
1000 sprintf(buf, "%d", utype->defense_strength);
1001 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), buf);
1002 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1003 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), buf);
1004 sprintf(buf, "%d", utype->firepower);
1005 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), buf);
1006 sprintf(buf, "%d", utype->hp);
1007 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), buf);
1008 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]),
1009 helptext_unit_upkeep_str(utype));
1010 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1011 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), buf);
1012 if (A_NEVER == utype->require_advance) {
1013 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1014 } else {
1015 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
1016 advance_name_translation(utype->require_advance));
1017 }
1018/* create_tech_tree(help_improvement_tree, 0, advance_number(utype->require_advance), 3);*/
1019 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1020 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1021 } else {
1022 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]),
1023 utype_name_translation(utype->obsoleted_by));
1024 }
1025
1026 helptext_unit(buf, sizeof(buf), client.conn.playing, pitem->text, utype);
1027
1028 gtk_text_buffer_set_text(help_text, buf, -1);
1029 gtk_widget_show(help_text_sw);
1030
1031 set_help_tile_from_sprite(get_unittype_sprite(tileset, utype,
1032 direction8_invalid()));
1033 } else {
1034 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), "0");
1035 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), "0");
1036 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), "0");
1037 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), "0");
1038 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), "0");
1039 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), "0");
1040 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]), "0");
1041 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), "0");
1042
1043 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1044/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3);*/
1045 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1046
1047 gtk_text_buffer_set_text(help_text, buf, -1);
1048 gtk_widget_show(help_text_sw);
1049 }
1050 gtk_widget_show(help_utable);
1051}
1052
1053/**********************************************************************/
1056 static char *fc_chomp(char *str, size_t len)
1057{
1058 gchar *i;
1059
1060 if (!str || !*str) {
1061 return str;
1062 }
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/**********************************************************************/
1076 static 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);
1093 create_tech_tree(i, TECH_TREE_DEPTH, NULL);
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
1101 set_help_tile_from_sprite(get_tech_sprite(tileset, i));
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);
1136 w = help_slink_new_page(government_name_translation(pgov),
1137 HELP_GOVERNMENT);
1138 gtk_container_add(GTK_CONTAINER(hbox), w);
1139 gtk_widget_show_all(hbox);
1140 }
1141 } requirement_vector_iterate_end;
1142 } governments_iterate_end;
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);
1153 w = help_slink_new_page(improvement_name_translation(pimprove),
1154 is_great_wonder(pimprove)
1155 ? HELP_WONDER
1156 : HELP_IMPROVEMENT);
1157 gtk_container_add(GTK_CONTAINER(hbox), w);
1158 gtk_widget_show_all(hbox);
1159 }
1160 } requirement_vector_iterate_end;
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);
1169 w = help_slink_new_page(improvement_name_translation(pimprove),
1170 is_great_wonder(pimprove)
1171 ? HELP_WONDER
1172 : HELP_IMPROVEMENT);
1173 gtk_container_add(GTK_CONTAINER(hbox), w);
1174 gtk_widget_show_all(hbox);
1175 }
1176 } requirement_vector_iterate_end;
1177 }
1178 } improvement_iterate_end;
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);
1188 w = help_slink_new_page(utype_name_translation(punittype), HELP_UNIT);
1189 gtk_container_add(GTK_CONTAINER(hbox), w);
1190 gtk_widget_show_all(hbox);
1191 } unit_type_iterate_end;
1192
1193 advance_iterate(A_NONE, ptest) {
1194 if (padvance == advance_requires(ptest, AR_ONE)) {
1195 if (advance_by_number(A_NONE) == advance_requires(ptest, AR_TWO)) {
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);
1200 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
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);
1208 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
1209 gtk_container_add(GTK_CONTAINER(hbox), w);
1210 w = gtk_label_new(_("with"));
1211 gtk_container_add(GTK_CONTAINER(hbox), w);
1212 w = help_slink_new_page(advance_name_translation(advance_requires(ptest,
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);
1226 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
1227 gtk_container_add(GTK_CONTAINER(hbox), w);
1228 w = gtk_label_new(_("with"));
1229 gtk_container_add(GTK_CONTAINER(hbox), w);
1230 w = help_slink_new_page(advance_name_translation(advance_requires(ptest, AR_ONE)),
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 }
1237 } advance_iterate_end;
1238 gtk_widget_show(help_vbox);
1239 }
1240}
1241
1242/**********************************************************************/
1245 static 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/**********************************************************************/
1268 static 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))) {
1277 add_act_help_for_terrain(label,
1278 extra_name_translation(pextra), HELP_EXTRA,
1279 helptext_extra_for_terrain_str(pextra, pterr,
1280 act));
1281 }
1282 } extra_type_by_cause_iterate_end;
1283}
1284
1285/**********************************************************************/
1288 static 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
1297 set_help_tile_from_terrain(pterrain);
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),",
1325 extra_name_translation(*r),
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"),
1346 terrain_name_translation(pterrain->cultivate_result),
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"),
1356 terrain_name_translation(pterrain->plant_result),
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"),
1367 terrain_name_translation(pterrain->transform_result),
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/**********************************************************************/
1399 static void help_update_extra(const struct help_item *pitem, char *title)
1400{
1401 char buf[8192];
1402 struct extra_type *pextra = extra_type_by_translated_name(title);
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
1411 set_help_tile_from_extra(pextra);
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 }
1440 } extra_type_iterate_end;
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
1448 output_type_iterate(o) {
1449 if (proad->tile_incr[o] > 0) {
1450 /* TRANS: Road bonus depends on terrain. */
1451 bonus = _("Terrain specific");
1452 break;
1453 }
1454 } output_type_iterate_end;
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/**********************************************************************/
1478 static 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/**********************************************************************/
1498 static void help_update_specialist(const struct help_item *pitem,
1499 char *title)
1500{
1501 char buf[8192];
1502 struct specialist *pspec = specialist_by_translated_name(title);
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/**********************************************************************/
1518 static void help_update_government(const struct help_item *pitem,
1519 char *title)
1520{
1521 char buf[8192];
1522 struct government *gov = government_by_translated_name(title);
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/**********************************************************************/
1537 static 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
1547 set_help_tile_from_sprite(get_nation_flag_sprite(tileset, pnation));
1548 }
1549
1550 gtk_text_buffer_set_text(help_text, buf, -1);
1551 gtk_widget_show(help_text_sw);
1552}
1553
1554/**********************************************************************/
1557 static 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:
1599 help_update_nation(pitem, top, nation_by_translated_plural(top));
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/**********************************************************************/
1616 static 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/**********************************************************************/
1642 static 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;
1676 } help_items_iterate_end;
1677
1678 return path;
1679}
1680
1681/**********************************************************************/
1684 static 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/**********************************************************************/
1706 static 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/**********************************************************************/
1729 static 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) {
1736 help_history_pos--;
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);
1742 help_command_update();
1743 }
1744 } else if (response_id == 2) {
1745 if (help_history_pos < help_history->len - 1) {
1746 help_history_pos++;
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);
1752 help_command_update();
1753 }
1754 } else {
1755 gtk_widget_destroy(help_dialog_shell);
1756 }
1757}
action_id_univs_not_blocking
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:950
str
#define str
Definition astring.c:76
city.h
output_type_iterate
#define output_type_iterate(output)
Definition city.h:812
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:818
client
struct civclient client
Definition client_main.c:149
client_main.h
client_player
#define client_player()
Definition client_main.h:106
climisc.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
extra_type_by_translated_name
struct extra_type * extra_type_by_translated_name(const char *name)
Definition extras.c:227
activity_to_extra_cause
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1028
can_extras_coexist
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:952
extra_name_translation
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:186
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:291
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:297
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:196
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:185
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
O_SHIELD
@ O_SHIELD
Definition fc_types.h:91
O_FOOD
@ O_FOOD
Definition fc_types.h:91
O_TRADE
@ O_TRADE
Definition fc_types.h:91
skip_intl_qualifier_prefix
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
PL_
#define PL_(String1, String2, n)
Definition fcintl.h:71
_
#define _(String)
Definition fcintl.h:67
N_
#define N_(String)
Definition fcintl.h:69
game.h
government_name_translation
const char * government_name_translation(const struct government *pgovern)
Definition government.c:142
government_by_translated_name
struct government * government_by_translated_name(const char *name)
Definition government.c:39
government.h
governments_iterate
#define governments_iterate(NAME_pgov)
Definition government.h:120
governments_iterate_end
#define governments_iterate_end
Definition government.h:123
FC_STATIC_CANVAS_INIT
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:27
toplevel
GtkWidget * toplevel
Definition gui_main.c:124
set_relative_window_position
void set_relative_window_position(GtkWindow *ref, GtkWindow *w, int px, int py)
Definition gui_stuff.c:58
setup_dialog
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:281
help_tree_sw
static GtkWidget * help_tree_sw
Definition helpdlg.c:82
set_title_topic
static void set_title_topic(char *topic)
Definition helpdlg.c:172
activated_topic
static void activated_topic(GtkTreeView *view, gpointer data)
Definition helpdlg.c:467
help_tree
static GtkWidget * help_tree
Definition helpdlg.c:79
help_tree_expand
static GtkWidget * help_tree_expand
Definition helpdlg.c:83
help_ulabel
static GtkWidget * help_ulabel[5][5]
Definition helpdlg.c:88
help_update_specialist
static void help_update_specialist(const struct help_item *pitem, char *title)
Definition helpdlg.c:1498
help_hyperlink_callback
static void help_hyperlink_callback(GtkWidget *w)
Definition helpdlg.c:343
help_elabel
static GtkWidget * help_elabel[6]
Definition helpdlg.c:90
help_etable
static GtkWidget * help_etable
Definition helpdlg.c:78
help_destroy_callback
static void help_destroy_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:458
set_help_tile_from_extra
static void set_help_tile_from_extra(const struct extra_type *pextra)
Definition helpdlg.c:848
help_frame
static GtkWidget * help_frame
Definition helpdlg.c:68
help_tech_tree_activated_callback
static void help_tech_tree_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition helpdlg.c:310
help_update_tech
static void help_update_tech(const struct help_item *pitem, char *title)
Definition helpdlg.c:1076
help_item_zoom
static void help_item_zoom(GtkTreePath *path)
Definition helpdlg.c:1616
help_slink_new_page
static GtkWidget * help_slink_new_page(const gchar *txt, enum help_page_type page)
Definition helpdlg.c:425
help_tlabel
static GtkWidget * help_tlabel[2][5]
Definition helpdlg.c:89
help_item_path
static GtkTreePath * help_item_path(const struct help_item *pitem)
Definition helpdlg.c:1642
help_tree_collapse
static GtkWidget * help_tree_collapse
Definition helpdlg.c:84
help_update_nation
static void help_update_nation(const struct help_item *pitem, char *title, struct nation_type *pnation)
Definition helpdlg.c:1537
create_help_dialog
static void create_help_dialog(void)
Definition helpdlg.c:508
help_text
static GtkTextBuffer * help_text
Definition helpdlg.c:69
help_update_wonder
static void help_update_wonder(const struct help_item *pitem, char *title)
Definition helpdlg.c:926
help_hyperlink_new_page
static GtkWidget * help_hyperlink_new_page(GtkWidget *label, enum help_page_type page)
Definition helpdlg.c:400
help_dialog_shell
static GtkWidget * help_dialog_shell
Definition helpdlg.c:63
help_text_sw
static GtkWidget * help_text_sw
Definition helpdlg.c:70
help_history
static GPtrArray * help_history
Definition helpdlg.c:94
help_elabel_name
static const char * help_elabel_name[6]
Definition helpdlg.c:131
create_tech_tree
static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
Definition helpdlg.c:225
help_update_extra
static void help_update_extra(const struct help_item *pitem, char *title)
Definition helpdlg.c:1399
help_ilabel
static GtkWidget * help_ilabel[6]
Definition helpdlg.c:86
set_help_tile_from_sprite
static void set_help_tile_from_sprite(struct sprite *spr)
Definition helpdlg.c:804
help_wlabel_name
static const char * help_wlabel_name[6]
Definition helpdlg.c:110
help_ulabel_name
static const char * help_ulabel_name[5][5]
Definition helpdlg.c:116
help_tech_tree_collapse_callback
static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:335
set_help_tile_from_terrain
static void set_help_tile_from_terrain(struct terrain *pterr)
Definition helpdlg.c:817
help_view
static GtkWidget * help_view
Definition helpdlg.c:66
help_update_goods
static void help_update_goods(const struct help_item *pitem, char *title)
Definition helpdlg.c:1478
help_system_init
void help_system_init(void)
Definition helpdlg.c:156
help_box_hide
static void help_box_hide(void)
Definition helpdlg.c:434
help_update_unit_type
static void help_update_unit_type(const struct help_item *pitem, char *title)
Definition helpdlg.c:990
popdown_help_dialog
void popdown_help_dialog(void)
Definition helpdlg.c:185
help_update_terrain
static void help_update_terrain(const struct help_item *pitem, char *title)
Definition helpdlg.c:1288
help_update_dialog
static void help_update_dialog(const struct help_item *pitem)
Definition helpdlg.c:1557
fc_chomp
static char * fc_chomp(char *str, size_t len)
Definition helpdlg.c:1057
popup_help_dialog_string
void popup_help_dialog_string(const char *item)
Definition helpdlg.c:211
help_history_pos
static int help_history_pos
Definition helpdlg.c:95
help_wndr_req
static struct help_page_selection help_wndr_req
Definition helpdlg.c:112
help_wlabel
static GtkWidget * help_wlabel[6]
Definition helpdlg.c:87
help_box
static GtkWidget * help_box
Definition helpdlg.c:73
help_extras_of_act_for_terrain
static void help_extras_of_act_for_terrain(struct terrain *pterr, enum unit_activity act, char *label)
Definition helpdlg.c:1268
popup_help_dialog_typed
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:195
REQ_LABEL_NEVER
#define REQ_LABEL_NEVER
Definition helpdlg.c:143
help_command_update
static void help_command_update(void)
Definition helpdlg.c:1706
page_selections
static struct help_page_selection page_selections[HELP_LAST]
Definition helpdlg.c:114
TECH_TREE_DEPTH
#define TECH_TREE_DEPTH
Definition helpdlg.c:58
help_tlabel_name
static const char * help_tlabel_name[2][5]
Definition helpdlg.c:125
help_impr_req
static struct help_page_selection help_impr_req
Definition helpdlg.c:108
REQ_LABEL_NONE
#define REQ_LABEL_NONE
Definition helpdlg.c:142
help_wtable
static GtkWidget * help_wtable
Definition helpdlg.c:75
help_slink_new
static GtkWidget * help_slink_new(const gchar *txt, struct help_page_selection *select)
Definition helpdlg.c:409
help_vbox
static GtkWidget * help_vbox
Definition helpdlg.c:71
help_tech_tree_expand_callback
static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:327
help_tile
static GtkWidget * help_tile
Definition helpdlg.c:72
help_hyperlink_new
static GtkWidget * help_hyperlink_new(GtkWidget *label, struct help_page_selection *select)
Definition helpdlg.c:378
help_update_government
static void help_update_government(const struct help_item *pitem, char *title)
Definition helpdlg.c:1518
help_ttable
static GtkWidget * help_ttable
Definition helpdlg.c:77
help_update_improvement
static void help_update_improvement(const struct help_item *pitem, char *title)
Definition helpdlg.c:876
help_ilabel_name
static const char * help_ilabel_name[6]
Definition helpdlg.c:106
help_tree_buttons_hbox
static GtkWidget * help_tree_buttons_hbox
Definition helpdlg.c:85
help_view_sw
static GtkWidget * help_view_sw
Definition helpdlg.c:64
select_help_item_string
static void select_help_item_string(const char *item, enum help_page_type htype)
Definition helpdlg.c:1684
help_advances
static bool help_advances[A_LAST]
Definition helpdlg.c:92
help_utable
static GtkWidget * help_utable
Definition helpdlg.c:76
help_itable
static GtkWidget * help_itable
Definition helpdlg.c:74
tstore
static GtkTreeStore * tstore
Definition helpdlg.c:80
add_act_help_for_terrain
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
help_command_callback
static void help_command_callback(GtkWidget *w, gint response_id)
Definition helpdlg.c:1729
title
const char * title
Definition repodlgs.c:1313
type
GType type
Definition repodlgs.c:1312
gui_stuff.h
colors.h
graphics.h
gui_main.h
helpdlg.h
helptext_government
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4175
helptext_advance
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3115
help_type_by_requirement
enum help_page_type help_type_by_requirement(const struct requirement *req)
Definition helpdata.c:5037
helptext_extra
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
Definition helpdata.c:3619
helptext_goods
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
Definition helpdata.c:4094
helptext_road_bonus_str
const char * helptext_road_bonus_str(const struct terrain *pterrain, const struct road_type *proad)
Definition helpdata.c:3455
helptext_unit_upkeep_str
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Definition helpdata.c:4834
helptext_extra_for_terrain_str
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
Definition helpdata.c:3585
helptext_specialist
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
Definition helpdata.c:4140
get_help_item_spec
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
Definition helpdata.c:1223
helptext_building
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1316
helptext_terrain
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
Definition helpdata.c:3338
helptext_unit
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype)
Definition helpdata.c:1763
helptext_nation
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:4871
helpdata.h
help_items_iterate
#define help_items_iterate(pitem)
Definition helpdata.h:70
help_items_iterate_end
#define help_items_iterate_end
Definition helpdata.h:74
HELP_ABOUT_ITEM
#define HELP_ABOUT_ITEM
help_page_type
help_page_type
Definition helpdlg_g.h:20
HELP_ANY
@ HELP_ANY
Definition helpdlg_g.h:20
HELP_TERRAIN
@ HELP_TERRAIN
Definition helpdlg_g.h:21
HELP_EXTRA
@ HELP_EXTRA
Definition helpdlg_g.h:21
HELP_NATIONS
@ HELP_NATIONS
Definition helpdlg_g.h:23
HELP_LAST
@ HELP_LAST
Definition helpdlg_g.h:24
HELP_IMPROVEMENT
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
HELP_UNIT
@ HELP_UNIT
Definition helpdlg_g.h:20
HELP_SPECIALIST
@ HELP_SPECIALIST
Definition helpdlg_g.h:22
HELP_GOVERNMENT
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
HELP_GOODS
@ HELP_GOODS
Definition helpdlg_g.h:22
HELP_WONDER
@ HELP_WONDER
Definition helpdlg_g.h:21
HELP_TECH
@ HELP_TECH
Definition helpdlg_g.h:21
HELP_TEXT
@ HELP_TEXT
Definition helpdlg_g.h:20
valid_improvement
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
Definition improvement.c:209
impr_base_build_shield_cost
int impr_base_build_shield_cost(const struct impr_type *pimprove)
Definition improvement.c:259
is_great_wonder
bool is_great_wonder(const struct impr_type *pimprove)
Definition improvement.c:767
improvement_by_translated_name
struct impr_type * improvement_by_translated_name(const char *name)
Definition improvement.c:350
improvement_name_translation
const char * improvement_name_translation(const struct impr_type *pimprove)
Definition improvement.c:241
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
map.h
put_drawn_sprites
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
Definition mapview_common.c:1313
mem.h
move_points_text
const char * move_points_text(int mp, bool reduce)
Definition movement.c:973
movement.h
nation_by_translated_plural
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:105
options.h
len
int len
Definition packhand.c:125
universal_name_translation
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
Definition requirements.c:5529
requirement_fulfilled_by_terrain
#define requirement_fulfilled_by_terrain(_ter_, _rqs_)
Definition requirements.h:411
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:93
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:91
research_goal_unknown_techs
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:747
research_advance_name_translation
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:271
research_get
struct research * research_get(const struct player *pplayer)
Definition research.c:126
research_invention_state
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:616
research.h
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
specialist_by_translated_name
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:130
specialist.h
advance
Definition tech.h:124
canvas
Definition canvas.h:21
canvas::surface
cairo_surface_t * surface
Definition canvas.h:22
civclient::conn
struct connection conn
Definition client_main.h:96
color
Definition colors.h:20
connection::playing
struct player * playing
Definition connection.h:156
drawn_sprite
Definition tilespec.h:109
extra_type
Definition extras.h:85
extra_type::buildable
bool buildable
Definition extras.h:112
extra_type::build_time
int build_time
Definition extras.h:114
goods_type
Definition traderoutes.h:180
government
Definition government.h:52
help_item
Definition helpdata.h:25
help_item::topic
char * topic
Definition helpdata.h:26
help_item::type
enum help_page_type type
Definition helpdata.h:27
help_item::text
char * text
Definition helpdata.h:26
help_page_selection
Definition helpdlg.c:98
help_page_selection::type
enum help_page_selection::@152 type
help_page_selection::page
enum help_page_type page
Definition helpdlg.c:101
help_page_selection::HPAGE_SRC_REQ
@ HPAGE_SRC_REQ
Definition helpdlg.c:99
help_page_selection::HPAGE_SRC_ENUM
@ HPAGE_SRC_ENUM
Definition helpdlg.c:99
help_page_selection::req
const struct requirement * req
Definition helpdlg.c:102
help_page_selection::u
union help_page_selection::@153 u
impr_type
Definition improvement.h:68
impr_type::upkeep
int upkeep
Definition improvement.h:78
impr_type::obsolete_by
struct requirement_vector obsolete_by
Definition improvement.h:76
impr_type::reqs
struct requirement_vector reqs
Definition improvement.h:75
item
Definition climisc.h:80
nation_type
Definition nation.h:97
requirement
Definition requirements.h:80
research
Definition research.h:39
road_type
Definition road.h:75
road_type::tile_incr
int tile_incr[O_LAST]
Definition road.h:81
specialist
Definition specialist.h:29
sprite
Definition sprite.h:22
sprite::surface
cairo_surface_t * surface
Definition sprite.h:23
terrain
Definition terrain.h:176
terrain::cultivate_result
struct terrain * cultivate_result
Definition terrain.h:203
terrain::resources
struct extra_type ** resources
Definition terrain.h:197
terrain::road_time
int road_time
Definition terrain.h:201
terrain::plant_time
int plant_time
Definition terrain.h:207
terrain::plant_result
struct terrain * plant_result
Definition terrain.h:206
terrain::defense_bonus
int defense_bonus
Definition terrain.h:193
terrain::cultivate_time
int cultivate_time
Definition terrain.h:204
terrain::movement_cost
int movement_cost
Definition terrain.h:192
terrain::output
int output[O_LAST]
Definition terrain.h:195
terrain::transform_time
int transform_time
Definition terrain.h:218
terrain::transform_result
struct terrain * transform_result
Definition terrain.h:217
terrain::base_time
int base_time
Definition terrain.h:200
tileset
Definition tilespec.c:459
unit_type
Definition unittype.h:481
unit_type::defense_strength
int defense_strength
Definition unittype.h:496
unit_type::firepower
int firepower
Definition unittype.h:506
unit_type::obsoleted_by
const struct unit_type * obsoleted_by
Definition unittype.h:510
unit_type::vision_radius_sq
int vision_radius_sq
Definition unittype.h:503
unit_type::move_rate
int move_rate
Definition unittype.h:497
unit_type::require_advance
struct advance * require_advance
Definition unittype.h:500
unit_type::hp
int hp
Definition unittype.h:505
unit_type::attack_strength
int attack_strength
Definition unittype.h:495
universal
Definition fc_types.h:756
universal::kind
enum universals_n kind
Definition fc_types.h:758
view
Definition mapview_common.h:36
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
is_future_tech
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
advance_by_translated_name
struct advance * advance_by_translated_name(const char *name)
Definition tech.c:185
advance_requires
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
Definition tech.c:136
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
advance_required
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Definition tech.c:121
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
tech.h
A_NEVER
#define A_NEVER
Definition tech.h:51
AR_TWO
@ AR_TWO
Definition tech.h:112
AR_ONE
@ AR_ONE
Definition tech.h:111
advance_iterate
#define advance_iterate(_start, _p)
Definition tech.h:264
A_NONE
#define A_NONE
Definition tech.h:43
advance_iterate_end
#define advance_iterate_end
Definition tech.h:270
A_LAST
#define A_LAST
Definition tech.h:45
terrain_by_translated_name
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:190
terrain_name_translation
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:226
T_NONE
#define T_NONE
Definition terrain.h:56
get_building_sprite
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6498
get_unittype_sprite
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum direction8 facing)
Definition tilespec.c:6520
fill_basic_extra_sprite_array
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:6901
fill_basic_terrain_layer_sprite_array
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:6868
tileset_tile_height
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:728
get_nation_flag_sprite
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6471
tileset_tile_width
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:716
get_tech_sprite
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6489
tilespec.h
goods_by_translated_name
struct goods_type * goods_by_translated_name(const char *name)
Definition traderoutes.c:652
unit.h
utype_build_shield_cost_base
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1520
unit_type_by_translated_name
struct unit_type * unit_type_by_translated_name(const char *name)
Definition unittype.c:1804
utype_name_translation
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1612
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
U_NOT_OBSOLETED
#define U_NOT_OBSOLETED
Definition unittype.h:509
freeciv_name_version
const char * freeciv_name_version(void)
Definition version.c:35
version.h