]> granicus.if.org Git - nethack/commitdiff
X11 persistent inventory again: initial display
authorPatR <rankin@nethack.org>
Sun, 14 Feb 2021 08:57:34 +0000 (00:57 -0800)
committerPatR <rankin@nethack.org>
Sun, 14 Feb 2021 08:57:34 +0000 (00:57 -0800)
If 'perm_invent' is preset in player's options, have X11 show the
persistent inventory window from the start instead of waiting for
an 'i' command.  moveloop() prolog needed a tweak do deal with it
cleanly.

Require WC_PERM_INVENT in order to honor the perm_invent option.
X11 and curses already set that, tty and curses don't support it,
so only Windows GUI needed to be updated for it.

doc/fixes37.0
src/allmain.c
src/options.c
win/X11/X11-issues.txt
win/X11/winX.c
win/win32/mswproc.c

index d7537d19533fe4e7132ee117082f75acf18416fc..fd992ba7ba28ec1e27ddeb7c5e1e8b8f6ec77baf 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.452 $ $NHDT-Date: 1613272633 2021/02/14 03:17:13 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.453 $ $NHDT-Date: 1613292825 2021/02/14 08:53:45 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -531,6 +531,8 @@ X11: was still initializing map to 'stone' instead of 'unexplored' after they
        became separate glyphs
 X11: for text map without color, add support for black&white ice; draw it in
        inverse video to distinguish from ordinary floor
+X11: if perm_invent is set in NETHACKOPTIONS or config file, start with the
+       persistent inventory window displayed
 X11+OSX: after the "bad Atom" fix (below), the persistent inventory window
        crept downward every time it got updated
 
index 1534b449cfad1400c92d64b2dc5b32648c9c8d65..ba0a1f0e3b0e626301803b68b56dca7e33ea4d02 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 allmain.c       $NHDT-Date: 1596498146 2020/08/03 23:42:26 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.145 $ */
+/* NetHack 3.7 allmain.c       $NHDT-Date: 1613292825 2021/02/14 08:53:45 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.151 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -68,7 +68,6 @@ moveloop(boolean resuming)
         g.context.seer_turn = (long) rnd(30);
     }
     g.context.botlx = TRUE; /* for STATUS_HILITES */
-    update_inventory(); /* for perm_invent */
     if (resuming) { /* restoring old game */
         read_engr_at(u.ux, u.uy); /* subset of pickup() */
     }
@@ -85,6 +84,11 @@ moveloop(boolean resuming)
     g.context.move = 0;
 
     g.program_state.in_moveloop = 1;
+    /* for perm_invent preset at startup, display persistent inventory after
+       invent is fully populated and the in_moveloop flag has been set */
+    if (iflags.perm_invent)
+        update_inventory();
+
     for (;;) {
 #ifdef SAFERHANGUP
         if (g.program_state.done_hup)
index e23620bed8beb442310eb5ed9b6da4ad6a68be7c..ecef4de8d7b1d70f955ecab290b5ebc940e80c37 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 options.c       $NHDT-Date: 1612431350 2021/02/04 09:35:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.500 $ */
+/* NetHack 3.7 options.c       $NHDT-Date: 1613293046 2021/02/14 08:57:26 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.506 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2008. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -8091,6 +8091,7 @@ static struct wc_Opt wc_options[] = {
     { "color", WC_COLOR },
     { "eight_bit_tty", WC_EIGHT_BIT_IN },
     { "hilite_pet", WC_HILITE_PET },
+    { "perm_invent", WC_PERM_INVENT },
     { "popup_dialog", WC_POPUP_DIALOG },
     { "player_selection", WC_PLAYER_SELECTION },
     { "preload_tiles", WC_PRELOAD_TILES },
@@ -8098,15 +8099,11 @@ static struct wc_Opt wc_options[] = {
     { "tile_file", WC_TILE_FILE },
     { "tile_width", WC_TILE_WIDTH },
     { "tile_height", WC_TILE_HEIGHT },
-    { "use_inverse", WC_INVERSE },
     { "align_message", WC_ALIGN_MESSAGE },
     { "align_status", WC_ALIGN_STATUS },
     { "font_map", WC_FONT_MAP },
     { "font_menu", WC_FONT_MENU },
     { "font_message", WC_FONT_MESSAGE },
-#if 0
-    {"perm_invent", WC_PERM_INVENT},
-#endif
     { "font_size_map", WC_FONTSIZ_MAP },
     { "font_size_menu", WC_FONTSIZ_MENU },
     { "font_size_message", WC_FONTSIZ_MESSAGE },
@@ -8118,6 +8115,7 @@ static struct wc_Opt wc_options[] = {
     { "scroll_amount", WC_SCROLL_AMOUNT },
     { "scroll_margin", WC_SCROLL_MARGIN },
     { "splash_screen", WC_SPLASH_SCREEN },
+    { "use_inverse", WC_INVERSE },
     { "vary_msgcount", WC_VARY_MSGCOUNT },
     { "windowcolors", WC_WINDOWCOLORS },
     { "mouse_support", WC_MOUSE_SUPPORT },
index 89607f76521ee5b1b69ec57b9fd5615918affe02..747f3a60a3e4bf039881524b1f62a87207fc91eb 100644 (file)
@@ -1,6 +1,3 @@
-Starting or restoring a game with 'perm_invent' enabled via config file
-or NETHACKOPTIONS does not begin with inventory shown.
-
 When persistent inventory window is first populated, focus is given to
 its window (behavior might be window manager-specific; it happens with
 default window manager on OSX).  Focus should be explicitly directed
index 054c6000c49658894699d93867354a46fcb6a06e..252bca4777d7d57beb3f73041217ca50ecac517c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 winX.c  $NHDT-Date: 1613272634 2021/02/14 03:17:14 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.96 $ */
+/* NetHack 3.7 winX.c  $NHDT-Date: 1613292827 2021/02/14 08:53:47 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.97 $ */
 /* Copyright (c) Dean Luick, 1992                                 */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1242,17 +1242,22 @@ X11_destroy_nhwindow(winid window)
 void
 X11_update_inventory(void)
 {
+    struct xwindow *wp = 0;
+
     if (!x_inited)
         return;
 
-    if (window_list[WIN_INVEN].menu_information->is_up) {
-        if (iflags.perm_invent) {
+    if (iflags.perm_invent) {
+        /* skip any calls to update_inventory() before in_moveloop starts */
+        if (g.program_state.in_moveloop || g.program_state.gameover) {
             updated_inventory = 1; /* hack to avoid mapping&raising window */
             (void) display_inventory((char *) 0, FALSE);
             updated_inventory = 0;
-        } else {
-            x11_no_perminv(&window_list[WIN_INVEN]);
         }
+    } else if ((wp = &window_list[WIN_INVEN]) != 0
+               && wp->type == NHW_MENU && wp->menu_information->is_up) {
+        /* persistent inventory is up but perm_invent is off, take it down */
+        x11_no_perminv(wp);
     }
 }
 
index 3ebb1922e7bfe1fa951f86a7e295ddfef3ac3442..a6f1db9bcb85b0520a0331391e88d256b3ec4ee3 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mswproc.c       $NHDT-Date: 1596498364 2020/08/03 23:46:04 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.153 $ */
+/* NetHack 3.7 mswproc.c       $NHDT-Date: 1613292828 2021/02/14 08:53:48 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.165 $ */
 /* Copyright (C) 2001 by Alex Kompel    */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -86,6 +86,7 @@ struct window_procs mswin_procs = {
         | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_MENU
         | WC_FONTSIZ_TEXT | WC_TILE_WIDTH | WC_TILE_HEIGHT | WC_TILE_FILE
         | WC_VARY_MSGCOUNT | WC_WINDOWCOLORS | WC_PLAYER_SELECTION
+        | WC_PERM_INVENT
         | WC_SPLASH_SCREEN | WC_POPUP_DIALOG | WC_MOUSE_SUPPORT,
 #ifdef STATUS_HILITES
     WC2_HITPOINTBAR | WC2_FLUSH_STATUS | WC2_RESET_STATUS | WC2_HILITE_STATUS |