summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-01 12:11:05 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-01 12:11:05 +0000
commit0a8672084b1c7d63b2e87a5a6e579f4c2afeabd7 (patch)
tree0433cac3c2c0180fe1c02f87d5465d2adffb5c09 /crawl-ref
parentb0bb78bd1d4f2364fb560ce31dadd878d3253573 (diff)
downloadcrawl-ref-0a8672084b1c7d63b2e87a5a6e579f4c2afeabd7.tar.gz
crawl-ref-0a8672084b1c7d63b2e87a5a6e579f4c2afeabd7.zip
Allow yesno to use an override keymap applied after getchm(), make Escape cancel out of the explore stop prompt (bobbens).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2716 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/stuff.cc6
-rw-r--r--crawl-ref/source/stuff.h5
-rw-r--r--crawl-ref/source/travel.cc5
3 files changed, 13 insertions, 3 deletions
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 7562d1e0b0..29c03cd096 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -725,7 +725,8 @@ void canned_msg(canned_message_type which_message)
// jmf: general helper (should be used all over in code)
// -- idea borrowed from Nethack
bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
- bool interrupt_delays, bool noprompt )
+ bool interrupt_delays, bool noprompt,
+ const explicit_keymap *map )
{
if (interrupt_delays && !crawl_state.is_repeating_cmd())
interrupt_activity( AI_FORCE_INTERRUPT );
@@ -737,6 +738,9 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after,
int tmp = getchm(KC_CONFIRM);
+ if (map && map->find(tmp) != map->end())
+ tmp = map->find(tmp)->second;
+
if ((tmp == ' ' || tmp == 27 || tmp == '\r' || tmp == '\n')
&& safeanswer)
tmp = safeanswer;
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index 4b23042cbb..e9a4248bd1 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -17,6 +17,7 @@
#define STUFF_H
#include "externs.h"
+#include <map>
std::string make_time_string(time_t abs_time, bool terse = false);
void set_redraw_status( unsigned long flags );
@@ -67,9 +68,11 @@ void redraw_screen();
void canned_msg(canned_message_type which_message);
+typedef std::map<int, int> explicit_keymap;
bool yesno( const char * str, bool safe = true, int safeanswer = 0,
bool clear_after = true, bool interrupt_delays = true,
- bool noprompt = false );
+ bool noprompt = false,
+ const explicit_keymap *map = NULL );
int yesnoquit( const char* str, bool safe = true,
int safeanswer = 0, bool clear_after = true );
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 3295f550a3..53f6fb7795 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -931,7 +931,10 @@ void explore_pickup_event(int did_pickup, int tried_pickup)
"Could not pick up %s here, shall I ignore %s? ",
tried_pickup == 1? "an item" : "some items",
tried_pickup == 1? "it" : "them");
- if (yesno(prompt.c_str(), true, 'y', true, false))
+ // Make Escape => 'n' and stop run.
+ explicit_keymap map;
+ map[ESCAPE] = 'n';
+ if (yesno(prompt.c_str(), true, 'y', true, false, false, &map))
{
mark_items_non_pickup_at(you.pos());
// Don't stop explore.