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

Freeciv-3.3

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