-/* 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. */
*/
/* 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
/* [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);
}
#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 */
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;
#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 */
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);