diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-21 10:39:51 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-03-21 10:39:51 +0000 |
commit | 7ceb7f873d97c45c70fcccc36746d473cf6086e6 (patch) | |
tree | f2f7982dd155ae9dcae5b07666b78f739adb7060 /crawl-ref/source/stuff.cc | |
parent | 90c49293ad5c814eb7fc341060a81a8184819a0d (diff) | |
download | crawl-ref-7ceb7f873d97c45c70fcccc36746d473cf6086e6.tar.gz crawl-ref-7ceb7f873d97c45c70fcccc36746d473cf6086e6.zip |
Tweak yesnoquit some more to allow for a second alternative yes character,
and use it for the chopping prompt. Also tweak eat.lua to allow y=e for
inventory as well.
Oh, and finally fix beheld handling to allow diagonal movement.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3787 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/stuff.cc')
-rw-r--r-- | crawl-ref/source/stuff.cc | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 2dfcc061da..fb509b3485 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -829,15 +829,66 @@ bool yesno( const char *str, bool safe, int safeanswer, bool clear_after, } } // end yesno() +static std::string _list_alternative_yes(char yes1, char yes2, + bool lowered = false, + bool brackets = false) +{ + std::string help = ""; + bool print_yes = false; + if (yes1 != 'Y') + { + if (lowered) + help += tolower(yes1); + else + help += yes1; + print_yes = true; + } + + if (yes2 != 'Y' && yes2 != yes1) + { + if (print_yes) + help += "/"; + + if (lowered) + help += tolower(yes2); + else + help += yes2; + print_yes = true; + } + + if (print_yes) + { + if (brackets) + help = " (" + help + ")"; + else + help = "/" + help; + } + + return help; +} + +static const char* _list_allowed_keys(char yes1, char yes2, + bool lowered = false) +{ + std::string result = " ["; + result += (lowered ? "y" : "Y"); + result += _list_alternative_yes(yes1, yes2, lowered); + result += (lowered ? "/n/q" : "/N/Q"); + result += "]"; + + return (result.c_str()); +} + // like yesno(), but returns 0 for no, 1 for yes, and -1 for quit +// alt_yes and alt_yes2 allow up to two synonyms for 'Y' int yesnoquit( const char* str, bool safe, int safeanswer, - bool clear_after, char alt_yes ) + bool clear_after, char alt_yes, char alt_yes2 ) { if (!crawl_state.is_repeating_cmd()) interrupt_activity( AI_FORCE_INTERRUPT ); - std::string prompt = make_stringf("%s ", str ? str : "Buggy prompt?"); - // std::string prompt = make_stringf("%s (y/n/q) ", str); + std::string prompt = make_stringf("%s%s ", str ? str : "Buggy prompt?", + _list_allowed_keys(alt_yes, alt_yes2, safe)); while (1) { @@ -866,7 +917,8 @@ int yesnoquit( const char* str, bool safe, int safeanswer, else if (tmp == 'Y' || tmp == alt_yes) return 1; else - mpr("[Y]es, [N]o or [Q]uit only, please."); + mprf("[Y]es%s, [N]o or [Q]uit only, please.", + _list_alternative_yes(alt_yes, alt_yes2, false, true).c_str()); } } |