replace getenv("TTYINV") with perminv_mode option

Add a new option 'perminv_mode' to augment perm_invent.  It handles
the same choices as the temporary TTYINV method:  show all items other
than gold, show full inventory including gold, or only show in-use
items (similar to the '*' command).

For tty, both the all-except-gold and full-inventory modes can add
the poorly named 'sparse' variation which populates unused slots in
its fixed grid with the inventory letter that would go in each.

For others, the default has been changed from full-inventory to
all-except-gold.  Note that gold is treated as part of 'all' or of
'in-use' if it is quivered because having the amount be shown on the
status line doesn't make that redundant.

Changing the default may mess up WinGUI if it assumes that perm_invent
is full inventory with gold.

Initially I was going to change perm_invent into a compound but this
leaves it as an on/off toggle and adds perminv_mode as a separate
option for how to show the inventory when the toggle is on.  It may
make sense to combine them since dual controls is a little confusing,
but right now setting perm_invent On when perminv_mode is 'none'
changes that to 'all' and changing perminv_mode away from 'none' when
perm_invent is Off toggles it to On.

Guidebook.mn has been updated but as usual Guidebook.tex is lagging.
This commit is contained in:
PatR
2023-11-05 02:31:26 -08:00
parent e16f80395b
commit 2ee7509945
8 changed files with 369 additions and 79 deletions

View File

@@ -2800,10 +2800,9 @@ win_request_info *
tty_ctrl_nhwindow(winid window UNUSED, int request, win_request_info *wri)
{
#if !defined(TTY_PERM_INVENT)
wri = (win_request_info *) 0;
nhUse(window);
nhUse(request);
nhUse(wri);
return (win_request_info *) 0;
#else
boolean tty_ok /*, show_gold */, inuse_only;
int maxslot;
@@ -2831,18 +2830,24 @@ tty_ctrl_nhwindow(winid window UNUSED, int request, win_request_info *wri)
wri->tocore.haverows = (int) ttyDisplay->rows;
wri->tocore.havecols = (int) ttyDisplay->cols;
if (!tty_ok) {
wri->tocore.tocore_flags |= prohibited; /* prohibited */
#ifdef RESIZABLE
/* terminal isn't big enough right now but player might resize it
and then use 'm O' to try to set 'perm_invent' again */
wri->tocore.tocore_flags |= too_small;
#else
wri->tocore.tocore_flags |= prohibited;
#endif
} else {
maxslot = (maxrow - 2) * (!inuse_only ? 2 : 1);
wri->tocore.maxslot = maxslot;
}
break;
default:
impossible("invalid request to tty_update_invent_slot %u", request);
impossible("invalid request to tty_ctrl_nhwindow: %d", request);
break;
}
return wri;
#endif
return wri;
}
#ifdef TTY_PERM_INVENT
@@ -3023,6 +3028,13 @@ ttyinv_add_menu(
if (text[1] == 'h' && text[2] == 'e' && text[3] == ' ')
text += 4;
}
/*
* TODO?
* Replace "c - " prefix with "c: " or just "c " to have a bit more
* room for 'text' (the item description). If this prefix gets
* changed, the indentation for empty inventory in ttyinv_render()
* should be changed to match.
*/
Snprintf(invbuf, sizeof invbuf, "%c - %s", ch, text);
text = invbuf;
row = (slot % rows_per_side) + 1; /* +1: top border */