keep perm_invent option

Make it apparent why tty perm_invent can't be set in-game
if the terminal cannot support it.
This commit is contained in:
nhmall
2022-06-20 13:43:50 -04:00
parent cb0dd7af3f
commit 8fca10029a
3 changed files with 42 additions and 20 deletions

View 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

View 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 */