analagous to "yesno". Tested with zot,lava,water,quit.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3666 c06c8d41-db1a-0410-9941-cceddc491573
POETVWRYRKRTPDOAM6YLJRBAWF7QDCOUCK3JPQURB2Y4PJN7EE2QC
XEFLKDEZCVSPO4SMGNXRNQWAJ6KKWABWFX2PULITTDJUIKYPVPSAC
EO4FXWNFJRHPOSDHWH2Y6QNUP7KB5ANLX43GA3TJLXR3QOOJZ7VQC
SKV6JBDAWUWTFECFSQARSNA3DDPUFCR7N3T7D5J35NYTEDMXLP3QC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
ZHH4MGCGXMAKIZ4GVA6Q4MS3IWJTGNMWLPSAG2MWLQS2G3WU5YCAC
JW2KRJHES33W7UTWZ6NDO4TLMK4EFU4HKZXBWR2UJOMPCCOTR4CQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
QUFPPRIIRXHUFEDH3EFES7CSHTA7GG2DAXTRHUAUQBYMSWK4BP6AC
// Like yesno, but requires a full typed answer.
// Unlike yesno, prompt should have no trailing space.
// Returns true if the user typed "yes", false if something else or cancel.
bool yes_or_no( const char* fmt, ... )
{
char buf[200];
va_list args;
va_start(args, fmt);
vsnprintf(buf, sizeof buf, fmt, args);
va_end(args);
buf[sizeof(buf)-1] = 0;
mprf(MSGCH_PROMPT, "%s? (Confirm with \"yes\".) ", buf);
if (cancelable_get_line(buf, sizeof buf))
return false;
if (strcasecmp(buf, "yes") != 0)
return false;
return true;
}
mprf(MSGCH_PROMPT,
"Do you really want to step into the %s? "
"(Confirm with \"yes\".) ",
(new_grid == DNGN_LAVA ? "lava" : "deep water"));
char buf[10];
if (cancelable_get_line(buf, sizeof buf)
|| strcasecmp(buf, "yes"))
{
if (! yes_or_no("Do you really want to step into the %s",
(new_grid == DNGN_LAVA ? "lava" : "deep water")))
{
void quit_game(void)
{
char buf[10];
mpr("Are you sure you want to quit (enter \"yes\" to confirm)? ",
MSGCH_PROMPT);
if (!cancelable_get_line(buf, sizeof buf) && !strcasecmp(buf, "yes"))
ouch(INSTANT_DEATH, 0, KILLED_BY_QUITTING);
else
canned_msg(MSG_OK);
}