symbol set reorganization

Change the way symbol sets are loaded to make them have the same order
as they appear in the symbols file rather than being reversed.

Revise dat/symbols so that the new ordering yields a result similar
to the old ordering, more or less.  I've added a few set descriptions.
The only substantive change is marking DECgraphics as primary-only
(not available on rogue level) and adding new set DECgraphics_2 which
is commented out near the end.

Define symbol handling H_MAC since one of the sets specifies
'handling: MAC'.  All H_MAC is used for now is to avoid showing
MACgraphics as a symset when compiled without MAC_GRAPHICS_ENV (which
was used for pre-OSX Mac by the old code in sys/mac/), so it will be
hidden for everyone.

I left handling H_CURS even though curses doesn't implement anything
for it.  It could do something when rendering the map or assign a
function to 'cursesgraphics_mode_callback' for special init or both
but hasn't needed to.  Since curses is now supporting DECgraphics,
define 'decgraphics_mode_callback' for it.  No value is being
assigned so that doesn't do anything; curses seems to be setting up
the primary character set as text and secondary one as line-drawing
without the need for that hook.

With the added set descriptions, 'O's symset menu looked horrible for
curses due to the way curses decides to set the width of menus and
the resulting line wrapping which took place because of a too-narrow
menu.  I've added a chunk of code to the options handling code which
shouldn't really be there but makes the menu much easier to read.

Lastly, do some formatting cleanup in files.c.
This commit is contained in:
PatR
2019-10-17 05:00:58 -07:00
parent 33d33fcf19
commit 3e368b9a51
6 changed files with 474 additions and 364 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 drawing.c $NHDT-Date: 1546656404 2019/01/05 02:46:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.59 $ */
/* NetHack 3.6 drawing.c $NHDT-Date: 1571313651 2019/10/17 12:00:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.61 $ */
/* Copyright (c) NetHack Development Team 1992. */
/* NetHack may be freely redistributed. See license for details. */
@@ -255,9 +255,9 @@ static const uchar def_r_oc_syms[MAXOCLASSES] = {
#undef C
#ifdef TERMLIB
#if defined(TERMLIB) || defined(CURSES_GRAPHICS)
void NDECL((*decgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
#endif /* TERMLIB */
#endif /* TERMLIB || CURSES */
#ifdef PC9800
void NDECL((*ibmgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
@@ -496,17 +496,22 @@ int nondefault;
#ifdef PC9800
if (SYMHANDLING(H_IBM) && ibmgraphics_mode_callback)
(*ibmgraphics_mode_callback)();
else if (!symset[currentgraphics].name && ascgraphics_mode_callback)
else if (SYMHANDLING(H_UNK) && ascgraphics_mode_callback)
(*ascgraphics_mode_callback)();
#endif
#ifdef TERMLIB
#if defined(TERMLIB) || defined(CURSES_GRAPHICS)
/* curses doesn't assign any routine to dec..._callback but
probably does the expected initialization under the hood
for terminals capable of rendering DECgraphics */
if (SYMHANDLING(H_DEC) && decgraphics_mode_callback)
(*decgraphics_mode_callback)();
#endif
# ifdef CURSES_GRAPHICS
/* there aren't any symbol sets with CURS handling, and the
curses interface never assigns a routine to curses..._callback */
if (SYMHANDLING(H_CURS) && cursesgraphics_mode_callback)
(*cursesgraphics_mode_callback)();
# endif
#endif
} else {
init_l_symbols();
init_showsyms();
@@ -563,6 +568,7 @@ const char *known_handling[] = {
"IBM", /* H_IBM */
"DEC", /* H_DEC */
"CURS", /* H_CURS */
"MAC", /* H_MAC -- pre-OSX MACgraphics */
(const char *) 0,
};

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1562719337 2019/07/10 00:42:17 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.252 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1571313652 2019/10/17 12:00:52 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.253 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2111,7 +2111,7 @@ const char *name; /* name of option for error message */
break;
default:
gi_error:
gi_error:
raw_printf("Syntax error in %s", name);
wait_synch();
return count;
@@ -3063,9 +3063,10 @@ boolean FDECL((*proc), (char *));
}
ep = inbuf;
while (*ep == ' ' || *ep == '\t') ep++;
while (*ep == ' ' || *ep == '\t')
++ep;
/* lines beginning with '#' are comments. ignore empty lines. */
/* ingore empty lines and full-line comment lines */
if (!*ep || *ep == '#')
ignoreline = TRUE;
@@ -3074,9 +3075,9 @@ boolean FDECL((*proc), (char *));
/* merge now read line with previous ones, if necessary */
if (!ignoreline) {
len = strlen(inbuf) + 1;
len = (int) strlen(inbuf) + 1;
if (buf)
len += strlen(buf);
len += (int) strlen(buf);
tmpbuf = (char *) alloc(len);
if (buf) {
Sprintf(tmpbuf, "%s %s", buf, inbuf);
@@ -3100,6 +3101,7 @@ boolean FDECL((*proc), (char *));
if (match_varname(buf, "CHOOSE", 6)) {
char *section;
char *bufp = find_optparam(buf);
if (!bufp) {
config_error_add(
"Format is CHOOSE=section1,section2,...");
@@ -3259,13 +3261,19 @@ int which_set;
building a pick-list of possible symset
values from the file, so only do that */
if (symp->range == SYM_CONTROL) {
struct symsetentry *tmpsp;
struct symsetentry *tmpsp, *lastsp;
for (lastsp = symset_list; lastsp; lastsp = lastsp->next)
if (!lastsp->next)
break;
switch (symp->idx) {
case 0:
tmpsp = (struct symsetentry *) alloc(sizeof *tmpsp);
tmpsp->next = symset_list;
symset_list = tmpsp;
tmpsp->next = (struct symsetentry *) 0;
if (!lastsp)
symset_list = tmpsp;
else
lastsp->next = tmpsp;
tmpsp->idx = symset_count++;
tmpsp->name = dupstr(bufp);
tmpsp->desc = (char *) 0;
@@ -3277,21 +3285,22 @@ int which_set;
break;
case 2:
/* handler type identified */
tmpsp = symset_list; /* most recent symset */
tmpsp = lastsp; /* most recent symset */
for (i = 0; known_handling[i]; ++i)
if (!strcmpi(known_handling[i], bufp)) {
tmpsp->handling = i;
break; /* for loop */
}
break;
case 3: /* description:something */
tmpsp = symset_list; /* most recent symset */
case 3:
/* description:something */
tmpsp = lastsp; /* most recent symset */
if (tmpsp && !tmpsp->desc)
tmpsp->desc = dupstr(bufp);
break;
case 5:
/* restrictions: xxxx*/
tmpsp = symset_list; /* most recent symset */
tmpsp = lastsp; /* most recent symset */
for (i = 0; known_restrictions[i]; ++i) {
if (!strcmpi(known_restrictions[i], bufp)) {
switch (i) {
@@ -4103,7 +4112,7 @@ unsigned oid; /* book identifier */
}
}
cleanup:
cleanup:
(void) dlb_fclose(fp);
if (nowin_buf) {
/* one-line buffer */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1571045295 2019/10/14 09:28:15 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.376 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1571313653 2019/10/17 12:00:53 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.378 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -5336,8 +5336,8 @@ boolean setinitial, setfromfile;
MENU_UNSELECTED);
for (i = 0; i < numapes && ape; i++) {
any.a_void = (opt_idx == 1) ? 0 : ape;
/* length of pattern plus quotes (plus '<'/'>') is less than
BUFSZ */
/* length of pattern plus quotes (plus '<'/'>') is
less than BUFSZ */
Sprintf(apebuf, "\"%c%s\"", ape->grab ? '<' : '>',
ape->pattern);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, apebuf,
@@ -5383,18 +5383,27 @@ boolean setinitial, setfromfile;
symset[which_set].name = symset_name;
if (res && symset_list) {
int thissize, biggest = 0;
int thissize,
biggest = (int) (sizeof "Default Symbols" - sizeof ""),
big_desc = 0;
for (sl = symset_list; sl; sl = sl->next) {
/* check restrictions */
if (rogueflag ? sl->primary : sl->rogue)
continue;
#ifndef MAC_GRAPHICS_ENV
if (sl->handling == H_MAC)
continue;
#endif
setcount++;
/* find biggest name */
thissize = sl->name ? (int) strlen(sl->name) : 0;
if (thissize > biggest)
biggest = thissize;
thissize = sl->desc ? (int) strlen(sl->desc) : 0;
if (thissize > big_desc)
big_desc = thissize;
}
if (!setcount) {
pline("There are no appropriate %s symbol sets available.",
@@ -5402,10 +5411,48 @@ boolean setinitial, setfromfile;
return TRUE;
}
Sprintf(fmtstr, "%%-%ds %%s", biggest + 5);
Sprintf(fmtstr, "%%-%ds %%s", biggest + 2);
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any = zeroany;
#ifdef CURSES_GRAPHICS /* this ought to be handled within curses... */
/*
* Symbol sets are formatted in two columns, "name description",
* on selectable lines. curses bases menu width on the length
* of non-selectable lines (main header, separators if present,
* with trailing spaces ignored) and defaults to half the map.
* Without something like this separator (shown after the menu
* title and a blank line which follows that) to force a wider
* menu, entries with long descriptions wrap. That would be
* ok if wrapping operated on the same two columns, but the
* menu doesn't know anything about those and the description
* is wrapping into the next line's name column, making long
* descriptions--and menus containing them--hard to read.
*/
if (WINDOWPORT("curses")) {
char tmp1[BUFSZ], tmp2[BUFSZ], bigbuf[BUFSZ + 1 + BUFSZ];
/* 4: room for space+letter+paren+space, fake selector;
2: added to 'biggest' when constructing 'fmtstr';
1: space between symset name+2 and symset description */
if (4 + biggest + 2 + 1 > (int) sizeof tmp1 - 1)
biggest = (int) sizeof tmp1 - 1 - (4 + 2 + 1);
(void) memset((genericptr_t) tmp1, '-', biggest);
tmp1[biggest] = '\0';
if (big_desc > (int) sizeof tmp2 - 1)
big_desc = (int) sizeof tmp2 - 1;
(void) memset((genericptr_t) tmp2, '-', big_desc);
tmp2[big_desc] = '\0';
Sprintf(bigbuf, "%4s", "");
Sprintf(eos(bigbuf), fmtstr, tmp1, tmp2);
bigbuf[BUFSZ - 1] = '\0';
any.a_int = 0;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
bigbuf, MENU_UNSELECTED);
}
#else
nhUse(big_desc);
#endif
any.a_int = 1;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
"Default Symbols", MENU_UNSELECTED);
@@ -5414,6 +5461,10 @@ boolean setinitial, setfromfile;
/* check restrictions */
if (rogueflag ? sl->primary : sl->rogue)
continue;
#ifndef MAC_GRAPHICS_ENV
if (sl->handling == H_MAC)
continue;
#endif
if (sl->name) {
any.a_int = sl->idx + 2;