From d748dbaa12f2686e9ed18f8edff75e49bbdc1ac4 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 14 Nov 2023 17:51:27 -0800 Subject: [PATCH] more menu headings Simplify suppression of highlighting for menu header lines during end of game disclosure. Didn't actually affect as many things as I was expecting. Plus a bit left out of the optfn_dogname() parsing commit. --- src/dog.c | 12 +++++------- src/dungeon.c | 13 ++++--------- src/end.c | 9 +-------- src/options.c | 8 +++----- src/pickup.c | 9 +++++---- src/windows.c | 16 +++++++++++----- 6 files changed, 29 insertions(+), 38 deletions(-) diff --git a/src/dog.c b/src/dog.c index 934d88aef..9b1513362 100644 --- a/src/dog.c +++ b/src/dog.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 dog.c $NHDT-Date: 1693427872 2023/08/30 20:37:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.146 $ */ +/* NetHack 3.7 dog.c $NHDT-Date: 1700012881 2023/11/15 01:48:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.147 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -188,12 +188,10 @@ makedog(void) return ((struct monst *) 0); pettype = pet_type(); - if (pettype == PM_LITTLE_DOG) - petname = gd.dogname; - else if (pettype == PM_PONY) - petname = gh.horsename; - else - petname = gc.catname; + petname = (pettype == PM_LITTLE_DOG) ? gd.dogname + : (pettype == PM_KITTEN) ? gc.catname + : (pettype == PM_PONY) ? gh.horsename + : ""; /* default pet names */ if (!*petname && pettype == PM_LITTLE_DOG) { diff --git a/src/dungeon.c b/src/dungeon.c index 368431e1e..d0194bdfe 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 dungeon.c $NHDT-Date: 1689629244 2023/07/17 21:27:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.188 $ */ +/* NetHack 3.7 dungeon.c $NHDT-Date: 1700012885 2023/11/15 01:48:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.197 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -38,8 +38,7 @@ static void Fread(genericptr_t, int, int, dlb *); static xint16 dname_to_dnum(const char *); static int find_branch(const char *, struct proto_dungeon *); static xint16 parent_dnum(const char *, struct proto_dungeon *); -static int level_range(xint16, int, int, int, struct proto_dungeon *, - int *); +static int level_range(xint16, int, int, int, struct proto_dungeon *, int *); static xint16 parent_dlevel(const char *, struct proto_dungeon *); static int correct_branch_type(struct tmpbranch *); static branch *add_branch(int, int, struct proto_dungeon *); @@ -53,8 +52,7 @@ static int get_dgn_align(lua_State *); static void init_dungeon_levels(lua_State *, struct proto_dungeon *, int); static boolean unplaced_floater(struct dungeon *); static boolean unreachable_level(d_level *, boolean); -static void tport_menu(winid, char *, struct lchoice *, d_level *, - boolean); +static void tport_menu(winid, char *, struct lchoice *, d_level *, boolean); static const char *br_string(int); static char chr_u_on_lvl(d_level *); static void print_branch(winid, int, int, int, boolean, struct lchoice *); @@ -3650,10 +3648,7 @@ print_mapseen( gd.dungeons[dnum].dname, depthstart, depthstart + gd.dungeons[dnum].dunlev_ureached - 1); - if (final) /* no highlighting during end-of-game disclosure */ - add_menu_str(win, buf); - else - add_menu_heading(win, buf); + add_menu_heading(win, buf); } /* calculate level number */ diff --git a/src/end.c b/src/end.c index f0498aa95..1791a29dd 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 end.c $NHDT-Date: 1693519356 2023/08/31 22:02:36 $ $NHDT-Branch: keni-crashweb2 $:$NHDT-Revision: 1.277 $ */ +/* NetHack 3.7 end.c $NHDT-Date: 1700012887 2023/11/15 01:48:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.282 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1079,16 +1079,9 @@ 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 */ - color_attr 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.attr = ATR_NONE; /* don't highlight class hdrs */ - iflags.menu_headings.color = NO_COLOR; (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/options.c b/src/options.c index 94daec302..9a7f92e17 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 options.c $NHDT-Date: 1687852124 2023/06/27 07:48:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.649 $ */ +/* NetHack 3.7 options.c $NHDT-Date: 1700012888 2023/11/15 01:48:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.675 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -8780,8 +8780,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ indexoffset = 1; any = cg.zeroany; - add_menu_heading(tmpwin, - "Booleans (selecting will toggle value):"); + add_menu_heading(tmpwin, "Booleans (selecting will toggle value):"); any.a_int = 0; /* first list any other non-modifiable booleans, then modifiable ones */ for (pass = 0; pass <= 1; pass++) @@ -8849,8 +8848,7 @@ doset(void) /* changing options via menu by Per Liboriussen */ #ifdef PREFIXES_IN_USE add_menu_str(tmpwin, ""); - add_menu_heading(tmpwin, - "Variable playground locations:"); + add_menu_heading(tmpwin, "Variable playground locations:"); for (i = 0; i < PREFIX_COUNT; i++) doset_add_menu(tmpwin, fqn_prefix_names[i], fmtstr_doset, -1, 0); #endif diff --git a/src/pickup.c b/src/pickup.c index 30fe251e4..0b4124f42 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 pickup.c $NHDT-Date: 1698264789 2023/10/25 20:13:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.339 $ */ +/* NetHack 3.7 pickup.c $NHDT-Date: 1700012890 2023/11/15 01:48:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1066,11 +1066,12 @@ query_objlist(const char *qstr, /* query string */ if ((*allow)(curr)) { /* if sorting, print type name (once only) */ if (sorted && !printed_type_name) { + boolean with_oc_sym = (how != PICK_NONE + && iflags.menu_head_objsym); + any = cg.zeroany; add_menu_heading(win, - let_to_name(*pack, FALSE, - ((how != PICK_NONE) - && iflags.menu_head_objsym))); + let_to_name(*pack, FALSE, with_oc_sym)); printed_type_name = TRUE; } diff --git a/src/windows.c b/src/windows.c index c3b506230..68a69385a 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 windows.c $NHDT-Date: 1661202202 2022/08/22 21:03:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.97 $ */ +/* NetHack 3.7 windows.c $NHDT-Date: 1700012891 2023/11/15 01:48:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.109 $ */ /* Copyright (c) D. Cohrs, 1993. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1623,23 +1623,29 @@ add_menu( ch, gch, attr, color, str, itemflags); } +/* insert a non-selectable, possibly highlighted line of text into a menu */ void add_menu_heading(winid tmpwin, const char *buf) { anything any = cg.zeroany; + int attr = iflags.menu_headings.attr, + color = iflags.menu_headings.color; - add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, - iflags.menu_headings.attr, iflags.menu_headings.color, + /* suppress highlighting during end-of-game disclosure */ + if (gp.program_state.gameover) + attr = ATR_NONE, color = NO_COLOR; + + add_menu(tmpwin, &nul_glyphinfo, &any, '\0', '\0', attr, color, buf, MENU_ITEMFLAGS_SKIPMENUCOLORS); } +/* insert a non-selectable, unhighlighted line of text into a menu */ void add_menu_str(winid tmpwin, const char *buf) { anything any = cg.zeroany; - add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, - ATR_NONE, NO_COLOR, + add_menu(tmpwin, &nul_glyphinfo, &any, '\0', '\0', ATR_NONE, NO_COLOR, buf, MENU_ITEMFLAGS_NONE); }