summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-21 10:39:51 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-21 10:39:51 +0000
commit7ceb7f873d97c45c70fcccc36746d473cf6086e6 (patch)
treef2f7982dd155ae9dcae5b07666b78f739adb7060
parent90c49293ad5c814eb7fc341060a81a8184819a0d (diff)
downloadcrawl-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
-rw-r--r--crawl-ref/source/acr.cc6
-rw-r--r--crawl-ref/source/food.cc35
-rw-r--r--crawl-ref/source/lua/eat.lua2
-rw-r--r--crawl-ref/source/stuff.cc60
-rw-r--r--crawl-ref/source/stuff.h2
5 files changed, 69 insertions, 36 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 35e4c60300..83058e5978 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -3920,9 +3920,9 @@ static void move_player(int move_x, int move_y)
{
monsters* mon = &menv[you.beheld_by[i]];
coord_def pos = mon->pos();
- int olddist = distance(you.x_pos, you.y_pos, pos.x, pos.y);
- int newdist = distance(you.x_pos + move_x, you.y_pos + move_y,
- pos.x, pos.y);
+ int olddist = grid_distance(you.x_pos, you.y_pos, pos.x, pos.y);
+ int newdist = grid_distance(you.x_pos + move_x, you.y_pos + move_y,
+ pos.x, pos.y);
if (olddist < newdist)
{
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index d65224bc52..c2d929401a 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -306,42 +306,23 @@ bool butchery(int which_corpse)
continue;
// offer the possibility of butchering
- mprf("%s %s? [y/n/q/c]", can_bottle_blood_from_corpse(mitm[o].plus)?
- "Bottle" : "Butcher",
- mitm[o].name(DESC_NOCAP_A).c_str());
-
- // possible results:
- // 0 - cancel all butchery (quit)
- // 1 - say no to this butchery, continue prompting
- // 2 - OK this butchery
- // Yes, this is a hack because it's too annoying to adapt
- // yesnoquit() to this purpose.
-
- int result = 100;
- while (result == 100)
- {
- const int keyin = getchm(KC_CONFIRM);
- if (keyin == CK_ESCAPE || keyin == 'q' || keyin == 'Q')
- result = 0;
- if (keyin == ' ' || keyin == '\r' || keyin == '\n' ||
- keyin == 'n' || keyin == 'N')
- result = 1;
- if (keyin == 'y' || keyin == 'Y' || keyin == 'c' || keyin == 'C'
- || keyin == 'D' ) // D for users of the old keyset
- result = 2;
- }
-
- if ( result == 0 )
+ snprintf(info, INFO_SIZE, "%s %s?",
+ can_bottle_blood_from_corpse(mitm[o].plus)? "Bottle" : "Butcher",
+ mitm[o].name(DESC_NOCAP_A).c_str());
+
+ const int result = yesnoquit(info, true, 'N', false, 'C', 'D');
+ if ( result == -1 )
{
canceled_butcher = true;
corpse_id = -1;
break;
}
- else if ( result == 2 )
+ else if ( result == 1 )
{
corpse_id = o;
break;
}
+ // continue loop for 0
}
}
diff --git a/crawl-ref/source/lua/eat.lua b/crawl-ref/source/lua/eat.lua
index d07cf97fa9..f27f69068b 100644
--- a/crawl-ref/source/lua/eat.lua
+++ b/crawl-ref/source/lua/eat.lua
@@ -96,7 +96,7 @@ function c_eat(floor, inv)
if answer == "escape" then
return
end
- if answer == "y" then
+ if answer == "y" or answer == "e" then
food.eat(it)
return
end
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());
}
}
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index 1f59ed45b0..09af22d8d6 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -78,7 +78,7 @@ bool yesno( const char * str, bool safe = true, int safeanswer = 0,
const explicit_keymap *map = NULL );
int yesnoquit( const char* str, bool safe = true, int safeanswer = 0,
- bool clear_after = true, char alt_yes = 'Y' );
+ bool clear_after = true, char alt_yes = 'Y', char alt_yes2 = 'Y' );
bool in_bounds( int x, int y );