'I' command support for BUCX
Allow the 'I' command to show inventory of known blessed items via pseudo object classes B, C, U, and X. That's instead of an showing inventory of specific object class. The two can't be combined because 'I' operates on single character input. I had to modify tty_yn_function to prevent it from forcing a BUCX character into lower case (simply using lower case would cause a conflict with 'u' and 'x' for inventory of shopping bill), and did that by checking whether any of the acceptable response characters are upper case. Pretty straightforward and shouldn't impact any other uses that don't specify upper case choices. I did the same thing for X11. Other interfaces most likely need to do something similar. If they don't, a response of 'B' or 'C' (for menustyle:traditional or menustyle:combination) will simply not work, without causing any problems, same as typing an invalid choice, and 'U' or 'X' will give shop feedback instead of the requested subset of inventory. The Guidebook revisions are untested.
This commit is contained in:
+13
-2
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 winX.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.5 winX.c $NHDT-Date: 1430040327 2015/04/26 09:25:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
|
||||
/* NetHack 3.5 winX.c $Date: 2012/01/24 04:26:26 $ $Revision: 1.27 $ */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1532,6 +1532,7 @@ static char yn_esc_map; /* ESC maps to this char. */
|
||||
static Widget yn_popup; /* popup for the yn fuction (created once) */
|
||||
static Widget yn_label; /* label for yn function (created once) */
|
||||
static boolean yn_getting_num; /* TRUE if accepting digits */
|
||||
static boolean yn_preserve_case; /* default is to force yn to lower case */
|
||||
static int yn_ndigits; /* digit count */
|
||||
static long yn_val; /* accumulated value */
|
||||
|
||||
@@ -1604,7 +1605,8 @@ yn_key(w, event, params, num_params)
|
||||
if (!yn_choices) { /* accept any input */
|
||||
yn_return = ch;
|
||||
} else {
|
||||
ch = lowc(ch); /* move to lower case */
|
||||
if (!yn_preserve_case)
|
||||
ch = lowc(ch); /* move to lower case */
|
||||
|
||||
if (ch == '\033') {
|
||||
yn_getting_num = FALSE;
|
||||
@@ -1664,6 +1666,7 @@ X11_yn_function(ques, choices, def)
|
||||
|
||||
yn_choices = choices; /* set up globals for callback to use */
|
||||
yn_def = def;
|
||||
yn_preserve_case = !choices; /* preserve when arbitrary response allowed */
|
||||
|
||||
/*
|
||||
* This is sort of a kludge. There are quite a few places in the main
|
||||
@@ -1679,6 +1682,14 @@ X11_yn_function(ques, choices, def)
|
||||
char *cb, choicebuf[QBUFSZ];
|
||||
|
||||
Strcpy(choicebuf, choices); /* anything beyond <esc> is hidden */
|
||||
/* default when choices are present is to force yn answer to
|
||||
lowercase unless one or more choices are explicitly uppercase;
|
||||
check this before stripping the hidden choices */
|
||||
for (cb = choicebuf; *cb; ++cb)
|
||||
if ('A' <= *cb && *cb <= 'Z') {
|
||||
yn_preserve_case = TRUE;
|
||||
break;
|
||||
}
|
||||
if ((cb = index(choicebuf, '\033')) != 0) *cb = '\0';
|
||||
/* ques [choices] (def) */
|
||||
if ((int)(1 + strlen(ques) + 2 + strlen(choicebuf) + 4) >= BUFSZ)
|
||||
|
||||
+16
-4
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1425081315 2015/02/27 23:55:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1430040322 2015/04/26 09:25:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.29 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -333,7 +333,7 @@ char def;
|
||||
{
|
||||
register char q;
|
||||
char rtmp[40];
|
||||
boolean digit_ok, allow_num;
|
||||
boolean digit_ok, allow_num, preserve_case = FALSE;
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
boolean doprev = 0;
|
||||
char prompt[BUFSZ];
|
||||
@@ -347,6 +347,14 @@ char def;
|
||||
|
||||
allow_num = (index(resp, '#') != 0);
|
||||
Strcpy(respbuf, resp);
|
||||
/* normally we force lowercase, but if any uppercase letters
|
||||
are present in the allowed response, preserve case;
|
||||
check this before stripping the hidden choices */
|
||||
for (rb = respbuf; *rb; ++rb)
|
||||
if ('A' <= *rb && *rb <= 'Z') {
|
||||
preserve_case = TRUE;
|
||||
break;
|
||||
}
|
||||
/* any acceptable responses that follow <esc> aren't displayed */
|
||||
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
||||
(void)strncpy(prompt, query, QBUFSZ-1);
|
||||
@@ -358,13 +366,16 @@ char def;
|
||||
Strcat(prompt, " ");
|
||||
pline("%s", prompt);
|
||||
} else {
|
||||
/* no restriction on allowed response, so always preserve case */
|
||||
/* preserve_case = TRUE; -- moot since we're jumping to the end */
|
||||
pline("%s ", query);
|
||||
q = readchar();
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
do { /* loop until we get valid input */
|
||||
q = lowc(readchar());
|
||||
q = readchar();
|
||||
if (!preserve_case) q = lowc(q);
|
||||
if (q == '\020') { /* ctrl-P */
|
||||
if (iflags.prevmsg_window != 's') {
|
||||
int sav = ttyDisplay->inread;
|
||||
@@ -422,7 +433,8 @@ char def;
|
||||
q = '#';
|
||||
}
|
||||
do { /* loop until we get a non-digit */
|
||||
z = lowc(readchar());
|
||||
z = readchar();
|
||||
if (!preserve_case) z = lowc(z);
|
||||
if (digit(z)) {
|
||||
value = (10 * value) + (z - '0');
|
||||
if (value < 0) break; /* overflow: try again */
|
||||
|
||||
Reference in New Issue
Block a user