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
82
89static GtkWidget *help_ulabel[5][5];
90static GtkWidget *help_tlabel[2][5];
92
93static bool help_advances[A_LAST];
94
97
99{
101 union {
102 enum help_page_type page;
103 const struct requirement *req;
104 } u;
105};
106
107static const char *help_ilabel_name[6] =
108{ N_("Base Cost:"), NULL, N_("Upkeep:"), NULL, N_("Requirement:"), NULL };
110
111static const char *help_wlabel_name[6] =
112{ N_("Base Cost:"), NULL, N_("Requirement:"), NULL, N_("Obsolete by:"), NULL };
114
116
117static 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
126static 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
132static 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);
153
154/**********************************************************************/
169
170/**********************************************************************/
173static void set_title_topic(char *topic)
174{
175 if (strcmp(topic, _(HELP_ABOUT_ITEM)) == 0) {
177 } else {
179 }
180}
181
182/**********************************************************************/
191
192/**********************************************************************/
204
205/**********************************************************************/
213
214/**********************************************************************/
223static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
224{
225 const struct research *presearch;
226 int bg;
227 int turns_to_tech;
228 bool original;
230 GValue value = { 0, };
231 enum tech_state state;
232
233 if (advance_required(tech, AR_ONE) == A_LAST
234 && advance_required(tech, AR_TWO) == A_LAST) {
236
238 help_advances[tech] = TRUE;
239
241 g_value_set_static_string(&value, _("Removed"));
242 gtk_tree_store_set_value(tstore, &l, 0, &value);
243 g_value_unset(&value);
244
246 1, -1,
247 2, tech,
248 3, &get_color(tileset, bg)->color
249 -1);
250 return;
251 }
252
254
255 state = research_invention_state(presearch, tech);
256 if (tech_state_is_valid(state)) {
257 switch (state) {
258 case TECH_UNKNOWN:
260 break;
261 case TECH_KNOWN:
263 break;
266 break;
267 }
268 } else {
270 }
272
273 /* l is the original in the tree. */
274 original = !help_advances[tech];
275
277 help_advances[tech] = TRUE;
278
282 tech));
283 gtk_tree_store_set_value(tstore, &l, 0, &value);
284 g_value_unset(&value);
285
287 1, turns_to_tech,
288 2, tech,
289 3, &get_color(tileset, bg)->color,
290 -1);
291
292 if (--levels <= 0) {
293 return;
294 }
295
296 if (original) {
297 /* Only add children to orginals */
298 if (advance_required(tech, AR_ONE) != A_NONE)
299 create_tech_tree(advance_required(tech, AR_ONE), levels, &l);
300 if (advance_required(tech, AR_TWO) != A_NONE)
301 create_tech_tree(advance_required(tech, AR_TWO), levels, &l);
302 }
303}
304
305/**********************************************************************/
321
322/**********************************************************************/
329
330/**********************************************************************/
337
338/**********************************************************************/
342{
343 const char *s;
344 struct help_page_selection *select;
346
348 select = (struct help_page_selection *)(g_object_get_data(G_OBJECT(w),
349 "page_type"));
350
351 switch (select->type) {
352 case HPAGE_SRC_ENUM:
353 type = select->u.page;
354 break;
355 case HPAGE_SRC_REQ:
357 break;
358 }
359
360 if (type == HELP_LAST) {
361 return;
362 }
363
364 /* FIXME: May be able to skip, or may need to modify, advances[A_NONE]
365 below, depending on which i18n is done elsewhere.
366 */
367 if (strcmp(s, REQ_LABEL_NEVER) != 0
371 }
372}
373
374/**********************************************************************/
378 struct help_page_selection *select)
379{
380 GtkWidget *button;
381
382 button = gtk_button_new();
386 gtk_widget_set_name(label, "help_link");
387 gtk_button_set_child(GTK_BUTTON(button), label);
389 g_signal_connect_swapped(button, "clicked",
391 g_object_set_data(G_OBJECT(label), "page_type", select);
392
393 return button;
394}
395
396/**********************************************************************/
400 enum help_page_type page)
401{
402 return help_hyperlink_new(label, &(page_selections[page]));
403}
404
405/**********************************************************************/
409 struct help_page_selection *select)
410{
411 GtkWidget *button, *label;
412
413 label = gtk_label_new(txt);
416 button = help_hyperlink_new(label, select);
417
418 return button;
419}
420
421/**********************************************************************/
425 enum help_page_type page)
426{
428}
429
430/**********************************************************************/
451
452/**********************************************************************/
459
460/**********************************************************************/
463static void help_box_clear(void)
464{
466
467 while (child != NULL) {
470 }
471}
472
473/**********************************************************************/
481
482/**********************************************************************/
486{
487 GtkTreePath *path;
489 GtkTreeModel *model;
490 GtkTreeIter it;
491 struct help_item *pitem;
492
494
495 if (model == NULL) {
496 return;
497 }
498
500 gtk_tree_model_get_iter(model, &it, path);
501 gtk_tree_path_free(path);
502
503 if (path == NULL) {
504 return;
505 }
506
507 gtk_tree_model_get(model, &it, 1, &pitem, -1);
508
509 if (help_history_pos >= 0
511 return;
512 }
513
515
516 /* Add to history. */
519 }
521
524}
525
526/**********************************************************************/
529static void create_help_dialog(void)
530{
532 GtkWidget *button;
534 int i, j;
537 GArray *array;
538 GtkTreeStore *store;
539 GtkTreeSelection *selection;
541
543 help_history_pos = -1;
544
545 help_dialog_shell = gtk_dialog_new_with_buttons(_("Freeciv Help Browser"),
546 NULL,
547 0,
548 _("_Back"),
549 1,
550 _("_Forward"),
551 2,
552 _("_Close"),
554 NULL);
559
564
567 hbox);
569
570 /* Build tree store. */
572
573 array = g_array_new(FALSE, FALSE, sizeof(GtkTreeIter));
575 GtkTreeIter *it, *parent;
576 const char *s;
577 int depth;
578
579 for (s = pitem->topic; *s == ' '; s++) {
580 /* Nothing */
581 }
582 depth = s - pitem->topic;
583
584 array = g_array_set_size(array, depth+1);
585
586 if (depth > 0) {
587 parent = &g_array_index(array, GtkTreeIter, depth-1);
588 } else {
589 parent = NULL;
590 }
591
592 it = &g_array_index(array, GtkTreeIter, depth);
593 gtk_tree_store_append(store, it, parent);
594
595 gtk_tree_store_set(store, it, 0, pitem->topic, 1, pitem, -1);
597
598 /* Create tree view. */
600 g_object_unref(store);
603
604 g_signal_connect(help_view, "cursor-changed",
606
609
613
622
627
630
641
644
645 for (i = 0; i < 6; i++) {
646 help_ilabel[i] =
649
650 if (i == 5) {
652 gtk_grid_attach(GTK_GRID(help_itable), button, i, 0, 1, 1);
653 } else {
655 gtk_widget_set_name(help_ilabel[i], "help_label");
656 }
657
659 }
660
663
664 for (i = 0; i < 6; i++) {
665 help_wlabel[i] =
668
669 if (i == 3 || i == 5) {
671 gtk_grid_attach(GTK_GRID(help_wtable), button, i, 0, 1, 1);
672 } else {
674 gtk_widget_set_name(help_wlabel[i], "help_label");
675 }
676
678 }
679
682
683 for (i = 0; i < 5; i++) {
684 for (j = 0; j < 5; j++) {
685 help_ulabel[j][i] =
688
689 if (j == 4 && (i == 1 || i == 4)) {
690 if (i == 1) {
692 } else {
694 }
695
696 gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
697 } else {
699 i, j, 1, 1);
700 gtk_widget_set_name(help_ulabel[j][i], "help_label");
701 }
702
704 }
705 }
706
709
710 for (j = 0; j < 2; j++) {
711 for (i = 0; i < 5; i++) {
712 help_tlabel[j][i] =
715 gtk_widget_set_name(help_tlabel[j][i], "help_label");
716
717 /* Ugly (but these numbers are hardcoded in help_update_terrain() too) */
718 if (j == 1 && i == 1) {
719 /* Extra wide cell for terrain specials */
721 i, j, 4, 1);
723 break; /* Skip rest of row */
724 } else {
726 i, j, 1, 1);
728 }
729 }
730 }
731
734
735 for (i = 0; i < 6; i++) {
739 gtk_grid_attach(GTK_GRID(help_etable), help_elabel[i], i % 4, i / 4, 1, 1);
740 gtk_widget_set_name(help_elabel[i], "help_label");
742 }
743
750
761 gtk_widget_set_name(text, "help_text");
764
770
771 /* Build tech store. */
773 G_TYPE_STRING, /* Tech name */
774 G_TYPE_INT, /* Turns to tech */
775 G_TYPE_INT, /* Tech id */
776 GDK_TYPE_RGBA); /* Color */
782
783 g_signal_connect(help_tree, "row_activated",
785
786
788
793 "text", 0,
794 "background-rgba", 3,
795 NULL);
797 g_object_set(rend, "weight", PANGO_WEIGHT_BOLD, "xalign", 1.0, NULL);
800 "text", 1,
801 "background-rgba", 3,
802 NULL);
803
805
813
816
821
827}
828
829/**********************************************************************/
833{
834 if (spr == NULL) {
835 return;
836 }
837
840}
841
842/**********************************************************************/
872
873/**********************************************************************/
900
901/**********************************************************************/
904static void help_update_improvement(const struct help_item *pitem,
905 char *title)
906{
907 char buf[8192];
909
910 if (imp != NULL && !is_great_wonder(imp)) {
912 char req_buf[512];
913
916 sprintf(buf, "%d", imp->upkeep);
918
919 /* FIXME: this should show ranges, negated reqs, and all the
920 * MAX_NUM_REQS reqs.
921 * Currently it's limited to 1 req but this code is partially prepared
922 * to be extended. Remember MAX_NUM_REQS is a compile-time
923 * definition. */
926 if (!preq->present) {
927 continue;
928 }
929 req = universal_name_translation(&preq->source, req_buf, sizeof(req_buf));
931 break;
934/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
935 } else {
939/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
940 }
941
943
945
946 helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp);
949}
950
951/**********************************************************************/
954static void help_update_wonder(const struct help_item *pitem,
955 char *title)
956{
957 char buf[8192];
959
960 if (imp != NULL && is_great_wonder(imp)) {
961 int i;
962 char req_buf[512];
963
966
967 /* FIXME: this should show ranges, negated reqs, and all the
968 * MAX_NUM_REQS reqs.
969 * Currently it's limited to 1 req but this code is partially prepared
970 * to be extended. Remember MAX_NUM_REQS is a compile-time
971 * definition. */
972 i = 0;
975 if (!preq->present) {
976 continue;
977 }
980 req_buf, sizeof(req_buf)));
982 i++;
983 break;
985
987 requirement_vector_iterate(&imp->obsolete_by, pobs) {
988 if (pobs->source.kind == VUT_ADVANCE && pobs->present) {
991 (pobs->source.value.advance));
992
993 break;
994 }
996
997/* create_tech_tree(help_improvement_tree, 0, imp->tech_req, 3); */
998 } else {
999 /* Can't find wonder */
1003/* create_tech_tree(help_improvement_tree, 0, advance_count(), 3); */
1004 }
1005
1007
1009
1010 helptext_building(buf, sizeof(buf), client_player(), pitem->text, imp);
1013}
1014
1015/**********************************************************************/
1018static void help_update_unit_type(const struct help_item *pitem,
1019 char *title)
1020{
1021 char buf[8192];
1023
1024 if (utype != NULL) {
1027 sprintf(buf, "%d", utype->attack_strength);
1029 sprintf(buf, "%d", utype->defense_strength);
1031 sprintf(buf, "%s", move_points_text(utype->move_rate, TRUE));
1033 sprintf(buf, "%d", utype->firepower);
1035 sprintf(buf, "%d", utype->hp);
1039 sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
1043
1044#if 0
1046 advance_number(utype->require_advance), 3);
1047#endif
1048
1049 if (U_NOT_OBSOLETED == utype->obsoleted_by) {
1052 } else {
1055 }
1056
1057 helptext_unit(buf, sizeof(buf), client_player(), pitem->text, utype,
1058 TRUE);
1059
1062
1066 } else {
1075
1077/* create_tech_tree(help_improvement_tree, 0, A_LAST, 3); */
1080
1083 }
1084
1086}
1087
1088/**********************************************************************/
1091static char *fc_chomp(char *str, size_t len)
1092{
1093 gchar *i;
1094
1095 if (str == NULL || !*str) {
1096 return str;
1097 }
1098
1099 i = str + len;
1100 for (i = g_utf8_find_prev_char(str, i);
1103 *i = '\0';
1104 }
1105
1106 return str;
1107}
1108
1109/**********************************************************************/
1112static void help_update_tech(const struct help_item *pitem, char *title)
1113{
1114 int i, j;
1115 GtkWidget *w, *hbox;
1116 char buf[8192];
1118
1119 if (padvance != NULL
1122 size_t len;
1123
1125
1126 for (j = 0; j < ARRAY_SIZE(help_advances); j++) {
1127 help_advances[j] = FALSE;
1128 }
1129
1134
1135 helptext_advance(buf, sizeof(buf), client.conn.playing, pitem->text, i);
1136 len = strlen(buf);
1137 fc_chomp(buf, len);
1138
1140
1141 w = gtk_text_view_new();
1146 gtk_widget_set_name(w, "help_text");
1152 help_box_add(w);
1154
1156 if (txt != NULL) {
1158 }
1159
1167 help_box_add(w);
1169
1171 /* FIXME: need a more general mechanism for this, since this
1172 * helptext needs to be shown in all possible req source types. */
1174 if (VUT_ADVANCE == preq->source.kind
1175 && preq->source.value.advance == padvance) {
1178 w = gtk_label_new(_("Allows"));
1184 }
1187
1188 improvement_iterate(pimprove) {
1189 if (valid_improvement(pimprove)) {
1190 requirement_vector_iterate(&pimprove->reqs, preq) {
1191 if (VUT_ADVANCE == preq->source.kind
1192 && preq->source.value.advance == padvance) {
1195 w = gtk_label_new(_("Allows"));
1198 is_great_wonder(pimprove)
1199 ? HELP_WONDER
1203 }
1205 requirement_vector_iterate(&pimprove->obsolete_by, pobs) {
1206 if (pobs->source.kind == VUT_ADVANCE
1207 && pobs->source.value.advance == padvance
1208 && pobs->present) {
1211 w = gtk_label_new(_("Obsoletes"));
1214 is_great_wonder(pimprove)
1215 ? HELP_WONDER
1219 }
1221 }
1223
1226 continue;
1227 }
1228
1231 w = gtk_label_new(_("Allows"));
1237
1243 w = gtk_label_new(_("Allows"));
1248 } else {
1251 w = gtk_label_new(_("Allows"));
1255 w = gtk_label_new(_("with"));
1258 AR_TWO)),
1259 HELP_TECH);
1261 w = gtk_label_new(Q_("?techhelp:"));
1264 }
1265 }
1269 w = gtk_label_new(_("Allows"));
1273 w = gtk_label_new(_("with"));
1276 AR_ONE)),
1277 HELP_TECH);
1279 w = gtk_label_new(Q_("?techhelp:"));
1282 }
1284
1286 }
1287}
1288
1289/**********************************************************************/
1311
1312/**********************************************************************/
1316 enum unit_activity act,
1317 char *label)
1318{
1319 enum extra_cause cause = activity_to_extra_cause(act);
1320
1321 extra_type_by_cause_iterate(cause, pextra) {
1322 if (pextra->buildable
1323 && requirement_fulfilled_by_terrain(pterr, &(pextra->reqs))) {
1327 act));
1328 }
1330}
1331
1332/**********************************************************************/
1335static void help_update_terrain(const struct help_item *pitem,
1336 char *title)
1337{
1338 char buf[8192];
1339 struct terrain *pterrain = terrain_by_translated_name(title);
1340
1341 if (pterrain != NULL) {
1342 struct universal for_terr = { .kind = VUT_TERRAIN, .value = { .terrain = pterrain }};
1343
1345
1346 {
1347 /* 25 => "1.25"; 50 => "1.5"; 100 => "2.0" */
1348 int defbonus = pterrain->defense_bonus + 100;
1349 int frac = defbonus % 100;
1350
1351 if ((frac % 10) == 0) {
1352 frac /= 10;
1353 }
1354 sprintf(buf, "%d/%d.%d",
1355 pterrain->movement_cost, defbonus / 100, frac);
1356 }
1358
1359 sprintf(buf, "%d/%d/%d",
1360 pterrain->output[O_FOOD],
1361 pterrain->output[O_SHIELD],
1362 pterrain->output[O_TRADE]);
1364
1365 buf[0] = '\0';
1366 if (*(pterrain->resources)) {
1367 struct extra_type **r;
1368
1369 /* TODO: include resource frequency information */
1370 for (r = pterrain->resources; *r; r++) {
1371 /* TRANS: " Whales (2/1/2)," */
1372 sprintf (buf + strlen (buf), " %s (%d/%d/%d),",
1374 pterrain->output[O_FOOD] + (*r)->data.resource->output[O_FOOD],
1375 pterrain->output[O_SHIELD] + (*r)->data.resource->output[O_SHIELD],
1376 pterrain->output[O_TRADE] + (*r)->data.resource->output[O_TRADE]);
1377 }
1378 buf[strlen (buf) - 1] = '.';
1379 } else {
1380 /* TRANS: "Resources: (none)" */
1381 sprintf (buf + strlen (buf), _("(none)"));
1382 }
1384
1386
1387 if (pterrain->cultivate_result != T_NONE
1389 NULL, &for_terr)) {
1390 fc_snprintf(buf, sizeof(buf),
1391 PL_("%d turn", "%d turns", pterrain->cultivate_time),
1392 pterrain->cultivate_time);
1393 add_act_help_for_terrain(_("Cultivate Rslt/Time"),
1395 HELP_TERRAIN, buf);
1396 }
1397
1398 if (pterrain->plant_result != T_NONE
1400 fc_snprintf(buf, sizeof(buf),
1401 PL_("%d turn", "%d turns", pterrain->plant_time),
1402 pterrain->plant_time);
1403 add_act_help_for_terrain(_("Plant Rslt/Time"),
1405 HELP_TERRAIN, buf);
1406 }
1407
1408 if (pterrain->transform_result != T_NONE
1410 NULL, &for_terr)) {
1411 fc_snprintf(buf, sizeof(buf),
1412 PL_("%d turn", "%d turns", pterrain->transform_time),
1413 pterrain->transform_time);
1414 add_act_help_for_terrain(_("Trans. Rslt/Time"),
1416 HELP_TERRAIN, buf);
1417 }
1418
1421 _("Build as irrigation"));
1422 }
1425 _("Build as mine"));
1426 }
1429 _("Build as road"));
1430 }
1433 _("Build as base"));
1434 }
1436 }
1437
1439 pitem->text, pterrain);
1440
1443
1445}
1446
1447/**********************************************************************/
1450static void help_update_extra(const struct help_item *pitem, char *title)
1451{
1452 char buf[8192];
1454
1455 buf[0] = '\0';
1456 if (pextra == NULL) {
1457 strcat(buf, pitem->text);
1458 } else {
1459 struct road_type *proad = extra_road_get(pextra);
1461
1463
1464 /* Cost to build */
1465 if (pextra->buildable) {
1466 if (pextra->build_time != 0) {
1467 /* TRANS: "MP" = movement points */
1468 sprintf(buf, _("%d MP"), pextra->build_time);
1469 } else {
1470 /* TRANS: Build time depends on terrain. */
1471 sprintf(buf, _("Terrain specific"));
1472 }
1473 } else {
1474 sprintf(buf, "-");
1475 }
1477 /* Conflicting extras */
1478 buf[0] = '\0';
1479 if (is_resource) {
1480 /* TRANS: (Resource extra) Conflicts with: */
1481 strcat(buf, _("Other Resources"));
1482 }
1484 if (!can_extras_coexist(pextra, pextra2)
1486 if (buf[0] != '\0') {
1487 strcat(buf, "/");
1488 }
1490 }
1492 /* TRANS: "Conflicts with: (none)" (extras) */
1493 gtk_label_set_text(GTK_LABEL(help_elabel[3]), buf[0] ? buf : _("(none)"));
1494
1495 /* Bonus */
1496 if (proad != NULL) {
1497 const char *bonus = NULL;
1498
1500 if (proad->tile_incr[o] > 0) {
1501 /* TRANS: Road bonus depends on terrain. */
1502 bonus = _("Terrain specific");
1503 break;
1504 }
1506 if (bonus == NULL) {
1508
1509 if (bonus == NULL) {
1510 /* TRANS: No output bonus from a road */
1511 bonus = Q_("?bonus:None");
1512 }
1513 }
1515 } else {
1516 gtk_label_set_text(GTK_LABEL(help_elabel[5]), Q_("?bonus:None"));
1517 }
1518
1519 helptext_extra(buf, sizeof(buf), client.conn.playing, pitem->text, pextra);
1520 }
1522
1525}
1526
1527/**********************************************************************/
1530static void help_update_goods(const struct help_item *pitem,
1531 char *title)
1532{
1533 char buf[8192];
1535
1536 if (pgood == NULL) {
1537 strcat(buf, pitem->text);
1538 } else {
1539 helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
1540 pgood);
1541 }
1542
1545}
1546
1547/**********************************************************************/
1550static void help_update_specialist(const struct help_item *pitem,
1551 char *title)
1552{
1553 char buf[8192];
1555
1556 if (pspec == NULL) {
1557 strcat(buf, pitem->text);
1558 } else {
1560 pspec);
1561 }
1562
1565}
1566
1567/**********************************************************************/
1570static void help_update_government(const struct help_item *pitem,
1571 char *title)
1572{
1573 char buf[8192];
1575
1576 if (gov == NULL) {
1577 strcat(buf, pitem->text);
1578 } else {
1580 pitem->text, gov);
1581 }
1582
1585}
1586
1587/**********************************************************************/
1590static void help_update_nation(const struct help_item *pitem, char *title,
1591 struct nation_type *pnation)
1592{
1593 char buf[4096];
1594
1595 if (pnation == NULL) {
1596 strcat(buf, pitem->text);
1597 } else {
1598 helptext_nation(buf, sizeof(buf), pnation, pitem->text);
1599
1601 }
1602
1605}
1606
1607/**********************************************************************/
1610static void help_update_dialog(const struct help_item *pitem)
1611{
1612 char *top;
1613
1614 /* Figure out what kind of item is required for pitem ingo */
1615
1616 for (top = pitem->topic; *top == ' '; top++) {
1617 /* Nothing */
1618 }
1619
1620 help_box_hide();
1622
1623 switch (pitem->type) {
1624 case HELP_IMPROVEMENT:
1626 break;
1627 case HELP_WONDER:
1629 break;
1630 case HELP_UNIT:
1632 break;
1633 case HELP_TECH:
1634 help_update_tech(pitem, top);
1635 break;
1636 case HELP_TERRAIN:
1638 break;
1639 case HELP_EXTRA:
1641 break;
1642 case HELP_GOODS:
1644 break;
1645 case HELP_SPECIALIST:
1647 break;
1648 case HELP_GOVERNMENT:
1650 break;
1651 case HELP_NATIONS:
1653 break;
1654 case HELP_TEXT:
1655 default:
1656 /* It was a pure text item */
1659 break;
1660 }
1661 set_title_topic(pitem->topic);
1662
1664}
1665
1666/**********************************************************************/
1669static void help_item_zoom(GtkTreePath *path)
1670{
1671 GtkTreeModel *model;
1672 GtkTreeIter it, child, item;
1673 GtkTreeSelection *selection;
1674
1676 gtk_tree_model_get_iter(model, &item, path);
1677
1678 for (child = item; gtk_tree_model_iter_parent(model, &it, &child); child = it) {
1680
1681 it_path = gtk_tree_model_get_path(model, &it);
1684 }
1685
1689 TRUE, 0.0, 0.0);
1690}
1691
1692/**********************************************************************/
1696{
1697 GtkTreePath *path;
1698 bool next;
1699
1700 path = gtk_tree_path_new_first();
1701 next = FALSE;
1703 const char *s;
1704 int depth;
1705
1706 for (s = pitem2->topic; *s == ' '; s++) {
1707 /* Nothing */
1708 }
1709 depth = s - pitem2->topic + 1;
1710
1711 while (depth < gtk_tree_path_get_depth(path)) {
1712 gtk_tree_path_up(path);
1713 gtk_tree_path_next(path);
1714 next = FALSE;
1715 }
1716 while (depth > gtk_tree_path_get_depth(path)) {
1717 gtk_tree_path_down(path);
1718 next = FALSE;
1719 }
1720
1721 if (next) {
1722 gtk_tree_path_next(path);
1723 }
1724
1725 if (pitem == pitem2) {
1726 break;
1727 }
1728
1729 next = TRUE;
1731
1732 return path;
1733}
1734
1735/**********************************************************************/
1738static void select_help_item_string(const char *item, enum help_page_type htype)
1739{
1740 const struct help_item *pitem;
1741 int idx;
1742 GtkTreePath *path;
1744
1745 if (!(pitem = get_help_item_spec(item, htype, &idx))) {
1746 return;
1747 }
1748
1749 path = help_item_path(pitem);
1750 help_item_zoom(path);
1751
1754 gtk_tree_path_free(path);
1755}
1756
1757/**********************************************************************/
1760static void help_command_update(void)
1761{
1763
1764 if (help_history_pos < 0) {
1767 } else {
1770
1771 if (help_history_pos == 0) {
1773 }
1774 if (help_history_pos >= help_history->len - 1) {
1776 }
1777 }
1778}
1779
1780/**********************************************************************/
1784{
1785 GtkTreePath *path;
1786 const struct help_item *pitem;
1787
1788 if (response_id == 1) {
1789 if (help_history_pos > 0) {
1791
1793 path = help_item_path(pitem);
1794 help_item_zoom(path);
1797 }
1798 } else if (response_id == 2) {
1801
1803 path = help_item_path(pitem);
1804 help_item_zoom(path);
1807 }
1808 } else {
1810 }
1811}
#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:83
static void set_title_topic(char *topic)
Definition helpdlg.c:173
static void activated_topic(GtkTreeView *view, gpointer data)
Definition helpdlg.c:469
static GtkWidget * help_tree
Definition helpdlg.c:80
static GtkWidget * help_tree_expand
Definition helpdlg.c:84
static GtkWidget * help_ulabel[5][5]
Definition helpdlg.c:89
static void help_update_specialist(const struct help_item *pitem, char *title)
Definition helpdlg.c:1503
static void help_hyperlink_callback(GtkWidget *w)
Definition helpdlg.c:345
static GtkWidget * help_elabel[6]
Definition helpdlg.c:91
static GtkWidget * help_etable
Definition helpdlg.c:79
static void help_destroy_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:460
static void set_help_tile_from_extra(const struct extra_type *pextra)
Definition helpdlg.c:848
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:312
static void help_update_tech(const struct help_item *pitem, char *title)
Definition helpdlg.c:1075
static void help_item_zoom(GtkTreePath *path)
Definition helpdlg.c:1621
static GtkWidget * help_slink_new_page(const gchar *txt, enum help_page_type page)
Definition helpdlg.c:427
static GtkWidget * help_tlabel[2][5]
Definition helpdlg.c:90
static GtkTreePath * help_item_path(const struct help_item *pitem)
Definition helpdlg.c:1647
static GtkWidget * help_tree_collapse
Definition helpdlg.c:85
static void help_update_nation(const struct help_item *pitem, char *title, struct nation_type *pnation)
Definition helpdlg.c:1542
static void create_help_dialog(void)
Definition helpdlg.c:509
static GtkTextBuffer * help_text
Definition helpdlg.c:70
static void help_update_wonder(const struct help_item *pitem, char *title)
Definition helpdlg.c:926
static GtkWidget * help_hyperlink_new_page(GtkWidget *label, enum help_page_type page)
Definition helpdlg.c:402
static GtkWidget * help_dialog_shell
Definition helpdlg.c:64
static GtkWidget * help_text_sw
Definition helpdlg.c:71
static GPtrArray * help_history
Definition helpdlg.c:95
static const char * help_elabel_name[6]
Definition helpdlg.c:132
static void create_tech_tree(int tech, int levels, GtkTreeIter *parent)
Definition helpdlg.c:226
static void help_update_extra(const struct help_item *pitem, char *title)
Definition helpdlg.c:1404
static GtkWidget * help_ilabel[6]
Definition helpdlg.c:87
static void set_help_tile_from_sprite(struct sprite *spr)
Definition helpdlg.c:804
static const char * help_wlabel_name[6]
Definition helpdlg.c:111
static const char * help_ulabel_name[5][5]
Definition helpdlg.c:117
static void help_tech_tree_collapse_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:337
static void set_help_tile_from_terrain(struct terrain *pterr)
Definition helpdlg.c:817
static GtkWidget * help_view
Definition helpdlg.c:67
static void help_update_goods(const struct help_item *pitem, char *title)
Definition helpdlg.c:1483
void help_system_init(void)
Definition helpdlg.c:157
static void help_box_hide(void)
Definition helpdlg.c:436
static void help_update_unit_type(const struct help_item *pitem, char *title)
Definition helpdlg.c:990
void popdown_help_dialog(void)
Definition helpdlg.c:186
static void help_update_terrain(const struct help_item *pitem, char *title)
Definition helpdlg.c:1289
static void help_update_dialog(const struct help_item *pitem)
Definition helpdlg.c:1562
static char * fc_chomp(char *str, size_t len)
Definition helpdlg.c:1055
void popup_help_dialog_string(const char *item)
Definition helpdlg.c:212
static int help_history_pos
Definition helpdlg.c:96
static struct help_page_selection help_wndr_req
Definition helpdlg.c:113
static GtkWidget * help_wlabel[6]
Definition helpdlg.c:88
static GtkWidget * help_box
Definition helpdlg.c:74
static void help_extras_of_act_for_terrain(struct terrain *pterr, enum unit_activity act, char *label)
Definition helpdlg.c:1269
void popup_help_dialog_typed(const char *item, enum help_page_type htype)
Definition helpdlg.c:196
#define REQ_LABEL_NEVER
Definition helpdlg.c:144
static void help_command_update(void)
Definition helpdlg.c:1711
static struct help_page_selection page_selections[HELP_LAST]
Definition helpdlg.c:115
#define TECH_TREE_DEPTH
Definition helpdlg.c:59
static const char * help_tlabel_name[2][5]
Definition helpdlg.c:126
static struct help_page_selection help_impr_req
Definition helpdlg.c:109
#define REQ_LABEL_NONE
Definition helpdlg.c:143
static GtkWidget * help_wtable
Definition helpdlg.c:76
static GtkWidget * help_slink_new(const gchar *txt, struct help_page_selection *select)
Definition helpdlg.c:411
static GtkWidget * help_vbox
Definition helpdlg.c:72
static void help_tech_tree_expand_callback(GtkWidget *w, gpointer data)
Definition helpdlg.c:329
static GtkWidget * help_tile
Definition helpdlg.c:73
static GtkWidget * help_hyperlink_new(GtkWidget *label, struct help_page_selection *select)
Definition helpdlg.c:380
static void help_update_government(const struct help_item *pitem, char *title)
Definition helpdlg.c:1523
static GtkWidget * help_ttable
Definition helpdlg.c:78
static void help_update_improvement(const struct help_item *pitem, char *title)
Definition helpdlg.c:876
static const char * help_ilabel_name[6]
Definition helpdlg.c:107
static GtkWidget * help_tree_buttons_hbox
Definition helpdlg.c:86
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:1689
static bool help_advances[A_LAST]
Definition helpdlg.c:93
static GtkWidget * help_utable
Definition helpdlg.c:77
static GtkWidget * help_itable
Definition helpdlg.c:75
static GtkTreeStore * tstore
Definition helpdlg.c:81
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:1246
static void help_command_callback(GtkWidget *w, gint response_id)
Definition helpdlg.c:1734
const char * title
Definition repodlgs.c:1314
GType type
Definition repodlgs.c:1313
static void help_box_add(GtkWidget *wdg)
Definition helpdlg.c:455
static void help_box_clear(void)
Definition helpdlg.c:463
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:4340
void helptext_advance(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, int i)
Definition helpdata.c:3299
enum help_page_type help_type_by_requirement(const struct requirement *req)
Definition helpdata.c:5205
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:1932
void helptext_extra(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct extra_type *pextra)
Definition helpdata.c:3794
void helptext_goods(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct goods_type *pgood)
Definition helpdata.c:4259
const char * helptext_road_bonus_str(const struct terrain *pterrain, const struct road_type *proad)
Definition helpdata.c:3630
char * helptext_unit_upkeep_str(const struct unit_type *utype)
Definition helpdata.c:5002
const char * helptext_extra_for_terrain_str(struct extra_type *pextra, struct terrain *pterrain, enum unit_activity act)
Definition helpdata.c:3760
void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct specialist *pspec)
Definition helpdata.c:4305
const struct help_item * get_help_item_spec(const char *name, enum help_page_type htype, int *pos)
Definition helpdata.c:1288
char * helptext_building(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, const struct impr_type *pimprove)
Definition helpdata.c:1381
void helptext_terrain(char *buf, size_t bufsz, struct player *pplayer, const char *user_text, struct terrain *pterrain)
Definition helpdata.c:3520
void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation, const char *user_text)
Definition helpdata.c:5039
#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:1015
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:102
const struct requirement * req
Definition helpdlg.c:103
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:6783
int fill_basic_extra_sprite_array(const struct tileset *t, struct drawn_sprite *sprs, const struct extra_type *pextra)
Definition tilespec.c:7200
int fill_basic_terrain_layer_sprite_array(struct tileset *t, struct drawn_sprite *sprs, int layer, struct terrain *pterrain)
Definition tilespec.c:7167
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:6805
struct sprite * get_nation_flag_sprite(const struct tileset *t, const struct nation_type *pnation)
Definition tilespec.c:6756
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:6774
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