summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/help.lua27
-rw-r--r--lib/scpt/help.lua25
-rw-r--r--src/birth.c5
-rw-r--r--src/externs.h1
-rw-r--r--src/help.c94
5 files changed, 99 insertions, 53 deletions
diff --git a/lib/mods/theme/scpt/help.lua b/lib/mods/theme/scpt/help.lua
index d8900d6c..3d4450b5 100644
--- a/lib/mods/theme/scpt/help.lua
+++ b/lib/mods/theme/scpt/help.lua
@@ -24,33 +24,6 @@ ingame_help
-- list of files for classes, { filename, anchor }
local t =
{
- ["race"] =
- {
- ["Beorning"] = { "r_beorn.txt", 0 },
- ["Dragon"] = { "r_dragon.txt", 0 },
- ["Dark-Elf"] = { "r_drkelf.txt", 0 },
- ["Dunadan"] = { "r_dunad.txt", 0 },
- ["Dwarf"] = { "r_dwarf.txt", 0 },
- ["Elf"] = { "r_elf.txt", 0 },
- ["Ent"] = { "r_ent.txt", 0 },
- ["Gnome"] = { "r_gnome.txt", 0 },
- ["Half-Elf"] = { "r_hafelf.txt", 0 },
- ["Half-Ogre"] = { "r_hafogr.txt", 0 },
- ["High-Elf"] = { "r_hielf.txt", 0 },
- ["Hobbit"] = { "r_hobbit.txt", 0 },
- ["Human"] = { "r_human.txt", 0 },
- ["Druadan"] = { "r_druadan.txt", 0 },
- ["Maia"] = { "r_maia.txt", 0 },
- ["Orc"] = { "r_orc.txt", 0 },
- ["Petty-Dwarf"] = { "r_pettyd.txt", 0 },
- ["RohanKnight"] = { "r_rohank.txt", 0 },
- ["Eagle"] = { "r_eagle.txt", 0 },
- ["Troll"] = { "r_troll.txt", 0 },
- ["Wood-Elf"] = { "r_wodelf.txt", 0 },
- ["Yeek"] = { "r_yeek.txt", 0 },
- ["Easterling"] = { "r_easterl.txt", 0 },
- ["Demon"] = { "r_demon.txt", 0},
- },
["subrace"] =
{
["Barbarian"] = { "rm_barb.txt", 0 },
diff --git a/lib/scpt/help.lua b/lib/scpt/help.lua
index 734747ed..694fefeb 100644
--- a/lib/scpt/help.lua
+++ b/lib/scpt/help.lua
@@ -24,31 +24,6 @@ ingame_help
-- list of files for classes, { filename, anchor }
local t =
{
- ["race"] =
- {
- ["Beorning"] = { "r_beorn.txt", 0 },
- ["DeathMold"] = { "r_deathm.txt", 0 },
- ["Dark-Elf"] = { "r_drkelf.txt", 0 },
- ["Dunadan"] = { "r_dunad.txt", 0 },
- ["Dwarf"] = { "r_dwarf.txt", 0 },
- ["Elf"] = { "r_elf.txt", 0 },
- ["Ent"] = { "r_ent.txt", 0 },
- ["Gnome"] = { "r_gnome.txt", 0 },
- ["Half-Elf"] = { "r_hafelf.txt", 0 },
- ["Half-Ogre"] = { "r_hafogr.txt", 0 },
- ["High-Elf"] = { "r_hielf.txt", 0 },
- ["Hobbit"] = { "r_hobbit.txt", 0 },
- ["Human"] = { "r_human.txt", 0 },
- ["Kobold"] = { "r_kobold.txt", 0 },
- ["Maia"] = { "r_maia.txt", 0 },
- ["Orc"] = { "r_orc.txt", 0 },
- ["Petty-Dwarf"] = { "r_pettyd.txt", 0 },
- ["RohanKnight"] = { "r_rohank.txt", 0 },
- ["Thunderlord"] = { "r_thlord.txt", 0 },
- ["Troll"] = { "r_troll.txt", 0 },
- ["Wood-Elf"] = { "r_wodelf.txt", 0 },
- ["Yeek"] = { "r_yeek.txt", 0 },
- },
["subrace"] =
{
["Barbarian"] = { "rm_barb.txt", 0 },
diff --git a/src/birth.c b/src/birth.c
index aaef998c..0192abc3 100644
--- a/src/birth.c
+++ b/src/birth.c
@@ -1924,7 +1924,10 @@ static bool_ player_birth_aux_ask()
}
k = (islower(c) ? A2I(c) : -1);
if ((k >= 0) && (k < n)) break;
- if (c == '?') exec_lua(format("ingame_help('select_context', 'race', '%s')", race_info[sel].title + rp_name));
+ if (c == '?')
+ {
+ help_race(race_info[sel].title + rp_name);
+ }
else if (c == '=')
{
screen_save();
diff --git a/src/externs.h b/src/externs.h
index f727da82..87489bcc 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -618,6 +618,7 @@ extern void initialize_bookable_spells();
/* help.c */
extern void init_hooks_help();
+extern void help_race(cptr race);
/* birth.c */
extern void print_desc_aux(cptr txt, int y, int x);
diff --git a/src/help.c b/src/help.c
index a80d1a33..689e1d1b 100644
--- a/src/help.c
+++ b/src/help.c
@@ -57,6 +57,55 @@ struct triggered_help_type
};
/**
+ * Struct for context-sensitive help
+ */
+typedef struct context_help_type context_help_type;
+struct context_help_type
+{
+ cptr key; /* Lookup key */
+ cptr file_name; /* Name of help file */
+ int anchor; /* Anchor in file */
+};
+
+/**
+ * Race help files.
+ */
+context_help_type race_table[] =
+{
+ /* ToME */
+ { "Beorning", "r_beorn.txt", 0 },
+ { "DeathMold", "r_deathm.txt", 0 },
+ { "Dark-Elf", "r_drkelf.txt", 0 },
+ { "Dunadan", "r_dunad.txt", 0 },
+ { "Dwarf", "r_dwarf.txt", 0 },
+ { "Elf", "r_elf.txt", 0 },
+ { "Ent", "r_ent.txt", 0 },
+ { "Gnome", "r_gnome.txt", 0 },
+ { "Half-Elf", "r_hafelf.txt", 0 },
+ { "Half-Ogre", "r_hafogr.txt", 0 },
+ { "High-Elf", "r_hielf.txt", 0 },
+ { "Hobbit", "r_hobbit.txt", 0 },
+ { "Human", "r_human.txt", 0 },
+ { "Kobold", "r_kobold.txt", 0 },
+ { "Maia", "r_maia.txt", 0 },
+ { "Orc", "r_orc.txt", 0 },
+ { "Petty-Dwarf", "r_pettyd.txt", 0 },
+ { "RohanKnight", "r_rohank.txt", 0 },
+ { "Thunderlord", "r_thlord.txt", 0 },
+ { "Troll", "r_troll.txt", 0 },
+ { "Wood-Elf", "r_wodelf.txt", 0 },
+ { "Yeek", "r_yeek.txt", 0 },
+ /* Theme */
+ { "Dragon", "r_dragon.txt", 0 },
+ { "Druadan", "r_druadan.txt", 0 },
+ { "Eagle", "r_eagle.txt", 0 },
+ { "Easterling", "r_easterl.txt", 0 },
+ { "Demon", "r_demon.txt", 0 },
+ /* End of list */
+ { NULL, NULL, 0 },
+};
+
+/**
* Trigger functions
*/
static bool_ trigger_void_jumpgate(void *in, void *out) {
@@ -411,3 +460,48 @@ void init_hooks_help()
{
setup_triggered_help_hooks();
}
+
+/*
+ * Show help file
+ */
+static void show_context_help(context_help_type *context_help)
+{
+ assert(context_help != NULL);
+
+ screen_save();
+
+ show_file(context_help->file_name, 0, -context_help->anchor, 0);
+
+ screen_load();
+}
+
+/*
+ * Find context help
+ */
+static context_help_type *find_context_help(context_help_type table[], cptr key)
+{
+ int i;
+
+ for (i = 0; ; i++)
+ {
+ context_help_type *context_help = &table[i];
+
+ if (context_help->key == NULL)
+ {
+ return NULL; /* End of list */
+ }
+
+ if (streq(key, context_help->key))
+ {
+ return context_help;
+ }
+ }
+}
+
+/*
+ * Racial help
+ */
+void help_race(cptr race)
+{
+ show_context_help(find_context_help(race_table, race));
+}