summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mods/theme/scpt/help.lua11
-rw-r--r--lib/scpt/help.lua11
-rw-r--r--src/cmd4.c3
-rw-r--r--src/dungeon.c2
-rw-r--r--src/externs.h2
-rw-r--r--src/help.c104
6 files changed, 100 insertions, 33 deletions
diff --git a/lib/mods/theme/scpt/help.lua b/lib/mods/theme/scpt/help.lua
index 4e244df6..ca6fa6c6 100644
--- a/lib/mods/theme/scpt/help.lua
+++ b/lib/mods/theme/scpt/help.lua
@@ -9,17 +9,6 @@
ingame_help
{
["hook"] = HOOK_MOVE,
- ["event"] = function(y, x) if cave(y, x).feat == FEAT_BETWEEN then return TRUE end end,
- ["desc"] =
- {
- "Void Jumpgates can be entered by pressing the > key. They will transport",
- "you to another jumpgate, but beware of the cold damage that might kill you.",
- }
-}
-
-ingame_help
-{
- ["hook"] = HOOK_MOVE,
["event"] = function(y, x) if cave(y, x).feat == FEAT_FOUNTAIN then return TRUE end end,
["desc"] =
{
diff --git a/lib/scpt/help.lua b/lib/scpt/help.lua
index 5350fec8..293de713 100644
--- a/lib/scpt/help.lua
+++ b/lib/scpt/help.lua
@@ -9,17 +9,6 @@
ingame_help
{
["hook"] = HOOK_MOVE,
- ["event"] = function(y, x) if cave(y, x).feat == FEAT_BETWEEN then return TRUE end end,
- ["desc"] =
- {
- "Void Jumpgates can be entered by pressing the > key. They will transport",
- "you to another jumpgate, but beware of the cold damage that might kill you.",
- }
-}
-
-ingame_help
-{
- ["hook"] = HOOK_MOVE,
["event"] = function(y, x) if cave(y, x).feat == FEAT_FOUNTAIN then return TRUE end end,
["desc"] =
{
diff --git a/src/cmd4.c b/src/cmd4.c
index d0099360..fd57a9b5 100644
--- a/src/cmd4.c
+++ b/src/cmd4.c
@@ -1442,9 +1442,6 @@ void do_cmd_options(void)
/* Restore the screen */
screen_load();
-
- /* Set the ingame help */
- ingame_help(p_ptr->help.enabled);
}
diff --git a/src/dungeon.c b/src/dungeon.c
index 342779b2..840094c1 100644
--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -5625,7 +5625,7 @@ void play_game(bool_ new_game)
/* Initialize hooks */
init_hooks();
- ingame_help(p_ptr->help.enabled);
+ init_hooks_help();
/* React to changes */
Term_xtra(TERM_XTRA_REACT, 0);
diff --git a/src/externs.h b/src/externs.h
index 3c345051..3b952681 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -617,7 +617,7 @@ extern bool_ process_hooks_new(int h_idx, void *in, void *out);
extern void initialize_bookable_spells();
/* help.c */
-extern void ingame_help(bool_ enable);
+extern void init_hooks_help();
/* birth.c */
extern void print_desc_aux(cptr txt, int y, int x);
diff --git a/src/help.c b/src/help.c
index d0bdbedf..a87a146a 100644
--- a/src/help.c
+++ b/src/help.c
@@ -1,13 +1,10 @@
/* File: help.c */
/* Purpose: ingame help */
-/*
- * Actually this is now handled by lua,
- * I'll remove this file when I feel un-lazy
- */
/*
* Copyright (c) 2001 DarkGod
+ * Copyright (c) 2012 Bardur Arantsson
*
* This software may be copied and distributed for educational, research, and
* not for profit purposes provided that this copyright and statement are
@@ -16,8 +13,103 @@
#include "angband.h"
+#define DESC_MAX 10
+#define TRIGGERED_HELP_MAX 1
+
+#define HELP_VOID_JUMPGATE 0
+
+/**
+ * Struct for help triggered by a boolean condition
+ */
+typedef struct triggered_help_type triggered_help_type;
+struct triggered_help_type
+{
+ /* Help item index; see HELP_* constants above */
+ int help_index;
+ /* Hook type */
+ int hook_type;
+ /* Trigger function */
+ bool_ (*trigger_func)(void *in, void *out);
+ /* Description; NULL terminated */
+ cptr desc[DESC_MAX];
+};
+
+/**
+ * Trigger functions
+ */
+static bool_ trigger_void_jumpgate(void *in, void *out) {
+ hook_move_in *p = (hook_move_in *) in;
+ return cave[p->y][p->x].feat == FEAT_BETWEEN;
+}
+
+/**
+ * Trigger-based help items
+ */
+static triggered_help_type triggered_help[TRIGGERED_HELP_MAX] =
+{
+ { HELP_VOID_JUMPGATE,
+ HOOK_MOVE,
+ trigger_void_jumpgate,
+ { "Void Jumpgates can be entered by pressing the > key. They will transport",
+ "you to another jumpgate, but beware of the cold damage that might kill you.",
+ NULL }
+ }
+};
+
+static bool_ triggered_help_hook(void *data, void *in, void *out)
+{
+ triggered_help_type *triggered_help = (triggered_help_type *) data;
+ /* Not triggered before and trigger now? */
+ if ((option_ingame_help) &&
+ (!p_ptr->help.activated[triggered_help->help_index]) &&
+ triggered_help->trigger_func(in,out))
+ {
+ int i;
+
+ /* Triggered */
+ p_ptr->help.activated[triggered_help->help_index] = TRUE;
+
+ /* Show the description */
+ for (i = 0; (i < DESC_MAX) && (triggered_help->desc[i] != NULL); i++)
+ {
+ cmsg_print(TERM_YELLOW, triggered_help->desc[i]);
+ }
+ }
+ /* Don't stop processing */
+ return FALSE;
+}
+
+static void setup_triggered_help_hook(int i)
+{
+ static int counter = 0;
+ char name[40];
+ triggered_help_type *h = &triggered_help[i];
+
+ /* Build name */
+ sprintf(name, "help_trigger_%d", counter);
+ counter++;
+
+ /* Add the hook */
+ add_hook_new(h->hook_type,
+ triggered_help_hook,
+ name,
+ h);
+}
+
+static void setup_triggered_help_hooks()
+{
+ int i;
+
+ for (i = 0; i < TRIGGERED_HELP_MAX; i++)
+ {
+ setup_triggered_help_hook(i);
+ }
+}
+
/*
* Driver for the context-sensitive help system
*/
-void ingame_help(bool_ enable)
-{}
+void init_hooks_help()
+{
+ setup_triggered_help_hooks();
+}