From ac57c070befc36286fc535e5a863dfcb8b4903b5 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 5 Nov 2023 23:50:12 -0800 Subject: [PATCH] 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. --- src/artifact.c | 3 ++- src/dungeon.c | 4 ++-- src/end.c | 6 ++++++ src/insight.c | 16 ++++++++-------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index 61794b395..7aae6ebd9 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1071,7 +1071,8 @@ dump_artifact_info(winid tmpwin) int m; 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) { Snprintf(buf2, sizeof buf2, "[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */ diff --git a/src/dungeon.c b/src/dungeon.c index 9cc34ed51..d80d5a4d7 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -3649,8 +3649,8 @@ print_mapseen( Sprintf(buf, "%s: levels %d to %d", gd.dungeons[dnum].dname, depthstart, 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); else add_menu_heading(win, buf); diff --git a/src/end.c b/src/end.c index 59f7d76d0..4f276594d 100644 --- a/src/end.c +++ b/src/end.c @@ -1079,9 +1079,15 @@ disclose(int how, boolean taken) ask = should_query_disclose_option('i', &defquery); c = ask ? yn_function(qbuf, ynqchars, defquery, TRUE) : defquery; 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' 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); + iflags.menu_headings = save_menu_headings; container_contents(gi.invent, TRUE, TRUE, FALSE); } if (c == 'q') diff --git a/src/insight.c b/src/insight.c index 6c4addce6..b007cba02 100644 --- a/src/insight.c +++ b/src/insight.c @@ -2758,10 +2758,10 @@ list_vanquished(char defquery, boolean ask) mlet = mons[i].mlet; if (class_header && mlet != prev_mlet) { Strcpy(buf, def_monsyms[(int) mlet].explain); - if (ask) - putstr(klwin, 0, upstart(buf)); - else - add_menu_heading(klwin, upstart(buf)); + /* 'ask' implies final disclosure, where highlighting + of various header lines is suppressed */ + putstr(klwin, ask ? ATR_NONE : iflags.menu_headings, + upstart(buf)); prev_mlet = mlet; } if (UniqCritterIndx(i)) { @@ -2969,10 +2969,10 @@ list_genocided(char defquery, boolean ask) mlet = mons[mndx].mlet; if (class_header && mlet != prev_mlet) { Strcpy(buf, def_monsyms[(int) mlet].explain); - if (ask) - putstr(klwin, 0, upstart(buf)); - else - add_menu_heading(klwin, upstart(buf)); + /* 'ask' implies final disclosure, where highlighting + of various header lines is suppressed */ + putstr(klwin, ask ? ATR_NONE : iflags.menu_headings, + upstart(buf)); prev_mlet = mlet; } Sprintf(buf, " %s", makeplural(mons[mndx].pmnames[NEUTRAL]));