X11 status overhaul

I started out adding a few new status conditions to X11's "fancy status"
(the default) to gauge how difficult it was going to be.  In the process
I found several latent bugs.  After fixing those, I decided that the same
status conditions should be added to the alternate "tty-style status".
Lots more latent bugs, some of the same nature, others different.  Things
spiraled until the code change is very substantial.

Code for the old two-line status is still present but I don't know how
to activate it.  Unlike tty-style status, it composes and displays two
lines of text and isn't capable of highlighting portions of that text,
so it would be considered deprecated anyway.

All testing was done with the default NetHack.ad (except when turning
'fancy_status' off) so I don't know whether the new code might override
previously customizable status settings.  I'm not sure whether this list
covers all the fixes....

both tty-style and fancy
  add new status conditions 'grabbed' (by eel), 'held', 'trapped', and
    'sinking-into-lava' (others will eventually follow); grab and lava
    are on by default, the others have to be enabled via options

both tty-style (not handled) and fancy (faulty boolean logic)
  polymorphing didn't change Xp to HD (silver lining: rehumanizing
    didn't need to reverse it)

tty-style only; fancy was ok
  force white text (on black background) instead of settling for gray
  turning on optional showexp, showscore, and/or time worked but turning
    them back off again didn't remove the relevant fields
  polymorphing when showexp was on didn't suppress Exp-points

tty-style only; fancy uses different layout
  condense conditions into simple left-to-right space separated list
    instead of giving them specific locations and having gaps of blank
    space for conditions that aren't in effect

tty-style only; not applicable for fancy (status_hilites not implemented)
  all highlights stuck if 'statushilites' was reset to 0 to disable them
  displaying anything with bold attribute stuck; it wouldn't revert to
    normal text if a different highlight rule without bold was used for
    subsequent updates
  avoid inverting leading space that separates from preceding field when
    highlighting with inverse video attribute
  add support for 'dim' attribute using gray foreground (only viable
    after the fix for white foreground)

fancy only
  reorganize the field layout so that things line up nicely instead of
    having columns with six, seven, or eight lines be spread over same
    amount of vertical space
  line up the values of the six characteristics, similar to how vertical
    status works in curses: all two digits; when exceptional strength is
    present, the '18' lines up and rest goes past implicit right margin
  use status conditions as provided by core instead of duplicating them
    (other fields still duplicate stuff done in botl.c); doing this
    required forcing 'VIA_WINDOWPORT()' if built without STATUS_HILITES
This commit is contained in:
PatR
2020-03-14 03:47:27 -07:00
parent 55bfc8115a
commit 3cd9d1afd8
4 changed files with 1000 additions and 626 deletions

View File

@@ -126,6 +126,7 @@ msdos: Add -DSTATUES_LOOK_LIKE_MONSTERS to Makefile1.cross so the VESA mode
tty: role and race selection menus weren't filtering out potential choices
which got excluded by OPTIONS=align:!lawful or !neutral or !chaotic
windows: update for new status condition fields
X11: substantial overhaul of status display, both 'fancy' and 'tty-style'
General New Features

View File

@@ -115,10 +115,18 @@ struct mesg_info_t {
};
/*
* Information specific to a "text" status window.
* Information specific to "fancy", "text", or "tty-style" status window.
* (Tty-style supports status highlighting and effectively makes "text"
* obsolete.)
*/
struct status_info_t {
struct text_buffer text; /* Just a text buffer. */
Pixel fg, bg; /* foreground and background */
XFontStruct *fs; /* Status window font structure. */
Dimension spacew; /* width of one space */
Position x, y[3]; /* x coord (not used), y for up to three lines */
Dimension wd, ht; /* width (not used), height (same for all lines) */
Dimension brd, in_wd; /* border width, internal width */
};
/*
@@ -285,11 +293,12 @@ E void (*input_func)();
extern struct window_procs X11_procs;
/* Check for an invalid window id. */
#define check_winid(window) \
if ((window) < 0 || (window) >= MAX_WINDOWS) { \
panic("illegal windid [%d] in %s at line %d", window, __FILE__, \
__LINE__); \
}
#define check_winid(window) \
do { \
if ((window) < 0 || (window) >= MAX_WINDOWS) \
panic("illegal windid [%d] in %s at line %d", \
window, __FILE__, __LINE__); \
} while (0)
/* ### dialogs.c ### */
E Widget
@@ -442,8 +451,10 @@ E void FDECL(X11_number_pad, (int));
E void NDECL(X11_delay_output);
E void NDECL(X11_status_init);
E void NDECL(X11_status_finish);
E void FDECL(X11_status_enablefield, (int, const char *, const char *, BOOLEAN_P));
E void FDECL(X11_status_update, (int, genericptr_t, int, int, int, unsigned long *));
E void FDECL(X11_status_enablefield, (int, const char *, const char *,
BOOLEAN_P));
E void FDECL(X11_status_update, (int, genericptr_t, int, int, int,
unsigned long *));
/* other defs that really should go away (they're tty specific) */
E void NDECL(X11_start_screen);

View File

@@ -98,13 +98,15 @@ static XtSignalId X11_sig_id;
/* Interface definition, for windows.c */
struct window_procs X11_procs = {
"X11",
(WC_COLOR | WC_HILITE_PET | WC_ASCII_MAP | WC_TILED_MAP
| WC_PLAYER_SELECTION | WC_PERM_INVENT | WC_MOUSE_SUPPORT),
#if defined(STATUS_HILITES)
WC2_FLUSH_STATUS | WC2_RESET_STATUS | WC2_HILITE_STATUS |
( WC_COLOR | WC_HILITE_PET | WC_ASCII_MAP | WC_TILED_MAP
| WC_PLAYER_SELECTION | WC_PERM_INVENT | WC_MOUSE_SUPPORT ),
/* status requires VIA_WINDOWPORT(); WC2_FLUSH_STATUS ensures that */
( WC2_FLUSH_STATUS
#ifdef STATUS_HILITES
| WC2_RESET_STATUS | WC2_HILITE_STATUS
#endif
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
| 0L ),
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
X11_init_nhwindows,
X11_player_selection, X11_askname, X11_get_nh_event, X11_exit_nhwindows,
X11_suspend_nhwindows, X11_resume_nhwindows, X11_create_nhwindow,
@@ -300,6 +302,9 @@ struct xwindow *wp;
XtNbright_cyan,
XtNwhite,
};
static const char *wintypenames[NHW_TEXT] = {
"message", "status", "map", "menu", "text"
};
Display *dpy;
Colormap screen_colormap;
XrmDatabase rDB;
@@ -307,13 +312,8 @@ struct xwindow *wp;
Status rc;
int color;
char *ret_type[32];
char clr_name[BUFSZ];
char clrclass[BUFSZ];
const char *wintypenames[NHW_TEXT] = {
"message", "status", "map", "menu", "text"
};
char wtn_up[20], clr_name[BUFSZ], clrclass[BUFSZ];
const char *wtn;
char wtn_up[BUFSZ];
if (wp->nh_colors_inited || !wp->type)
return;
@@ -1414,7 +1414,8 @@ static XtActionsRec actions[] = {
static XtResource resources[] = {
{ nhStr("slow"), nhStr("Slow"), XtRBoolean, sizeof(Boolean),
XtOffset(AppResources *, slow), XtRString, nhStr("True") },
{ nhStr("fancy_status"), nhStr("Fancy_status"), XtRBoolean, sizeof(Boolean),
{ nhStr("fancy_status"), nhStr("Fancy_status"),
XtRBoolean, sizeof(Boolean),
XtOffset(AppResources *, fancy_status), XtRString, nhStr("True") },
{ nhStr("autofocus"), nhStr("AutoFocus"), XtRBoolean, sizeof(Boolean),
XtOffset(AppResources *, autofocus), XtRString, nhStr("False") },
@@ -1469,10 +1470,10 @@ XErrorEvent *error;
{
char buf[BUFSZ];
XGetErrorText(display, error->error_code, buf, BUFSZ);
fprintf(stderr, "X Error: code %i (%s), request %i, minor %i, serial %lu\n",
fprintf(stderr,
"X Error: code %i (%s), request %i, minor %i, serial %lu\n",
error->error_code, buf,
error->request_code, error->minor_code,
error->serial);
error->request_code, error->minor_code, error->serial);
panic("X Error");
return 0;
}
@@ -2289,8 +2290,8 @@ static int
input_event(exit_condition)
int exit_condition;
{
if (appResources.fancy_status && WIN_STATUS != WIN_ERR) /* hilighting on the fancy status window */
check_turn_events();
if (appResources.fancy_status && WIN_STATUS != WIN_ERR)
check_turn_events(); /* hilighting on the fancy status window */
if (WIN_MAP != WIN_ERR) /* make sure cursor is not clipped */
check_cursor_visibility(&window_list[WIN_MAP]);
if (WIN_MESSAGE != WIN_ERR) /* reset pause line */

File diff suppressed because it is too large Load Diff