summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-27 21:45:57 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-27 21:45:57 +0000
commitc917ff16cf44039e6412dcd2fd505fdc0ddb8fde (patch)
tree9eb41ad51c8a0645ee188d1d8e6ecff0a9c62774 /crawl-ref/source
parentd104ce8a38126b3db9aa7d5c50e02c306ca0cc24 (diff)
downloadcrawl-ref-c917ff16cf44039e6412dcd2fd505fdc0ddb8fde.tar.gz
crawl-ref-c917ff16cf44039e6412dcd2fd505fdc0ddb8fde.zip
[1982129] Wizard commands can now be used from the wizard help screen.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7044 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc152
-rw-r--r--crawl-ref/source/command.cc32
-rw-r--r--crawl-ref/source/command.h14
-rw-r--r--crawl-ref/source/menu.cc1
-rw-r--r--crawl-ref/source/newgame.cc4
5 files changed, 107 insertions, 96 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index da78a91c36..e3629e580a 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -431,80 +431,23 @@ static bool _item_type_can_be_artefact( int type)
return (type == OBJ_WEAPONS || type == OBJ_ARMOUR || type == OBJ_JEWELLERY);
}
-
-static void _handle_wizard_command( void )
+static void _do_wizard_command(int wiz_command, bool silent_fail)
{
- int wiz_command, tmp;
- char specs[256];
-
- // WIZ_NEVER gives protection for those who have wiz compiles,
- // and don't want to risk their characters.
- if (Options.wiz_mode == WIZ_NEVER)
- return;
-
+ ASSERT(you.wizard);
if (!you.wizard)
- {
- mpr( "WARNING: ABOUT TO ENTER WIZARD MODE!", MSGCH_WARN );
-
-#ifndef SCORE_WIZARD_MODE
- mpr( "If you continue, your game will not be scored!", MSGCH_WARN );
-#endif
-
- if (!yesno( "Do you really want to enter wizard mode?", false, 'n' ))
- return;
-
- take_note(Note(NOTE_MESSAGE, 0, 0, "Entered wizard mode."));
-
- you.wizard = true;
- redraw_screen();
-
- if (crawl_state.cmd_repeat_start)
- {
- crawl_state.cancel_cmd_repeat("Can't repeat entering wizard "
- "mode.");
- return;
- }
- }
-
- mpr( "Enter Wizard Command (? - help): ", MSGCH_PROMPT );
- wiz_command = getch();
-
- if (crawl_state.cmd_repeat_start)
- {
- // Easiest to list which wizard commands *can* be repeated.
- switch (wiz_command)
- {
- case 'x':
- case '$':
- case 'a':
- case 'c':
- case 'h':
- case 'H':
- case 'm':
- case 'M':
- case 'X':
- case '!':
- case '[':
- case ']':
- case '^':
- case '%':
- case 'o':
- case 'z':
- case 'Z':
- break;
+ return;
- default:
- crawl_state.cant_cmd_repeat("You cannot repeat that "
- "wizard command.");
- return;
- }
- }
+ int tmp;
+ char specs[256];
switch (wiz_command)
{
case '?':
- list_commands(true, 0, true); // tell it to list wizard commands
- break;
+ {
+ int key = list_wizard_commands(true);
+ _do_wizard_command(key, true);
+ return;
+ }
case CONTROL('G'):
save_ghost(true);
@@ -1146,11 +1089,82 @@ static void _handle_wizard_command( void )
}
default:
- formatted_mpr(formatted_string::parse_string("Not a <magenta>Wizard</magenta> Command."));
+ if (!silent_fail)
+ formatted_mpr(formatted_string::parse_string("Not a <magenta>Wizard</magenta> Command."));
break;
}
you.turn_is_over = false;
}
+
+static void _handle_wizard_command( void )
+{
+ int wiz_command;
+
+ // WIZ_NEVER gives protection for those who have wiz compiles,
+ // and don't want to risk their characters.
+ if (Options.wiz_mode == WIZ_NEVER)
+ return;
+
+ if (!you.wizard)
+ {
+ mpr( "WARNING: ABOUT TO ENTER WIZARD MODE!", MSGCH_WARN );
+
+#ifndef SCORE_WIZARD_MODE
+ mpr( "If you continue, your game will not be scored!", MSGCH_WARN );
+#endif
+
+ if (!yesno( "Do you really want to enter wizard mode?", false, 'n' ))
+ return;
+
+ take_note(Note(NOTE_MESSAGE, 0, 0, "Entered wizard mode."));
+
+ you.wizard = true;
+ redraw_screen();
+
+ if (crawl_state.cmd_repeat_start)
+ {
+ crawl_state.cancel_cmd_repeat("Can't repeat entering wizard "
+ "mode.");
+ return;
+ }
+ }
+
+ mpr( "Enter Wizard Command (? - help): ", MSGCH_PROMPT );
+ wiz_command = getch();
+
+ if (crawl_state.cmd_repeat_start)
+ {
+ // Easiest to list which wizard commands *can* be repeated.
+ switch (wiz_command)
+ {
+ case 'x':
+ case '$':
+ case 'a':
+ case 'c':
+ case 'h':
+ case 'H':
+ case 'm':
+ case 'M':
+ case 'X':
+ case '!':
+ case '[':
+ case ']':
+ case '^':
+ case '%':
+ case 'o':
+ case 'z':
+ case 'Z':
+ break;
+
+ default:
+ crawl_state.cant_cmd_repeat("You cannot repeat that "
+ "wizard command.");
+ return;
+ }
+ }
+
+ _do_wizard_command(wiz_command, false);
+}
#endif
// Set up the running variables for the current run.
@@ -2275,7 +2289,7 @@ void process_command( command_type cmd )
#endif
case CMD_DISPLAY_COMMANDS:
- list_commands(false, 0, true);
+ list_commands(0, true);
break;
case CMD_EXPERIENCE_CHECK:
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 9a0707686e..49241aea20 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -51,7 +51,6 @@
static void _adjust_item(void);
static void _adjust_spells(void);
static void _adjust_ability(void);
-static void _list_wizard_commands();
static const char *features[] = {
"Stash-tracking",
@@ -1558,9 +1557,9 @@ std::string help_highlighter::get_species_key() const
}
////////////////////////////////////////////////////////////////////////////
-static void _show_keyhelp_menu(const std::vector<formatted_string> &lines,
- bool with_manual, bool easy_exit = false,
- int hotkey = 0)
+static int _show_keyhelp_menu(const std::vector<formatted_string> &lines,
+ bool with_manual, bool easy_exit = false,
+ int hotkey = 0)
{
formatted_scroller cmd_help;
@@ -1694,6 +1693,8 @@ static void _show_keyhelp_menu(const std::vector<formatted_string> &lines,
cmd_help.jump_to_hotkey(hotkey);
cmd_help.show();
+
+ return cmd_help.getkey();
}
void show_specific_help( const std::string &help )
@@ -1988,18 +1989,8 @@ static void _add_formatted_tutorial_help(column_composer &cols)
true, true, _cmdhelp_textfilter, 40);
}
-void list_commands(bool wizard, int hotkey, bool do_redraw_screen)
+void list_commands(int hotkey, bool do_redraw_screen)
{
- if (wizard)
- {
- _list_wizard_commands();
-
- if (do_redraw_screen)
- redraw_screen();
-
- return;
- }
-
// 2 columns, split at column 40.
column_composer cols(2, 41);
@@ -2020,9 +2011,9 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen)
}
}
-static void _list_wizard_commands()
-{
#ifdef WIZARD
+int list_wizard_commands(bool do_redraw_screen)
+{
// 2 columns
column_composer cols(2, 43);
// Page size is number of lines - one line for --more-- prompt.
@@ -2098,6 +2089,9 @@ static void _list_wizard_commands()
"<w>?</w> : list wizard commands\n",
true, true);
- _show_keyhelp_menu(cols.formatted_lines(), false, true);
-#endif
+ int key = _show_keyhelp_menu(cols.formatted_lines(), false, true);
+ if (do_redraw_screen)
+ redraw_screen();
+ return key;
}
+#endif
diff --git a/crawl-ref/source/command.h b/crawl-ref/source/command.h
index f9f72c6032..6d28a0ab55 100644
--- a/crawl-ref/source/command.h
+++ b/crawl-ref/source/command.h
@@ -15,10 +15,10 @@
/* ***********************************************************************
* called from: acr
* *********************************************************************** */
-void adjust(void);
-void list_weapons(void);
-void list_armour(void);
-void list_jewellery(void);
+void adjust();
+void list_weapons();
+void list_armour();
+void list_jewellery();
/* ***********************************************************************
* called from: clua
@@ -31,8 +31,10 @@ void show_interlevel_travel_branch_help();
void show_interlevel_travel_depth_help();
void show_stash_search_help();
void show_butchering_help();
-void list_commands(bool wizard, int hotkey = 0,
- bool do_redraw_screen = false);
+void list_commands(int hotkey = 0, bool do_redraw_screen = false);
+#ifdef WIZARD
+int list_wizard_commands(bool do_redraw_screen = false);
+#endif
// XXX: Actually defined in acr.cc; we may want to move this to command.cc.
void process_command(command_type cmd);
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc
index 456fda7c7f..8d266223f0 100644
--- a/crawl-ref/source/menu.cc
+++ b/crawl-ref/source/menu.cc
@@ -1595,6 +1595,7 @@ bool formatted_scroller::jump_to_hotkey( int keyin )
bool formatted_scroller::process_key( int keyin )
{
+ lastch = keyin;
if (f_keyfilter)
keyin = (*f_keyfilter)(keyin);
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index e11f78d55d..d9b120e2ac 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -4008,10 +4008,10 @@ job_query:
break;
// help files
case '?':
- list_commands(false, '2');
+ list_commands('2');
return choose_class();
case '%':
- list_commands(false, '%');
+ list_commands('%');
return choose_class();
default:
break;