Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-gtk-4.0/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-4.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 */
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}
180
181/**********************************************************************/
184 void popdown_help_dialog(void)
185{
186 if (help_dialog_shell) {
187 gtk_window_destroy(GTK_WINDOW(help_dialog_shell));
188 }
189}
190
191/**********************************************************************/
194 void popup_help_dialog_typed(const char *item, enum help_page_type htype)
195{
196 if (!help_dialog_shell) {
197 create_help_dialog();
198 }
199 gtk_window_present(GTK_WINDOW(help_dialog_shell));
200
201 select_help_item_string(item, htype);
202}
203
204/**********************************************************************/
208 void popup_help_dialog_string(const char *item)
209{
210 popup_help_dialog_typed(Q_(item), HELP_ANY);
211}
212
213/**********************************************************************/
222 static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
223{
224 const struct research *presearch;
225 int bg;
226 int turns_to_tech;
227 bool original;
228 GtkTreeIter l;
229 GValue value = { 0, };
230 enum tech_state state;
231
232 if (advance_required(tech, AR_ONE) == A_LAST
233 && advance_required(tech, AR_TWO) == A_LAST) {
234 bg = COLOR_REQTREE_UNKNOWN;
235
236 gtk_tree_store_append(tstore, &l, parent);
237 help_advances[tech] = TRUE;
238
239 g_value_init(&value, G_TYPE_STRING);
240 g_value_set_static_string(&value, _("Removed"));
241 gtk_tree_store_set_value(tstore, &l, 0, &value);
242 g_value_unset(&value);
243
244 gtk_tree_store_set(tstore, &l,
245 1, -1,
246 2, tech,
247 3, &get_color(tileset, bg)->color
248 -1);
249 return;
250 }
251
252 presearch = research_get(client_player());
253
254 state = research_invention_state(presearch, tech);
255 if (tech_state_is_valid(state)) {
256 switch (state) {
257 case TECH_UNKNOWN:
258 bg = COLOR_REQTREE_UNKNOWN;
259 break;
260 case TECH_KNOWN:
261 bg = COLOR_REQTREE_KNOWN;
262 break;
263 case TECH_PREREQS_KNOWN:
264 bg = COLOR_REQTREE_PREREQS_KNOWN;
265 break;
266 }
267 } else {
268 bg = COLOR_REQTREE_BACKGROUND;
269 }
270 turns_to_tech = research_goal_unknown_techs(presearch, tech);
271
272 /* l is the original in the tree. */
273 original = !help_advances[tech];
274
275 gtk_tree_store_append(tstore, &l, parent);
276 help_advances[tech] = TRUE;
277
278 g_value_init(&value, G_TYPE_STRING);
279 g_value_set_static_string(&value,
280 research_advance_name_translation(presearch,
281 tech));
282 gtk_tree_store_set_value(tstore, &l, 0, &value);
283 g_value_unset(&value);
284
285 gtk_tree_store_set(tstore, &l,
286 1, turns_to_tech,
287 2, tech,
288 3, &get_color(tileset, bg)->color,
289 -1);
290
291 if (--levels <= 0) {
292 return;
293 }
294
295 if (original) {
296 /* Only add children to orginals */
297 if (advance_required(tech, AR_ONE) != A_NONE)
298 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
299 if (advance_required(tech, AR_TWO) != A_NONE)
300 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
301 }
302}
303
304/**********************************************************************/
307 static void help_tech_tree_activated_callback(GtkTreeView *view,
308 GtkTreePath *path,
309 GtkTreeViewColumn *col,
310 gpointer data)
311{
312 GtkTreeIter it;
313 gint tech;
314
315 gtk_tree_model_get_iter(GTK_TREE_MODEL(tstore), &it, path);
316 gtk_tree_model_get(GTK_TREE_MODEL(tstore), &it, 2, &tech, -1);
317 select_help_item_string(advance_name_translation(advance_by_number(tech)),
318 HELP_TECH);
319}
320
321/**********************************************************************/
324 static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
325{
326 gtk_tree_view_expand_all(GTK_TREE_VIEW(data));
327}
328
329/**********************************************************************/
332 static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
333{
334 gtk_tree_view_collapse_all(GTK_TREE_VIEW(data));
335}
336
337/**********************************************************************/
340 static void help_hyperlink_callback(GtkWidget *w)
341{
342 const char *s;
343 struct help_page_selection *select;
344 enum help_page_type type = HELP_LAST;
345
346 s = gtk_label_get_text(GTK_LABEL(w));
347 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w),
348 "page_type"));
349
350 switch (select->type) {
351 case HPAGE_SRC_ENUM:
352 type = select->u.page;
353 break;
354 case HPAGE_SRC_REQ:
355 type = help_type_by_requirement(select->u.req);
356 break;
357 }
358
359 if (type == HELP_LAST) {
360 return;
361 }
362
363 /* FIXME: May be able to skip, or may need to modify, advances[A_NONE]
364 below, depending on which i18n is done elsewhere.
365 */
366 if (strcmp(s, REQ_LABEL_NEVER) != 0
367 && strcmp(s, skip_intl_qualifier_prefix(REQ_LABEL_NONE)) != 0
368 && strcmp(s, advance_name_translation(advance_by_number(A_NONE))) != 0) {
369 select_help_item_string(s, type);
370 }
371}
372
373/**********************************************************************/
376 static GtkWidget *help_hyperlink_new(GtkWidget *label,
377 struct help_page_selection *select)
378{
379 GtkWidget *button;
380
381 button = gtk_button_new();
382 gtk_button_set_has_frame(GTK_BUTTON(button), FALSE);
383 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
384 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
385 gtk_widget_set_name(label, "help_link");
386 gtk_button_set_child(GTK_BUTTON(button), label);
387 gtk_widget_show(button);
388 g_signal_connect_swapped(button, "clicked",
389 G_CALLBACK(help_hyperlink_callback), label);
390 g_object_set_data(G_OBJECT(label), "page_type", select);
391
392 return button;
393}
394
395/**********************************************************************/
398 static GtkWidget *help_hyperlink_new_page(GtkWidget *label,
399 enum help_page_type page)
400{
401 return help_hyperlink_new(label, &(page_selections[page]));
402}
403
404/**********************************************************************/
407 static GtkWidget *help_slink_new(const gchar *txt,
408 struct help_page_selection *select)
409{
410 GtkWidget *button, *label;
411
412 label = gtk_label_new(txt);
413 gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
414 gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
415 button = help_hyperlink_new(label, select);
416
417 return button;
418}
419
420/**********************************************************************/
423 static GtkWidget *help_slink_new_page(const gchar *txt,
424 enum help_page_type page)
425{
426 return help_slink_new(txt, &(page_selections[page]));
427}
428
429/**********************************************************************/
432 static void help_box_hide(void)
433{
434 gtk_widget_hide(help_box);
435
436 gtk_widget_hide(help_tile);
437
438 gtk_widget_hide(help_itable);
439 gtk_widget_hide(help_wtable);
440 gtk_widget_hide(help_utable);
441 gtk_widget_hide(help_ttable);
442 gtk_widget_hide(help_etable);
443
444 gtk_widget_hide(help_tile); /* FIXME: twice? */
445
446 gtk_widget_hide(help_vbox);
447 gtk_widget_hide(help_text_sw);
448
449 gtk_widget_hide(help_tree_sw);
450 gtk_widget_hide(help_tree_buttons_hbox);
451}
452
453/**********************************************************************/
456 static void help_box_add(GtkWidget *wdg)
457{
458 gtk_box_append(GTK_BOX(help_vbox), wdg);
459}
460
461/**********************************************************************/
464 static void help_box_clear(void)
465{
466 GtkWidget *child = gtk_widget_get_first_child(help_vbox);
467
468 while (child != NULL) {
469 gtk_box_remove(GTK_BOX(help_vbox), child);
470 child = gtk_widget_get_first_child(help_vbox);
471 }
472}
473
474/**********************************************************************/
477 static void help_destroy_callback(GtkWidget *w, gpointer data)
478{
479 g_ptr_array_free(help_history, TRUE);
480 help_dialog_shell = NULL;
481}
482
483/**********************************************************************/
486 static void activated_topic(GtkTreeView *view, gpointer data)
487{
488 GtkTreePath *path;
489 GtkTreeViewColumn *col;
490 GtkTreeModel *model;
491 GtkTreeIter it;
492 struct help_item *pitem;
493
494 model = gtk_tree_view_get_model(view);
495
496 if (model == NULL) {
497 return;
498 }
499
500 gtk_tree_view_get_cursor(view, &path, &col);
501 gtk_tree_model_get_iter(model, &it, path);
502 gtk_tree_path_free(path);
503
504 if (path == NULL) {
505 return;
506 }
507
508 gtk_tree_model_get(model, &it, 1, &pitem, -1);
509
510 if (help_history_pos >= 0
511 && g_ptr_array_index(help_history, help_history_pos) == (gpointer) pitem) {
512 return;
513 }
514
515 help_update_dialog(pitem);
516
517 /* Add to history. */
518 if (help_history_pos < help_history->len - 1) {
519 g_ptr_array_set_size(help_history, help_history_pos + 1);
520 }
521 help_history_pos++;
522
523 g_ptr_array_add(help_history, (gpointer)pitem);
524 help_command_update();
525}
526
527/**********************************************************************/
530 static void create_help_dialog(void)
531{
532 GtkWidget *hbox;
533 GtkWidget *button;
534 GtkWidget *text;
535 int i, j;
536 GtkCellRenderer *rend;
537 GtkTreeViewColumn *col;
538 GArray *array;
539 GtkTreeStore *store;
540 GtkTreeSelection *selection;
541 GtkWidget *tile_sw;
542
543 help_history = g_ptr_array_new();
544 help_history_pos = -1;
545
546 help_dialog_shell = gtk_dialog_new_with_buttons(_("Freeciv Help Browser"),
547 NULL,
548 0,
549 _("_Back"),
550 1,
551 _("_Forward"),
552 2,
553 _("_Close"),
554 GTK_RESPONSE_CLOSE,
555 NULL);
556 setup_dialog(help_dialog_shell, toplevel);
557 gtk_dialog_set_default_response(GTK_DIALOG(help_dialog_shell),
558 GTK_RESPONSE_CLOSE);
559 gtk_widget_set_name(help_dialog_shell, "Freeciv");
560
561 g_signal_connect(help_dialog_shell, "response",
562 G_CALLBACK(help_command_callback), NULL);
563 g_signal_connect(help_dialog_shell, "destroy",
564 G_CALLBACK(help_destroy_callback), NULL);
565
566 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
567 gtk_box_append(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(help_dialog_shell))),
568 hbox);
569 gtk_widget_show(hbox);
570
571 /* Build tree store. */
572 store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
573
574 array = g_array_new(FALSE, FALSE, sizeof(GtkTreeIter));
575 help_items_iterate(pitem) {
576 GtkTreeIter *it, *parent;
577 const char *s;
578 int depth;
579
580 for (s = pitem->topic; *s == ' '; s++) {
581 /* Nothing */
582 }
583 depth = s - pitem->topic;
584
585 array = g_array_set_size(array, depth+1);
586
587 if (depth > 0) {
588 parent = &g_array_index(array, GtkTreeIter, depth-1);
589 } else {
590 parent = NULL;
591 }
592
593 it = &g_array_index(array, GtkTreeIter, depth);
594 gtk_tree_store_append(store, it, parent);
595
596 gtk_tree_store_set(store, it, 0, pitem->topic, 1, pitem, -1);
597 } help_items_iterate_end;
598
599 /* Create tree view. */
600 help_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
601 g_object_unref(store);
602 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(help_view));
603 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(help_view), FALSE);
604
605 g_signal_connect(help_view, "cursor-changed",
606 G_CALLBACK(activated_topic), NULL);
607
608 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(help_view));
609 gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
610
611 rend = gtk_cell_renderer_text_new();
612 col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", 0, NULL);
613 gtk_tree_view_append_column(GTK_TREE_VIEW(help_view), col);
614
615 help_view_sw = gtk_scrolled_window_new();
616 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_view_sw),
617 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
618 gtk_widget_set_size_request(help_view_sw, 190, -1);
619 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_view_sw), help_view);
620 gtk_widget_show(help_view);
621 gtk_box_append(GTK_BOX(hbox), help_view_sw);
622 gtk_widget_show(help_view_sw);
623
624 help_frame = gtk_frame_new("");
625 gtk_box_append(GTK_BOX(hbox), help_frame);
626 gtk_widget_set_hexpand(help_frame, TRUE);
627 gtk_widget_show(help_frame);
628
629 help_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
630 gtk_frame_set_child(GTK_FRAME(help_frame), help_box);
631
632 help_tile = gtk_picture_new();
633 gtk_picture_set_can_shrink(GTK_PICTURE(help_tile), FALSE);
634 gtk_widget_set_valign(help_tile, GTK_ALIGN_CENTER);
635 gtk_widget_set_halign(help_tile, GTK_ALIGN_CENTER);
636 tile_sw = gtk_scrolled_window_new();
637 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tile_sw),
638 GTK_POLICY_NEVER,
639 GTK_POLICY_NEVER);
640 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tile_sw), help_tile);
641 gtk_box_append(GTK_BOX(help_box), tile_sw);
642
643 help_itable = gtk_grid_new();
644 gtk_box_append(GTK_BOX(help_box), help_itable);
645
646 for (i = 0; i < 6; i++) {
647 help_ilabel[i] =
648 gtk_label_new(help_ilabel_name[i] != NULL ? _(help_ilabel_name[i]) : "");
649 gtk_widget_set_hexpand(help_ilabel[i], TRUE);
650
651 if (i == 5) {
652 button = help_hyperlink_new(help_ilabel[i], &help_impr_req);
653 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
654 } else {
655 gtk_grid_attach(GTK_GRID(help_itable), help_ilabel[i], i, 0, 1, 1);
656 gtk_widget_set_name(help_ilabel[i], "help_label");
657 }
658
659 gtk_widget_show(help_ilabel[i]);
660 }
661
662 help_wtable = gtk_grid_new();
663 gtk_box_append(GTK_BOX(help_box), help_wtable);
664
665 for (i = 0; i < 6; i++) {
666 help_wlabel[i] =
667 gtk_label_new(help_wlabel_name[i] ? _(help_wlabel_name[i]) : "");
668 gtk_widget_set_hexpand(help_wlabel[i], TRUE);
669
670 if (i == 3 || i == 5) {
671 button = help_hyperlink_new(help_wlabel[i], &help_wndr_req);
672 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
673 } else {
674 gtk_grid_attach(GTK_GRID(help_wtable), help_wlabel[i], i, 0, 1, 1);
675 gtk_widget_set_name(help_wlabel[i], "help_label");
676 }
677
678 gtk_widget_show(help_wlabel[i]);
679 }
680
681 help_utable = gtk_grid_new();
682 gtk_box_append(GTK_BOX(help_box), help_utable);
683
684 for (i = 0; i < 5; i++) {
685 for (j = 0; j < 5; j++) {
686 help_ulabel[j][i] =
687 gtk_label_new(help_ulabel_name[j][i] ? _(help_ulabel_name[j][i]) : "");
688 gtk_widget_set_hexpand(help_ulabel[j][i], TRUE);
689
690 if (j == 4 && (i == 1 || i == 4)) {
691 if (i == 1) {
692 button = help_hyperlink_new_page(help_ulabel[j][i], HELP_TECH);
693 } else {
694 button = help_hyperlink_new_page(help_ulabel[j][i], HELP_UNIT);
695 }
696
697 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
698 } else {
699 gtk_grid_attach(GTK_GRID(help_utable), help_ulabel[j][i],
700 i, j, 1, 1);
701 gtk_widget_set_name(help_ulabel[j][i], "help_label");
702 }
703 gtk_widget_show(help_ulabel[j][i]);
704 }
705 }
706
707 help_ttable = gtk_grid_new();
708 gtk_box_append(GTK_BOX(help_box), help_ttable);
709
710 for (j = 0; j < 2; j++) {
711 for (i = 0; i < 5; i++) {
712 help_tlabel[j][i] =
713 gtk_label_new(help_tlabel_name[j][i] ? _(help_tlabel_name[j][i]) : "");
714 gtk_widget_set_hexpand(help_tlabel[j][i], TRUE);
715 gtk_widget_set_name(help_tlabel[j][i], "help_label");
716
717 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
718 if (j == 1 && i == 1) {
719 /* Extra wide cell for terrain specials */
720 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
721 i, j, 4, 1);
722 gtk_widget_show(help_tlabel[j][i]);
723 break; /* skip rest of row */
724 } else {
725 gtk_grid_attach(GTK_GRID(help_ttable), help_tlabel[j][i],
726 i, j, 1, 1);
727 gtk_widget_show(help_tlabel[j][i]);
728 }
729 }
730 }
731
732 help_etable = gtk_grid_new();
733 gtk_box_append(GTK_BOX(help_box), help_etable);
734
735 for (i = 0; i < 6; i++) {
736 help_elabel[i] =
737 gtk_label_new(help_elabel_name[i] ? _(help_elabel_name[i]) : "");
738 gtk_widget_set_hexpand(help_elabel[i], TRUE);
739 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
740 gtk_widget_set_name(help_elabel[i], "help_label");
741 gtk_widget_show(help_elabel[i]);
742 }
743
744 help_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 1);
745 gtk_widget_set_margin_start(help_vbox, 5);
746 gtk_widget_set_margin_end(help_vbox, 5);
747 gtk_widget_set_margin_top(help_vbox, 5);
748 gtk_widget_set_margin_bottom(help_vbox, 5);
749 gtk_box_append(GTK_BOX(help_box), help_vbox);
750
751 text = gtk_text_view_new();
752 gtk_widget_set_hexpand(text, TRUE);
753 gtk_widget_set_vexpand(text, TRUE);
754 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
755 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
756 gtk_widget_set_margin_start(text, 5);
757 gtk_widget_set_margin_end(text, 5);
758 gtk_widget_set_margin_top(text, 5);
759 gtk_widget_set_margin_bottom(text, 5);
760 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
761 gtk_widget_set_name(text, "help_text");
762 help_text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
763 gtk_widget_show(text);
764
765 help_text_sw = gtk_scrolled_window_new();
766 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_text_sw),
767 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
768 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_text_sw), text);
769 gtk_box_append(GTK_BOX(help_box), help_text_sw);
770
771 /* Build tech store. */
772 tstore = gtk_tree_store_new(4,
773 G_TYPE_STRING, /* Tech name */
774 G_TYPE_INT, /* Turns to tech */
775 G_TYPE_INT, /* Tech id */
776 GDK_TYPE_RGBA); /* Color */
777 help_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(tstore));
778 gtk_widget_set_hexpand(help_tree, TRUE);
779 gtk_widget_set_vexpand(help_tree, TRUE);
780 g_object_unref(tstore);
781 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(help_tree), FALSE);
782
783 g_signal_connect(help_tree, "row_activated",
784 G_CALLBACK(help_tech_tree_activated_callback), NULL);
785
786
787 col = gtk_tree_view_column_new();
788
789 rend = gtk_cell_renderer_text_new();
790 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, NULL);
791 gtk_tree_view_column_pack_start(col, rend, TRUE);
792 gtk_tree_view_column_set_attributes(col, rend,
793 "text", 0,
794 "background-rgba", 3,
795 NULL);
796 rend = gtk_cell_renderer_text_new();
797 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
798 gtk_tree_view_column_pack_start(col, rend, FALSE);
799 gtk_tree_view_column_set_attributes(col, rend,
800 "text", 1,
801 "background-rgba", 3,
802 NULL);
803
804 gtk_tree_view_append_column(GTK_TREE_VIEW(help_tree), col);
805
806 help_tree_sw = gtk_scrolled_window_new();
807 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(help_tree_sw),
808 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
809 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(help_tree_sw), help_tree);
810 gtk_widget_set_size_request(help_tree_sw, -1, 200);
811 gtk_widget_show(help_tree);
812 gtk_box_append(GTK_BOX(help_box), help_tree_sw);
813
814 help_tree_expand = gtk_button_new_with_label(_("Expand All"));
815 help_tree_collapse = gtk_button_new_with_label(_("Collapse All"));
816
817 g_signal_connect(help_tree_expand, "clicked",
818 G_CALLBACK(help_tech_tree_expand_callback), help_tree);
819 g_signal_connect(help_tree_collapse, "clicked",
820 G_CALLBACK(help_tech_tree_collapse_callback), help_tree);
821
822 help_tree_buttons_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
823 gtk_box_append(GTK_BOX(help_tree_buttons_hbox), help_tree_expand);
824 gtk_box_append(GTK_BOX(help_tree_buttons_hbox), help_tree_collapse);
825 gtk_box_append(GTK_BOX(help_box), help_tree_buttons_hbox);
826 gtk_widget_show(help_tree_buttons_hbox);
827}
828
829/**********************************************************************/
832 static void set_help_tile_from_sprite(struct sprite *spr)
833{
834 if (spr == NULL) {
835 return;
836 }
837
838 picture_set_from_surface(GTK_PICTURE(help_tile), spr->surface);
839 gtk_widget_show(help_tile);
840}
841
842/**********************************************************************/
845 static void set_help_tile_from_terrain(struct terrain *pterr)
846{
847 struct canvas canvas = FC_STATIC_CANVAS_INIT;
848 cairo_t *cr;
849 int i;
850
851 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
852 tileset_tile_width(tileset),
853 tileset_tile_height(tileset));
854
855 cr = cairo_create(canvas.surface);
856 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
857 cairo_paint(cr);
858 cairo_destroy(cr);
859
860 for (i = 0; i < 3; i++) {
861 struct drawn_sprite sprs[80];
862 int count = fill_basic_terrain_layer_sprite_array(tileset, sprs,
863 i, pterr);
864
865 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
866 }
867
868 picture_set_from_surface(GTK_PICTURE(help_tile), canvas.surface);
869 gtk_widget_show(help_tile);
870 cairo_surface_destroy(canvas.surface);
871}
872
873/**********************************************************************/
876 static void set_help_tile_from_extra(const struct extra_type *pextra)
877{
878 struct canvas canvas = FC_STATIC_CANVAS_INIT;
879 cairo_t *cr;
880 struct drawn_sprite sprs[80];
881 int count;
882
883 canvas.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
884 tileset_tile_width(tileset),
885 tileset_tile_height(tileset));
886
887 cr = cairo_create(canvas.surface);
888 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
889 cairo_paint(cr);
890 cairo_destroy(cr);
891
892 count = fill_basic_extra_sprite_array(tileset, sprs, pextra);
893
894 put_drawn_sprites(&canvas, 1.0, 0, 0, count, sprs, FALSE);
895
896 picture_set_from_surface(GTK_PICTURE(help_tile), canvas.surface);
897 gtk_widget_show(help_tile);
898 cairo_surface_destroy(canvas.surface);
899}
900
901/**********************************************************************/
904 static void help_update_improvement(const struct help_item *pitem,
905 char *title)
906{
907 char buf[8192];
908 struct impr_type *imp = improvement_by_translated_name(title);
909
910 if (imp != NULL && !is_great_wonder(imp)) {
911 const char *req = skip_intl_qualifier_prefix(REQ_LABEL_NONE);
912 char req_buf[512];
913
914 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
915 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), buf);
916 sprintf(buf, "%d", imp->upkeep);
917 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), buf);
918
919 /* FIXME: this should show ranges, negated reqs, and all the
920 * MAX_NUM_REQS reqs.
921 * Currently it's limited to 1 req but this code is partially prepared
922 * to be extended. Remember MAX_NUM_REQS is a compile-time
923 * definition. */
924 help_impr_req.u.req = NULL;
925 requirement_vector_iterate(&imp->reqs, preq) {
926 if (!preq->present) {
927 continue;
928 }
929 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
930 help_impr_req.u.req = preq;
931 break;
932 } requirement_vector_iterate_end;
933 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), req);
934/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
935 } else {
936 gtk_label_set_text(GTK_LABEL(help_ilabel[1]), "0");
937 gtk_label_set_text(GTK_LABEL(help_ilabel[3]), "0");
938 gtk_label_set_text(GTK_LABEL(help_ilabel[5]), REQ_LABEL_NEVER);
939/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
940 }
941
942 set_help_tile_from_sprite(get_building_sprite(tileset, imp));
943
944 gtk_widget_show(help_itable);
945
946 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
947 gtk_text_buffer_set_text(help_text, buf, -1);
948 gtk_widget_show(help_text_sw);
949}
950
951/**********************************************************************/
954 static void help_update_wonder(const struct help_item *pitem,
955 char *title)
956{
957 char buf[8192];
958 struct impr_type *imp = improvement_by_translated_name(title);
959
960 if (imp != NULL && is_great_wonder(imp)) {
961 int i;
962 char req_buf[512];
963
964 sprintf(buf, "%d", impr_base_build_shield_cost(imp));
965 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), buf);
966
967 /* FIXME: this should show ranges, negated reqs, and all the
968 * MAX_NUM_REQS reqs.
969 * Currently it's limited to 1 req but this code is partially prepared
970 * to be extended. Remember MAX_NUM_REQS is a compile-time
971 * definition. */
972 i = 0;
973 help_wndr_req.u.req = NULL;
974 requirement_vector_iterate(&imp->reqs, preq) {
975 if (!preq->present) {
976 continue;
977 }
978 gtk_label_set_text(GTK_LABEL(help_wlabel[3 + i]),
979 universal_name_translation(&preq->source,
980 req_buf, sizeof(req_buf)));
981 help_wndr_req.u.req = preq;
982 i++;
983 break;
984 } requirement_vector_iterate_end;
985
986 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), REQ_LABEL_NEVER);
987 requirement_vector_iterate(&imp->obsolete_by, pobs) {
988 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
989 gtk_label_set_text(GTK_LABEL(help_wlabel[5]),
990 advance_name_translation
991 (pobs->source.value.advance));
992
993 break;
994 }
995 } requirement_vector_iterate_end;
996
997/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
998 } else {
999 /* Can't find wonder */
1000 gtk_label_set_text(GTK_LABEL(help_wlabel[1]), "0");
1001 gtk_label_set_text(GTK_LABEL(help_wlabel[3]), REQ_LABEL_NEVER);
1002 gtk_label_set_text(GTK_LABEL(help_wlabel[5]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1003/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
1004 }
1005
1006 set_help_tile_from_sprite(get_building_sprite(tileset, imp));
1007
1008 gtk_widget_show(help_wtable);
1009
1010 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
1011 gtk_text_buffer_set_text(help_text, buf, -1);
1012 gtk_widget_show(help_text_sw);
1013}
1014
1015/**********************************************************************/
1018 static void help_update_unit_type(const struct help_item *pitem,
1019 char *title)
1020{
1021 char buf[8192];
1022 struct unit_type *utype = unit_type_by_translated_name(title);
1023
1024 if (utype != NULL) {
1025 sprintf(buf, "%d", utype_build_shield_cost_base(utype));
1026 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), buf);
1027 sprintf(buf, "%d", utype->attack_strength);
1028 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), buf);
1029 sprintf(buf, "%d", utype->defense_strength);
1030 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), buf);
1031 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1032 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), buf);
1033 sprintf(buf, "%d", utype->firepower);
1034 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), buf);
1035 sprintf(buf, "%d", utype->hp);
1036 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), buf);
1037 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]),
1038 helptext_unit_upkeep_str(utype));
1039 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1040 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), buf);
1041 if (A_NEVER == utype->require_advance) {
1042 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1043 } else {
1044 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
1045 advance_name_translation(utype->require_advance));
1046 }
1047
1048#if 0
1049 create_tech_tree(help_improvement_tree, 0,
1050 advance_number(utype->require_advance), 3);
1051#endif
1052
1053 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1054 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]),
1055 skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1056 } else {
1057 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]),
1058 utype_name_translation(utype->obsoleted_by));
1059 }
1060
1061 helptext_unit(buf, sizeof(buf), client.conn.playing, pitem->text, utype);
1062
1063 gtk_text_buffer_set_text(help_text, buf, -1);
1064 gtk_widget_show(help_text_sw);
1065
1066 set_help_tile_from_sprite(get_unittype_sprite(tileset, utype,
1067 direction8_invalid()));
1068 } else {
1069 gtk_label_set_text(GTK_LABEL(help_ulabel[0][1]), "0");
1070 gtk_label_set_text(GTK_LABEL(help_ulabel[0][4]), "0");
1071 gtk_label_set_text(GTK_LABEL(help_ulabel[1][1]), "0");
1072 gtk_label_set_text(GTK_LABEL(help_ulabel[1][4]), "0");
1073 gtk_label_set_text(GTK_LABEL(help_ulabel[2][1]), "0");
1074 gtk_label_set_text(GTK_LABEL(help_ulabel[2][4]), "0");
1075 gtk_label_set_text(GTK_LABEL(help_ulabel[3][1]), "0");
1076 gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), "0");
1077
1078 gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]), REQ_LABEL_NEVER);
1079/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3); */
1080 gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]),
1081 skip_intl_qualifier_prefix(REQ_LABEL_NONE));
1082
1083 gtk_text_buffer_set_text(help_text, buf, -1);
1084 gtk_widget_show(help_text_sw);
1085 }
1086 gtk_widget_show(help_utable);
1087}
1088
1089/**********************************************************************/
1092 static char *fc_chomp(char *str, size_t len)
1093{
1094 gchar *i;
1095
1096 if (str == NULL || !*str) {
1097 return str;
1098 }
1099
1100 i = str + len;
1101 for (i = g_utf8_find_prev_char(str, i);
1102 (i != NULL && g_unichar_isspace(g_utf8_get_char(i)));
1103 i = g_utf8_find_prev_char(str, i)) {
1104 *i = '\0';
1105 }
1106
1107 return str;
1108}
1109
1110/**********************************************************************/
1113 static void help_update_tech(const struct help_item *pitem, char *title)
1114{
1115 int i, j;
1116 GtkWidget *w, *hbox;
1117 char buf[8192];
1118 struct advance *padvance = advance_by_translated_name(title);
1119
1120 if (padvance != NULL
1121 && !is_future_tech(i = advance_number(padvance))) {
1122 GtkTextBuffer *txt;
1123 size_t len;
1124
1125 help_box_clear();
1126
1127 for (j = 0; j < ARRAY_SIZE(help_advances); j++) {
1128 help_advances[j] = FALSE;
1129 }
1130 gtk_tree_store_clear(tstore);
1131 create_tech_tree(i, TECH_TREE_DEPTH, NULL);
1132 gtk_widget_show(help_tree_sw);
1133 gtk_widget_show(help_tree_buttons_hbox);
1134
1135 helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i);
1136 len = strlen(buf);
1137 fc_chomp(buf, len);
1138
1139 set_help_tile_from_sprite(get_tech_sprite(tileset, i));
1140
1141 w = gtk_text_view_new();
1142 gtk_widget_set_hexpand(w, TRUE);
1143 gtk_widget_set_vexpand(w, TRUE);
1144 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(w), FALSE);
1145 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(w), GTK_WRAP_WORD);
1146 gtk_widget_set_name(w, "help_text");
1147 gtk_widget_set_margin_start(w, 5);
1148 gtk_widget_set_margin_end(w, 5);
1149 gtk_widget_set_margin_top(w, 5);
1150 gtk_widget_set_margin_bottom(w, 5);
1151 gtk_text_view_set_editable(GTK_TEXT_VIEW(w), FALSE);
1152 help_box_add(w);
1153 gtk_widget_show(w);
1154
1155 txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
1156 if (txt) {
1157 gtk_text_buffer_set_text(txt, buf, -1);
1158 }
1159
1160 w = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
1161 gtk_widget_set_margin_bottom(w, 5);
1162 gtk_widget_set_margin_end(w, 5);
1163 gtk_widget_set_margin_start(w, 5);
1164 gtk_widget_set_margin_top(w, 5);
1165 gtk_widget_set_hexpand(w, TRUE);
1166 gtk_widget_set_vexpand(w, TRUE);
1167 help_box_add(w);
1168 gtk_widget_show(w);
1169
1170 governments_iterate(pgov) {
1171 /* FIXME: need a more general mechanism for this, since this
1172 * helptext needs to be shown in all possible req source types. */
1173 requirement_vector_iterate(&pgov->reqs, preq) {
1174 if (VUT_ADVANCE == preq->source.kind
1175 && preq->source.value.advance == padvance) {
1176 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1177 help_box_add(hbox);
1178 w = gtk_label_new(_("Allows"));
1179 gtk_box_append(GTK_BOX(hbox), w);
1180 w = help_slink_new_page(government_name_translation(pgov),
1181 HELP_GOVERNMENT);
1182 gtk_box_append(GTK_BOX(hbox), w);
1183 gtk_widget_show(hbox);
1184 }
1185 } requirement_vector_iterate_end;
1186 } governments_iterate_end;
1187
1188 improvement_iterate(pimprove) {
1189 if (valid_improvement(pimprove)) {
1190 requirement_vector_iterate(&pimprove->reqs, preq) {
1191 if (VUT_ADVANCE == preq->source.kind
1192 && preq->source.value.advance == padvance) {
1193 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1194 help_box_add(hbox);
1195 w = gtk_label_new(_("Allows"));
1196 gtk_box_append(GTK_BOX(hbox), w);
1197 w = help_slink_new_page(improvement_name_translation(pimprove),
1198 is_great_wonder(pimprove)
1199 ? HELP_WONDER
1200 : HELP_IMPROVEMENT);
1201 gtk_box_append(GTK_BOX(hbox), w);
1202 gtk_widget_show(hbox);
1203 }
1204 } requirement_vector_iterate_end;
1205 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1206 if (pobs->source.kind == VUT_ADVANCE
1207 && pobs->source.value.advance == padvance
1208 && pobs->present) {
1209 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1210 help_box_add(hbox);
1211 w = gtk_label_new(_("Obsoletes"));
1212 gtk_box_append(GTK_BOX(hbox), w);
1213 w = help_slink_new_page(improvement_name_translation(pimprove),
1214 is_great_wonder(pimprove)
1215 ? HELP_WONDER
1216 : HELP_IMPROVEMENT);
1217 gtk_box_append(GTK_BOX(hbox), w);
1218 gtk_widget_show(hbox);
1219 }
1220 } requirement_vector_iterate_end;
1221 }
1222 } improvement_iterate_end;
1223
1224 unit_type_iterate(punittype) {
1225 if (padvance != punittype->require_advance) {
1226 continue;
1227 }
1228 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1229 help_box_add(hbox);
1230 w = gtk_label_new(_("Allows"));
1231 gtk_box_append(GTK_BOX(hbox), w);
1232 w = help_slink_new_page(utype_name_translation(punittype), HELP_UNIT);
1233 gtk_box_append(GTK_BOX(hbox), w);
1234 gtk_widget_show(hbox);
1235 } unit_type_iterate_end;
1236
1237 advance_iterate(A_NONE, ptest) {
1238 if (padvance == advance_requires(ptest, AR_ONE)) {
1239 if (advance_by_number(A_NONE) == advance_requires(ptest, AR_TWO)) {
1240 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1241 help_box_add(hbox);
1242 w = gtk_label_new(_("Allows"));
1243 gtk_box_append(GTK_BOX(hbox), w);
1244 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
1245 gtk_box_append(GTK_BOX(hbox), w);
1246 gtk_widget_show(hbox);
1247 } else {
1248 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1249 help_box_add(hbox);
1250 w = gtk_label_new(_("Allows"));
1251 gtk_box_append(GTK_BOX(hbox), w);
1252 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
1253 gtk_box_append(GTK_BOX(hbox), w);
1254 w = gtk_label_new(_("with"));
1255 gtk_box_append(GTK_BOX(hbox), w);
1256 w = help_slink_new_page(advance_name_translation(advance_requires(ptest,
1257 AR_TWO)),
1258 HELP_TECH);
1259 gtk_box_append(GTK_BOX(hbox), w);
1260 w = gtk_label_new(Q_("?techhelp:"));
1261 gtk_box_append(GTK_BOX(hbox), w);
1262 gtk_widget_show(hbox);
1263 }
1264 }
1265 if (padvance == advance_requires(ptest, AR_TWO)) {
1266 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1267 help_box_add(hbox);
1268 w = gtk_label_new(_("Allows"));
1269 gtk_box_append(GTK_BOX(hbox), w);
1270 w = help_slink_new_page(advance_name_translation(ptest), HELP_TECH);
1271 gtk_box_append(GTK_BOX(hbox), w);
1272 w = gtk_label_new(_("with"));
1273 gtk_box_append(GTK_BOX(hbox), w);
1274 w = help_slink_new_page(advance_name_translation(advance_requires(ptest,
1275 AR_ONE)),
1276 HELP_TECH);
1277 gtk_box_append(GTK_BOX(hbox), w);
1278 w = gtk_label_new(Q_("?techhelp:"));
1279 gtk_box_append(GTK_BOX(hbox), w);
1280 gtk_widget_show(hbox);
1281 }
1282 } advance_iterate_end;
1283
1284 gtk_widget_show(help_vbox);
1285 }
1286}
1287
1288/**********************************************************************/
1291 static void add_act_help_for_terrain(const char *act_label,
1292 const char *result_link_label,
1293 enum help_page_type result_link_type,
1294 const char *descr_label)
1295{
1296 GtkWidget *w;
1297 GtkWidget *hbox;
1298
1299 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
1300 help_box_add(hbox);
1301 w = gtk_label_new(act_label);
1302 gtk_box_append(GTK_BOX(hbox), w);
1303 w = help_slink_new_page(result_link_label, result_link_type);
1304 gtk_box_append(GTK_BOX(hbox), w);
1305 w = gtk_label_new(descr_label);
1306 gtk_box_append(GTK_BOX(hbox), w);
1307
1308 gtk_widget_show(hbox);
1309}
1310
1311/**********************************************************************/
1314 static void help_extras_of_act_for_terrain(struct terrain *pterr,
1315 enum unit_activity act,
1316 char *label)
1317{
1318 enum extra_cause cause = activity_to_extra_cause(act);
1319
1320 extra_type_by_cause_iterate(cause, pextra) {
1321 if (pextra->buildable
1322 && requirement_fulfilled_by_terrain(pterr, &(pextra->reqs))) {
1323 add_act_help_for_terrain(label,
1324 extra_name_translation(pextra), HELP_EXTRA,
1325 helptext_extra_for_terrain_str(pextra, pterr,
1326 act));
1327 }
1328 } extra_type_by_cause_iterate_end;
1329}
1330
1331/**********************************************************************/
1334 static void help_update_terrain(const struct help_item *pitem,
1335 char *title)
1336{
1337 char buf[8192];
1338 struct terrain *pterrain = terrain_by_translated_name(title);
1339
1340 if (pterrain != NULL) {
1341 struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
1342
1343 set_help_tile_from_terrain(pterrain);
1344
1345 {
1346 /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
1347 int defbonus = pterrain->defense_bonus + 100;
1348 int frac = defbonus % 100;
1349
1350 if ((frac % 10) == 0) {
1351 frac /= 10;
1352 }
1353 sprintf(buf, "%d/%d.%d",
1354 pterrain->movement_cost, defbonus / 100, frac);
1355 }
1356 gtk_label_set_text(GTK_LABEL(help_tlabel[0][1]), buf);
1357
1358 sprintf(buf, "%d/%d/%d",
1359 pterrain->output[O_FOOD],
1360 pterrain->output[O_SHIELD],
1361 pterrain->output[O_TRADE]);
1362 gtk_label_set_text(GTK_LABEL(help_tlabel[0][4]), buf);
1363
1364 buf[0] = '\0';
1365 if (*(pterrain->resources)) {
1366 struct extra_type **r;
1367
1368 for (r = pterrain->resources; *r; r++) {
1369 /* TRANS: " Whales (2/1/2)," */
1370 sprintf (buf + strlen (buf), " %s (%d/%d/%d),",
1371 extra_name_translation(*r),
1372 pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD],
1373 pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD],
1374 pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]);
1375 }
1376 buf[strlen (buf) - 1] = '.';
1377 } else {
1378 /* TRANS: "Resources: (none)" */
1379 sprintf (buf + strlen (buf), _("(none)"));
1380 }
1381 gtk_label_set_text(GTK_LABEL(help_tlabel[1][1]), buf);
1382
1383 help_box_clear();
1384
1385 if (pterrain->cultivate_result != T_NONE
1386 && action_id_univs_not_blocking(ACTION_CULTIVATE,
1387 NULL, &for_terr)) {
1388 fc_snprintf(buf, sizeof(buf),
1389 PL_("%d turn", "%d turns", pterrain->cultivate_time),
1390 pterrain->cultivate_time);
1391 add_act_help_for_terrain(_("Cultivate Rslt/Time"),
1392 terrain_name_translation(pterrain->cultivate_result),
1393 HELP_TERRAIN, buf);
1394 }
1395
1396 if (pterrain->plant_result != T_NONE
1397 && action_id_univs_not_blocking(ACTION_PLANT, NULL, &for_terr)) {
1398 fc_snprintf(buf, sizeof(buf),
1399 PL_("%d turn", "%d turns", pterrain->plant_time),
1400 pterrain->plant_time);
1401 add_act_help_for_terrain(_("Plant Rslt/Time"),
1402 terrain_name_translation(pterrain->plant_result),
1403 HELP_TERRAIN, buf);
1404 }
1405
1406 if (pterrain->transform_result != T_NONE
1407 && action_id_univs_not_blocking(ACTION_TRANSFORM_TERRAIN,
1408 NULL, &for_terr)) {
1409 fc_snprintf(buf, sizeof(buf),
1410 PL_("%d turn", "%d turns", pterrain->transform_time),
1411 pterrain->transform_time);
1412 add_act_help_for_terrain(_("Trans. Rslt/Time"),
1413 terrain_name_translation(pterrain->transform_result),
1414 HELP_TERRAIN, buf);
1415 }
1416
1417 if (action_id_univs_not_blocking(ACTION_IRRIGATE, NULL, &for_terr)) {
1418 help_extras_of_act_for_terrain(pterrain, ACTIVITY_IRRIGATE,
1419 _("Build as irrigation"));
1420 }
1421 if (action_id_univs_not_blocking(ACTION_MINE, NULL, &for_terr)) {
1422 help_extras_of_act_for_terrain(pterrain, ACTIVITY_MINE,
1423 _("Build as mine"));
1424 }
1425 if (pterrain->road_time != 0
1426 && action_id_univs_not_blocking(ACTION_ROAD, NULL, &for_terr)) {
1427 help_extras_of_act_for_terrain(pterrain, ACTIVITY_GEN_ROAD,
1428 _("Build as road"));
1429 }
1430 if (pterrain->base_time != 0
1431 && action_id_univs_not_blocking(ACTION_BASE, NULL, &for_terr)) {
1432 help_extras_of_act_for_terrain(pterrain, ACTIVITY_BASE,
1433 _("Build as base"));
1434 }
1435 gtk_widget_show(help_vbox);
1436 }
1437
1438 helptext_terrain(buf, sizeof(buf), client.conn.playing,
1439 pitem->text, pterrain);
1440
1441 gtk_text_buffer_set_text(help_text, buf, -1);
1442 gtk_widget_show(help_text_sw);
1443
1444 gtk_widget_show(help_ttable);
1445}
1446
1447/**********************************************************************/
1450 static void help_update_extra(const struct help_item *pitem, char *title)
1451{
1452 char buf[8192];
1453 struct extra_type *pextra = extra_type_by_translated_name(title);
1454
1455 buf[0] = '\0';
1456 if (pextra == NULL) {
1457 strcat(buf, pitem->text);
1458 } else {
1459 struct road_type *proad = extra_road_get(pextra);
1460 bool is_resource = is_extra_caused_by(pextra, EC_RESOURCE);
1461
1462 set_help_tile_from_extra(pextra);
1463
1464 /* Cost to build */
1465 if (pextra->buildable) {
1466 if (pextra->build_time != 0) {
1467 /* TRANS: "MP" = movement points */
1468 sprintf(buf, _("%d MP"), pextra->build_time);
1469 } else {
1470 /* TRANS: Build time depends on terrain. */
1471 sprintf(buf, _("Terrain specific"));
1472 }
1473 } else {
1474 sprintf(buf, "-");
1475 }
1476 gtk_label_set_text(GTK_LABEL(help_elabel[1]), buf);
1477 /* Conflicting extras */
1478 buf[0] = '\0';
1479 if (is_resource) {
1480 /* TRANS: (Resource extra) Conflicts with: */
1481 strcat(buf, _("Other Resources"));
1482 }
1483 extra_type_iterate(pextra2) {
1484 if (!can_extras_coexist(pextra, pextra2)
1485 && (!is_resource || !is_extra_caused_by(pextra2, EC_RESOURCE))) {
1486 if (buf[0] != '\0') {
1487 strcat(buf, "/");
1488 }
1489 strcat(buf, extra_name_translation(pextra2));
1490 }
1491 } extra_type_iterate_end;
1492 /* TRANS: "Conflicts with: (none)" (extras) */
1493 gtk_label_set_text(GTK_LABEL(help_elabel[3]), buf[0] ? buf : _("(none)"));
1494
1495 /* Bonus */
1496 if (proad != NULL) {
1497 const char *bonus = NULL;
1498
1499 output_type_iterate(o) {
1500 if (proad->tile_incr[o] > 0) {
1501 /* TRANS: Road bonus depends on terrain. */
1502 bonus = _("Terrain specific");
1503 break;
1504 }
1505 } output_type_iterate_end;
1506 if (bonus == NULL) {
1507 bonus = helptext_road_bonus_str(NULL, proad);
1508
1509 if (bonus == NULL) {
1510 /* TRANS: No output bonus from a road */
1511 bonus = Q_("?bonus:None");
1512 }
1513 }
1514 gtk_label_set_text(GTK_LABEL(help_elabel[5]), bonus);
1515 } else {
1516 gtk_label_set_text(GTK_LABEL(help_elabel[5]), Q_("?bonus:None"));
1517 }
1518
1519 helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra);
1520 }
1521 gtk_widget_show(help_etable);
1522
1523 gtk_text_buffer_set_text(help_text, buf, -1);
1524 gtk_widget_show(help_text_sw);
1525}
1526
1527/**********************************************************************/
1530 static void help_update_goods(const struct help_item *pitem,
1531 char *title)
1532{
1533 char buf[8192];
1534 struct goods_type *pgood = goods_by_translated_name(title);
1535
1536 if (pgood == NULL) {
1537 strcat(buf, pitem->text);
1538 } else {
1539 helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
1540 pgood);
1541 }
1542
1543 gtk_text_buffer_set_text(help_text, buf, -1);
1544 gtk_widget_show(help_text_sw);
1545}
1546
1547/**********************************************************************/
1550 static void help_update_specialist(const struct help_item *pitem,
1551 char *title)
1552{
1553 char buf[8192];
1554 struct specialist *pspec = specialist_by_translated_name(title);
1555
1556 if (pspec == NULL) {
1557 strcat(buf, pitem->text);
1558 } else {
1559 helptext_specialist(buf, sizeof(buf), client.conn.playing, pitem->text,
1560 pspec);
1561 }
1562
1563 gtk_text_buffer_set_text(help_text, buf, -1);
1564 gtk_widget_show(help_text_sw);
1565}
1566
1567/**********************************************************************/
1570 static void help_update_government(const struct help_item *pitem,
1571 char *title)
1572{
1573 char buf[8192];
1574 struct government *gov = government_by_translated_name(title);
1575
1576 if (gov == NULL) {
1577 strcat(buf, pitem->text);
1578 } else {
1579 helptext_government(buf, sizeof(buf), client.conn.playing,
1580 pitem->text, gov);
1581 }
1582
1583 gtk_text_buffer_set_text(help_text, buf, -1);
1584 gtk_widget_show(help_text_sw);
1585}
1586
1587/**********************************************************************/
1590 static void help_update_nation(const struct help_item *pitem, char *title,
1591 struct nation_type *pnation)
1592{
1593 char buf[4096];
1594
1595 if (pnation == NULL) {
1596 strcat(buf, pitem->text);
1597 } else {
1598 helptext_nation(buf, sizeof(buf), pnation, pitem->text);
1599
1600 set_help_tile_from_sprite(get_nation_flag_sprite(tileset, pnation));
1601 }
1602
1603 gtk_text_buffer_set_text(help_text, buf, -1);
1604 gtk_widget_show(help_text_sw);
1605}
1606
1607/**********************************************************************/
1610 static void help_update_dialog(const struct help_item *pitem)
1611{
1612 char *top;
1613
1614 /* Figure out what kind of item is required for pitem ingo */
1615
1616 for (top = pitem->topic; *top == ' '; top++) {
1617 /* Nothing */
1618 }
1619
1620 help_box_hide();
1621 gtk_text_buffer_set_text(help_text, "", -1);
1622
1623 switch (pitem->type) {
1624 case HELP_IMPROVEMENT:
1625 help_update_improvement(pitem, top);
1626 break;
1627 case HELP_WONDER:
1628 help_update_wonder(pitem, top);
1629 break;
1630 case HELP_UNIT:
1631 help_update_unit_type(pitem, top);
1632 break;
1633 case HELP_TECH:
1634 help_update_tech(pitem, top);
1635 break;
1636 case HELP_TERRAIN:
1637 help_update_terrain(pitem, top);
1638 break;
1639 case HELP_EXTRA:
1640 help_update_extra(pitem, top);
1641 break;
1642 case HELP_GOODS:
1643 help_update_goods(pitem, top);
1644 break;
1645 case HELP_SPECIALIST:
1646 help_update_specialist(pitem, top);
1647 break;
1648 case HELP_GOVERNMENT:
1649 help_update_government(pitem, top);
1650 break;
1651 case HELP_NATIONS:
1652 help_update_nation(pitem, top, nation_by_translated_plural(top));
1653 break;
1654 case HELP_TEXT:
1655 default:
1656 /* It was a pure text item */
1657 gtk_text_buffer_set_text(help_text, pitem->text, -1);
1658 gtk_widget_show(help_text_sw);
1659 break;
1660 }
1661 set_title_topic(pitem->topic);
1662
1663 gtk_widget_show(help_box);
1664}
1665
1666/**********************************************************************/
1669 static void help_item_zoom(GtkTreePath *path)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter it, child, item;
1673 GtkTreeSelection *selection;
1674
1675 model = gtk_tree_view_get_model(GTK_TREE_VIEW(help_view));
1676 gtk_tree_model_get_iter(model, &item, path);
1677
1678 for (child = item; gtk_tree_model_iter_parent(model, &it, &child); child = it) {
1679 GtkTreePath *it_path;
1680
1681 it_path = gtk_tree_model_get_path(model, &it);
1682 gtk_tree_view_expand_row(GTK_TREE_VIEW(help_view), it_path, TRUE);
1683 gtk_tree_path_free(it_path);
1684 }
1685
1686 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(help_view));
1687 gtk_tree_selection_select_iter(selection, &item);
1688 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(help_view), path, NULL,
1689 TRUE, 0.0, 0.0);
1690}
1691
1692/**********************************************************************/
1695 static GtkTreePath *help_item_path(const struct help_item *pitem)
1696{
1697 GtkTreePath *path;
1698 bool next;
1699
1700 path = gtk_tree_path_new_first();
1701 next = FALSE;
1702 help_items_iterate(pitem2) {
1703 const char *s;
1704 int depth;
1705
1706 for (s = pitem2->topic; *s == ' '; s++) {
1707 /* Nothing */
1708 }
1709 depth = s - pitem2->topic + 1;
1710
1711 while (depth < gtk_tree_path_get_depth(path)) {
1712 gtk_tree_path_up(path);
1713 gtk_tree_path_next(path);
1714 next = FALSE;
1715 }
1716 while (depth > gtk_tree_path_get_depth(path)) {
1717 gtk_tree_path_down(path);
1718 next = FALSE;
1719 }
1720
1721 if (next) {
1722 gtk_tree_path_next(path);
1723 }
1724
1725 if (pitem == pitem2) {
1726 break;
1727 }
1728
1729 next = TRUE;
1730 } help_items_iterate_end;
1731
1732 return path;
1733}
1734
1735/**********************************************************************/
1738 static void select_help_item_string(const char *item, enum help_page_type htype)
1739{
1740 const struct help_item *pitem;
1741 int idx;
1742 GtkTreePath *path;
1743 GtkTreeViewColumn *col;
1744
1745 if (!(pitem = get_help_item_spec(item, htype, &idx))) {
1746 return;
1747 }
1748
1749 path = help_item_path(pitem);
1750 help_item_zoom(path);
1751
1752 col = gtk_tree_view_get_column(GTK_TREE_VIEW(help_view), 0);
1753 gtk_tree_view_set_cursor(GTK_TREE_VIEW(help_view), path, col, FALSE);
1754 gtk_tree_path_free(path);
1755}
1756
1757/**********************************************************************/
1760 static void help_command_update(void)
1761{
1762 GtkDialog *dialog = GTK_DIALOG(help_dialog_shell);
1763
1764 if (help_history_pos < 0) {
1765 gtk_dialog_set_response_sensitive(dialog, 1, FALSE);
1766 gtk_dialog_set_response_sensitive(dialog, 2, FALSE);
1767 } else {
1768 gtk_dialog_set_response_sensitive(dialog, 1, TRUE);
1769 gtk_dialog_set_response_sensitive(dialog, 2, TRUE);
1770
1771 if (help_history_pos == 0) {
1772 gtk_dialog_set_response_sensitive(dialog, 1, FALSE);
1773 }
1774 if (help_history_pos >= help_history->len - 1) {
1775 gtk_dialog_set_response_sensitive(dialog, 2, FALSE);
1776 }
1777 }
1778}
1779
1780/**********************************************************************/
1783 static void help_command_callback(GtkWidget *w, gint response_id)
1784{
1785 GtkTreePath *path;
1786 const struct help_item *pitem;
1787
1788 if (response_id == 1) {
1789 if (help_history_pos > 0) {
1790 help_history_pos--;
1791
1792 pitem = g_ptr_array_index(help_history, help_history_pos);
1793 path = help_item_path(pitem);
1794 help_item_zoom(path);
1795 help_update_dialog(pitem);
1796 help_command_update();
1797 }
1798 } else if (response_id == 2) {
1799 if (help_history_pos < help_history->len - 1) {
1800 help_history_pos++;
1801
1802 pitem = g_ptr_array_index(help_history, help_history_pos);
1803 path = help_item_path(pitem);
1804 help_item_zoom(path);
1805 help_update_dialog(pitem);
1806 help_command_update();
1807 }
1808 } else {
1809 gtk_window_destroy(GTK_WINDOW(help_dialog_shell));
1810 }
1811}
action_id_univs_not_blocking
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:947
str
#define str
Definition astring.c:76
city.h
output_type_iterate
#define output_type_iterate(output)
Definition city.h:809
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:815
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
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
help_box_add
static void help_box_add(GtkWidget *wdg)
Definition helpdlg.c:456
help_box_clear
static void help_box_clear(void)
Definition helpdlg.c:464
picture_set_from_surface
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
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