Qt status display

Move gold from in front of HP to the end of the line they're on,
and change its label from "Au:" to "Gold:".  That makes both HP
and gold easier to see, by having HP first and by having gold
be shown after a blank column (where 'Exp' was once displayed
separately from 'Xp').

Get rid of the obsolete 'exp' widget, replacing it with 'blank1'.
Used to force 6 columns for HP, Energy, AC, Xp+Exp, blank, Gold
so that the row lines up with the six characteristics above it.

Handle Blind the same way as all the other On/Off conditions
instead of setting its label dynamically every time status gets
updated.  The Qt3 code in outdated/ used to do things that way
and there doesn't seem to be any reason to have changed it.
Maybe someone (Ray?) had planned to show "Blindfolded" instead
of "Blind" when that's the only reason for being blind.

Reorder the widget declarations and initializations to match
their display order, and add a lot of comments.
This commit is contained in:
PatR
2020-11-16 03:06:39 -08:00
parent 5c291bc540
commit 7395d1eda1
2 changed files with 95 additions and 60 deletions
+55 -39
View File
@@ -14,9 +14,9 @@
// six characteristic texts ("Str:18/03", "Dex:15", &c) // six characteristic texts ("Str:18/03", "Dex:15", &c)
// separator line // separator line
// five status fields without icons (some containing two values: // five status fields without icons (some containing two values:
// Gold, HP/HPmax, Energy/Enmax, AC, XpLevel/ExpPoints or HD) // HP/HPmax, Energy/Enmax, AC, XpLevel/ExpPoints or HD, [blank], Gold)
// optional line with two text fields (Time:1234, Score:89)
// separator line // separator line
// optional line with two text fields (Time:1234, Score:89)
// varying number of icons (one or more, each paired with...) // varying number of icons (one or more, each paired with...)
// corresponding text (Alignment plus zero or more status conditions // corresponding text (Alignment plus zero or more status conditions
// including Hunger if not "normal" and encumbrance if not "normal") // including Hunger if not "normal" and encumbrance if not "normal")
@@ -29,16 +29,38 @@
// Time and Score are spaced as if each were three fields wide. // Time and Score are spaced as if each were three fields wide.
// Icons and texts for alignment and conditions are left justified. // Icons and texts for alignment and conditions are left justified.
// The separator lines are thin and don't take up much vertical space. // The separator lines are thin and don't take up much vertical space.
// The hitpoint bar line and the Time+Score line are omitted when the // When enabled, the hitpoint bar bisects the margin above Title,
// corresponding items are disabled. // increasing the overall status height by 9 pixels; when disabled,
// the status shifts up by those 9 pixels.
// When Time+Score line is empty, it still takes up the vertical space
// that would be used to show those values.
// //
// FIXME: // FIXME:
// When hitpoint bar is shown, attempting to resize horizontally won't // When hitpoint bar is shown, attempting to resize horizontally won't
// do anything. Toggling it off, then resizing, and back On works. // do anything. Toggling it off, then resizing, and back On works.
// (Caused by specifying min-width and max-width constraints in the
// style sheets used to control color, but removing those constraints
// causes the bar display to get screwed up.)
// //
// TODO: // TODO:
// If/when status conditions become too wide for the status window, scale // If/when status conditions become too wide for the status window, scale
// down their icons and switch their text to a smaller font to match. // down their icons and switch their text to a smaller font to match.
// Title and Location are explicitly rendered with a bigger font than
// the rest of status. That takes up more space, which is ok, but it
// also increases the vertical margin in between them by more than is
// necessary. Should squeeze some of that excess blank space out.
// Changed values are highlighted as "gone Up" (green) or "gone Down" (red)
// with NetHackQtLabelledIcon::setLabel() taking an optional boolean
// argument indicating "lower is better" (for AC). That flag should
// have other choices: "changed" (third color with no better or worse
// judgement, for alignment and dungeon location) and "ignore" (don't
// highlight, to suppress the bogus highlighting that currently happens
// when toggling 'showexp' or 'showscore').
// Maybe: if Alignment was moved to the characteristics line, giving that
// seven columns, then Time and Score could replace the one blank field
// on the HP line, giving it seven fields too and eliminating a whole
// line. [Maybe handle this dynamically, controlled via existing
// 'statuslines' 2 vs 3 that's currently a no-op for Qt?]
// //
extern "C" { extern "C" {
@@ -65,43 +87,49 @@ extern int qt_compact_mode;
namespace nethack_qt_ { namespace nethack_qt_ {
NetHackQtStatusWindow::NetHackQtStatusWindow() : NetHackQtStatusWindow::NetHackQtStatusWindow() :
/* first three rows: hitpoint bar, title (plname the Rank), location */
hpbar_health(this),
hpbar_injury(this),
name(this,"(name)"), name(this,"(name)"),
dlevel(this,"(dlevel)"), dlevel(this,"(dlevel)"),
/* next two rows: icon over text label for the six characteristics */
str(this, "Str"), str(this, "Str"),
dex(this, "Dex"), dex(this, "Dex"),
con(this, "Con"), con(this, "Con"),
intel(this, "Int"), intel(this, "Int"),
wis(this, "Wis"), wis(this, "Wis"),
cha(this, "Cha"), cha(this, "Cha"),
gold(this,"Gold"), /* sixth row, text only: some contain two slash-separated values */
hp(this,"Hit Points"), hp(this,"Hit Points"),
power(this,"Power"), power(this,"Power"),
ac(this,"Armour Class"), ac(this,"Armor Class"),
level(this,"Level"), level(this,"Level"), // Xp level, with "/"+Exp points optionally appended
exp(this, "_"), // exp displayed as Xp/Exp but exp widget used for padding blank1(this, ""), // used for padding to align columns (was once 'exp')
gold(this,"Gold"), // gold used to be this row's first column, now last
/* seventh row: two optionally displayed values (just text, no icons) */
time(this,"Time"), // if 'time' option On
score(this,"Score"), // if SCORE_ON_BOTL defined and 'showscore' option On
/* last two rows: alignment followed by conditions (icons over text) */
align(this,"Alignment"), align(this,"Alignment"),
time(this,"Time"),
score(this,"Score"),
hunger(this,""), hunger(this,""),
encumber(this,""), encumber(this,""),
stoned(this,"Stone"), stoned(this,"Stone"), // major conditions
slimed(this,"Slime"), slimed(this,"Slime"),
strngld(this,"Strngl"), strngld(this,"Strngl"),
sick_fp(this,"FoodPois"), sick_fp(this,"FoodPois"),
sick_il(this,"TermIll"), sick_il(this,"TermIll"),
stunned(this,"Stun"), stunned(this,"Stun"), // minor conditions
confused(this,"Conf"), confused(this,"Conf"),
hallu(this,"Hallu"), hallu(this,"Hallu"),
blind(this,""), blind(this,"Blind"),
deaf(this,"Deaf"), deaf(this,"Deaf"),
lev(this,"Lev"), lev(this,"Lev"), // 'other' conditions
fly(this,"Fly"), fly(this,"Fly"),
ride(this,"Ride"), ride(this,"Ride"),
hpbar_health(this), hline1(this), // separators
hpbar_injury(this),
hline1(this),
hline2(this), hline2(this),
hline3(this), hline3(this),
/* miscellaneous; not display fields */
cursy(0), cursy(0),
first_set(true), first_set(true),
alreadyfullhp(false) alreadyfullhp(false)
@@ -179,6 +207,7 @@ NetHackQtStatusWindow::NetHackQtStatusWindow() :
hline2.setLineWidth(1); hline2.setLineWidth(1);
hline3.setLineWidth(1); hline3.setLineWidth(1);
// set up last but shown first (above name) via layout below */
QHBoxLayout *hpbar = InitHitpointBar(); QHBoxLayout *hpbar = InitHitpointBar();
#if 1 //RLC #if 1 //RLC
@@ -200,12 +229,12 @@ NetHackQtStatusWindow::NetHackQtStatusWindow() :
vbox->addLayout(atr1box); vbox->addLayout(atr1box);
vbox->addWidget(&hline2); vbox->addWidget(&hline2);
QHBoxLayout *atr2box = new QHBoxLayout(); QHBoxLayout *atr2box = new QHBoxLayout();
atr2box->addWidget(&gold);
atr2box->addWidget(&hp); atr2box->addWidget(&hp);
atr2box->addWidget(&power); atr2box->addWidget(&power);
atr2box->addWidget(&ac); atr2box->addWidget(&ac);
atr2box->addWidget(&level); atr2box->addWidget(&level);
atr2box->addWidget(&exp); atr2box->addWidget(&blank1); // empty column #5
atr2box->addWidget(&gold);
vbox->addLayout(atr2box); vbox->addLayout(atr2box);
vbox->addWidget(&hline3); vbox->addWidget(&hline3);
QHBoxLayout *timebox = new QHBoxLayout(); QHBoxLayout *timebox = new QHBoxLayout();
@@ -251,15 +280,14 @@ void NetHackQtStatusWindow::doUpdate()
intel.setFont(normal); intel.setFont(normal);
wis.setFont(normal); wis.setFont(normal);
cha.setFont(normal); cha.setFont(normal);
gold.setFont(normal);
hp.setFont(normal); hp.setFont(normal);
power.setFont(normal); power.setFont(normal);
ac.setFont(normal); ac.setFont(normal);
level.setFont(normal); level.setFont(normal);
//exp.setFont(normal); gold.setFont(normal);
align.setFont(normal);
time.setFont(normal); time.setFont(normal);
score.setFont(normal); score.setFont(normal);
align.setFont(normal);
hunger.setFont(normal); hunger.setFont(normal);
encumber.setFont(normal); encumber.setFont(normal);
stoned.setFont(normal); stoned.setFont(normal);
@@ -415,7 +443,6 @@ void NetHackQtStatusWindow::fadeHighlighting()
power.dissipateHighlight(); power.dissipateHighlight();
ac.dissipateHighlight(); ac.dissipateHighlight();
level.dissipateHighlight(); level.dissipateHighlight();
//exp.dissipateHighlight();
align.dissipateHighlight(); align.dissipateHighlight();
time.dissipateHighlight(); time.dissipateHighlight();
@@ -646,14 +673,9 @@ void NetHackQtStatusWindow::updateStats()
if (Stunned) stunned.show(); else stunned.hide(); if (Stunned) stunned.show(); else stunned.hide();
if (Confusion) confused.show(); else confused.hide(); if (Confusion) confused.show(); else confused.hide();
if (Hallucination) hallu.show(); else hallu.hide(); if (Hallucination) hallu.show(); else hallu.hide();
// [pr - Why is blind handled differently from other on/off conditions?] if (Blind) blind.show(); else blind.hide();
if (Blind) {
blind.setLabel("Blind");
blind.show();
} else {
blind.hide();
}
if (Deaf) deaf.show(); else deaf.hide(); if (Deaf) deaf.show(); else deaf.hide();
// flying is blocked when levitating, so Lev and Fly are mutually exclusive // flying is blocked when levitating, so Lev and Fly are mutually exclusive
if (Levitation) lev.show(); else lev.hide(); if (Levitation) lev.show(); else lev.hide();
if (Flying) fly.show(); else fly.hide(); if (Flying) fly.show(); else fly.hide();
@@ -677,8 +699,6 @@ void NetHackQtStatusWindow::updateStats()
// new depth compared to old // new depth compared to old
dlevel.setLabel(buf3, false); dlevel.setLabel(buf3, false);
gold.setLabel("Au:", money_cnt(g.invent));
if (Upolyd) { if (Upolyd) {
// You're a monster! // You're a monster!
buf.sprintf("/%d", u.mhmax); buf.sprintf("/%d", u.mhmax);
@@ -706,12 +726,9 @@ void NetHackQtStatusWindow::updateStats()
buf.sprintf("/%d", u.uenmax); buf.sprintf("/%d", u.uenmax);
power.setLabel("Pow:", u.uen, buf); power.setLabel("Pow:", u.uen, buf);
ac.setLabel("AC:", (long) u.uac); ac.setLabel("AC:", (long) u.uac);
//if (::flags.showexp) { // label prefix used to be "Au:", tty uses "$:"
// exp.setLabel("Exp:", (long) u.uexp); gold.setLabel("Gold:", money_cnt(g.invent));
//} else {
// 'exp' is now only used to pad the line that Xp/Exp is displayed on
exp.setLabel("");
//}
text = NULL; text = NULL;
if (u.ualign.type==A_CHAOTIC) { if (u.ualign.type==A_CHAOTIC) {
align.setIcon(p_chaotic); align.setIcon(p_chaotic);
@@ -763,7 +780,6 @@ void NetHackQtStatusWindow::updateStats()
power.highlightWhenChanging(); power.highlightWhenChanging();
ac.highlightWhenChanging(); ac.lowIsGood(); ac.highlightWhenChanging(); ac.lowIsGood();
level.highlightWhenChanging(); level.highlightWhenChanging();
//exp.highlightWhenChanging(); -- 'exp' is just padding
align.highlightWhenChanging(); align.highlightWhenChanging();
// don't highlight 'time' because it changes almost continuously // don't highlight 'time' because it changes almost continuously
+40 -21
View File
@@ -65,9 +65,18 @@ private:
QPixmap p_fly; QPixmap p_fly;
QPixmap p_ride; QPixmap p_ride;
NetHackQtLabelledIcon name; /*
NetHackQtLabelledIcon dlevel; * Status fields, in display order (the three separator lines
* are exceptions). Hitpoint bar is optionally displayed and
* contains two side-by-side parts; neither part is labelled.
*/
QLabel hpbar_health; // hit point bar, left half
QLabel hpbar_injury; // hit point bar, right half
NetHackQtLabelledIcon name; // (aka title) centered on its own row
NetHackQtLabelledIcon dlevel; // (aka location) likewise
/* the six characteristics; each is shown with a 40x40 icon above
and a text label below, so implicitly two rows */
NetHackQtLabelledIcon str; NetHackQtLabelledIcon str;
NetHackQtLabelledIcon dex; NetHackQtLabelledIcon dex;
NetHackQtLabelledIcon con; NetHackQtLabelledIcon con;
@@ -75,21 +84,34 @@ private:
NetHackQtLabelledIcon wis; NetHackQtLabelledIcon wis;
NetHackQtLabelledIcon cha; NetHackQtLabelledIcon cha;
NetHackQtLabelledIcon gold; /* five various status fields, some showing two values, shown as
NetHackQtLabelledIcon hp; a row of text only; 'exp' used to be a separate field but is
NetHackQtLabelledIcon power; now displayed with 'level', with a blank field where it was so
NetHackQtLabelledIcon ac; that there continue to be six columns which line up beneath the
NetHackQtLabelledIcon level; // Xp level characteristics; gold used to be left-most but doesn't warrant
NetHackQtLabelledIcon exp; // appended to Xp rather than separate that position; Xp or Xp/Exp is replaced by HD when polymorphed */
// but still used to pad their line NetHackQtLabelledIcon hp; // current HP / maximum HP
NetHackQtLabelledIcon align; // alignment is on Conditions line NetHackQtLabelledIcon power; // current energy / maximum energy
// because it has an icon above it NetHackQtLabelledIcon ac; // armor class
NetHackQtLabelledIcon time; NetHackQtLabelledIcon level; // Xp level / Exp points (if 'showexp')
NetHackQtLabelledIcon score; NetHackQtLabelledIcon blank1; // pads the line to six columns
NetHackQtLabelledIcon gold; // used to come before HP
NetHackQtLabelledIcon hunger; /* next row: two more fields, possibly blank; when present, each
NetHackQtLabelledIcon encumber; is sized as if for three fields, so their centered values line
up with 2nd and 5th columns of the rows above */
NetHackQtLabelledIcon time; // moves counter (if 'time' is set)
NetHackQtLabelledIcon score; // tentative score (if compiled with
// SCORE_ON_BOTL and 'showscore' is set)
/* last rows: alignment and zero or more status conditions;
like the characteristics, they are shown as if in two rows with
a 40x40 icon above and text lebel below; blank values are omitted
and non-blank values are left justified */
NetHackQtLabelledIcon align; // w/ alignment-specific ankh icon
NetHackQtLabelledIcon hunger; // blank if 'normal'
NetHackQtLabelledIcon encumber; // blank if 'unencumbered' ('normal')
/* zero or more status conditions; in major, minor, 'other' order */
NetHackQtLabelledIcon stoned; NetHackQtLabelledIcon stoned;
NetHackQtLabelledIcon slimed; NetHackQtLabelledIcon slimed;
NetHackQtLabelledIcon strngld; NetHackQtLabelledIcon strngld;
@@ -104,12 +126,9 @@ private:
NetHackQtLabelledIcon fly; NetHackQtLabelledIcon fly;
NetHackQtLabelledIcon ride; NetHackQtLabelledIcon ride;
QLabel hpbar_health; // hit point bar, left half QFrame hline1; // between dlevel and characteristics
QLabel hpbar_injury; // hit point bar, right half QFrame hline2; // between characteristics and regular status fields
QFrame hline3; // between regular fields and time,score or conditions
QFrame hline1;
QFrame hline2;
QFrame hline3;
int cursy; int cursy;