today's Qt status update: non-standard conditions

Qt's status highlighting was treating any change to hunger or
to encumbrance as "worse" (shown in red).  That's wrong if you
go from weak to just hungry or from stressed to encumbered.

Comparing satiated with other hunger states is tricky.  I've
ranked it between hungry and weak but that's fairly arbitrary.

Also, change the highlighting when Lev, Fly, and Ride are new
conditions from red to blue.
This commit is contained in:
PatR
2020-11-24 09:45:55 -08:00
parent 229930e505
commit 018d838eb9
3 changed files with 57 additions and 29 deletions

View File

@@ -718,24 +718,45 @@ void NetHackQtStatusWindow::updateStats()
boolean spreadout = (::iflags.wc2_statuslines != 2);
int k = 0; // number of conditions shown
const char* hung=hu_stat[u.uhs];
long qt_uhs = 0L;
const char *hung = hu_stat[u.uhs];
if (hung[0]==' ') {
hunger.hide();
if (!hunger.isHidden()) {
hunger.setLabel("", NetHackQtLabelledIcon::NoNum, qt_uhs);
hunger.hide();
}
} else {
// satiated is worse (due to risk of death from overeating)
// than not-hungry and we'll treat it as also worse than hungry,
// but better than weak or fainting; the u.uhs enum values
// order them differently so we jump through a hoop
switch (u.uhs) {
case NOT_HUNGRY: qt_uhs = 0L; break;
case HUNGRY: qt_uhs = 1L; break;
case SATIATED: qt_uhs = 2L; break;
case WEAK: qt_uhs = 3L; break;
case FAINTING: qt_uhs = 4L; break;
default: qt_uhs = 5L; break; // fainted, starved
}
hunger.setIcon(u.uhs ? p_hungry : p_satiated);
hunger.setLabel(hung);
hunger.setLabel(hung, NetHackQtLabelledIcon::NoNum, qt_uhs);
hunger.ForceResize();
++k, hunger.show();
}
const char *enc = enc_stat[near_capacity()];
long encindx = (long) near_capacity();
const char *enc = enc_stat[encindx];
if (enc[0]==' ' || !enc[0]) {
encumber.hide();
if (!encumber.isHidden()) {
encumber.setLabel("", NetHackQtLabelledIcon::NoNum, encindx);
encumber.hide();
}
} else {
encumber.setIcon(p_encumber[near_capacity() - 1]);
encumber.setLabel(enc);
encumber.setIcon(p_encumber[encindx - 1]);
encumber.setLabel(enc, NetHackQtLabelledIcon::NoNum, encindx);
encumber.ForceResize();
++k, encumber.show();
}
if (Stoned) ++k, stoned.show(); else stoned.hide();
if (Slimed) ++k, slimed.show(); else slimed.hide();
if (Strangled) ++k, strngld.show(); else strngld.hide();
@@ -917,12 +938,13 @@ void NetHackQtStatusWindow::updateStats()
if (first_set) {
first_set=false;
was_polyd = Upolyd ? true : false;
had_exp = ::flags.showexp ? true : false;
had_score = ::flags.showscore ? true : false;
/*
* Default compareMode is BiggerIsBetter: an increased value
* is an improvement.
*/
name.highlightWhenChanging();
dlevel.highlightWhenChanging(); dlevel.setCompareMode(NeitherIsBetter);
dlevel.highlightWhenChanging();
dlevel.setCompareMode(NeitherIsBetter);
str.highlightWhenChanging();
dex.highlightWhenChanging();
@@ -933,7 +955,8 @@ void NetHackQtStatusWindow::updateStats()
hp.highlightWhenChanging();
power.highlightWhenChanging();
ac.highlightWhenChanging(); ac.setCompareMode(SmallerIsBetter);
ac.highlightWhenChanging();
ac.setCompareMode(SmallerIsBetter);
level.highlightWhenChanging();
gold.highlightWhenChanging();
@@ -942,10 +965,13 @@ void NetHackQtStatusWindow::updateStats()
//time.highlightWhenChanging(); time.setCompareMode(NeitherIsBetter);
score.highlightWhenChanging();
align.highlightWhenChanging(); align.setCompareMode(NeitherIsBetter);
align.highlightWhenChanging();
align.setCompareMode(NeitherIsBetter);
hunger.highlightWhenChanging();
hunger.setCompareMode(SmallerIsBetter);
encumber.highlightWhenChanging();
encumber.setCompareMode(SmallerIsBetter);
stoned.highlightWhenChanging();
slimed.highlightWhenChanging();
strngld.highlightWhenChanging();
@@ -956,9 +982,15 @@ void NetHackQtStatusWindow::updateStats()
hallu.highlightWhenChanging();
blind.highlightWhenChanging();
deaf.highlightWhenChanging();
// the default behavior is to highlight a newly shown condition
// as "worse" but that isn't appropriate for 'other' conds;
// NetHackQtLabelledIcon::show() uses NeitherIsBetter to handle it
lev.highlightWhenChanging();
lev.setCompareMode(NeitherIsBetter);
fly.highlightWhenChanging();
fly.setCompareMode(NeitherIsBetter);
ride.highlightWhenChanging();
ride.setCompareMode(NeitherIsBetter);
}
}