menuinvertmode

Change the 'menuinvertmode' default from 0 to 1 so that it gets more
exercise.  It can be changed back to 0 via option settings but it's
doubtful that anyone will care enough to bother.

Some pickup/take-off actions have been using it to avoid setting
their 'all' choice when bulk toggling for current-page or whole-menu
takes place; 'O' specifies it for its '?' help choice.  This adds
the skipinvert flag to the 'all' choice of #wizidentify.

The comments describing it now state that menuinvertmode applies to
bulk set-on operations as well as to toggle-on/off operations but
that will only be true if/when interfaces call menuitem_invert_test()
for set as well as for invert.  tty is about to start doing that.
This commit is contained in:
PatR
2022-03-16 16:19:30 -07:00
parent 7f484815e5
commit 5db6dac863
4 changed files with 40 additions and 16 deletions

View File

@@ -313,7 +313,7 @@ opt_##a,
NHOPTO("menu colors", o_menu_colors, BUFSZ, opt_in, set_in_game,
No, Yes, No, NoAlias, "edit menu colors")
NHOPTC(menuinvertmode, 5, opt_in, set_in_game, No, Yes, No, No, NoAlias,
"behaviour of menu iverts")
"experimental behaviour of menu inverts")
NHOPTC(menustyle, MENUTYPELEN, opt_in, set_in_game, Yes, Yes, No, Yes,
NoAlias, "user interface for object selection")
NHOPTO("message types", o_message_types, BUFSZ, opt_in, set_in_game,

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 invent.c $NHDT-Date: 1629409876 2021/08/19 21:51:16 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.339 $ */
/* NetHack 3.7 invent.c $NHDT-Date: 1647472704 2022/03/16 23:18:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.355 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2674,7 +2674,7 @@ display_pickinv(
Sprintf(eos(prompt), " (%s for all)",
visctrl(iflags.override_ID));
add_menu(win, &nul_glyphinfo, &any, '_', iflags.override_ID,
ATR_NONE, prompt, MENU_ITEMFLAGS_NONE);
ATR_NONE, prompt, MENU_ITEMFLAGS_SKIPINVERT);
gotsomething = TRUE;
}
} else if (xtra_choice) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 options.c $NHDT-Date: 1645000577 2022/02/16 08:36:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.540 $ */
/* NetHack 3.7 options.c $NHDT-Date: 1647472681 2022/03/16 23:18:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.542 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -5838,6 +5838,19 @@ initoptions_init(void)
/* only used by curses */
iflags.wc2_windowborders = 2; /* 'Auto' */
/*
* A few menus have certain items (typically operate-on-everything or
* change-subset or sort or help entries) flagged as 'skip-invert' to
* control how whole-page and whole-menu operations affect them.
* 'menuinvertmode' controls how that functions:
* 0: ignore 'skip-invert' flag on menu items (used to be the default);
* 1: don't toggle 'skip-invert' items On for set-all/set-page/invert-
* all/invert-page but do toggle Off if already set (default);
* 2: don't toggle 'skip-invert' items either On of Off for set-all/
* set-page/unset-all/unset-page/invert-all/invert-page.
*/
iflags.menuinvertmode = 1;
/* since this is done before init_objects(), do partial init here */
objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD;
nmcpy(g.pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 windows.c $NHDT-Date: 1612127121 2021/01/31 21:05:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.82 $ */
/* NetHack 3.7 windows.c $NHDT-Date: 1647472699 2022/03/16 23:18:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.86 $ */
/* Copyright (c) D. Cohrs, 1993. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1493,21 +1493,32 @@ genl_putmixed(winid window, int attr, const char *str)
* logic into one place instead of 7 different window-port routines.
*/
boolean
menuitem_invert_test(int mode,
unsigned itemflags, /* The itemflags for the item */
boolean is_selected) /* The current selection status
of the item */
menuitem_invert_test(
int mode UNUSED, /* 0: invert; 1: set; 2: unset */
unsigned itemflags, /* itemflags for the item */
boolean is_selected) /* current selection status of the item */
{
boolean skipinvert = (itemflags & MENU_ITEMFLAGS_SKIPINVERT) != 0;
if ((iflags.menuinvertmode == 1 || iflags.menuinvertmode == 2)
&& !mode && skipinvert && !is_selected)
if (!skipinvert) /* if not flagged SKIPINVERT, always pass test */
return TRUE;
/*
* mode 0: inverting current on/off state;
* 1: unconditionally setting on;
* 2: unconditionally setting off.
* menuinvertmode 0: treat entries flagged with skipinvert as ordinary
* (same as if not flagged);
* menuinvertmode 1: don't toggle bulk invert or bulk set entries On
* (allow such toggling or setting to change to Off);
* menuinvertmode 2: don't toggle skipinvert entries either On or Off
* when a bulk change is performed.
*/
if (iflags.menuinvertmode == 2) {
return FALSE;
else if (iflags.menuinvertmode == 2
&& !mode && skipinvert && is_selected)
return TRUE;
else
return TRUE;
} else if (iflags.menuinvertmode == 1) {
return is_selected ? TRUE : FALSE;
}
return TRUE;
}
/*windows.c*/