curses options and status groundwork
More groundwork for overhauling the status display for curses, plus
a few functional changes. It was doing a full status update for
every changed field (except conditions), instead of waiting for a
flush directive after gathering multiple changes at a time. Since
it already does gather every change, the fix to wait is trivial.
This decouples 'hitpointbar' from 'statushilites'. When highlighting
is off, it uses inverse video only. When on, it behaves as before:
using inverse video plus the most recent color used to highlight HP
(which can vary if that has rules to highlight changes or percentage
thresholds) but ignoring any HP attribute(s). This also enables the
latent 'statuslines' option and changes 'windowborders' option from
being settable at startup only to changeable during play.
'statuslines' can have a value of 2 (the default) or 3 and applies to
'align_status:bottom' or 'top'; it's ignored for 'left' and 'right'.
At the moment, setting it to 3 only allows status condition overflow
to wrap from the end of line to 2 to the beginning of line 3, and if
window borders are drawn they'll clobber the last character on line 2
and first one on line 3. There's no point in trying to fix that
because it will go away when the main status overhaul changes go in.
Condition wrapping for vertical orientation (left or right placement)
was already subject to the same phenomenon and will be superseded too.
This also changes the meaning of the 'windowborders' value so could
impact players using source from git (or possibly beta binaries for
Windows, but not for OSX where curses interface wasn't included).
Old:
0 = unspecified, 1 = On, 2 = Off, 3 = Auto (On if display is big
enough, Off otherwise; reevaluated after dynamic resizing);
Unspecified got changed to 3 during curses windowing initialization.
New:
0 = Off, 1 = On, 2 = Auto;
0 gets changed to 2 for default value at start of options processing.
So old value of 2 is changing meaning and explicit old value of 3 is
becoming invalid. Implicit 3 changes to default 2. Explicit 3 could
be the subject of a fixup but there isn't much point since 2 can't
have a similar fix. Users who are using old 2 or explicit 3 will need
to update their run-time config files.
This adds 'statuslines' to the Guidebook and moves some other recently
added documentation of curses options from among the general options
(section 9.4) to "Window Port Customization options" (section 9.5).
None of them have been added to dat/opthelp which seems to be missing
all the wincap options.
Originally I made a lot of changes (mostly moving C99 declarations to
start of their blocks) to the old '#if 0' code at end of cursstat.c,
but have tossed those, except for one subtle bug that assumed 'int'
and 'long' are the same size.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1552521022 2019/03/13 23:50:22 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.357 $ */
|
||||
/* NetHack 3.6 options.c $NHDT-Date: 1553204012 2019/03/21 21:33:32 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.358 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2008. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -394,10 +394,10 @@ static struct Comp_Opt {
|
||||
#endif
|
||||
#ifdef CURSES_GRAPHICS
|
||||
{ "statuslines",
|
||||
"0,1,2 = classic behavior, 3 = alternative behavior",
|
||||
20, DISP_IN_GAME },
|
||||
"2 or 3 lines for horizonal (bottom or top) status display",
|
||||
20, SET_IN_GAME }, /*WC2*/
|
||||
#else
|
||||
{ "statuslines", "# of status lines", 20, SET_IN_FILE },
|
||||
{ "statuslines", "2 or 3 lines for status display", 20, SET_IN_FILE },
|
||||
#endif
|
||||
{ "symset", "load a set of display symbols from the symbols file", 70,
|
||||
SET_IN_GAME },
|
||||
@@ -433,7 +433,7 @@ static struct Comp_Opt {
|
||||
{ "whatis_filter",
|
||||
"filter coordinate locations when targeting next or previous",
|
||||
1, SET_IN_GAME },
|
||||
{ "windowborders", "1 (on), 2 (off), 3 (auto)", 9, DISP_IN_GAME }, /*WC2*/
|
||||
{ "windowborders", "0 (off), 1 (on), 2 (auto)", 9, SET_IN_GAME }, /*WC2*/
|
||||
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
|
||||
80, DISP_IN_GAME },
|
||||
{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
|
||||
@@ -817,6 +817,12 @@ initoptions_init()
|
||||
#endif /* MAC_GRAPHICS_ENV */
|
||||
flags.menu_style = MENU_FULL;
|
||||
|
||||
iflags.wc_align_message = ALIGN_TOP;
|
||||
iflags.wc_align_status = ALIGN_BOTTOM;
|
||||
/* these are currently only used by curses */
|
||||
iflags.wc2_statuslines = 2;
|
||||
iflags.wc2_windowborders = 2; /* 'Auto' */
|
||||
|
||||
/* since this is done before init_objects(), do partial init here */
|
||||
objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD;
|
||||
nmcpy(pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ);
|
||||
@@ -1370,7 +1376,8 @@ static const struct {
|
||||
{ "inverse", ATR_INVERSE },
|
||||
{ NULL, ATR_NONE }, /* everything after this is an alias */
|
||||
{ "normal", ATR_NONE },
|
||||
{ "uline", ATR_ULINE }
|
||||
{ "uline", ATR_ULINE },
|
||||
{ "reverse", ATR_INVERSE },
|
||||
};
|
||||
|
||||
const char *
|
||||
@@ -3676,14 +3683,15 @@ boolean tinitial, tfrom_file;
|
||||
int itmp;
|
||||
|
||||
if (negated)
|
||||
itmp = 2; /* Off */
|
||||
itmp = 0; /* Off */
|
||||
else if (!op)
|
||||
itmp = 1; /* On */
|
||||
else /* Value supplied; expect 1 (on), 2 (off), or 3 (auto) */
|
||||
else /* Value supplied; expect 0 (off), 1 (on), or 2 (auto) */
|
||||
itmp = atoi(op);
|
||||
|
||||
if (itmp < 1 || itmp > 3) {
|
||||
config_error_add("Invalid %s: %s.", fullname, opts);
|
||||
if (itmp < 0 || itmp > 2) {
|
||||
config_error_add("Invalid %s (should be 0, 1, or 2): %s",
|
||||
fullname, opts);
|
||||
retval = FALSE;
|
||||
} else {
|
||||
iflags.wc2_windowborders = itmp;
|
||||
@@ -3691,6 +3699,31 @@ boolean tinitial, tfrom_file;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* WINCAP2
|
||||
* statuslines:n */
|
||||
fullname = "statuslines";
|
||||
if (match_optname(opts, fullname, 11, TRUE)) {
|
||||
int itmp = 0;
|
||||
|
||||
op = string_for_opt(opts, negated);
|
||||
if (negated) {
|
||||
bad_negation(fullname, TRUE);
|
||||
itmp = 2;
|
||||
retval = FALSE;
|
||||
} else if (op) {
|
||||
itmp = atoi(op);
|
||||
}
|
||||
if (itmp < 2 || itmp > 3) {
|
||||
config_error_add("'%s' requires a value of 2 and 3", fullname);
|
||||
retval = FALSE;
|
||||
} else {
|
||||
iflags.wc2_statuslines = itmp;
|
||||
if (!initial)
|
||||
need_redraw = TRUE;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
#endif /* CURSES_GRAPHICS */
|
||||
|
||||
/* menustyle:traditional or combination or full or partial */
|
||||
@@ -5424,29 +5457,17 @@ char *buf;
|
||||
int i;
|
||||
|
||||
buf[0] = '\0';
|
||||
if (!strcmp(optname, "align_message"))
|
||||
if (!strcmp(optname, "align_message")
|
||||
|| !strcmp(optname, "align_status")) {
|
||||
int which = !strcmp(optname, "align_status") ? iflags.wc_align_status
|
||||
: iflags.wc_align_message;
|
||||
Sprintf(buf, "%s",
|
||||
iflags.wc_align_message == ALIGN_TOP
|
||||
? "top"
|
||||
: iflags.wc_align_message == ALIGN_LEFT
|
||||
? "left"
|
||||
: iflags.wc_align_message == ALIGN_BOTTOM
|
||||
? "bottom"
|
||||
: iflags.wc_align_message == ALIGN_RIGHT
|
||||
? "right"
|
||||
: defopt);
|
||||
else if (!strcmp(optname, "align_status"))
|
||||
Sprintf(buf, "%s",
|
||||
iflags.wc_align_status == ALIGN_TOP
|
||||
? "top"
|
||||
: iflags.wc_align_status == ALIGN_LEFT
|
||||
? "left"
|
||||
: iflags.wc_align_status == ALIGN_BOTTOM
|
||||
? "bottom"
|
||||
: iflags.wc_align_status == ALIGN_RIGHT
|
||||
? "right"
|
||||
: defopt);
|
||||
else if (!strcmp(optname, "align"))
|
||||
(which == ALIGN_TOP) ? "top"
|
||||
: (which == ALIGN_LEFT) ? "left"
|
||||
: (which == ALIGN_BOTTOM) ? "bottom"
|
||||
: (which == ALIGN_RIGHT) ? "right"
|
||||
: defopt);
|
||||
} else if (!strcmp(optname, "align"))
|
||||
Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj));
|
||||
#ifdef WIN32
|
||||
else if (!strcmp(optname, "altkeyhandler"))
|
||||
@@ -5707,6 +5728,9 @@ char *buf;
|
||||
Sprintf(buf, "%ld (on: highlight status for %ld turns)",
|
||||
iflags.hilite_delta, iflags.hilite_delta);
|
||||
#endif
|
||||
} else if (!strcmp(optname,"statuslines")) {
|
||||
Strcpy(buf, (WINDOWPORT("curses")
|
||||
&& iflags.wc2_statuslines < 3) ? "2" : "3");
|
||||
} else if (!strcmp(optname, "suppress_alert")) {
|
||||
if (flags.suppress_alert == 0L)
|
||||
Strcpy(buf, none);
|
||||
@@ -5764,14 +5788,12 @@ char *buf;
|
||||
ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
|
||||
ttycolors[CLR_BRIGHT_MAGENTA], ttycolors[CLR_BRIGHT_CYAN]);
|
||||
#endif /* VIDEOSHADES */
|
||||
#ifdef CURSES_GRAPHICS
|
||||
} else if (!strcmp(optname,"windowborders")) {
|
||||
Sprintf(buf, "%s",
|
||||
(iflags.wc2_windowborders == 1) ? "1=on"
|
||||
: (iflags.wc2_windowborders == 2) ? "2=off"
|
||||
: (iflags.wc2_windowborders == 3) ? "3=auto"
|
||||
(iflags.wc2_windowborders == 0) ? "0=off"
|
||||
: (iflags.wc2_windowborders == 1) ? "1=on"
|
||||
: (iflags.wc2_windowborders == 2) ? "2=auto"
|
||||
: defopt);
|
||||
#endif
|
||||
} else if (!strcmp(optname, "windowtype")) {
|
||||
Sprintf(buf, "%s", windowprocs.name);
|
||||
} else if (!strcmp(optname, "windowcolors")) {
|
||||
@@ -6479,6 +6501,7 @@ static struct wc_Opt wc2_options[] = {
|
||||
{ "term_rows", WC2_TERM_SIZE },
|
||||
{ "petattr", WC2_PETATTR },
|
||||
{ "guicolor", WC2_GUICOLOR },
|
||||
{ "statuslines", WC2_STATUSLINES },
|
||||
{ "windowborders", WC2_WINDOWBORDERS },
|
||||
{ (char *) 0, 0L }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user