simplified menu_headings fix

Reported by entrez, some putstr() to text window got changed to
add_menu_str().  I didn't test with curses; with tty some headers
ended up in limbo:  "Artifacts" header for '` a y' (wizard mode show
artifacts, something I had forgotten even existed) and also monster
class headers for 'm #vanquished by-class' (available to everyone).
Qt lost them too, but at least it didn't panic.

Not due to over-simplification:  end of game disclosure suppresses
header line highlighting, except when disclosing final inventory.
Change it to do so, although it would be simpler overall to just not
bother with any menu_headings highlight suppression.
This commit is contained in:
PatR
2023-11-05 23:50:12 -08:00
parent a40dbe791e
commit ac57c070be
4 changed files with 18 additions and 11 deletions
+2 -1
View File
@@ -1071,7 +1071,8 @@ dump_artifact_info(winid tmpwin)
int m; int m;
char buf[BUFSZ], buf2[BUFSZ]; char buf[BUFSZ], buf2[BUFSZ];
add_menu_heading(tmpwin, "Artifacts"); /* not a menu, but header uses same bold or whatever attribute as such */
putstr(tmpwin, iflags.menu_headings, "Artifacts");
for (m = 1; m <= NROFARTIFACTS; ++m) { for (m = 1; m <= NROFARTIFACTS; ++m) {
Snprintf(buf2, sizeof buf2, Snprintf(buf2, sizeof buf2,
"[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */ "[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */
+2 -2
View File
@@ -3649,8 +3649,8 @@ print_mapseen(
Sprintf(buf, "%s: levels %d to %d", Sprintf(buf, "%s: levels %d to %d",
gd.dungeons[dnum].dname, depthstart, gd.dungeons[dnum].dname, depthstart,
depthstart + gd.dungeons[dnum].dunlev_ureached - 1); depthstart + gd.dungeons[dnum].dunlev_ureached - 1);
any = cg.zeroany;
if (final) if (final) /* no highlighting during end-of-game disclosure */
add_menu_str(win, buf); add_menu_str(win, buf);
else else
add_menu_heading(win, buf); add_menu_heading(win, buf);
+6
View File
@@ -1079,9 +1079,15 @@ disclose(int how, boolean taken)
ask = should_query_disclose_option('i', &defquery); ask = should_query_disclose_option('i', &defquery);
c = ask ? yn_function(qbuf, ynqchars, defquery, TRUE) : defquery; c = ask ? yn_function(qbuf, ynqchars, defquery, TRUE) : defquery;
if (c == 'y') { if (c == 'y') {
/* save and restore menu_headings in case something like
#saveoptions is ever allowed to be run at the very end */
int save_menu_headings = iflags.menu_headings;
/* caller has already ID'd everything; we pass 'want_reply=True' /* caller has already ID'd everything; we pass 'want_reply=True'
to force display_pickinv() to avoid using WIN_INVENT */ to force display_pickinv() to avoid using WIN_INVENT */
iflags.menu_headings = ATR_NONE; /* don't highlight class hdrs */
(void) display_inventory((char *) 0, TRUE); (void) display_inventory((char *) 0, TRUE);
iflags.menu_headings = save_menu_headings;
container_contents(gi.invent, TRUE, TRUE, FALSE); container_contents(gi.invent, TRUE, TRUE, FALSE);
} }
if (c == 'q') if (c == 'q')
+8 -8
View File
@@ -2758,10 +2758,10 @@ list_vanquished(char defquery, boolean ask)
mlet = mons[i].mlet; mlet = mons[i].mlet;
if (class_header && mlet != prev_mlet) { if (class_header && mlet != prev_mlet) {
Strcpy(buf, def_monsyms[(int) mlet].explain); Strcpy(buf, def_monsyms[(int) mlet].explain);
if (ask) /* 'ask' implies final disclosure, where highlighting
putstr(klwin, 0, upstart(buf)); of various header lines is suppressed */
else putstr(klwin, ask ? ATR_NONE : iflags.menu_headings,
add_menu_heading(klwin, upstart(buf)); upstart(buf));
prev_mlet = mlet; prev_mlet = mlet;
} }
if (UniqCritterIndx(i)) { if (UniqCritterIndx(i)) {
@@ -2969,10 +2969,10 @@ list_genocided(char defquery, boolean ask)
mlet = mons[mndx].mlet; mlet = mons[mndx].mlet;
if (class_header && mlet != prev_mlet) { if (class_header && mlet != prev_mlet) {
Strcpy(buf, def_monsyms[(int) mlet].explain); Strcpy(buf, def_monsyms[(int) mlet].explain);
if (ask) /* 'ask' implies final disclosure, where highlighting
putstr(klwin, 0, upstart(buf)); of various header lines is suppressed */
else putstr(klwin, ask ? ATR_NONE : iflags.menu_headings,
add_menu_heading(klwin, upstart(buf)); upstart(buf));
prev_mlet = mlet; prev_mlet = mlet;
} }
Sprintf(buf, " %s", makeplural(mons[mndx].pmnames[NEUTRAL])); Sprintf(buf, " %s", makeplural(mons[mndx].pmnames[NEUTRAL]));