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-4.0 */
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_dlog_width = 520, help_dlog_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 {
103 enum help_page_type page;
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}
182
183/**********************************************************************/
192
193/**********************************************************************/
205
206/**********************************************************************/
214
215/**********************************************************************/
224static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
225{
226 const struct research *presearch;
227 int bg;
228 int turns_to_tech;
229 bool original;
231 GValue value = { 0, };
232 enum tech_state state;
233
234 if (advance_required(tech, AR_ONE) == A_LAST
235 && advance_required(tech, AR_TWO) == A_LAST) {
237
239 help_advances[tech] = TRUE;
240
242 g_value_set_static_string(&value, _("Removed"));
243 gtk_tree_store_set_value(tstore, &l, 0, &value);
244 g_value_unset(&value);
245
247 1, -1,
248 2, tech,
249 3, &get_color(tileset, bg)->color
250 -1);
251 return;
252 }
253
255
256 state = research_invention_state(presearch, tech);
257 if (tech_state_is_valid(state)) {
258 switch (state) {
259 case TECH_UNKNOWN:
261 break;
262 case TECH_KNOWN:
264 break;
267 break;
268 }
269 } else {
271 }
273
274 /* l is the original in the tree. */
275 original = !help_advances[tech];
276
278 help_advances[tech] = TRUE;
279
283 tech));
284 gtk_tree_store_set_value(tstore, &l, 0, &value);
285 g_value_unset(&value);
286
288 1, turns_to_tech,
289 2, tech,
290 3, &get_color(tileset, bg)->color,
291 -1);
292
293 if (--levels <= 0) {
294 return;
295 }
296
297 if (original) {
298 /* Only add children to originals */
299 if (advance_required(tech, AR_ONE) != A_NONE) {
300 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
301 }
302 if (advance_required(tech, AR_TWO) != A_NONE) {
303 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
304 }
305 }
306}
307
308/**********************************************************************/
324
325/**********************************************************************/
332
333/**********************************************************************/
340
341/**********************************************************************/
345{
346 const char *s;
347 struct help_page_selection *select;
349
351 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w),
352 "page_type"));
353
354 switch (select->type) {
355 case HPAGE_SRC_ENUM:
356 type = select->u.page;
357 break;
358 case HPAGE_SRC_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
374 }
375}
376
377/**********************************************************************/
381 struct help_page_selection *select)
382{
383 GtkWidget *button;
384
385 button = gtk_button_new();
389 gtk_widget_set_name(label, "help_link");
390 gtk_button_set_child(GTK_BUTTON(button), label);
392 g_signal_connect_swapped(button, "clicked",
394 g_object_set_data(G_OBJECT(label), "page_type", select);
395
396 return button;
397}
398
399/**********************************************************************/
403 enum help_page_type page)
404{
405 return help_hyperlink_new(label, &(page_selections[page]));
406}
407
408/**********************************************************************/
412 struct help_page_selection *select)
413{
414 GtkWidget *button, *label;
415
416 label = gtk_label_new(txt);
419 button = help_hyperlink_new(label, select);
420
421 return button;
422}
423
424/**********************************************************************/
428 enum help_page_type page)
429{
431}
432
433/**********************************************************************/
454
455/**********************************************************************/
462
463/**********************************************************************/
466static void help_box_clear(void)
467{
469
470 while (child != NULL) {
473 }
474}
475
476/**********************************************************************/
484
485/**********************************************************************/
489{
490 GtkTreePath *path;
492 GtkTreeModel *model;
493 GtkTreeIter it;
494 struct help_item *pitem;
495
497
498 if (model == NULL) {
499 return;
500 }
501
503 gtk_tree_model_get_iter(model, &it, path);
504 gtk_tree_path_free(path);
505
506 if (path == NULL) {
507 return;
508 }
509
510 gtk_tree_model_get(model, &it, 1, &pitem, -1);
511
512 if (help_history_pos >= 0
514 return;
515 }
516
518
519 /* Add to history. */
522 }
524
527}
528
529/**********************************************************************/
532static void create_help_dialog(void)
533{
535 GtkWidget *button;
537 int i, j;
540 GArray *array;
541 GtkTreeStore *store;
542 GtkTreeSelection *selection;
544
546 help_history_pos = -1;
547
548 help_dialog_shell = gtk_dialog_new_with_buttons(_("Freeciv Help Browser"),
549 NULL,
550 0,
551 _("_Back"),
552 1,
553 _("_Forward"),
554 2,
555 _("_Close"),
557 NULL);
562
570
573 hbox);
575
576 /* Build tree store. */
578
579 array = g_array_new(FALSE, FALSE, sizeof(GtkTreeIter));
581 GtkTreeIter *it, *parent;
582 const char *s;
583 int depth;
584
585 for (s = pitem->topic; *s == ' '; s++) {
586 /* Nothing */
587 }
588 depth = s - pitem->topic;
589
590 array = g_array_set_size(array, depth+1);
591
592 if (depth > 0) {
593 parent = &g_array_index(array, GtkTreeIter, depth-1);
594 } else {
595 parent = NULL;
596 }
597
598 it = &g_array_index(array, GtkTreeIter, depth);
599 gtk_tree_store_append(store, it, parent);
600
601 gtk_tree_store_set(store, it, 0, pitem->topic, 1, pitem, -1);
603
604 /* Create tree view. */
606 g_object_unref(store);
609
610 g_signal_connect(help_view, "cursor-changed",
612
615
619
628
633
636
647
650
651 for (i = 0; i < 6; i++) {
652 help_ilabel[i] =
655
656 if (i == 5) {
658 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
659 } else {
661 gtk_widget_set_name(help_ilabel[i], "help_label");
662 }
663
665 }
666
669
670 for (i = 0; i < 6; i++) {
671 help_wlabel[i] =
674
675 if (i == 3 || i == 5) {
677 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
678 } else {
680 gtk_widget_set_name(help_wlabel[i], "help_label");
681 }
682
684 }
685
688
689 for (i = 0; i < 5; i++) {
690 for (j = 0; j < 5; j++) {
691 help_ulabel[j][i] =
694
695 if (j == 4 && (i == 1 || i == 4)) {
696 if (i == 1) {
698 } else {
700 }
701
702 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
703 } else {
705 i, j, 1, 1);
706 gtk_widget_set_name(help_ulabel[j][i], "help_label");
707 }
708
710 }
711 }
712
715
716 for (j = 0; j < 2; j++) {
717 for (i = 0; i < 5; i++) {
718 help_tlabel[j][i] =
721 gtk_widget_set_name(help_tlabel[j][i], "help_label");
722
723 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
724 if (j == 1 && i == 1) {
725 /* Extra wide cell for terrain specials */
727 i, j, 4, 1);
729 break; /* Skip rest of row */
730 } else {
732 i, j, 1, 1);
734 }
735 }
736 }
737
740
741 for (i = 0; i < 6; i++) {
745 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
746 gtk_widget_set_name(help_elabel[i], "help_label");
748 }
749
756
767 gtk_widget_set_name(text, "help_text");
770
776
777 /* Build tech store. */
779 G_TYPE_STRING, /* Tech name */
780 G_TYPE_INT, /* Turns to tech */
781 G_TYPE_INT, /* Tech id */
782 GDK_TYPE_RGBA); /* Color */
788
789 g_signal_connect(help_tree, "row_activated",
791
792
794
799 "text", 0,
800 "background-rgba", 3,
801 NULL);
803 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
806 "text", 1,
807 "background-rgba", 3,
808 NULL);
809
811
819
822
827
833}
834
835/**********************************************************************/
839{
840 if (spr == NULL) {
841 return;
842 }
843
846}
847
848/**********************************************************************/
878
879/**********************************************************************/
906
907/**********************************************************************/
910static void help_update_improvement(const struct help_item *pitem,
911 char *title)
912{
913 char buf[8192];
915
916 if (imp != NULL && !is_great_wonder(imp)) {
918 char req_buf[512];
919
922 sprintf(buf, "%d", imp->upkeep);
924
925 /* FIXME: this should show ranges, negated reqs, and all the
926 * MAX_NUM_REQS reqs.
927 * Currently it's limited to 1 req but this code is partially prepared
928 * to be extended. Remember MAX_NUM_REQS is a compile-time
929 * definition. */
932 if (!preq->present) {
933 continue;
934 }
935 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
937 break;
940/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
941 } else {
945/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
946 }
947
949
951
952 helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp);
955}
956
957/**********************************************************************/
960static void help_update_wonder(const struct help_item *pitem,
961 char *title)
962{
963 char buf[8192];
965
966 if (imp != NULL && is_great_wonder(imp)) {
967 int i;
968 char req_buf[512];
969
972
973 /* FIXME: this should show ranges, negated reqs, and all the
974 * MAX_NUM_REQS reqs.
975 * Currently it's limited to 1 req but this code is partially prepared
976 * to be extended. Remember MAX_NUM_REQS is a compile-time
977 * definition. */
978 i = 0;
981 if (!preq->present) {
982 continue;
983 }
986 req_buf, sizeof(req_buf)));
988 i++;
989 break;
991
993 requirement_vector_iterate(&imp->obsolete_by, pobs) {
994 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
997 (pobs->source.value.advance));
998
999 break;
1000 }
1002
1003/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
1004 } else {
1005 /* Can't find wonder */
1009/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
1010 }
1011
1013
1015
1016 helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp);
1019}
1020
1021/**********************************************************************/
1024static void help_update_unit_type(const struct help_item *pitem,
1025 char *title)
1026{
1027 char buf[8192];
1029
1030 if (utype != NULL) {
1033 sprintf(buf, "%d", utype->attack_strength);
1035 sprintf(buf, "%d", utype->defense_strength);
1037 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1039 sprintf(buf, "%d", utype->firepower);
1041 sprintf(buf, "%d", utype->hp);
1045 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1049
1050#if 0
1052 advance_number(utype->require_advance), 3);
1053#endif
1054
1055 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1058 } else {
1061 }
1062
1063 helptext_unit(buf, sizeof(buf), client_player(), pitem->text, utype,
1064 TRUE);
1065
1068
1072 } else {
1081
1083/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3); */
1086
1089 }
1090
1092}
1093
1094/**********************************************************************/
1097static char *fc_chomp(char *str, size_t len)
1098{
1099 gchar *i;
1100
1101 if (str == NULL || !*str) {
1102 return str;
1103 }
1104
1105 i = str + len;
1106 for (i = g_utf8_find_prev_char(str, i);
1109 *i = '\0';
1110 }
1111
1112 return str;
1113}
1114
1115/**********************************************************************/
1118static void help_update_tech(const struct help_item *pitem, char *title)
1119{
1120 int i, j;
1121 GtkWidget *w, *hbox;
1122 char buf[8192];
1124
1125 if (padvance != NULL
1128 size_t len;
1129
1131
1132 for (j = 0; j < ARRAY_SIZE(help_advances); j++) {
1133 help_advances[j] = FALSE;
1134 }
1135
1140
1141 helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i);
1142 len = strlen(buf);
1143 fc_chomp(buf, len);
1144
1146
1147 w = gtk_text_view_new();
1152 gtk_widget_set_name(w, "help_text");
1158 help_box_add(w);
1160
1162 if (txt != NULL) {
1164 }
1165
1173 help_box_add(w);
1175
1177 /* FIXME: need a more general mechanism for this, since this
1178 * helptext needs to be shown in all possible req source types. */
1180 if (VUT_ADVANCE == preq->source.kind
1181 && preq->source.value.advance == padvance) {
1184 w = gtk_label_new(_("Allows"));
1190 }
1193
1194 improvement_iterate(pimprove) {
1195 if (valid_improvement(pimprove)) {
1196 requirement_vector_iterate(&pimprove->reqs, preq) {
1197 if (VUT_ADVANCE == preq->source.kind
1198 && preq->source.value.advance == padvance) {
1201 w = gtk_label_new(_("Allows"));
1204 is_great_wonder(pimprove)
1205 ? HELP_WONDER
1209 }
1211 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1212 if (pobs->source.kind == VUT_ADVANCE
1213 && pobs->source.value.advance == padvance
1214 && pobs->present) {
1217 w = gtk_label_new(_("Obsoletes"));
1220 is_great_wonder(pimprove)
1221 ? HELP_WONDER
1225 }
1227 }
1229
1232 continue;
1233 }
1234
1237 w = gtk_label_new(_("Allows"));
1243
1249 w = gtk_label_new(_("Allows"));
1254 } else {
1257 w = gtk_label_new(_("Allows"));
1261 w = gtk_label_new(_("with"));
1264 AR_TWO)),
1265 HELP_TECH);
1267 w = gtk_label_new(Q_("?techhelp:"));
1270 }
1271 }
1275 w = gtk_label_new(_("Allows"));
1279 w = gtk_label_new(_("with"));
1282 AR_ONE)),
1283 HELP_TECH);
1285 w = gtk_label_new(Q_("?techhelp:"));
1288 }
1290
1292 }
1293}
1294
1295/**********************************************************************/
1317
1318/**********************************************************************/
1322 enum unit_activity act,
1323 char *label)
1324{
1325 enum extra_cause cause = activity_to_extra_cause(act);
1326
1327 extra_type_by_cause_iterate(cause, pextra) {
1328 if (pextra->buildable
1329 && requirement_fulfilled_by_terrain(pterr, &(pextra->reqs))) {
1333 act));
1334 }
1336}
1337
1338/**********************************************************************/
1341static void help_update_terrain(const struct help_item *pitem,
1342 char *title)
1343{
1344 char buf[8192];
1345 struct terrain *pterrain = terrain_by_translated_name(title);
1346
1347 if (pterrain != NULL) {
1348 struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
1349
1351
1352 {
1353 /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
1354 int defbonus = pterrain->defense_bonus + 100;
1355 int frac = defbonus % 100;
1356
1357 if ((frac % 10) == 0) {
1358 frac /= 10;
1359 }
1360 sprintf(buf, "%d/%d.%d",
1361 pterrain->movement_cost, defbonus / 100, frac);
1362 }
1364
1365 sprintf(buf, "%d/%d/%d",
1366 pterrain->output[O_FOOD],
1367 pterrain->output[O_SHIELD],
1368 pterrain->output[O_TRADE]);
1370
1371 buf[0] = '\0';
1372 if (*(pterrain->resources)) {
1373 struct extra_type **r;
1374
1375 /* TODO: include resource frequency information */
1376 for (r = pterrain->resources; *r; r++) {
1377 /* TRANS: " Whales (2/1/2)," */
1378 sprintf (buf + strlen (buf), " %s (%d/%d/%d),",
1380 pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD],
1381 pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD],
1382 pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]);
1383 }
1384 buf[strlen (buf) - 1] = '.';
1385 } else {
1386 /* TRANS: "Resources: (none)" */
1387 sprintf (buf + strlen (buf), _("(none)"));
1388 }
1390
1392
1393 if (pterrain->cultivate_result != T_NONE
1395 NULL, &for_terr)) {
1396 fc_snprintf(buf, sizeof(buf),
1397 PL_("%d turn", "%d turns", pterrain->cultivate_time),
1398 pterrain->cultivate_time);
1399 add_act_help_for_terrain(_("Cultivate Rslt/Time"),
1401 HELP_TERRAIN, buf);
1402 }
1403
1404 if (pterrain->plant_result != T_NONE
1406 fc_snprintf(buf, sizeof(buf),
1407 PL_("%d turn", "%d turns", pterrain->plant_time),
1408 pterrain->plant_time);
1409 add_act_help_for_terrain(_("Plant Rslt/Time"),
1411 HELP_TERRAIN, buf);
1412 }
1413
1414 if (pterrain->transform_result != T_NONE
1416 NULL, &for_terr)) {
1417 fc_snprintf(buf, sizeof(buf),
1418 PL_("%d turn", "%d turns", pterrain->transform_time),
1419 pterrain->transform_time);
1420 add_act_help_for_terrain(_("Trans. Rslt/Time"),
1422 HELP_TERRAIN, buf);
1423 }
1424
1427 _("Build as irrigation"));
1428 }
1431 _("Build as mine"));
1432 }
1435 _("Build as road"));
1436 }
1439 _("Build as base"));
1440 }
1442 }
1443
1445 pitem->text, pterrain);
1446
1449
1451}
1452
1453/**********************************************************************/
1456static void help_update_extra(const struct help_item *pitem, char *title)
1457{
1458 char buf[8192];
1460
1461 buf[0] = '\0';
1462 if (pextra == NULL) {
1463 strcat(buf, pitem->text);
1464 } else {
1465 struct road_type *proad = extra_road_get(pextra);
1467
1469
1470 /* Cost to build */
1471 if (pextra->buildable) {
1472 if (pextra->build_time != 0) {
1473 /* TRANS: "MP" = movement points */
1474 sprintf(buf, _("%d MP"), pextra->build_time);
1475 } else {
1476 /* TRANS: Build time depends on terrain. */
1477 sprintf(buf, _("Terrain specific"));
1478 }
1479 } else {
1480 sprintf(buf, "-");
1481 }
1483 /* Conflicting extras */
1484 buf[0] = '\0';
1485 if (is_resource) {
1486 /* TRANS: (Resource extra) Conflicts with: */
1487 strcat(buf, _("Other Resources"));
1488 }
1490 if (!can_extras_coexist(pextra, pextra2)
1492 if (buf[0] != '\0') {
1493 strcat(buf, "/");
1494 }
1496 }
1498 /* TRANS: "Conflicts with: (none)" (extras) */
1499 gtk_label_set_text(GTK_LABEL(help_elabel[3]), buf[0] ? buf : _("(none)"));
1500
1501 /* Bonus */
1502 if (proad != NULL) {
1503 const char *bonus = NULL;
1504
1506 if (proad->tile_incr[o] > 0) {
1507 /* TRANS: Road bonus depends on terrain. */
1508 bonus = _("Terrain specific");
1509 break;
1510 }
1512 if (bonus == NULL) {
1514
1515 if (bonus == NULL) {
1516 /* TRANS: No output bonus from a road */
1517 bonus = Q_("?bonus:None");
1518 }
1519 }
1523 } else {
1526 }
1527
1528 helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra);
1529 }
1531
1534}
1535
1536/**********************************************************************/
1539static void help_update_goods(const struct help_item *pitem,
1540 char *title)
1541{
1542 char buf[8192];
1544
1545 if (pgood == NULL) {
1546 strcat(buf, pitem->text);
1547 } else {
1548 helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
1549 pgood);
1550 }
1551
1554}
1555
1556/**********************************************************************/
1559static void help_update_specialist(const struct help_item *pitem,
1560 char *title)
1561{
1562 char buf[8192];
1564
1565 if (pspec == NULL) {
1566 strcat(buf, pitem->text);
1567 } else {
1569 pspec);
1570 }
1571
1574}
1575
1576/**********************************************************************/
1579static void help_update_government(const struct help_item *pitem,
1580 char *title)
1581{
1582 char buf[8192];
1584
1585 if (gov == NULL) {
1586 strcat(buf, pitem->text);
1587 } else {
1589 pitem->text, gov);
1590 }
1591
1594}
1595
1596/**********************************************************************/
1599static void help_update_nation(const struct help_item *pitem, char *title,
1600 struct nation_type *pnation)
1601{
1602 char buf[4096];
1603
1604 if (pnation == NULL) {
1605 strcat(buf, pitem->text);
1606 } else {
1607 helptext_nation(buf, sizeof(buf), pnation, pitem->text);
1608
1610 }
1611
1614}
1615
1616/**********************************************************************/
1619static void help_update_dialog(const struct help_item *pitem)
1620{
1621 char *top;
1622
1623 /* Figure out what kind of item is required for pitem ingo */
1624
1625 for (top = pitem->topic; *top == ' '; top++) {
1626 /* Nothing */
1627 }
1628
1629 help_box_hide();
1631
1632 switch (pitem->type) {
1633 case HELP_IMPROVEMENT:
1635 break;
1636 case HELP_WONDER:
1638 break;
1639 case HELP_UNIT:
1641 break;
1642 case HELP_TECH:
1643 help_update_tech(pitem, top);
1644 break;
1645 case HELP_TERRAIN:
1647 break;
1648 case HELP_EXTRA:
1650 break;
1651 case HELP_GOODS:
1653 break;
1654 case HELP_SPECIALIST:
1656 break;
1657 case HELP_GOVERNMENT:
1659 break;
1660 case HELP_NATIONS:
1662 break;
1663 case HELP_TEXT:
1664 default:
1665 /* It was a pure text item */
1668 break;
1669 }
1670 set_title_topic(pitem->topic);
1671
1673}
1674
1675/**********************************************************************/
1678static void help_item_zoom(GtkTreePath *path)
1679{
1680 GtkTreeModel *model;
1681 GtkTreeIter it, child, item;
1682 GtkTreeSelection *selection;
1683
1685 gtk_tree_model_get_iter(model, &item, path);
1686
1687 for (child = item; gtk_tree_model_iter_parent(model, &it, &child); child = it) {
1689
1690 it_path = gtk_tree_model_get_path(model, &it);
1693 }
1694
1698 TRUE, 0.0, 0.0);
1699}
1700
1701/**********************************************************************/
1705{
1706 GtkTreePath *path;
1707 bool next;
1708
1709 path = gtk_tree_path_new_first();
1710 next = FALSE;
1712 const char *s;
1713 int depth;
1714
1715 for (s = pitem2->topic; *s == ' '; s++) {
1716 /* Nothing */
1717 }
1718 depth = s - pitem2->topic + 1;
1719
1720 while (depth < gtk_tree_path_get_depth(path)) {
1721 gtk_tree_path_up(path);
1722 gtk_tree_path_next(path);
1723 next = FALSE;
1724 }
1725 while (depth > gtk_tree_path_get_depth(path)) {
1726 gtk_tree_path_down(path);
1727 next = FALSE;
1728 }
1729
1730 if (next) {
1731 gtk_tree_path_next(path);
1732 }
1733
1734 if (pitem == pitem2) {
1735 break;
1736 }
1737
1738 next = TRUE;
1740
1741 return path;
1742}
1743
1744/**********************************************************************/
1747static void select_help_item_string(const char *item, enum help_page_type htype)
1748{
1749 const struct help_item *pitem;
1750 int idx;
1751 GtkTreePath *path;
1753
1754 if (!(pitem = get_help_item_spec(item, htype, &idx))) {
1755 return;
1756 }
1757
1758 path = help_item_path(pitem);
1759 help_item_zoom(path);
1760
1763 gtk_tree_path_free(path);
1764}
1765
1766/**********************************************************************/
1769static void help_command_update(void)
1770{
1772
1773 if (help_history_pos < 0) {
1776 } else {
1779
1780 if (help_history_pos == 0) {
1782 }
1783 if (help_history_pos >= help_history->len - 1) {
1785 }
1786 }
1787}
1788
1789/**********************************************************************/
1793{
1794 GtkTreePath *path;
1795 const struct help_item *pitem;
1796
1797 if (response_id == 1) {
1798 if (help_history_pos > 0) {
1800
1802 path = help_item_path(pitem);
1803 help_item_zoom(path);
1806 }
1807 } else if (response_id == 2) {
1810
1812 path = help_item_path(pitem);
1813 help_item_zoom(path);
1816 }
1817 } else {
1818 /* Save size of the dialog. */
1823 }
1824}
#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 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:471
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:1508
static void help_hyperlink_callback(GtkWidget *w)
Definition helpdlg.c:347
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:462
static void set_help_tile_from_extra(const struct extra_type *pextra)
Definition helpdlg.c:850
static GtkWidget * help_frame
Definition helpdlg.c:69
static void help_tech_tree_activated_callback(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
Definition helpdlg.c:314
static void help_update_tech(const struct help_item *pitem, char *title)
Definition helpdlg.c:1077
static void help_item_zoom(GtkTreePath *path)
Definition helpdlg.c:1626
static GtkWidget * help_slink_new_page(const gchar *txt, enum help_page_type page)
Definition helpdlg.c:429
static GtkWidget * help_tlabel[2][5]
Definition helpdlg.c:91
static GtkTreePath * help_item_path(const struct help_item *pitem)
Definition helpdlg.c:1652
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:1547
static void create_help_dialog(void)
Definition helpdlg.c:511
static GtkTextBuffer * help_text
Definition helpdlg.c:71
static void help_update_wonder(const struct help_item *pitem, char *title)
Definition helpdlg.c:928
static GtkWidget * help_hyperlink_new_page(GtkWidget *label, enum help_page_type page)
Definition helpdlg.c:404
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:1406
static GtkWidget * help_ilabel[6]
Definition helpdlg.c:88
static void set_help_tile_from_sprite(struct sprite *spr)
Definition helpdlg.c:806
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:339
static void set_help_tile_from_terrain(struct terrain *pterr)
Definition helpdlg.c:819
static GtkWidget * help_view
Definition helpdlg.c:67
static void help_update_goods(const struct help_item *pitem, char *title)
Definition helpdlg.c:1488
void help_system_init(void)
Definition helpdlg.c:158
static void help_box_hide(void)
Definition helpdlg.c:438
static void help_update_unit_type(const struct help_item *pitem, char *title)
Definition helpdlg.c:992
void popdown_help_dialog(void)
Definition helpdlg.c:187
static void help_update_terrain(const struct help_item *pitem, char *title)
Definition helpdlg.c:1291
static void help_update_dialog(const struct help_item *pitem)
Definition helpdlg.c:1567
static char * fc_chomp(char *str, size_t len)
Definition helpdlg.c:1057
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:1271
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:1716
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:413
static GtkWidget * help_vbox
Definition helpdlg.c:73
static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:331
static GtkWidget * help_tile
Definition helpdlg.c:74
static GtkWidget * help_hyperlink_new(GtkWidget *label, struct help_page_selection *select)
Definition helpdlg.c:382
static void help_update_government(const struct help_item *pitem, char *title)
Definition helpdlg.c:1528
static GtkWidget * help_ttable
Definition helpdlg.c:79
static void help_update_improvement(const struct help_item *pitem, char *title)
Definition helpdlg.c:878
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:1694
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:1248
static void help_command_callback(GtkWidget *w, gint response_id)
Definition helpdlg.c:1739
const char * title
Definition repodlgs.c:1314
GType type
Definition repodlgs.c:1313
static void help_box_add(GtkWidget *wdg)
Definition helpdlg.c:458
static int help_dlog_height
Definition helpdlg.c:70
static void help_box_clear(void)
Definition helpdlg.c:466
static int help_dlog_width
Definition helpdlg.c:70
void picture_set_from_surface(GtkPicture *pic, cairo_surface_t *surf)
Definition sprite.c:544
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:6794
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:7211
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:7178
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:6816
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6767
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:6785
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