curses persistent inventory window tweak
Under curses interface, provide a way to get a little more space for perm_invent without turning off windowborders entirely. Possible 'windowborders' values: 0 = no borders, max screen space available for useful info 1 = full borders, two lines and two columns wasted for each window 2 = contingent borders, show if screen is big enough, else hide New: 3 = as 1 except no borders for perm_invent window 4 = as 2 except never borders for perm_invent window 3 and 4 let the map, message, and status windows have borders while providing two extra lines and two extra columns on each line for persistent inventory. It's not much but better than nothing when borders are enabled.
This commit is contained in:
@@ -115,20 +115,27 @@ curses_create_main_windows(void)
|
||||
int status_orientation = 0;
|
||||
int border_space = 0;
|
||||
int hspace = term_cols - 80;
|
||||
boolean borders = FALSE;
|
||||
boolean borders = FALSE, noperminv_borders = FALSE;
|
||||
|
||||
switch (iflags.wc2_windowborders) {
|
||||
default:
|
||||
case 0: /* Off */
|
||||
borders = FALSE;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
noperminv_borders = TRUE;
|
||||
/*FALLTHRU*/
|
||||
case 1: /* On */
|
||||
borders = TRUE;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
noperminv_borders = TRUE;
|
||||
/*FALLTHRU*/
|
||||
case 2: /* Auto */
|
||||
borders = (term_cols > 81 && term_rows > 25);
|
||||
borders = (term_cols >= 80 + 2 && term_rows >= 24 + 2);
|
||||
break;
|
||||
default:
|
||||
borders = FALSE;
|
||||
}
|
||||
|
||||
if (borders) {
|
||||
@@ -228,6 +235,9 @@ curses_create_main_windows(void)
|
||||
ALIGN_RIGHT, &map_x, &map_y,
|
||||
&map_width, &map_height,
|
||||
border_space, -1, width);
|
||||
/* suppress borders on perm_invent window, part I */
|
||||
if (noperminv_borders)
|
||||
inv_width += border_space, inv_height += border_space; /*+=2*/
|
||||
}
|
||||
|
||||
if (msg_vertical)
|
||||
@@ -276,7 +286,9 @@ curses_create_main_windows(void)
|
||||
|
||||
if (iflags.perm_invent)
|
||||
curses_add_nhwin(INV_WIN, inv_height, inv_width, inv_y, inv_x,
|
||||
ALIGN_RIGHT, borders);
|
||||
ALIGN_RIGHT,
|
||||
/* suppress perm_invent borders, part II */
|
||||
borders && !noperminv_borders);
|
||||
|
||||
curses_add_nhwin(MAP_WIN, map_height, map_width,
|
||||
map_y, map_x, 0, borders);
|
||||
|
||||
@@ -55,8 +55,7 @@ curses_update_inv(void)
|
||||
|
||||
/* Adds an inventory item. 'y' is 1 rather than 0 for the first item. */
|
||||
void
|
||||
curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
|
||||
attr_t attr, const char *str)
|
||||
curses_add_inv(int y, char accelerator, attr_t attr, const char *str)
|
||||
{
|
||||
WINDOW *win = curses_get_nhwin(INV_WIN);
|
||||
int color = NO_COLOR;
|
||||
@@ -70,12 +69,8 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
|
||||
curses_get_window_size(INV_WIN, &height, &width);
|
||||
/*
|
||||
* TODO:
|
||||
* If border is On and 'y' is too big, turn border Off in order to
|
||||
* get two more lines of perm_invent.
|
||||
*
|
||||
* And/or implement a way to switch focus from map to inventory
|
||||
* so that the latter can be scrolled. Must not require use of a
|
||||
* mouse.
|
||||
* Implement a way to switch focus from map to inventory so that
|
||||
* the latter can be scrolled. Must not require use of a mouse.
|
||||
*
|
||||
* Also, when entries are omitted due to lack of space, mark the
|
||||
* last line to indicate "there's more that you can't see" (like
|
||||
@@ -88,28 +83,22 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
|
||||
|
||||
wmove(win, y, x);
|
||||
if (accelerator) {
|
||||
#if 0
|
||||
attr_t bold = A_BOLD;
|
||||
|
||||
wattron(win, bold);
|
||||
waddch(win, accelerator);
|
||||
wattroff(win, bold);
|
||||
wprintw(win, ") ");
|
||||
#else
|
||||
/* despite being shown as a menu, nothing is selectable from the
|
||||
persistent inventory window so don't highlight inventory letters */
|
||||
persistent inventory window so avoid the usual highlighting of
|
||||
inventory letters */
|
||||
wprintw(win, "%c) ", accelerator);
|
||||
#endif
|
||||
available_width -= 3; /* letter+parenthesis+space */
|
||||
|
||||
/* narrow the entries to fit more of the interesting text; do so
|
||||
unconditionally rather than trying to figure whether it's needed;
|
||||
when 'sortpack' is enabled we could also strip out "<class> of"
|
||||
from "<prefix><class> of <item><suffix> but if that's to be done,
|
||||
core ought to do it;
|
||||
'stroffset': defer skipping the article prefix until after menu
|
||||
color pattern matching has taken place so that the persistent
|
||||
inventory window always gets same coloring as regular inventory */
|
||||
/*
|
||||
* Narrow the entries to fit more of the interesting text. Do so
|
||||
* unconditionally rather than trying to figure whether it's needed.
|
||||
* When 'sortpack' is enabled we could also strip out "<class> of"
|
||||
* from "<prefix><class> of <item><suffix> but if that's to be done,
|
||||
* the core ought to do it.
|
||||
*
|
||||
* 'stroffset': defer skipping the article prefix until after menu
|
||||
* color pattern matching has taken place so that the persistent
|
||||
* inventory window always gets same coloring as regular inventory.
|
||||
*/
|
||||
if (!strncmpi(str, "a ", 2))
|
||||
stroffset = 2;
|
||||
else if (!strncmpi(str, "an ", 3))
|
||||
@@ -117,24 +106,8 @@ curses_add_inv(int y, const glyph_info *glyphinfo UNUSED, char accelerator,
|
||||
else if (!strncmpi(str, "the ", 4))
|
||||
stroffset = 4;
|
||||
}
|
||||
#if 0 /* FIXME: MENU GLYPHS */
|
||||
if (accelerator && iflags.use_menu_glyphs
|
||||
&& glyphinfo->glyph != NO_GLYPH ) {
|
||||
int symbol;
|
||||
attr_t glyphclr;
|
||||
|
||||
symbol = glyphinfo->ttychar;
|
||||
color = glyphinfo->color;
|
||||
|
||||
glyphclr = curses_color_attr(color, 0);
|
||||
wattron(win, glyphclr);
|
||||
wprintw(win, "%c ", symbol);
|
||||
wattroff(win, glyphclr);
|
||||
available_width -= 2;
|
||||
}
|
||||
#endif
|
||||
if (accelerator /* Don't colorize categories */
|
||||
&& iflags.use_menu_color) {
|
||||
/* only perform menu coloring on item entries, not subtitles */
|
||||
if (accelerator && iflags.use_menu_color) {
|
||||
attr = 0;
|
||||
get_menu_coloring(str, &color, (int *) &attr);
|
||||
attr = curses_convert_attr(attr);
|
||||
|
||||
@@ -543,7 +543,7 @@ add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
*/
|
||||
void
|
||||
curses_add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
const ANY_P * identifier,
|
||||
const ANY_P *identifier,
|
||||
char accelerator, char group_accel, int attr,
|
||||
const char *str, unsigned itemflags)
|
||||
{
|
||||
@@ -553,12 +553,16 @@ curses_add_menu(winid wid, const glyph_info *glyphinfo,
|
||||
curses_attr = curses_convert_attr(attr);
|
||||
|
||||
if (inv_update) {
|
||||
curses_add_inv(inv_update, glyphinfo, accelerator, curses_attr, str);
|
||||
/* 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);
|
||||
inv_update++;
|
||||
return;
|
||||
}
|
||||
|
||||
curses_add_nhmenu_item(wid, glyphinfo, identifier, accelerator, group_accel,
|
||||
curses_add_nhmenu_item(wid, glyphinfo, identifier,
|
||||
accelerator, group_accel,
|
||||
curses_attr, str, itemflags);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user