Freeciv-3.2
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 */
66
68
70static int help_frame_width = 520, help_frame_height = 350;
83
90static GtkWidget *help_ulabel[5][5];
91static GtkWidget *help_tlabel[2][5];
93
94static bool help_advances[A_LAST];
95
98
100{
102 union {
104 const struct requirement *req;
105 } u;
106};
107
108static const char *help_ilabel_name[6] =
109{ N_("Base Cost:"), NULL, N_("Upkeep:"), NULL, N_("Requirement:"), NULL };
111
112static const char *help_wlabel_name[6] =
113{ N_("Base Cost:"), NULL, N_("Requirement:"), NULL, N_("Obsolete by:"), NULL };
115
117
118static const char *help_ulabel_name[5][5] =
119{
120 { N_("Cost:"), NULL, NULL, N_("Attack:"), NULL },
121 { N_("Defense:"), NULL, NULL, N_("Move:"), NULL },
122 { N_("Firepower:"), NULL, NULL, N_("Hitpoints:"), NULL },
123 { N_("Basic Upkeep:"), NULL, NULL, N_("Vision:"), NULL },
124 { N_("Requirement:"), NULL, NULL, N_("Obsolete by:"), NULL }
125};
126
127static const char *help_tlabel_name[2][5] =
128{
129 { N_("Move/Defense:"), NULL, NULL, N_("Food/Res/Trade:"), NULL },
130 { N_("Resources:"), NULL, NULL, NULL, NULL }
131};
132
133static const char *help_elabel_name[6] =
134/* TRANS: Label for build cost for extras in help. Will be followed by
135 * something like "3 MP" (where MP = Movement Points) */
136{ N_("Build:"), NULL,
137/* TRANS: Extra conflicts in help. Will be followed by a list of extras
138 * that can't be built on the same tile as this one. */
139 N_("Conflicts with:"), NULL,
140/* TRANS: Extra bonus in help. Will be followed by food/production/trade
141 * stats like "0/0/+1", "0/+50%/0" */
142 N_("Bonus (F/P/T):"), NULL };
143
144#define REQ_LABEL_NONE _("?tech:None")
145#define REQ_LABEL_NEVER _("(Never)")
146
147static void create_help_dialog(void);
148static void help_update_dialog(const struct help_item *pitem);
149
150static void select_help_item_string(const char *item,
151 enum help_page_type htype);
152static void help_command_update(void);
154
155/**********************************************************************/
170
171/**********************************************************************/
174static void set_title_topic(char *topic)
175{
176 if (strcmp(topic, _(HELP_ABOUT_ITEM)) == 0) {
178 } else {
180 }
181 return;
182}
183
184/**********************************************************************/
193
194/**********************************************************************/
208
209/**********************************************************************/
217
218/**********************************************************************/
227static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
228{
229 const struct research *presearch;
230 int bg;
231 int turns_to_tech;
232 bool original;
234 GValue value = { 0, };
235 enum tech_state state;
236
237 if (advance_required(tech, AR_ONE) == A_LAST
238 && advance_required(tech, AR_TWO) == A_LAST) {
240
242 help_advances[tech] = TRUE;
243
245 g_value_set_static_string(&value, _("Removed"));
246 gtk_tree_store_set_value(tstore, &l, 0, &value);
247 g_value_unset(&value);
248
250 1, -1,
251 2, tech,
252 3, &get_color(tileset, bg)->color
253 -1);
254 return;
255 }
256
258
259 state = research_invention_state(presearch, tech);
260 if (tech_state_is_valid(state)) {
261 switch (state) {
262 case TECH_UNKNOWN:
264 break;
265 case TECH_KNOWN:
267 break;
270 break;
271 }
272 } else {
274 }
276
277 /* l is the original in the tree. */
278 original = !help_advances[tech];
279
281 help_advances[tech] = TRUE;
282
286 tech));
287 gtk_tree_store_set_value(tstore, &l, 0, &value);
288 g_value_unset(&value);
289
291 1, turns_to_tech,
292 2, tech,
293 3, &get_color(tileset, bg)->color,
294 -1);
295
296 if (--levels <= 0) {
297 return;
298 }
299
300 if (original) {
301 /* only add children to orginals */
302 if (advance_required(tech, AR_ONE) != A_NONE)
303 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
304 if (advance_required(tech, AR_TWO) != A_NONE)
305 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
306 }
307 return;
308}
309
310/**********************************************************************/
326
327/**********************************************************************/
334
335/**********************************************************************/
342
343/**********************************************************************/
347{
348 const char *s;
349 struct help_page_selection *select;
351
353 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w), "page_type"));
354
355 switch (select->type) {
356 case HPAGE_SRC_ENUM:
357 type = select->u.page;
358 break;
359 case HPAGE_SRC_REQ:
361 break;
362 }
363
364 if (type == HELP_LAST) {
365 return;
366 }
367
368 /* FIXME: May be able to skip, or may need to modify, advances[A_NONE]
369 below, depending on which i18n is done elsewhere.
370 */
371 if (strcmp(s, REQ_LABEL_NEVER) != 0
375 }
376}
377
378/**********************************************************************/
382 struct help_page_selection *select)
383{
384 GtkWidget *button;
385
386 button = gtk_button_new();
390 gtk_widget_set_name(label, "help_link");
391 gtk_container_add(GTK_CONTAINER(button), label);
392 gtk_widget_show(button);
393 g_signal_connect_swapped(button, "clicked",
395 g_object_set_data(G_OBJECT(label), "page_type", select);
396
397 return button;
398}
399
400/**********************************************************************/
404 enum help_page_type page)
405{
406 return help_hyperlink_new(label, &(page_selections[page]));
407}
408
409/**********************************************************************/
413 struct help_page_selection *select)
414{
415 GtkWidget *button, *label;
416
417 label = gtk_label_new(txt);
420 button = help_hyperlink_new(label, select);
421
422 return button;
423}
424
425/**********************************************************************/
429 enum help_page_type page)
430{
432}
433
434/**********************************************************************/
457
458/**********************************************************************/
466
467/**********************************************************************/
471{
472 GtkTreePath *path;
474 GtkTreeModel *model;
475 GtkTreeIter it;
476 struct help_item *pitem;
477
479
481 gtk_tree_model_get_iter(model, &it, path);
482 gtk_tree_path_free(path);
483
484 if (!path) {
485 return;
486 }
487
488 gtk_tree_model_get(model, &it, 1, &pitem, -1);
489
490 if (help_history_pos >= 0
492 return;
493 }
494
496
497 /* add to history. */
500 }
502
505}
506
507/**********************************************************************/
510static void create_help_dialog(void)
511{
513 GtkWidget *button;
515 int i, j;
518 GArray *array;
519 GtkTreeStore *store;
520 GtkTreeSelection *selection;
521
523 help_history_pos = -1;
524
525 help_dialog_shell = gtk_dialog_new_with_buttons(_("Freeciv Help Browser"),
526 NULL,
527 0,
528 _("_Back"),
529 1,
530 _("_Forward"),
531 2,
532 _("_Close"),
534 NULL);
539
544
545 hbox = gtk_grid_new();
549
550 /* build tree store. */
552
553 array = g_array_new(FALSE, FALSE, sizeof(GtkTreeIter));
555 GtkTreeIter *it, *parent;
556 const char *s;
557 int depth;
558
559 for (s = pitem->topic; *s == ' '; s++) {
560 /* nothing */
561 }
562 depth = s - pitem->topic;
563
564 array = g_array_set_size(array, depth+1);
565
566 if (depth > 0) {
567 parent = &g_array_index(array, GtkTreeIter, depth-1);
568 } else {
569 parent = NULL;
570 }
571
572 it = &g_array_index(array, GtkTreeIter, depth);
573 gtk_tree_store_append(store, it, parent);
574
575 gtk_tree_store_set(store, it, 0, pitem->topic, 1, pitem, -1);
577
578
579 /* create tree view. */
581 g_object_unref(store);
584
585 g_signal_connect(help_view, "cursor-changed",
587
590
594
603
608
614
617
620
621 for (i = 0; i < 6; i++) {
622 help_ilabel[i] =
625
626 if (i == 5) {
628 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
629 } else {
631 gtk_widget_set_name(help_ilabel[i], "help_label");
632 }
633
635 }
636
639
640 for (i = 0; i < 6; i++) {
641 help_wlabel[i] =
644
645 if (i == 3 || i == 5) {
647 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
648 } else {
650 gtk_widget_set_name(help_wlabel[i], "help_label");
651 }
652
654 }
655
658
659 for (i = 0; i < 5; i++) {
660 for (j = 0; j < 5; j++) {
661 help_ulabel[j][i] =
664
665 if (j == 4 && (i == 1 || i == 4)) {
666 if (i == 1) {
668 } else {
670 }
671
672 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
673 } else {
675 i, j, 1, 1);
676 gtk_widget_set_name(help_ulabel[j][i], "help_label");
677 }
679 }
680 }
681
684
685 for (j = 0; j < 2; j++) {
686 for (i = 0; i < 5; i++) {
687 help_tlabel[j][i] =
690 gtk_widget_set_name(help_tlabel[j][i], "help_label");
691
692 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
693 if (j == 1 && i == 1) {
694 /* Extra wide cell for terrain specials */
696 i, j, 4, 1);
698 break; /* skip rest of row */
699 } else {
701 i, j, 1, 1);
703 }
704 }
705 }
706
709
710 for (i = 0; i < 6; i++) {
711 help_elabel[i] =
714 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
715 gtk_widget_set_name(help_elabel[i], "help_label");
717 }
718
725
733 gtk_widget_set_name(text, "help_text");
736
742
743 /* build tech store. */
745 G_TYPE_STRING, /* tech name */
746 G_TYPE_INT, /* turns to tech */
747 G_TYPE_INT, /* tech id */
748 GDK_TYPE_RGBA); /* color */
754
755 g_signal_connect(help_tree, "row_activated",
757
758
760
765 "text", 0,
766 "background-rgba", 3,
767 NULL);
769 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
772 "text", 1,
773 "background-rgba", 3,
774 NULL);
775
777
778
785
787 = gtk_button_new_with_label(_("Expand All"));
789
794
800}
801
802/**********************************************************************/
806{
807 if (spr == NULL) {
808 return;
809 }
810
813}
814
815/**********************************************************************/
845
846/**********************************************************************/
873
874/**********************************************************************/
877static void help_update_improvement(const struct help_item *pitem,
878 char *title)
879{
880 char buf[8192];
882
883 if (imp && !is_great_wonder(imp)) {
885 char req_buf[512];
886
889 sprintf(buf, "%d", imp->upkeep);
891
892 /* FIXME: this should show ranges, negated reqs, and all the
893 * MAX_NUM_REQS reqs.
894 * Currently it's limited to 1 req but this code is partially prepared
895 * to be extended. Remember MAX_NUM_REQS is a compile-time
896 * definition. */
899 if (!preq->present) {
900 continue;
901 }
902 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
904 break;
907/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
908 } else {
912/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3);*/
913 }
914
916
918
919 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
922}
923
924/**********************************************************************/
927static void help_update_wonder(const struct help_item *pitem,
928 char *title)
929{
930 char buf[8192];
932
933 if (imp && is_great_wonder(imp)) {
934 int i;
935 char req_buf[512];
936
939
940 /* FIXME: this should show ranges, negated reqs, and all the
941 * MAX_NUM_REQS reqs.
942 * Currently it's limited to 1 req but this code is partially prepared
943 * to be extended. Remember MAX_NUM_REQS is a compile-time
944 * definition. */
945 i = 0;
948 if (!preq->present) {
949 continue;
950 }
953 req_buf, sizeof(req_buf)));
955 i++;
956 break;
958
960 requirement_vector_iterate(&imp->obsolete_by, pobs) {
961 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
964 (pobs->source.value.advance));
965
966 break;
967 }
969
970/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3);*/
971 } else {
972 /* can't find wonder */
976/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
977 }
978
980
982
983 helptext_building(buf, sizeof(buf), client.conn.playing, pitem->text, imp);
986}
987
988/**********************************************************************/
991static void help_update_unit_type(const struct help_item *pitem,
992 char *title)
993{
994 char buf[8192];
996
997 if (utype) {
1000 sprintf(buf, "%d", utype->attack_strength);
1002 sprintf(buf, "%d", utype->defense_strength);
1004 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1006 sprintf(buf, "%d", utype->firepower);
1008 sprintf(buf, "%d", utype->hp);
1012 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1016/* create_tech_tree(help_improvement_tree, 0, advance_number(utype->require_advance), 3);*/
1017 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1019 } else {
1022 }
1023
1024 helptext_unit(buf, sizeof(buf), client.conn.playing, pitem->text, utype,
1025 TRUE);
1026
1029
1033 } else {
1042
1044/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3);*/
1046
1049 }
1051}
1052
1053/**********************************************************************/
1056static char *fc_chomp(char *str, size_t len)
1057{
1058 gchar *i;
1059
1060 if (!str || !*str) {
1061 return str;
1062 }
1063
1064 i = str + len;
1065 for (i = g_utf8_find_prev_char(str, i);
1068 *i = '\0';
1069 }
1070 return str;
1071}
1072
1073/**********************************************************************/
1076static void help_update_tech(const struct help_item *pitem, char *title)
1077{
1078 int i, j;
1079 GtkWidget *w, *hbox;
1080 char buf[8192];
1082
1085 size_t len;
1086
1088
1089 for (j = 0; j < ARRAY_SIZE(help_advances); j++) {
1090 help_advances[j] = FALSE;
1091 }
1096
1097 helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i);
1098 len = strlen(buf);
1099 fc_chomp(buf, len);
1100
1102
1103 w = gtk_text_view_new();
1108 gtk_widget_set_name(w, "help_text");
1112 gtk_widget_show(w);
1113
1115 if (txt) {
1117 }
1118
1120 g_object_set(w, "margin", 5, NULL);
1124 gtk_widget_show(w);
1125
1127 /* FIXME: need a more general mechanism for this, since this
1128 * helptext needs to be shown in all possible req source types. */
1130 if (VUT_ADVANCE == preq->source.kind
1131 && preq->source.value.advance == padvance) {
1132 hbox = gtk_grid_new();
1134 w = gtk_label_new(_("Allows"));
1140 }
1143
1144 improvement_iterate(pimprove) {
1145 if (valid_improvement(pimprove)) {
1146 requirement_vector_iterate(&pimprove->reqs, preq) {
1147 if (VUT_ADVANCE == preq->source.kind
1148 && preq->source.value.advance == padvance) {
1149 hbox = gtk_grid_new();
1151 w = gtk_label_new(_("Allows"));
1154 is_great_wonder(pimprove)
1155 ? HELP_WONDER
1159 }
1161 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1162 if (pobs->source.kind == VUT_ADVANCE
1163 && pobs->source.value.advance == padvance
1164 && pobs->present) {
1165 hbox = gtk_grid_new();
1167 w = gtk_label_new(_("Obsoletes"));
1170 is_great_wonder(pimprove)
1171 ? HELP_WONDER
1175 }
1177 }
1179
1181
1183 continue;
1184 }
1185
1186 hbox = gtk_grid_new();
1188 w = gtk_label_new(_("Allows"));
1194
1198 hbox = gtk_grid_new();
1200 w = gtk_label_new(_("Allows"));
1205 } else {
1206 hbox = gtk_grid_new();
1208 w = gtk_label_new(_("Allows"));
1212 w = gtk_label_new(_("with"));
1215 AR_TWO)),
1216 HELP_TECH);
1218 w = gtk_label_new(Q_("?techhelp:"));
1221 }
1222 }
1224 hbox = gtk_grid_new();
1226 w = gtk_label_new(_("Allows"));
1230 w = gtk_label_new(_("with"));
1233 HELP_TECH);
1235 w = gtk_label_new(Q_("?techhelp:"));
1238 }
1241 }
1242}
1243
1244/**********************************************************************/
1266
1267/**********************************************************************/
1271 enum unit_activity act,
1272 char *label)
1273{
1274 enum extra_cause cause = activity_to_extra_cause(act);
1275
1276 extra_type_by_cause_iterate(cause, pextra) {
1277 if (pextra->buildable
1278 && requirement_fulfilled_by_terrain(pterr, &(pextra->reqs))) {
1282 act));
1283 }
1285}
1286
1287/**********************************************************************/
1290static void help_update_terrain(const struct help_item *pitem,
1291 char *title)
1292{
1293 char buf[8192];
1294 struct terrain *pterrain = terrain_by_translated_name(title);
1295
1296 if (pterrain) {
1297 struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
1298
1300
1301 {
1302 /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
1303 int defbonus = pterrain->defense_bonus + 100;
1304 int frac = defbonus % 100;
1305
1306 if ((frac % 10) == 0) {
1307 frac /= 10;
1308 }
1309 sprintf(buf, "%d/%d.%d",
1310 pterrain->movement_cost, defbonus / 100, frac);
1311 }
1313
1314 sprintf(buf, "%d/%d/%d",
1315 pterrain->output[O_FOOD],
1316 pterrain->output[O_SHIELD],
1317 pterrain->output[O_TRADE]);
1319
1320 buf[0] = '\0';
1321 if (*(pterrain->resources)) {
1322 struct extra_type **r;
1323
1324 /* TODO: include resource frequency information */
1325 for (r = pterrain->resources; *r; r++) {
1326 /* TRANS: " Whales (2/1/2)," */
1327 sprintf (buf + strlen (buf), " %s (%d/%d/%d),",
1329 pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD],
1330 pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD],
1331 pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]);
1332 }
1333 buf[strlen (buf) - 1] = '.';
1334 } else {
1335 /* TRANS: "Resources: (none)" */
1336 sprintf (buf + strlen (buf), _("(none)"));
1337 }
1339
1341
1342 if (pterrain->cultivate_result != T_NONE
1344 NULL, &for_terr)) {
1345 fc_snprintf(buf, sizeof(buf),
1346 PL_("%d turn", "%d turns", pterrain->cultivate_time),
1347 pterrain->cultivate_time);
1348 add_act_help_for_terrain(_("Cultivate Rslt/Time"),
1350 HELP_TERRAIN, buf);
1351 }
1352
1353 if (pterrain->plant_result != T_NONE
1355 fc_snprintf(buf, sizeof(buf),
1356 PL_("%d turn", "%d turns", pterrain->plant_time),
1357 pterrain->plant_time);
1358 add_act_help_for_terrain(_("Plant Rslt/Time"),
1360 HELP_TERRAIN, buf);
1361 }
1362
1363 if (pterrain->transform_result != T_NONE
1365 NULL, &for_terr)) {
1366 fc_snprintf(buf, sizeof(buf),
1367 PL_("%d turn", "%d turns", pterrain->transform_time),
1368 pterrain->transform_time);
1369 add_act_help_for_terrain(_("Trans. Rslt/Time"),
1371 HELP_TERRAIN, buf);
1372 }
1373
1376 _("Build as irrigation"));
1377 }
1380 _("Build as mine"));
1381 }
1384 _("Build as road"));
1385 }
1388 _("Build as base"));
1389 }
1390
1392 }
1393
1394 helptext_terrain(buf, sizeof(buf), client.conn.playing, pitem->text, pterrain);
1395
1398
1400}
1401
1402/**********************************************************************/
1405static void help_update_extra(const struct help_item *pitem, char *title)
1406{
1407 char buf[8192];
1409
1410 buf[0] = '\0';
1411 if (pextra == NULL) {
1412 strcat(buf, pitem->text);
1413 } else {
1414 struct road_type *proad = extra_road_get(pextra);
1416
1418
1419 /* Cost to build */
1420 if (pextra->buildable) {
1421 if (pextra->build_time != 0) {
1422 /* TRANS: "MP" = movement points */
1423 sprintf(buf, _("%d MP"), pextra->build_time);
1424 } else {
1425 /* TRANS: Build time depends on terrain. */
1426 sprintf(buf, _("Terrain specific"));
1427 }
1428 } else {
1429 sprintf(buf, "-");
1430 }
1432 /* Conflicting extras */
1433 buf[0] = '\0';
1434 if (is_resource) {
1435 /* TRANS: (Resource extra) Conflicts with: */
1436 strcat(buf, _("Other Resources"));
1437 }
1439 if (!can_extras_coexist(pextra, pextra2)
1441 if (buf[0] != '\0') {
1442 strcat(buf, "/");
1443 }
1445 }
1447 /* TRANS: "Conflicts with: (none)" (extras) */
1448 gtk_label_set_text(GTK_LABEL(help_elabel[3]), buf[0] ? buf : _("(none)"));
1449
1450 /* Bonus */
1451 if (proad != NULL) {
1452 const char *bonus = NULL;
1453
1455 if (proad->tile_incr[o] > 0) {
1456 /* TRANS: Road bonus depends on terrain. */
1457 bonus = _("Terrain specific");
1458 break;
1459 }
1461 if (!bonus) {
1463 }
1464 if (!bonus) {
1465 /* TRANS: No output bonus from a road */
1466 bonus = Q_("?bonus:None");
1467 }
1469 } else {
1470 gtk_label_set_text(GTK_LABEL(help_elabel[5]), Q_("?bonus:None"));
1471 }
1472
1473 helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra);
1474 }
1476
1479}
1480
1481/**********************************************************************/
1484static void help_update_goods(const struct help_item *pitem,
1485 char *title)
1486{
1487 char buf[8192];
1489
1490 if (!pgood) {
1491 strcat(buf, pitem->text);
1492 } else {
1493 helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
1494 pgood);
1495 }
1496
1499}
1500
1501/**********************************************************************/
1504static void help_update_specialist(const struct help_item *pitem,
1505 char *title)
1506{
1507 char buf[8192];
1509
1510 if (!pspec) {
1511 strcat(buf, pitem->text);
1512 } else {
1514 pspec);
1515 }
1516
1519}
1520
1521/**********************************************************************/
1524static void help_update_government(const struct help_item *pitem,
1525 char *title)
1526{
1527 char buf[8192];
1529
1530 if (!gov) {
1531 strcat(buf, pitem->text);
1532 } else {
1533 helptext_government(buf, sizeof(buf), client.conn.playing, pitem->text, gov);
1534 }
1535
1538}
1539
1540/**********************************************************************/
1543static void help_update_nation(const struct help_item *pitem, char *title,
1544 struct nation_type *pnation)
1545{
1546 char buf[4096];
1547
1548 if (!pnation) {
1549 strcat(buf, pitem->text);
1550 } else {
1551 helptext_nation(buf, sizeof(buf), pnation, pitem->text);
1552
1554 }
1555
1558}
1559
1560/**********************************************************************/
1563static void help_update_dialog(const struct help_item *pitem)
1564{
1565 char *top;
1566
1567 /* figure out what kind of item is required for pitem ingo */
1568
1569 for (top = pitem->topic; *top == ' '; top++) {
1570 /* nothing */
1571 }
1572
1573 help_box_hide();
1575
1576 switch (pitem->type) {
1577 case HELP_IMPROVEMENT:
1579 break;
1580 case HELP_WONDER:
1582 break;
1583 case HELP_UNIT:
1585 break;
1586 case HELP_TECH:
1587 help_update_tech(pitem, top);
1588 break;
1589 case HELP_TERRAIN:
1591 break;
1592 case HELP_EXTRA:
1594 break;
1595 case HELP_GOODS:
1597 break;
1598 case HELP_SPECIALIST:
1600 break;
1601 case HELP_GOVERNMENT:
1603 break;
1604 case HELP_NATIONS:
1606 break;
1607 case HELP_TEXT:
1608 default:
1609 /* it was a pure text item */
1612 break;
1613 }
1614 set_title_topic(pitem->topic);
1615
1617}
1618
1619/**********************************************************************/
1622static void help_item_zoom(GtkTreePath *path)
1623{
1624 GtkTreeModel *model;
1625 GtkTreeIter it, child, item;
1626 GtkTreeSelection *selection;
1627
1629 gtk_tree_model_get_iter(model, &item, path);
1630
1631 for (child = item; gtk_tree_model_iter_parent(model, &it, &child); child=it) {
1633
1634 it_path = gtk_tree_model_get_path(model, &it);
1637 }
1638
1642 TRUE, 0.0, 0.0);
1643}
1644
1645/**********************************************************************/
1649{
1650 GtkTreePath *path;
1651 bool next;
1652
1653 path = gtk_tree_path_new_first();
1654 next = FALSE;
1656 const char *s;
1657 int depth;
1658
1659 for (s = pitem2->topic; *s == ' '; s++) {
1660 /* nothing */
1661 }
1662 depth = s - pitem2->topic + 1;
1663
1664 while (depth < gtk_tree_path_get_depth(path)) {
1665 gtk_tree_path_up(path);
1666 gtk_tree_path_next(path);
1667 next = FALSE;
1668 }
1669 while (depth > gtk_tree_path_get_depth(path)) {
1670 gtk_tree_path_down(path);
1671 next = FALSE;
1672 }
1673
1674 if (next) {
1675 gtk_tree_path_next(path);
1676 }
1677
1678 if (pitem == pitem2)
1679 break;
1680
1681 next = TRUE;
1683
1684 return path;
1685}
1686
1687/**********************************************************************/
1690static void select_help_item_string(const char *item, enum help_page_type htype)
1691{
1692 const struct help_item *pitem;
1693 int idx;
1694 GtkTreePath *path;
1696
1697 if (!(pitem = get_help_item_spec(item, htype, &idx))) {
1698 return;
1699 }
1700
1701 path = help_item_path(pitem);
1702 help_item_zoom(path);
1703
1706 gtk_tree_path_free(path);
1707}
1708
1709/**********************************************************************/
1712static void help_command_update(void)
1713{
1715
1716 if (help_history_pos < 0) {
1719 } else {
1722
1723 if (help_history_pos == 0) {
1725 }
1726 if (help_history_pos >= help_history->len - 1) {
1728 }
1729 }
1730}
1731
1732/**********************************************************************/
1736{
1737 GtkTreePath *path;
1738 const struct help_item *pitem;
1739
1740 if (response_id == 1) {
1741 if (help_history_pos > 0) {
1743
1745 path = help_item_path(pitem);
1746 help_item_zoom(path);
1749 }
1750 } else if (response_id == 2) {
1753
1755 path = help_item_path(pitem);
1756 help_item_zoom(path);
1759 }
1760 } else {
1761 /* Save size of the dialog. */
1765 }
1766}
#define action_id_univs_not_blocking(act_id, act_uni, tgt_uni)
Definition actions.h:945
#define str
Definition astring.c:76
#define output_type_iterate(output)
Definition city.h:845
#define output_type_iterate_end
Definition city.h:851
struct civclient client
#define client_player()
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
char * incite_cost
Definition comments.c:75
struct extra_type * extra_type_by_translated_name(const char *name)
Definition extras.c:235
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1076
bool can_extras_coexist(const struct extra_type *pextra1, const struct extra_type *pextra2)
Definition extras.c:1003
const char * extra_name_translation(const struct extra_type *pextra)
Definition extras.c:194
#define extra_type_iterate(_p)
Definition extras.h:315
#define extra_type_iterate_end
Definition extras.h:321
#define is_extra_caused_by(e, c)
Definition extras.h:203
#define extra_road_get(_e_)
Definition extras.h:191
#define extra_type_by_cause_iterate_end
Definition extras.h:339
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:333
@ O_SHIELD
Definition fc_types.h:101
@ O_FOOD
Definition fc_types.h:101
@ O_TRADE
Definition fc_types.h:101
const char * skip_intl_qualifier_prefix(const char *str)
Definition fcintl.c:48
#define Q_(String)
Definition fcintl.h:70
#define PL_(String1, String2, n)
Definition fcintl.h:71
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const char * government_name_translation(const struct government *pgovern)
Definition government.c:143
struct government * government_by_translated_name(const char *name)
Definition government.c:40
#define governments_iterate(NAME_pgov)
Definition government.h:124
#define governments_iterate_end
Definition government.h:127
#define FC_STATIC_CANVAS_INIT
Definition canvas.h:28
GtkWidget * toplevel
Definition gui_main.c:125
void set_relative_window_position(GtkWindow *ref, GtkWindow *w, int px, int py)
Definition gui_stuff.c:60
void setup_dialog(GtkWidget *shell, GtkWidget *parent)
Definition gui_stuff.c:287
static GtkWidget * help_tree_sw
Definition helpdlg.c:84
static void set_title_topic(char *topic)
Definition helpdlg.c:174
static void activated_topic(GtkTreeView *view, gpointer data)
Definition helpdlg.c:470
static GtkWidget * help_tree
Definition helpdlg.c:81
static GtkWidget * help_tree_expand
Definition helpdlg.c:85
static GtkWidget * help_ulabel[5][5]
Definition helpdlg.c:90
static void help_update_specialist(const struct help_item *pitem, char *title)
Definition helpdlg.c:1504
static void help_hyperlink_callback(GtkWidget *w)
Definition helpdlg.c:346
static GtkWidget * help_elabel[6]
Definition helpdlg.c:92
static GtkWidget * help_etable
Definition helpdlg.c:80
static void help_destroy_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:461
static void set_help_tile_from_extra(const struct extra_type *pextra)
Definition helpdlg.c:849
static GtkWidget * help_frame
Definition helpdlg.c:69
static int help_frame_width
Definition helpdlg.c:70
static void help_tech_tree_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition helpdlg.c:313
static void help_update_tech(const struct help_item *pitem, char *title)
Definition helpdlg.c:1076
static void help_item_zoom(GtkTreePath *path)
Definition helpdlg.c:1622
static GtkWidget * help_slink_new_page(const gchar *txt, enum help_page_type page)
Definition helpdlg.c:428
static GtkWidget * help_tlabel[2][5]
Definition helpdlg.c:91
static GtkTreePath * help_item_path(const struct help_item *pitem)
Definition helpdlg.c:1648
static GtkWidget * help_tree_collapse
Definition helpdlg.c:86
static void help_update_nation(const struct help_item *pitem, char *title, struct nation_type *pnation)
Definition helpdlg.c:1543
static void create_help_dialog(void)
Definition helpdlg.c:510
static GtkTextBuffer * help_text
Definition helpdlg.c:71
static void help_update_wonder(const struct help_item *pitem, char *title)
Definition helpdlg.c:927
static GtkWidget * help_hyperlink_new_page(GtkWidget *label, enum help_page_type page)
Definition helpdlg.c:403
static GtkWidget * help_dialog_shell
Definition helpdlg.c:64
static GtkWidget * help_text_sw
Definition helpdlg.c:72
static GPtrArray * help_history
Definition helpdlg.c:96
static const char * help_elabel_name[6]
Definition helpdlg.c:133
static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
Definition helpdlg.c:227
static void help_update_extra(const struct help_item *pitem, char *title)
Definition helpdlg.c:1405
static GtkWidget * help_ilabel[6]
Definition helpdlg.c:88
static void set_help_tile_from_sprite(struct sprite *spr)
Definition helpdlg.c:805
static const char * help_wlabel_name[6]
Definition helpdlg.c:112
static const char * help_ulabel_name[5][5]
Definition helpdlg.c:118
static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:338
static void set_help_tile_from_terrain(struct terrain *pterr)
Definition helpdlg.c:818
static GtkWidget * help_view
Definition helpdlg.c:67
static void help_update_goods(const struct help_item *pitem, char *title)
Definition helpdlg.c:1484
void help_system_init(void)
Definition helpdlg.c:158
static void help_box_hide(void)
Definition helpdlg.c:437
static void help_update_unit_type(const struct help_item *pitem, char *title)
Definition helpdlg.c:991
void popdown_help_dialog(void)
Definition helpdlg.c:187
static void help_update_terrain(const struct help_item *pitem, char *title)
Definition helpdlg.c:1290
static int help_frame_height
Definition helpdlg.c:70
static void help_update_dialog(const struct help_item *pitem)
Definition helpdlg.c:1563
static char * fc_chomp(char *str, size_t len)
Definition helpdlg.c:1056
void popup_help_dialog_string(const char *item)
Definition helpdlg.c:213
static int help_history_pos
Definition helpdlg.c:97
static struct help_page_selection help_wndr_req
Definition helpdlg.c:114
static GtkWidget * help_wlabel[6]
Definition helpdlg.c:89
static GtkWidget * help_box
Definition helpdlg.c:75
static void help_extras_of_act_for_terrain(struct terrain *pterr, enum unit_activity act, char *label)
Definition helpdlg.c:1270
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:197
#define REQ_LABEL_NEVER
Definition helpdlg.c:145
static void help_command_update(void)
Definition helpdlg.c:1712
static struct help_page_selection page_selections[HELP_LAST]
Definition helpdlg.c:116
#define TECH_TREE_DEPTH
Definition helpdlg.c:59
static const char * help_tlabel_name[2][5]
Definition helpdlg.c:127
static struct help_page_selection help_impr_req
Definition helpdlg.c:110
#define REQ_LABEL_NONE
Definition helpdlg.c:144
static GtkWidget * help_wtable
Definition helpdlg.c:77
static GtkWidget * help_slink_new(const gchar *txt, struct help_page_selection *select)
Definition helpdlg.c:412
static GtkWidget * help_vbox
Definition helpdlg.c:73
static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:330
static GtkWidget * help_tile
Definition helpdlg.c:74
static GtkWidget * help_hyperlink_new(GtkWidget *label, struct help_page_selection *select)
Definition helpdlg.c:381
static void help_update_government(const struct help_item *pitem, char *title)
Definition helpdlg.c:1524
static GtkWidget * help_ttable
Definition helpdlg.c:79
static void help_update_improvement(const struct help_item *pitem, char *title)
Definition helpdlg.c:877
static const char * help_ilabel_name[6]
Definition helpdlg.c:108
static GtkWidget * help_tree_buttons_hbox
Definition helpdlg.c:87
static GtkWidget * help_view_sw
Definition helpdlg.c:65
static void select_help_item_string(const char *item, enum help_page_type htype)
Definition helpdlg.c:1690
static bool help_advances[A_LAST]
Definition helpdlg.c:94
static GtkWidget * help_utable
Definition helpdlg.c:78
static GtkWidget * help_itable
Definition helpdlg.c:76
static GtkTreeStore * tstore
Definition helpdlg.c:82
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:1247
static void help_command_callback(GtkWidget *w, gint response_id)
Definition helpdlg.c:1735
const char * title
Definition repodlgs.c:1314
GType type
Definition repodlgs.c:1313
void helptext_government(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct government *gov)
Definition helpdata.c:4400
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3359
enum help_page_type help_type_by_requirement(const struct requirement *req)
Definition helpdata.c:5265
char * helptext_unit(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct unit_type *utype, bool class_help)
Definition helpdata.c:1992
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
Definition helpdata.c:3854
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
Definition helpdata.c:4319
const char * helptext_road_bonus_str(const struct terrain *pterrain, const struct road_type *proad)
Definition helpdata.c:3690
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Definition helpdata.c:5062
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
Definition helpdata.c:3820
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
Definition helpdata.c:4365
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
Definition helpdata.c:1346
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1439
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
Definition helpdata.c:3580
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5099
#define help_items_iterate(pitem)
Definition helpdata.h:72
#define help_items_iterate_end
Definition helpdata.h:76
#define HELP_ABOUT_ITEM
help_page_type
Definition helpdlg_g.h:20
@ HELP_ANY
Definition helpdlg_g.h:20
@ HELP_TERRAIN
Definition helpdlg_g.h:21
@ HELP_EXTRA
Definition helpdlg_g.h:21
@ HELP_NATIONS
Definition helpdlg_g.h:24
@ HELP_LAST
Definition helpdlg_g.h:25
@ HELP_IMPROVEMENT
Definition helpdlg_g.h:20
@ HELP_UNIT
Definition helpdlg_g.h:20
@ HELP_SPECIALIST
Definition helpdlg_g.h:22
@ HELP_GOVERNMENT
Definition helpdlg_g.h:22
@ HELP_GOODS
Definition helpdlg_g.h:22
@ HELP_WONDER
Definition helpdlg_g.h:21
@ HELP_TECH
Definition helpdlg_g.h:21
@ HELP_TEXT
Definition helpdlg_g.h:20
const struct impr_type * valid_improvement(const struct impr_type *pimprove)
int impr_base_build_shield_cost(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
struct impr_type * improvement_by_translated_name(const char *name)
const char * improvement_name_translation(const struct impr_type *pimprove)
#define improvement_iterate_end
#define improvement_iterate(_p)
void put_drawn_sprites(struct canvas *pcanvas, float zoom, int canvas_x, int canvas_y, int count, struct drawn_sprite *pdrawn, bool fog)
const char * move_points_text(int mp, bool reduce)
Definition movement.c:1047
struct nation_type * nation_by_translated_plural(const char *name)
Definition nation.c:106
int len
Definition packhand.c:127
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
#define requirement_fulfilled_by_terrain(_ter_, _rqs_)
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
struct research * research_get(const struct player *pplayer)
Definition research.c:128
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
#define ARRAY_SIZE(x)
Definition shared.h:85
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:130
cairo_surface_t * surface
Definition canvas.h:23
struct connection conn
Definition client_main.h:96
Definition colors.h:21
struct player * playing
Definition connection.h:151
bool buildable
Definition extras.h:116
int build_time
Definition extras.h:118
char * text
Definition helpdata.h:26
enum help_page_type page
Definition helpdlg.c:103
const struct requirement * req
Definition helpdlg.c:104
enum help_page_selection::@155 type
union help_page_selection::@156 u
Definition climisc.h:82
struct terrain * cultivate_result
Definition terrain.h:215
struct extra_type ** resources
Definition terrain.h:204
int plant_time
Definition terrain.h:219
struct terrain * plant_result
Definition terrain.h:218
int defense_bonus
Definition terrain.h:200
int cultivate_time
Definition terrain.h:216
int movement_cost
Definition terrain.h:199
int output[O_LAST]
Definition terrain.h:202
int transform_time
Definition terrain.h:231
struct terrain * transform_result
Definition terrain.h:229
int defense_strength
Definition unittype.h:516
int firepower
Definition unittype.h:525
const struct unit_type * obsoleted_by
Definition unittype.h:529
int vision_radius_sq
Definition unittype.h:522
int move_rate
Definition unittype.h:517
int attack_strength
Definition unittype.h:515
enum universals_n kind
Definition fc_types.h:902
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:974
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
struct advance * advance_by_translated_name(const char *name)
Definition tech.c:185
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
Definition tech.c:136
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:290
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Definition tech.c:121
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
#define advance_iterate_all_end
Definition tech.h:279
@ AR_TWO
Definition tech.h:112
@ AR_ONE
Definition tech.h:111
#define advance_iterate_all(_p)
Definition tech.h:278
#define A_NONE
Definition tech.h:43
#define A_LAST
Definition tech.h:45
struct terrain * terrain_by_translated_name(const char *name)
Definition terrain.c:202
const char * terrain_name_translation(const struct terrain *pterrain)
Definition terrain.c:238
#define T_NONE
Definition terrain.h:56
struct sprite * get_building_sprite(const struct tileset *t, const struct impr_type *pimprove)
Definition tilespec.c:6784
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:7201
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:7168
int tileset_tile_height(const struct tileset *t)
Definition tilespec.c:765
struct sprite * get_unittype_sprite(const struct tileset *t, const struct unit_type *punittype, enum unit_activity activity, enum direction8 facing)
Definition tilespec.c:6806
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6757
int tileset_tile_width(const struct tileset *t)
Definition tilespec.c:753
struct sprite * get_tech_sprite(const struct tileset *t, Tech_type_id tech)
Definition tilespec.c:6775
struct goods_type * goods_by_translated_name(const char *name)
bool is_tech_req_for_utype(const struct unit_type *ptype, struct advance *padv)
Definition unittype.c:2724
int utype_build_shield_cost_base(const struct unit_type *punittype)
Definition unittype.c:1468
struct advance * utype_primary_tech_req(const struct unit_type *ptype)
Definition unittype.c:2710
struct unit_type * unit_type_by_translated_name(const char *name)
Definition unittype.c:1752
const char * utype_name_translation(const struct unit_type *punittype)
Definition unittype.c:1560
#define unit_type_iterate(_p)
Definition unittype.h:855
#define unit_type_iterate_end
Definition unittype.h:862
#define U_NOT_OBSOLETED
Definition unittype.h:528
const char * freeciv_name_version(void)
Definition version.c:35