]> granicus.if.org Git - nethack/commitdiff
keep perm_invent option
authornhmall <nhmall@nethack.org>
Mon, 20 Jun 2022 17:43:50 +0000 (13:43 -0400)
committernhmall <nhmall@nethack.org>
Mon, 20 Jun 2022 17:43:50 +0000 (13:43 -0400)
Make it apparent why tty perm_invent can't be set in-game
if the terminal cannot support it.

src/allmain.c
src/options.c
win/tty/wintty.c

index 00aef71775b1aa2283253f0c4eef22ee5197bd22..a39f5d21638bdda4d73d8850561121922a1433e8 100644 (file)
@@ -636,7 +636,7 @@ display_gamewindows(void)
     start_menu(WIN_INVEN, 0U), end_menu(WIN_INVEN, (char *) 0);
 
 #ifdef TTY_PERM_INVENT
-    if (WINDOWPORT("tty")) {
+    if (WINDOWPORT("tty") && iflags.perm_invent) {
         g.tty_invent_win = create_nhwindow(NHW_TTYINVENT);
     }
 #endif
index ec8886fcff83854b895735e7a2fd9badb4344bef..37281bb6632bde1461673971219c96506cc6cea0 100644 (file)
@@ -306,6 +306,7 @@ static int handle_add_list_remove(const char *, int);
 static void remove_autopickup_exception(struct autopickup_exception *);
 static int count_apes(void);
 static int count_cond(void);
+static void enhance_menu_text(char *, size_t, int, boolean *, struct allopt_t *);
 
 static int handler_align_misc(int);
 static int handler_autounlock(int);
@@ -7759,10 +7760,11 @@ doset(void) /* changing options via menu by Per Liboriussen */
                 else
                     Sprintf(buf, fmtstr_doset_tab,
                             name, *bool_p ? "true" : "false");
+                if (pass == 0)
+                    enhance_menu_text(buf, sizeof buf, pass, bool_p, &allopt[i]);
                 add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
                          ATR_NONE, buf, MENU_ITEMFLAGS_NONE);
             }
-
     any = cg.zeroany;
     add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
              ATR_NONE, "", MENU_ITEMFLAGS_NONE);
@@ -8895,6 +8897,30 @@ set_playmode(void)
     }
     /* don't need to do anything special for explore mode or normal play */
 }
+void
+enhance_menu_text(
+    char *buf,
+    size_t sz,
+    int whichpass,
+    boolean *bool_p,
+    struct allopt_t *thisopt)
+{
+    size_t nowsz, availsz;
+
+    if (!buf)
+        return;
+    nowsz = strlen(buf) + 1;
+    availsz = sz - nowsz;
+
+#ifdef TTY_PERM_INVENT
+    if (bool_p == &iflags.perm_invent && WINDOWPORT("tty")) {
+        if (thisopt->setwhere == set_gameview)
+            Snprintf(eos(buf), availsz, " *terminal size is too small");
+    }
+#endif
+    return;
+}
+
 
 #endif /* OPTION_LISTS_ONLY */
 
index 72a465d7d96a0fa639098cad22d11381e911b81b..e1fe089e9f6fecb7055d04cadf3157c875a1af33 100644 (file)
@@ -1623,31 +1623,27 @@ tty_create_nhwindow(int type)
         newwin->datlen = (short *) 0;
         newwin->cells = (struct tty_perminvent_cell **) 0;
 
+        if ((newwin->rows < tty_pi_minrow) || (newwin->cols < tty_pi_mincol)) {
         if (newwin->rows < tty_pi_minrow) {
             tty_destroy_nhwindow(newid);
-            if (iflags.perm_invent) {
-                raw_printf("tty perm_invent has been disabled.");
-                raw_printf(
-                    "tty perm_invent requires %d rows, your terminal has %d.",
-                    (iflags.wc2_statuslines > 2) ? 54 : 53, ttyDisplay->rows);
-                iflags.perm_invent = FALSE;
-            }
-            return WIN_ERR;
-        } else if (newwin->cols < tty_pi_mincol) {
-            tty_destroy_nhwindow(newid);
-            if (iflags.perm_invent) {
-                raw_printf("tty perm_invent has been disabled.");
-                raw_printf(
-                    "tty perm_invent requires %d columns, your terminal has %d.",
-                    tty_pi_mincol, ttyDisplay->cols);
-                iflags.perm_invent = FALSE;
+            if (!g.program_state.beyond_savefile_load)
+               raw_printf("tty perm_invent could not be enabled.");
+                if (newwin->rows < tty_pi_minrow)
+                    raw_printf(
+                "tty perm_invent requires %d rows, your terminal has %d.",
+                                (iflags.wc2_statuslines > 2) ? 54 : 53,
+                                ttyDisplay->rows);
+                else
+                   raw_printf(
+                "tty perm_invent requires %d columns, your terminal has %d.",
+                          tty_pi_mincol, ttyDisplay->cols);
             }
+            set_option_mod_status("perm_invent", set_gameview);
+            iflags.perm_invent = FALSE;
             return WIN_ERR;
         } else {
             int r, c;
 
-            iflags.perm_invent = TRUE;
-
             newwin->maxrow = tty_pi_minrow;
             newwin->maxcol = newwin->cols;
             /* establish the borders */