symset and roguesymset options

For 'O's menu, make the current symbol set be pre-selected so that
the set in use is clearly marked while contemplating changing it.
Using Return or Enter will pick it again; Escape is now needed to
deliberately not make any selection.

Also, change several symbol set initializations to use the new method
of deciding whether the default symbols are still in place.
This commit is contained in:
PatR
2019-10-18 18:23:47 -07:00
parent f114675739
commit 46225955bc
2 changed files with 35 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1571347977 2019/10/17 21:32:57 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.379 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1571448220 2019/10/19 01:23:40 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.380 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -784,9 +784,9 @@ initoptions_init()
*/
/* this detects the IBM-compatible console on most 386 boxes */
if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) {
if (!symset[PRIMARY].name)
if (!symset[PRIMARY].explicitly)
load_symset("IBMGraphics", PRIMARY);
if (!symset[ROGUESET].name)
if (!symset[ROGUESET].explicitly)
load_symset("RogueIBM", ROGUESET);
switch_symbols(TRUE);
#ifdef TEXTCOLOR
@@ -801,7 +801,7 @@ initoptions_init()
/* [could also check "xterm" which emulates vtXXX by default] */
&& !strncmpi(opts, "vt", 2)
&& AS && AE && index(AS, '\016') && index(AE, '\017')) {
if (!symset[PRIMARY].name)
if (!symset[PRIMARY].explicitly)
load_symset("DECGraphics", PRIMARY);
switch_symbols(TRUE);
}
@@ -810,15 +810,13 @@ initoptions_init()
#if defined(MSDOS) || defined(WIN32)
/* Use IBM defaults. Can be overridden via config file */
if (!symset[PRIMARY].name) {
if (!symset[PRIMARY].explicitly)
load_symset("IBMGraphics_2", PRIMARY);
}
if (!symset[ROGUESET].name) {
if (!symset[ROGUESET].explicitly)
load_symset("RogueEpyx", ROGUESET);
}
#endif
#ifdef MAC_GRAPHICS_ENV
if (!symset[PRIMARY].name)
if (!symset[PRIMARY].explicitly)
load_symset("MACGraphics", PRIMARY);
switch_symbols(TRUE);
#endif /* MAC_GRAPHICS_ENV */
@@ -5368,7 +5366,7 @@ boolean setinitial, setfromfile;
nothing_to_do = FALSE;
char *symset_name, fmtstr[20];
struct symsetentry *sl;
int res, which_set, setcount = 0, chosen = -2;
int res, which_set, setcount = 0, chosen = -2, defindx = 0;
which_set = rogueflag ? ROGUESET : PRIMARY;
symset_list = (struct symsetentry *) 0;
@@ -5451,9 +5449,13 @@ boolean setinitial, setfromfile;
#else
nhUse(big_desc);
#endif
any.a_int = 1;
any.a_int = 1; /* -1 + 2 [see 'if (sl->name) {' below]*/
if (!symset_name)
defindx = any.a_int;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
"Default Symbols", MENU_UNSELECTED);
"Default Symbols",
(any.a_int == defindx) ? MENU_SELECTED
: MENU_UNSELECTED);
for (sl = symset_list; sl; sl = sl->next) {
/* check restrictions */
@@ -5463,20 +5465,34 @@ boolean setinitial, setfromfile;
if (sl->handling == H_MAC)
continue;
#endif
if (sl->name) {
/* +2: sl->idx runs from 0 to N-1 for N symsets;
+1 because Defaults are implicitly in slot [0];
+1 again so that valid data is never 0 */
any.a_int = sl->idx + 2;
if (symset_name && !strcmpi(sl->name, symset_name))
defindx = any.a_int;
Sprintf(buf, fmtstr, sl->name, sl->desc ? sl->desc : "");
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
buf, MENU_UNSELECTED);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf,
(any.a_int == defindx) ? MENU_SELECTED
: MENU_UNSELECTED);
}
}
Sprintf(buf, "Select %ssymbol set:",
rogueflag ? "rogue level " : "");
end_menu(tmpwin, buf);
if (select_menu(tmpwin, PICK_ONE, &symset_pick) > 0) {
chosen = symset_pick->item.a_int - 2;
n = select_menu(tmpwin, PICK_ONE, &symset_pick);
if (n > 0) {
chosen = symset_pick[0].item.a_int;
/* if picking non-preselected entry yields 2, make sure
that we're going with the non-preselected one */
if (n == 2 && chosen == defindx)
chosen = symset_pick[1].item.a_int;
chosen -= 2; /* convert menu index to symset index;
* "Default symbols" have index -1 */
free((genericptr_t) symset_pick);
} else if (n == 0 && defindx > 0) {
chosen = defindx - 2;
}
destroy_nhwindow(tmpwin);