status line update

Adding deafness to the status line spurred me on to something I've
wanted to do for a long time.  This adds 'Stone' and 'Strngl' as
new status conditions, and moves the five fatal ones: "Stone Slime
Strngl FoodPois TermIll" to the front of the status list since
information about them is more important than any of the others.
"Ill" has been renamed "TermIll"; "Df" has been renamed "Deaf";
"Lev", "Fly", and "Ride" are three additional new conditions, with
Lev and Fly being mutually exclusive.  After the fatal ones, the
order of the rest is now
<hunger> <encumbrance> Blind Deaf Stun Conf Hallu Lev Fly Ride

To handle the longer potential status line, the basic bot2() is now
smarter.  If the line is wider than the map, 'T:moves' is moved from
the middle to the end.  If the line without time is still wider than
the map, then experience (HD if polyd, Xp:M/nnnnnn is showexp is on,
or Exp:M) is moved in front of time at the end.  If the line without
experience and time is still wider than the map, dungeon level plus
gold is moved from the beginning to be in front of experience.  The
fields are just reordered, not truncated, so if the interface code
can display lines wider than the map they'll retain the extra info.
The gist is than health and associated fields (Hp, Pw, Ac) get first
priority, status conditions get second priority, then the rest.  In
the usual case where there aren't many conditions, status display is
the same as it has been in the past.

STATUS_VIA_WINDOWPORT has been updated too, and it builds for tty
and X11.  But the bot2() revision to reorder sections has not been
implemented for that.

win/win32/mswproc.c has been updated but not tested.

STATUS_VIA_WINDOWPORT without STATUS_HILITES had several compile
problems; now fixed for core and tty.  STATUS_VIA_WINDOWPORT with
STATUS_HILITES has not been tested.
This commit is contained in:
PatR
2016-01-13 19:13:10 -08:00
parent 5acb659076
commit fa20ef382d
11 changed files with 421 additions and 288 deletions

View File

@@ -3387,17 +3387,23 @@ tty_status_init()
* -- ptr is usually a "char *", unless fldindex is BL_CONDITION.
* If fldindex is BL_CONDITION, then ptr is a long value with
* any or none of the following bits set (from botl.h):
* BL_MASK_BLIND 0x00000001L
* BL_MASK_CONF 0x00000002L
* BL_MASK_FOODPOIS 0x00000004L
* BL_MASK_ILL 0x00000008L
* BL_MASK_HALLU 0x00000010L
* BL_MASK_STUNNED 0x00000020L
* BL_MASK_SLIMED 0x00000040L
* -- The value passed for BL_GOLD includes a leading
* symbol for GOLD "$:nnn". If the window port needs to use
* the textual gold amount without the leading "$:" the port
* will have to add 2 to the passed "ptr" for the BL_GOLD case.
* BL_MASK_STONE 0x00000001L
* BL_MASK_SLIME 0x00000002L
* BL_MASK_STRNGL 0x00000004L
* BL_MASK_FOODPOIS 0x00000008L
* BL_MASK_TERMILL 0x00000010L
* BL_MASK_BLIND 0x00000020L
* BL_MASK_DEAF 0x00000040L
* BL_MASK_STUN 0x00000080L
* BL_MASK_CONF 0x00000100L
* BL_MASK_HALLU 0x00000200L
* BL_MASK_LEV 0x00000400L
* BL_MASK_FLY 0x00000800L
* BL_MASK_RIDE 0x00001000L
* -- The value passed for BL_GOLD includes an encoded leading
* symbol for GOLD "\GXXXXNNNN:nnn". If the window port needs to use
* the textual gold amount without the leading "$:" the port will
* have to skip past ':' in the passed "ptr" for the BL_GOLD case.
*/
void
tty_status_update(fldidx, ptr, chg, percent)
@@ -3412,8 +3418,6 @@ genericptr_t ptr;
* BL_HILITE_INVERSE -2 + 3 = 1 (statusattr[1])
* BL_HILITE_BOLD -3 + 3 = 0 (statusattr[0])
*/
int statusattr[] = { ATR_BOLD, ATR_INVERSE, ATR_NONE };
int attridx = 0;
long value = -1L;
static boolean beenhere = FALSE;
enum statusfields fieldorder[2][15] = {
@@ -3424,6 +3428,13 @@ genericptr_t ptr;
BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
BL_CAP, BL_CONDITION, BL_FLUSH }
};
#ifdef STATUS_HILITES
static int statusattr[] = { ATR_BOLD, ATR_INVERSE, ATR_NONE };
int attridx = 0;
#else
nhUse(chg);
nhUse(percent);
#endif
if (fldidx != BL_FLUSH) {
if (!status_activefields[fldidx])
@@ -3432,20 +3443,32 @@ genericptr_t ptr;
case BL_CONDITION:
cond = *condptr;
*status_vals[fldidx] = '\0';
if (cond & BL_MASK_BLIND)
Strcat(status_vals[fldidx], " Blind");
if (cond & BL_MASK_CONF)
Strcat(status_vals[fldidx], " Conf");
if (cond & BL_MASK_STONE)
Strcat(status_vals[fldidx], " Stone");
if (cond & BL_MASK_SLIME)
Strcat(status_vals[fldidx], " Slime");
if (cond & BL_MASK_STRNGL)
Strcat(status_vals[fldidx], " Strngl");
if (cond & BL_MASK_FOODPOIS)
Strcat(status_vals[fldidx], " FoodPois");
if (cond & BL_MASK_ILL)
Strcat(status_vals[fldidx], " Ill");
if (cond & BL_MASK_STUNNED)
if (cond & BL_MASK_TERMILL)
Strcat(status_vals[fldidx], " TermIll");
if (cond & BL_MASK_BLIND)
Strcat(status_vals[fldidx], " Blind");
if (cond & BL_MASK_DEAF)
Strcat(status_vals[fldidx], " Deaf");
if (cond & BL_MASK_STUN)
Strcat(status_vals[fldidx], " Stun");
if (cond & BL_MASK_CONF)
Strcat(status_vals[fldidx], " Conf");
if (cond & BL_MASK_HALLU)
Strcat(status_vals[fldidx], " Hallu");
if (cond & BL_MASK_SLIMED)
Strcat(status_vals[fldidx], " Slime");
if (cond & BL_MASK_LEV)
Strcat(status_vals[fldidx], " Lev");
if (cond & BL_MASK_FLY)
Strcat(status_vals[fldidx], " Fly");
if (cond & BL_MASK_RIDE)
Strcat(status_vals[fldidx], " Ride");
value = cond;
break;
default:
@@ -3554,23 +3577,26 @@ genericptr_t ptr;
int fldidx1 = fieldorder[0][i];
if (status_activefields[fldidx1]) {
if (tty_status_colors[fldidx1] < 0 &&
tty_status_colors[fldidx1] >= -3) {
#ifdef STATUS_HILITES
if (tty_status_colors[fldidx1] < 0
&& tty_status_colors[fldidx1] >= -3) {
/* attribute, not a color */
attridx = tty_status_colors[fldidx1] + 3;
term_start_attr(statusattr[attridx]);
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
term_end_attr(statusattr[attridx]);
} else
#ifdef TEXTCOLOR
} else if (tty_status_colors[fldidx1] != CLR_MAX) {
if (tty_status_colors[fldidx1] != CLR_MAX) {
if (tty_status_colors[fldidx1] != NO_COLOR)
term_start_color(tty_status_colors[fldidx1]);
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
if (tty_status_colors[fldidx1] != NO_COLOR)
term_end_color();
#endif
} else
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
#endif
#endif /* STATUS_HILITES */
putstr(WIN_STATUS, 0, status_vals[fldidx1]);
}
}
curs(WIN_STATUS, 1, 1);
@@ -3578,28 +3604,31 @@ genericptr_t ptr;
int fldidx2 = fieldorder[1][i];
if (status_activefields[fldidx2]) {
if (tty_status_colors[fldidx2] < 0 &&
tty_status_colors[fldidx2] >= -3) {
#ifdef STATUS_HILITES
if (tty_status_colors[fldidx2] < 0
&& tty_status_colors[fldidx2] >= -3) {
/* attribute, not a color */
attridx = tty_status_colors[fldidx2] + 3;
term_start_attr(statusattr[attridx]);
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
term_end_attr(statusattr[attridx]);
} else
#ifdef TEXTCOLOR
} else if (tty_status_colors[fldidx2] != CLR_MAX) {
if (tty_status_colors[fldidx2] != CLR_MAX) {
if (tty_status_colors[fldidx2] != NO_COLOR)
term_start_color(tty_status_colors[fldidx2]);
if (fldidx2 == BL_GOLD) {
/* putmixed() due to GOLD glyph */
putmixed(WIN_STATUS, 0, status_vals[fldidx2]);
putmixed(WIN_STATUS, 0, status_vals[fldidx2]);
} else {
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
}
if (tty_status_colors[fldidx2] != NO_COLOR)
term_end_color();
#endif
} else
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
#endif
#endif /* STATUS_HILITES */
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
}
}
return;

View File

@@ -2819,18 +2819,23 @@ status_update(int fldindex, genericptr_t ptr, int chg, int percentage)
-- ptr is usually a "char *", unless fldindex is BL_CONDITION.
If fldindex is BL_CONDITION, then ptr is a long value with
any or none of the following bits set (from botl.h):
BL_MASK_BLIND 0x00000001L
BL_MASK_CONF 0x00000002L
BL_MASK_FOODPOIS 0x00000004L
BL_MASK_ILL 0x00000008L
BL_MASK_HALLU 0x00000010L
BL_MASK_STUNNED 0x00000020L
BL_MASK_SLIMED 0x00000040L
-- The value passed for BL_GOLD includes a leading
symbol for GOLD "$:nnn". If the window port needs to use
the textual gold amount without the leading "$:" the port
will have to add 2 to the passed "ptr" for the BL_GOLD
case.
BL_MASK_STONE 0x00000001L
BL_MASK_SLIME 0x00000002L
BL_MASK_STRNGL 0x00000004L
BL_MASK_FOODPOIS 0x00000008L
BL_MASK_TERMILL 0x00000010L
BL_MASK_BLIND 0x00000020L
BL_MASK_DEAF 0x00000040L
BL_MASK_STUN 0x00000080L
BL_MASK_CONF 0x00000100L
BL_MASK_HALLU 0x00000200L
BL_MASK_LEV 0x00000400L
BL_MASK_FLY 0x00000800L
BL_MASK_RIDE 0x00001000L
-- The value passed for BL_GOLD includes an encoded leading
symbol for GOLD "\GXXXXNNNN:nnn". If window port needs
textual gold amount without the leading "$:" the port will
have to skip past ':' in passed "ptr" for the BL_GOLD case.
*/
void
mswin_status_update(int idx, genericptr_t ptr, int chg, int percent)
@@ -2851,20 +2856,32 @@ mswin_status_update(int idx, genericptr_t ptr, int chg, int percent)
case BL_CONDITION: {
cond = *condptr;
*_status_vals[idx] = '\0';
if (cond & BL_MASK_BLIND)
Strcat(_status_vals[idx], " Blind");
if (cond & BL_MASK_CONF)
Strcat(_status_vals[idx], " Conf");
if (cond & BL_MASK_STONE)
Strcat(_status_vals[idx], " Stone");
if (cond & BL_MASK_SLIME)
Strcat(_status_vals[idx], " Slime");
if (cond & BL_MASK_STRNGL)
Strcat(_status_vals[idx], " Strngl");
if (cond & BL_MASK_FOODPOIS)
Strcat(_status_vals[idx], " FoodPois");
if (cond & BL_MASK_ILL)
Strcat(_status_vals[idx], " Ill");
if (cond & BL_MASK_STUNNED)
if (cond & BL_MASK_TERMILL)
Strcat(_status_vals[idx], " TermIll");
if (cond & BL_MASK_BLIND)
Strcat(_status_vals[idx], " Blind");
if (cond & BL_MASK_DEAF)
Strcat(_status_vals[idx], " Deaf");
if (cond & BL_MASK_STUN)
Strcat(_status_vals[idx], " Stun");
if (cond & BL_MASK_CONF)
Strcat(_status_vals[idx], " Conf");
if (cond & BL_MASK_HALLU)
Strcat(_status_vals[idx], " Hallu");
if (cond & BL_MASK_SLIMED)
Strcat(_status_vals[idx], " Slime");
if (cond & BL_MASK_LEV)
Strcat(_status_vals[idx], " Lev");
if (cond & BL_MASK_FLY)
Strcat(_status_vals[idx], " Fly");
if (cond & BL_MASK_RIDE)
Strcat(_status_vals[idx], " Ride");
value = cond;
} break;
case BL_GOLD: {