]> granicus.if.org Git - nethack/commitdiff
menuinvertmode
authorPatR <rankin@nethack.org>
Wed, 16 Mar 2022 23:19:30 +0000 (16:19 -0700)
committerPatR <rankin@nethack.org>
Wed, 16 Mar 2022 23:19:30 +0000 (16:19 -0700)
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.

include/optlist.h
src/invent.c
src/options.c
src/windows.c

index b419909a0b9886f76be6a1242a123488faf4c89a..f1a57cc32f18877dd4ec18d18cb207df885e870e 100644 (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,
index 4231c8dee373bff8a0b30df4654d73e85a97e38f..1ff07a2d40df023aef3dc47890d56a1558c1e3e5 100644 (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) {
index 9ddad7dbd89a0ef769acf893c3d6b35cef4a1386..ee14ea5fa1473cdc5e46f2471b63c6e73c0d42f0 100644 (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);
index 3ca1aee2adae87cc6d1caedccc775e558553e1f6..fe6ca8e9d156f04c1a224c36080473505f2f0119 100644 (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)
-        return FALSE;
-    else if (iflags.menuinvertmode == 2
-        && !mode && skipinvert && is_selected)
-        return TRUE;
-    else
+    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 == 1) {
+        return is_selected ? TRUE : FALSE;
+    }
+    return TRUE;
 }
 
 /*windows.c*/