Files
nethack/include/botl.h
PatR d989b36763 revamped curses status display
I've overhauled the status display for curses.  Horizontal layout
supports both 2 lines and 3 lines which can be changed dynamically
via using 'O' to set 'statuslines'.  Fields are spread out a little
more than they used to be, making it more readable--at least to me--
but the extra spaces get squeezed out when lines become too long.
If 'showexp' is on and either conditions or hunger+encumbrance go
off the right edge, experience points are suppressed (but the option
is left on, so they'll come back once there is room).

For traditional 2-line hozizontal status, if hunger+encumbrance+
conditions go off the right edge even after experience points are
knocked out, there will be a '+' in the rightmost column if there
are any conditions that are all the way off.  At present it doesn't
use the tty method of switching to abbreviated condition names to
reduce their legnth.  I'll probably tackle that eventually if no one
beats me to it.

For 3-line horizonal status, there was an older implementation (but
disabled via #if 0) with gold and score moving to the third line.
(I'm not sure how status conditions were handled.)  This one ignored
that and modified 2-line from scratch, moving alignment from line one
to line 2 and level description, time, and conditions from line 2 to
line 3.  It looks like this (view with a fixed-width font...).

Wizard the Hatamoto            St:16 Dx:15 Co:18 In:8 Wi:11 Ch:7    S:25
Lawful  $:21  HP:25(25)  Pw:6(6)  AC:4  Xp:2/21  Hungry Burdened
Dlvl:1  T:36                                     Blind Lev

Score is actually right aligned with the edge but I've deleted several
spaces to keep the line shorter here.  The status conditions line up
with the hunger slot as that shifts due to changes in gold/HP/power/AC/
experience, and conditions prefer that column even when hunger and/or
encumbrance are blank.  Howver, if the number of conditions increase to
the point where they would go off the edge, the whole list shifts left
instead of trying to stay lined up with hunger.  (It's just coincidence
that the lefthand parts of lines 2 and 3 seem to line up in this sample.
In general, they don't.)

The vertical layout has reordered most of the fields and now has a few
blank lines to separate those fields into some groups for readability.
Lines have the form of
Field-name  : Value
and when highlights apply, now they only affect the value portion.
Single digit characteristics are padded with a leading space so that
all six of them line up (for "18/xx", "/xx" protrudes to the right).
HP and Pw are aligned with each other.  Hunger and encumbrance share a
line.  When there are more than three conditions, they're shown three
per line instead of wrapping across lines.  And if too many lines are
present, it will squeeze out enough blank ones to fit.

To see the vertical status, you need a display size of at least 106
columns with 'windowborders' explicitly off, or 110 with them on; also
set option 'align_status' to 'right' or 'left'.  (With borders on,
including the default 'auto' setting, the vertical status appears at
width of 108 columns, but does so by hiding 2 columns of the map; using
110 columns avoids that.)  Resizing from outside the game or changing
align_status via 'O' both cause dynamic reconfiguration of the layout;
there's no need to save, make config changes, then restore.
2019-03-23 17:38:23 -07:00

111 lines
3.9 KiB
C

/* NetHack 3.6 botl.h $NHDT-Date: 1553387147 2019/03/24 00:25:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.23 $ */
/* Copyright (c) Michael Allison, 2003 */
/* NetHack may be freely redistributed. See license for details. */
#ifndef BOTL_H
#define BOTL_H
/* MAXCO must hold longest uncompressed status line, and must be larger
* than COLNO
*
* longest practical second status line at the moment is
Astral Plane \GXXXXNNNN:123456 HP:1234(1234) Pw:1234(1234) AC:-127
Xp:30/123456789 T:123456 Stone Slime Strngl FoodPois TermIll
Satiated Overloaded Blind Deaf Stun Conf Hallu Lev Ride
* -- or about 185 characters. '$' gets encoded even when it
* could be used as-is. The first five status conditions are fatal
* so it's rare to have more than one at a time.
*
* When the full line is wider than the map, the basic status line
* formatting will move less important fields to the end, so if/when
* truncation is necessary, it will chop off the least significant
* information.
*/
#if COLNO <= 160
#define MAXCO 200
#else
#define MAXCO (COLNO + 40)
#endif
#ifdef STATUS_HILITES
struct condmap {
const char *id;
unsigned long bitmask;
};
#endif
enum statusfields {
BL_CHARACTERISTICS = -3, /* alias for BL_STR..BL_CH */
BL_RESET = -2, /* Force everything to redisplay */
BL_FLUSH = -1, /* Finished cycling through bot fields */
BL_TITLE = 0,
BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, /* 1..6 */
BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX, /* 7..12 */
BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, /* 13..18 */
BL_HPMAX, BL_LEVELDESC, BL_EXP, BL_CONDITION, /* 19..22 */
MAXBLSTATS /* [23] */
};
enum relationships { NO_LTEQGT = -1,
EQ_VALUE, LT_VALUE, LE_VALUE,
GE_VALUE, GT_VALUE, TXT_VALUE };
#define BEFORE 0
#define NOW 1
/* Boolean condition bits for the condition mask */
/* clang-format off */
#define BL_MASK_STONE 0x00000001L
#define BL_MASK_SLIME 0x00000002L
#define BL_MASK_STRNGL 0x00000004L
#define BL_MASK_FOODPOIS 0x00000008L
#define BL_MASK_TERMILL 0x00000010L
#define BL_MASK_BLIND 0x00000020L
#define BL_MASK_DEAF 0x00000040L
#define BL_MASK_STUN 0x00000080L
#define BL_MASK_CONF 0x00000100L
#define BL_MASK_HALLU 0x00000200L
#define BL_MASK_LEV 0x00000400L
#define BL_MASK_FLY 0x00000800L
#define BL_MASK_RIDE 0x00001000L
#define BL_MASK_BITS 13 /* number of mask bits that can be set */
/* clang-format on */
#define REASSESS_ONLY TRUE
/* #ifdef STATUS_HILITES */
/* hilite status field behavior - coloridx values */
#define BL_HILITE_NONE -1 /* no hilite of this field */
#define BL_HILITE_INVERSE -2 /* inverse hilite */
#define BL_HILITE_BOLD -3 /* bold hilite */
/* or any CLR_ index (0 - 15) */
#define BL_TH_NONE 0
#define BL_TH_VAL_PERCENTAGE 100 /* threshold is percentage */
#define BL_TH_VAL_ABSOLUTE 101 /* threshold is particular value */
#define BL_TH_UPDOWN 102 /* threshold is up or down change */
#define BL_TH_CONDITION 103 /* threshold is bitmask of conditions */
#define BL_TH_TEXTMATCH 104 /* threshold text value to match against */
#define BL_TH_ALWAYS_HILITE 105 /* highlight regardless of value */
#define HL_ATTCLR_DIM CLR_MAX + 0
#define HL_ATTCLR_BLINK CLR_MAX + 1
#define HL_ATTCLR_ULINE CLR_MAX + 2
#define HL_ATTCLR_INVERSE CLR_MAX + 3
#define HL_ATTCLR_BOLD CLR_MAX + 4
#define BL_ATTCLR_MAX CLR_MAX + 5
enum hlattribs { HL_UNDEF = 0x00,
HL_NONE = 0x01,
HL_BOLD = 0x02,
HL_INVERSE = 0x04,
HL_ULINE = 0x08,
HL_BLINK = 0x10,
HL_DIM = 0x20 };
/* #endif STATUS_HILITES */
extern const char *status_fieldnames[]; /* in botl.c */
#endif /* BOTL_H */