]> granicus.if.org Git - nethack/commitdiff
refresh content between really long menu pages
authornhmall <nhmall@nethack.org>
Fri, 24 Jun 2022 00:35:43 +0000 (20:35 -0400)
committernhmall <nhmall@nethack.org>
Fri, 24 Jun 2022 00:35:43 +0000 (20:35 -0400)
For a long while, I've noticed that if the first page of corner menu is
quite long, and the second page is much shorter, the content obliterated
by the first page is left missing until the menu is fully dismissed.

This attempts to fix that missing content up.

===========================================================================
BEFORE THIS PATCH - menu Page 1
===========================================================================
                                   Amulets
                                   J - a circular amulet
        ------------               Weapons
        |..........|       ------- a - a +0 two-handed sword (weapon in hands)
        |..........|       |...... b - a +0 axe (alternate weapon; not wielded)
       #...........|      #....... w - 7 orcish arrows
       #|{..........#######|...... G - a battle-axe
       #------------       |...... P - 7 ya
       ###                 ------- Armor
         ##                        c - an uncursed +0 ring mail (being worn)
          #                        E - a splint mail
          #                        Comestibles
    ------#                        d - an uncursed food ration
    |.....#                        f - 6 food rations
    |....|                         h - 2 sprigs of wolfsbane
    |....|                         i - a cream pie
    |....-###                      k - 3 tripe rations
    |.<..|  ######  ############## Scrolls
    |.d@..######################## r - a scroll labeled ETAOIN SHRDLU
    ------                 ####    u - a scroll labeled PHOL ENDE WODAN
                              #### z - a scroll labeled XIXAXA XOXAXA XUXAXA
                                   Spellbooks
Wizard the Plunderer           St: o - a tan spellbook
Dlvl:1 $:0 HP:16(16) Pw:2(2) AC:7  q - a wrinkled spellbook
                                   v - a thin spellbook
---------------------------------- x - a plain spellbook
|a - +0 two-handed sword (weapon i y - a tan spellbook
|b - +0 axe (alternate weapon; not H - an indigo spellbook
|c - uncursed +0 ring mail (being  W - a light blue spellbook
|d - uncursed food ration          X - a velvet spellbook
|e - uncursed oil lamp             Potions
|f - 6 food rations                g - a brilliant blue potion
|g - brilliant blue potion         j - a fizzy potion
|h - 2 sprigs of wolfsbane         m - an effervescent potion
|i - cream pie                     B - 2 golden potions
|j - fizzy potion                  D - a dark green potion
|k - 3 tripe rations               I - a bubbly potion
|l - moonstone ring                Rings
|m - effervescent potion           l - a moonstone ring
|n - tiger eye ring                n - a tiger eye ring
|o - tan spellbook                 Y - a topaz ring
|p - tinning kit                   Wands
|q - wrinkled spellbook            s - a crystal wand
|r - scroll labeled ETAOIN SHRDLU  Tools
|s - crystal wand                  e - an uncursed oil lamp
|t - oil lamp                      p - a tinning kit
|u - scroll labeled PHOL ENDE WODA t - an oil lamp
|v - thin spellbook                A - a stethoscope
|w - 7 orcish arrows               C - a bugle
|x - plain spellbook               F - an oil lamp
|y - tan spellbook                 Gems/Stones
|z - scroll labeled XIXAXA XOXAXA  L - 4 blue gems
---------------------------------- (1 of 2)

===========================================================================
BEFORE THIS PATCH - menu Page 2

While the second page is displayed, there are gaping missing portions of
the map, status lines, and now the tty perm_invent window.
===========================================================================

                                   V - a white gem
                                   (2 of 2)
        ------------
        |..........|       -------
        |..........|       |......
       #...........|      #.......
       #|{..........#######|......
       #------------       |......
       ###                 -------
         ##
          #
          #
    ------#
    |.....#
    |....|
    |....|
    |....-###
    |.<..|  ######  ##############
    |.d@..########################
    ------                 ####
                              ####

Wizard the Plunderer           St:
Dlvl:1 $:0 HP:16(16) Pw:2(2) AC:7

----------------------------------
|a - +0 two-handed sword (weapon i
|b - +0 axe (alternate weapon; not
|c - uncursed +0 ring mail (being
|d - uncursed food ration
|e - uncursed oil lamp
|f - 6 food rations
|g - brilliant blue potion
|h - 2 sprigs of wolfsbane
|i - cream pie
|j - fizzy potion
|k - 3 tripe rations
|l - moonstone ring
|m - effervescent potion
|n - tiger eye ring
|o - tan spellbook
|p - tinning kit
|q - wrinkled spellbook
|r - scroll labeled ETAOIN SHRDLU
|s - crystal wand
|t - oil lamp
|u - scroll labeled PHOL ENDE WODA
|v - thin spellbook
|w - 7 orcish arrows
|x - plain spellbook
|y - tan spellbook
|z - scroll labeled XIXAXA XOXAXA
----------------------------------

===========================================================================
AFTER THIS PATCH - menu Page 2

The obliterated content of the map, status lines, and tty perm_invent
are refreshed prior to displaying menu Page 2.
===========================================================================

                                   V - a white gem
                                   (2 of 2)
        ------------                                    ----------------
        |..........|       ---------------             #...............|
        |..........|       |.............|             #|..............|
       #...........|      #..............|             #|........^.....|
       #|{..........#######|.........{...|             #-+--------------
       #------------       |.............|             ###############
       ###                 -------------.-                #          #
         ##                             #                 #          #####
          #                            ##       ----------#      --------.-
          #                            #       #+........|#      |........|
    ------#                            #     ###|.........#      |........|
    |.....#                          # #     #  |...>....|   ####.........|
    |....|                         ----.--######..........####   |........|
    |....|                         |.....|#     ----------       |........|
    |....-###                      |.....|#             #        |........|
    |.<..|  ######  ###############+......#                      ----------
    |.d@..#########################|.....|#
    ------                 ####    -------#
                              #############

Wizard the Plunderer           St:18/01 Dx:16 Co:18 In:8 Wi:8 Ch:6 Chaotic
Dlvl:1 $:0 HP:16(16) Pw:2(2) AC:7 Xp:1 Stressed

------------------------------------------------------------------------------
|a - +0 two-handed sword (weapon in hands|A - stethoscope                    |
|b - +0 axe (alternate weapon; not wielde|B - 2 golden potions               |
|c - uncursed +0 ring mail (being worn)  |C - bugle                          |
|d - uncursed food ration                |D - dark green potion              |
|e - uncursed oil lamp                   |E - splint mail                    |
|f - 6 food rations                      |F - oil lamp                       |
|g - brilliant blue potion               |G - battle-axe                     |
|h - 2 sprigs of wolfsbane               |H - indigo spellbook               |
|i - cream pie                           |I - bubbly potion                  |
|j - fizzy potion                        |J - circular amulet                |
|k - 3 tripe rations                     |L - 4 blue gems                    |
|l - moonstone ring                      |P - 7 ya                           |
|m - effervescent potion                 |V - white gem                      |
|n - tiger eye ring                      |W - light blue spellbook           |
|o - tan spellbook                       |X - velvet spellbook               |
|p - tinning kit                         |Y - topaz ring                     |
|q - wrinkled spellbook                  |                                   |
|r - scroll labeled ETAOIN SHRDLU        |                                   |
|s - crystal wand                        |                                   |
|t - oil lamp                            |                                   |
|u - scroll labeled PHOL ENDE WODAN      |                                   |
|v - thin spellbook                      |                                   |
|w - 7 orcish arrows                     |                                   |
|x - plain spellbook                     |                                   |
|y - tan spellbook                       |                                   |
|z - scroll labeled XIXAXA XOXAXA XUXAXA |                                   |
------------------------------------------------------------------------------

include/wintty.h
win/tty/topl.c
win/tty/wintty.c

index 55d86f61a6e7baedae987e2ae34c8e1821d42bfd..552684d4c9f82052ba4ca46e99cc3a123832487a 100644 (file)
@@ -208,7 +208,7 @@ E void putsyms(const char *);
 #ifdef CLIPPING
 E void setclipped(void);
 #endif
-E void docorner(int, int);
+E void docorner(int, int, int);
 E void end_glyphout(void);
 E void g_putch(int);
 #ifdef ENHANCED_SYMBOLS
index fecdf665e3c248da37fb004628a04cda90d51560..69f965e927d9586b027f008176d5e0410399a115 100644 (file)
@@ -233,7 +233,7 @@ more(void)
     }
 
     if (ttyDisplay->toplin && cw->cury) {
-        docorner(1, cw->cury + 1);
+        docorner(1, cw->cury + 1, 0);
         cw->curx = cw->cury = 0;
         home();
     } else if (morc == '\033') {
@@ -271,8 +271,8 @@ update_topl(register const char *bp)
         if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
             more();
         } else if (cw->cury) { /* for toplin==TOPLINE_NON_EMPTY && cury > 1 */
-            docorner(1, cw->cury + 1); /* reset cury = 0 if redraw screen */
-            cw->curx = cw->cury = 0;   /* from home--cls() & docorner(1,n) */
+            docorner(1, cw->cury + 1, 0); /* reset cury = 0 if redraw screen */
+            cw->curx = cw->cury = 0;   /* from home--cls() & docorner(1,n,0) */
         }
     }
     remember_topl();
index 96d590ef9ea95ab0a8a6bed11ce1b6a29c3b5723..4f94704aec6c34ef2cd96820d21231d4a1dda9c4 100644 (file)
@@ -1758,7 +1758,7 @@ erase_menu_or_text(winid window, struct WinDesc *cw, boolean clear)
             flush_screen(1);
         }
     } else {
-        docorner((int) cw->offx, cw->maxrow + 1);
+        docorner((int) cw->offx, cw->maxrow + 1, 0);
     }
 }
 
@@ -1829,7 +1829,7 @@ tty_clear_nhwindow(winid window)
             home();
             cl_end();
             if (cw->cury)
-                docorner(1, cw->cury + 1);
+                docorner(1, cw->cury + 1, 0);
             ttyDisplay->toplin = TOPLINE_EMPTY;
         }
         break;
@@ -2092,7 +2092,7 @@ process_menu_window(winid window, struct WinDesc *cw)
 {
     tty_menu_item *page_start, *page_end, *curr;
     long count;
-    int n, attr_n, curr_page, page_lines, resp_len;
+    int n, attr_n, curr_page, page_lines, resp_len, previous_page_lines;
     boolean finished, counting, reset_count;
     char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], *msave, *morestr, really_morc;
 #define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
@@ -2105,6 +2105,7 @@ process_menu_window(winid window, struct WinDesc *cw)
     count = 0L;
     reset_count = TRUE;
     finished = FALSE;
+    previous_page_lines = 0;
 
     /* collect group accelerators; for PICK_NONE, they're ignored;
        for PICK_ONE, only those which match exactly one entry will be
@@ -2244,8 +2245,16 @@ process_menu_window(winid window, struct WinDesc *cw)
                     tty_curs(window, 1, n);
                     cl_end();
                 }
+                /*
+                 * If this corner menu was big, there are likely large
+                 * portions of the map, status window, and tty perm_invent
+                 * window (is there is one), that are all missing a lot of
+                 * information. Let's repair the blacked-out rows now
+                 * because it looks better.
+                 */
+                if (previous_page_lines != 0 && page_lines < previous_page_lines)
+                    docorner((int) cw->offx, cw->maxrow + 1, page_lines + 3);
             }
-
             /* set extra chars.. */
             Strcat(resp, default_menu_cmds);
             Strcat(resp, " ");                  /* next page or end */
@@ -2333,6 +2342,7 @@ process_menu_window(winid window, struct WinDesc *cw)
         case ' ':
         case MENU_NEXT_PAGE:
             if (cw->npages > 0 && curr_page != cw->npages - 1) {
+                previous_page_lines = page_lines;
                 curr_page++;
                 page_start = 0;
             } else if (morc == ' ') {
@@ -3820,10 +3830,17 @@ tty_wait_synch(void)
 }
 
 void
-docorner(register int xmin, register int ymax)
+docorner(register int xmin, register int ymax, int ystart_between_menu_pages)
 {
     register int y;
     register struct WinDesc *cw = wins[WIN_MAP];
+#ifdef TTY_PERM_INVENT
+    struct WinDesc *icw = 0;
+    int ystart = 0;
+
+    if (g.tty_invent_win != WIN_ERR)
+        icw = wins[g.tty_invent_win];
+#endif
 
     HUPSKIP();
 #if 0   /* this optimization is not valuable enough to justify
@@ -3842,16 +3859,18 @@ docorner(register int xmin, register int ymax)
     if (ymax > LI)
         ymax = LI; /* can happen if window gets smaller */
 #endif
-    for (y = 0; y < ymax; y++) {
+    if (ystart_between_menu_pages)
+        ystart = ystart_between_menu_pages;
+
+    for (y = ystart; y < ymax; y++) {
         tty_curs(BASE_WINDOW, xmin, y); /* move cursor */
-        cl_end();                       /* clear to end of line */
+        if (!ystart_between_menu_pages)
+            cl_end();                   /* clear to end of line */
 #ifdef TTY_PERM_INVENT
         /* the whole thing is beyond the board */
-        if (g.tty_invent_win != WIN_ERR && WINDOWPORT("tty")) {
-            struct WinDesc *icw = wins[g.tty_invent_win];
+        if (icw)
             tty_refresh_inventory(xmin - (int) icw->offx, icw->maxcol,
                                   y - (int) icw->offy);
-        }
 #endif
 #ifdef CLIPPING
         if (y < (int) cw->offy || y + clipy > ROWNO)