From 239ee7d1040f90fbdcad52e7f41017574df5a865 Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 5 Oct 2008 16:09:36 +0000 Subject: Minor typesafety fix. Added description for '!' and '@' to targeting help. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7137 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/cio.cc | 4 ++-- crawl-ref/source/cio.h | 4 +++- crawl-ref/source/command.cc | 4 +++- crawl-ref/source/enum.h | 16 ++++++++++++++++ crawl-ref/source/macro.h | 18 ++---------------- 5 files changed, 26 insertions(+), 20 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/cio.cc b/crawl-ref/source/cio.cc index fe4bbf23ac..dd21bf6caa 100644 --- a/crawl-ref/source/cio.cc +++ b/crawl-ref/source/cio.cc @@ -27,9 +27,9 @@ static keycode_type _numpad2vi(keycode_type key) } #endif -int unmangle_direction_keys(int keyin, int km, bool fake_ctrl, bool fake_shift) +int unmangle_direction_keys(int keyin, KeymapContext keymap, + bool fake_ctrl, bool fake_shift) { - const KeymapContext keymap = static_cast(km); #ifdef UNIX // Kludging running and opening as two character sequences // for Unix systems. This is an easy way out... all the diff --git a/crawl-ref/source/cio.h b/crawl-ref/source/cio.h index 38e8b8a2ba..b8d5420d39 100644 --- a/crawl-ref/source/cio.h +++ b/crawl-ref/source/cio.h @@ -10,9 +10,11 @@ #define CIO_H #include "AppHdr.h" +#include "enum.h" #include "externs.h" #include "defines.h" #include "directn.h" + #include #include #include @@ -50,7 +52,7 @@ int c_getch(); // Converts a key to a direction key, converting keypad and other sequences // to vi key sequences (shifted/control key directions are also handled). Non // direction keys (hopefully) pass through unmangled. -int unmangle_direction_keys(int keyin, int keymap = 0, +int unmangle_direction_keys(int keyin, KeymapContext keymap = KC_DEFAULT, bool fake_ctrl = true, bool fake_shift = true); void get_input_line( char *const buff, int len ); diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 35b03c0ade..dcdb6e831e 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -746,8 +746,10 @@ static const char *targeting_help_1 = "Targeting (zapping wands, casting spells, etc.):\n" "The keys from examine surroundings also work here.\n" "In addition, you can use:\n" - "! : fire at target (Enter, Del, Space)\n" + "Enter : fire at target (Space, Del)\n" ". : fire at target and stop there (may hit submerged creatures)\n" + "! : fire at target, ignoring range\n" + "@ : fire at target and stop there, ignoring range\n" "p : fire at Previous target (also f)\n" ": : show/hide beam path\n" "Shift-Dir : shoot straight-line beam\n" diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index f68fd730de..cdf74670c9 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1372,6 +1372,22 @@ enum job_type JOB_UNKNOWN = 100 }; +enum KeymapContext { + KC_DEFAULT, // For no-arg getchm(), must be zero. + KC_LEVELMAP, // When in the 'X' level map + KC_TARGETING, // Only during 'x' and other targeting modes + KC_CONFIRM, // When being asked y/n/q questions + KC_MENU, // For menus + +#ifdef USE_TILE + KC_TILE, // For context_for_command() +#endif + + KC_CONTEXT_COUNT, // Must always be the last real context + + KC_NONE +}; + // This order is *critical*. Don't mess with it (see mon_enchant) enum kill_category { diff --git a/crawl-ref/source/macro.h b/crawl-ref/source/macro.h index be3a51d974..2765136fac 100644 --- a/crawl-ref/source/macro.h +++ b/crawl-ref/source/macro.h @@ -11,6 +11,8 @@ #include +#include "enum.h" + #ifndef MACRO_CC #undef getch @@ -18,22 +20,6 @@ #endif -enum KeymapContext { - KC_DEFAULT, // For no-arg getchm(), must be zero. - KC_LEVELMAP, // When in the 'X' level map - KC_TARGETING, // Only during 'x' and other targeting modes - KC_CONFIRM, // When being asked y/n/q questions - KC_MENU, // For menus - -#ifdef USE_TILE - KC_TILE, // For context_for_command() -#endif - - KC_CONTEXT_COUNT, // Must always be the last real context - - KC_NONE -}; - class key_recorder; typedef bool (*key_recorder_callback)(key_recorder *recorder, int &ch, bool reverse); -- cgit v1.2.3-54-g00ecf