\#perminv, 2 of 2: implementation
Add new '|' command, aka #perminv, which allows the player to
send menu scrolling keystrokes to the persistent inventory window.
Implemented for X11, where its usefulness is limited, and for
curses, where it is more needed and also more fully functional.
The interface can either prompt for one keystroke, act upon it,
and return to normal play, or it can loop for multiple keystrokes
until player types <return> or <escape>. X11 does the former if
the 'slow' application resource is False so that prompting uses
popups, and the latter when 'slow' is True where prompting is in
a fixed spot and doesn't end up causing the persistent inventory
window to be stacked behind the map window. curses always does
the loop-until-done approach. It also accepts up and down arrow
keys to scroll one line at a time.
Also adds two new menu scrolling commands, menu_shift_right (key
'}' by default) and menu_shift_left ('{') if wincap2 flags contain
WC2_MENU_SHIFT. Shifting allows different substrings of too-long
lines to be seen.
For X11, neither works because their handling requires a horizontal
scrollbar and for some reason that escapes me our menus don't have
one of those. If they did, shifts could work for all menus but a
shifted window would hide the selection letters. So shifting would
be most usefully done as: pan right, read more of any long lines,
immediately pan back to the left.
For curses, they only apply to the persistent inventory window.
Shift right redraws it with class headers and inventory letters
shown normally but the item descriptions omit their leftmost
portion, showing more text towards the end. Shift left reverses
that and does nothing if the beginning is already in view. Forward
and backward scrolling while shifted leave the shift in place.
This commit is contained in:
@@ -48,7 +48,7 @@ struct window_procs curses_procs = {
|
||||
#endif
|
||||
| WC2_FLUSH_STATUS | WC2_TERM_SIZE
|
||||
| WC2_STATUSLINES | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR
|
||||
| WC2_SUPPRESS_HIST),
|
||||
| WC2_SUPPRESS_HIST | WC2_MENU_SHIFT),
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||
curses_init_nhwindows,
|
||||
curses_player_selection,
|
||||
@@ -436,6 +436,7 @@ curses_destroy_nhwindow(winid wid)
|
||||
curses_status_finish(); /* discard cached status data */
|
||||
break;
|
||||
case INV_WIN:
|
||||
curs_purge_perminv_data(TRUE);
|
||||
iflags.perm_invent = 0; /* avoid unexpected update_inventory() */
|
||||
break;
|
||||
case MAP_WIN:
|
||||
@@ -568,7 +569,7 @@ curses_add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
/* persistent inventory window; nothing is selectable;
|
||||
omit glyphinfo because perm_invent is to the side of
|
||||
the map so usually cramped for space */
|
||||
curses_add_inv(inv_update, accelerator, curses_attr, str);
|
||||
curs_add_invt(inv_update, accelerator, curses_attr, str);
|
||||
inv_update++;
|
||||
return;
|
||||
}
|
||||
@@ -631,24 +632,34 @@ curses_select_menu(winid wid, int how, MENU_ITEM_P ** selected)
|
||||
}
|
||||
|
||||
void
|
||||
curses_update_inventory(int arg UNUSED)
|
||||
curses_update_inventory(int arg)
|
||||
{
|
||||
/* Don't do anything if perm_invent is off unless it was on and
|
||||
player just changed the option. */
|
||||
if (!iflags.perm_invent) {
|
||||
if (curses_get_nhwin(INV_WIN)) {
|
||||
curs_reset_windows(TRUE, FALSE);
|
||||
curs_purge_perminv_data(FALSE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update inventory sidebar. NetHack uses normal menu functions
|
||||
when drawing the inventory, and we don't want to change the
|
||||
underlying code. So instead, track if an inventory update is
|
||||
being performed with a static variable. */
|
||||
inv_update = 1;
|
||||
curses_update_inv();
|
||||
inv_update = 0;
|
||||
/* skip inventory updating during character initialization */
|
||||
if (!g.program_state.in_moveloop && !g.program_state.gameover)
|
||||
return;
|
||||
|
||||
if (!arg) {
|
||||
/* Update inventory sidebar. NetHack uses normal menu functions
|
||||
when gathering the inventory, and we don't want to change the
|
||||
underlying code. So instead, track if an inventory update is
|
||||
being performed with a static variable. */
|
||||
inv_update = 1;
|
||||
curs_update_invt(0);
|
||||
inv_update = 0;
|
||||
} else {
|
||||
/* perform scrolling operations on persistent inventory window */
|
||||
curs_update_invt(arg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user