merge new use_menu_glyphs option with menu_objsyms

The two options are very similar but probably mutually exclusive
except when using look-here and look-into-container (both via ':')
with the default setting for 'sortloot', or with inventory when
'sortpack' has been toggled off.

This removes 'use_menu_glyphs' and changes 'menu_objsyms' from a
boolean to a compound taking six possible values:
| 0: no object symbols in menus,
| 1: append object class symbol to object header lines (same as old
|menu_objsyms boolean),
| 2: include object symbol in menu entry lines for objects (same as
|recently added use_menu_glyphs),
| 3: both 1 and 2,
| 4: display as #2 but only if the menu lacks class header lines,
| 5: if header lines are present, display as #1; if headers are not
|present, then display as #4 (which will implicitly be #2).
Default is #4.

Effectively replaces the options portion of pull request #1406 and
retains the functionality, but not as default for normal menus.

Guidebook.tex is only partially updated.  Someone else will need to
finish that.
This commit is contained in:
PatR
2025-04-28 18:12:02 -07:00
parent ba4f90eefb
commit a587ccaa26
8 changed files with 281 additions and 33 deletions

View File

@@ -60,6 +60,7 @@ typedef struct nhm {
unsigned long mbehavior; /* menu flags */
boolean reuse_accels; /* Non-unique accelerators per page */
boolean bottom_heavy; /* display multi-page menu starting at end */
boolean show_obj_syms; /* handle iflags.menuobjsyms */
struct nhm *prev_menu; /* Pointer to previous menu */
struct nhm *next_menu; /* Pointer to next menu */
} nhmenu;
@@ -552,6 +553,7 @@ curses_create_nhmenu(winid wid, unsigned long mbehavior)
new_menu->mbehavior = mbehavior;
new_menu->reuse_accels = FALSE;
new_menu->bottom_heavy = FALSE;
new_menu->show_obj_syms = FALSE;
return;
}
@@ -565,6 +567,7 @@ curses_create_nhmenu(winid wid, unsigned long mbehavior)
new_menu->mbehavior = mbehavior;
new_menu->reuse_accels = FALSE;
new_menu->bottom_heavy = FALSE;
new_menu->show_obj_syms = FALSE;
new_menu->next_menu = NULL;
if (nhmenus == NULL) { /* no menus in memory yet */
@@ -1029,6 +1032,18 @@ menu_win_size(nhmenu *menu)
int maxentrywidth = 0;
int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0;
nhmenu_item *menu_item_ptr, *last_item_ptr = NULL;
boolean only_if_no_headers = (iflags.menuobjsyms & 4) != 0;
/* check entire menu rather than one page at a time */
menu->show_obj_syms = iflags.use_menu_glyphs;
if (only_if_no_headers) {
for (menu_item_ptr = menu->entries; menu_item_ptr != NULL;
menu_item_ptr = menu_item_ptr->next_item)
if (menu_item_ptr->identifier.a_void == 0) {
menu->show_obj_syms = FALSE;
break;
}
}
#if 0 /* maxwidth is set below, so the value calculated here isn't used */
if (program_state.gameover) {
@@ -1061,7 +1076,7 @@ menu_win_size(nhmenu *menu)
/* Add space for accelerator (selector letter) */
curentrywidth += 4;
if (menu_item_ptr->glyphinfo.glyph != NO_GLYPH
&& iflags.use_menu_glyphs)
&& menu->show_obj_syms)
curentrywidth += 2;
}
if (curentrywidth > maxentrywidth) {
@@ -1282,10 +1297,11 @@ menu_display_page(
start_col += 4;
}
if (menu_item_ptr->glyphinfo.glyph != NO_GLYPH
&& iflags.use_menu_glyphs) {
&& menu->show_obj_syms) {
color = menu_item_ptr->glyphinfo.gm.sym.color;
curses_toggle_color_attr(win, color, NONE, ON);
mvwaddch(win, menu_item_ptr->line_num + 1, start_col, menu_item_ptr->glyphinfo.ttychar);
mvwaddch(win, menu_item_ptr->line_num + 1, start_col,
menu_item_ptr->glyphinfo.ttychar);
curses_toggle_color_attr(win, color, NONE, OFF);
mvwaddch(win, menu_item_ptr->line_num + 1, start_col + 1, ' ');
entry_cols -= 2;

View File

@@ -1330,7 +1330,8 @@ process_menu_window(winid window, struct WinDesc *cw)
tty_menu_item *page_start, *page_end, *curr;
long count;
int n, attr_n, curr_page, page_lines, resp_len, previous_page_lines;
boolean finished, counting, reset_count;
boolean finished, counting, reset_count, show_obj_syms,
only_if_no_headers = (iflags.menuobjsyms & 4) != 0;
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], *msave, *morestr, really_morc;
#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
@@ -1378,6 +1379,15 @@ process_menu_window(winid window, struct WinDesc *cw)
}
resp_len = 0; /* lint suppression */
show_obj_syms = iflags.use_menu_glyphs;
if (only_if_no_headers) {
for (curr = cw->mlist; curr; curr = curr->next)
if (curr->identifier.a_void == 0) {
show_obj_syms = FALSE;
break;
}
}
/* loop until finished */
while (!finished) {
HUPSKIP();
@@ -1432,7 +1442,7 @@ process_menu_window(winid window, struct WinDesc *cw)
if (curr->str[0] && curr->str[1] == ' '
&& curr->str[2] && strchr("-+#", curr->str[2])
&& curr->str[3] == ' ')
/* [0]=letter, [1]==space, [2]=[-+#], [3]=space */
/* [0]=letter, [1]=space, [2]=[-+#], [3]=space */
attr_n = 4; /* [4:N]=entry description */
/*
@@ -1454,15 +1464,14 @@ process_menu_window(winid window, struct WinDesc *cw)
if (n == attr_n && (color != NO_COLOR
|| attr != ATR_NONE))
toggle_menu_attr(TRUE, color, attr);
if (n == 2
&& curr->identifier.a_void != 0
if (n == 2 && curr->identifier.a_void != 0
&& curr->selected) {
if (curr->count == -1L)
(void) putchar('+'); /* all selected */
else
(void) putchar('#'); /* count selected */
} else if (iflags.use_menu_glyphs && n == 2
&& curr->identifier.a_void != 0
char c = (curr->count == -1L) ? '*' : '#';
/* all selected: '*' vs count selected: '#' */
(void) putchar(c);
} else if (n == 2 && curr->identifier.a_void != 0
&& show_obj_syms
&& curr->glyphinfo.glyph != NO_GLYPH) {
int gcolor = curr->glyphinfo.gm.sym.color;