headings in option menus

There was a great deal of inconsistency in
different menus on how headings were displayed.
This allows the user to select what they like best.
I was motivated to do this, because I wasn't satisfied
with the appearance of ATR_INVERSE in the menus
on win32tty, and several of them specified it.
This commit is contained in:
nethack.allison
2003-10-05 19:56:22 +00:00
parent f6f6c1f0d5
commit 4775dd3cbf
12 changed files with 87 additions and 19 deletions

View File

@@ -5,7 +5,7 @@
.ds vr "NetHack 3.4
.ds f0 "\*(vr
.ds f1
.ds f2 "August 14, 2003
.ds f2 "October 5, 2003
.mt
A Guide to the Mazes of Menace
(Guidebook for NetHack)
@@ -1855,6 +1855,10 @@ Default '\e'.
Menu character accelerator to jump to the first page in a menu.
Implemented by the Amiga, Gem and tty ports.
Default '^'.
.lp menu_headings
Controls how the headings in a menu are highlighted.
Values are 'bold', 'inverse', or 'underline'.
Not all ports can actually display all three types.
.lp menu_invert_all
Menu character accelerator to invert all items in a menu.
Implemented by the Amiga, Gem, X11 and tty ports.

View File

@@ -27,7 +27,7 @@
\begin{document}
%
% input file: guidebook.mn
% $Revision: 1.70 $ $Date: 2003/09/27 15:55:35 $
% $Revision: 1.71 $ $Date: 2003/09/28 03:42:24 $
%
%.ds h0 "
%.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
%.au
\author{Eric S. Raymond\\
(Extensively edited and expanded for 3.4)}
\date{August 14, 2003}
\date{October 5, 2003}
\maketitle
@@ -2294,6 +2294,10 @@ Default `\verb+\+'.
Menu character accelerator to jump to the first page in a menu.
Implemented by the Amiga, Gem and tty ports.
Default `\verb+^+'.
\item[\ib{menu\_headings}]
Controls how the headings in a menu are highlighted.
Values are ``{\tt bold}'', ``{\tt inverse}'', or ``{\tt underline}''.
Not all ports can actually display all three types.
\item[\ib{menu\_invert\_all}]
Menu character accelerator to invert all items in a menu.
Implemented by the Amiga, Gem, X11 and tty ports.

View File

@@ -56,6 +56,7 @@ General New Features
--------------------
bones file compatibility info is now written into the dat/options file
extend autodig to work downwards via '>'
make attribute that is used to distinguish headings in a menu configurable
Platform- and/or Interface-Specific New Features

View File

@@ -155,6 +155,7 @@ struct instance_flags {
boolean menu_requested; /* Flag for overloaded use of 'm' prefix
* on some non-move commands */
uchar num_pad_mode;
int menu_headings; /* ATR for menu headings */
int purge_monsters; /* # of dead monsters still on fmon list */
int *opt_booldup; /* for duplication of boolean opts in config file */
int *opt_compdup; /* for duplication of compound opts in config file */

View File

@@ -692,7 +692,7 @@ winid tmpwin; /* supplied by dodiscover() */
for (i = 0; i < NROFARTIFACTS; i++) {
if (artidisco[i] == 0) break; /* empty slot implies end of list */
if (i == 0) putstr(tmpwin, ATR_INVERSE, "Artifacts");
if (i == 0) putstr(tmpwin, iflags.menu_headings, "Artifacts");
m = artidisco[i];
otyp = artilist[m].otyp;
Sprintf(buf, " %s [%s %s]", artiname(m),

View File

@@ -1149,7 +1149,7 @@ minimal_enlightenment()
buf[0] = buf2[0] = '\0';
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Starting", FALSE);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Starting", FALSE);
/* Starting name, race, role, gender */
Sprintf(buf, fmtstr, "name", plname);
@@ -1168,7 +1168,7 @@ minimal_enlightenment()
/* Current name, race, role, gender */
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Current", FALSE);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Current", FALSE);
Sprintf(buf, fmtstr, "race", Upolyd ? youmonst.data->mname : urace.noun);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, FALSE);
if (Upolyd) {
@@ -1195,7 +1195,7 @@ minimal_enlightenment()
/* Deity list */
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", FALSE);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD, "Deities", FALSE);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Deities", FALSE);
Sprintf(buf2, deity_fmtstr, align_gname(A_CHAOTIC),
(u.ualignbase[A_ORIGINAL] == u.ualign.type
&& u.ualign.type == A_CHAOTIC) ? " (s,c)" :

View File

@@ -1584,7 +1584,7 @@ boolean bymenu;
}
if (bymenu) {
any.a_void = 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD, buf, MENU_UNSELECTED);
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, buf, MENU_UNSELECTED);
} else
putstr(win, 0, buf);
@@ -1624,7 +1624,7 @@ boolean bymenu;
if (first) {
if (bymenu) {
any.a_void = 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD,
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
"Floating branches", MENU_UNSELECTED);
} else {
putstr(win, 0, "");

View File

@@ -1718,7 +1718,7 @@ nextclass:
if (!flags.sortpack || otmp->oclass == *invlet) {
if (flags.sortpack && !classcount) {
any.a_void = 0; /* zero */
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE,
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
let_to_name(*invlet, FALSE), MENU_UNSELECTED);
classcount++;
}
@@ -2678,7 +2678,7 @@ const char *hdr, *txt;
any.a_void = 0;
win = create_nhwindow(NHW_MENU);
start_menu(win);
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE, hdr, MENU_UNSELECTED);
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, hdr, MENU_UNSELECTED);
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, txt, MENU_UNSELECTED);
end_menu(win, (char *)0);

View File

@@ -382,7 +382,7 @@ dodiscovered() /* free after Robert Viduya */
for (i = dis = 0; i < SIZE(uniq_objs); i++)
if (objects[uniq_objs[i]].oc_name_known) {
if (!dis++)
putstr(tmpwin, ATR_INVERSE, "Unique Items");
putstr(tmpwin, iflags.menu_headings, "Unique Items");
Sprintf(buf, " %s", OBJ_NAME(objects[uniq_objs[i]]));
putstr(tmpwin, 0, buf);
++ct;
@@ -406,7 +406,7 @@ dodiscovered() /* free after Robert Viduya */
if ((dis = disco[i]) && interesting_to_discover(dis)) {
ct++;
if (oclass != prev_class) {
putstr(tmpwin, ATR_INVERSE, let_to_name(oclass, FALSE));
putstr(tmpwin, iflags.menu_headings, let_to_name(oclass, FALSE));
prev_class = oclass;
}
Sprintf(buf, "%s %s",(objects[dis].oc_pre_discovered ? "*" : " "),

View File

@@ -254,6 +254,7 @@ static struct Comp_Opt
4, SET_IN_FILE },
{ "menu_first_page", "jump to the first page in a menu",
4, SET_IN_FILE },
{ "menu_headings", "bold, inverse, or underline headings", 9, SET_IN_GAME },
{ "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE },
{ "menu_invert_page", "invert all items on this page of a menu",
4, SET_IN_FILE },
@@ -507,6 +508,7 @@ initoptions()
#ifdef TTY_GRAPHICS
iflags.prevmsg_window = 's';
#endif
iflags.menu_headings = ATR_INVERSE;
/* Use negative indices to indicate not yet selected */
flags.initrole = -1;
@@ -2055,6 +2057,26 @@ goodfruit:
return;
}
fullname = "menu_headings";
if (match_optname(opts, fullname, 12, TRUE)) {
if (negated) {
bad_negation(fullname, FALSE);
return;
}
else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
return;
}
if (!strcmpi(opts,"bold"))
iflags.menu_headings = ATR_BOLD;
else if (!strcmpi(opts,"inverse"))
iflags.menu_headings = ATR_INVERSE;
else if (!strcmpi(opts,"underline"))
iflags.menu_headings = ATR_ULINE;
else
badoption(opts);
return;
}
/* check for menu command mapping */
for (i = 0; i < NUM_MENU_CMDS; i++) {
fullname = default_menu_cmd_info[i].name;
@@ -2344,7 +2366,7 @@ doset()
start_menu(tmpwin);
any.a_void = 0;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
"Booleans (selecting will toggle value):", MENU_UNSELECTED);
any.a_int = 0;
/* first list any other non-modifiable booleans, then modifiable ones */
@@ -2378,7 +2400,7 @@ doset()
indexoffset = boolcount;
any.a_void = 0;
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
"Compounds (selecting will prompt for new value):",
MENU_UNSELECTED);
@@ -2422,7 +2444,7 @@ doset()
}
#ifdef PREFIXES_IN_USE
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_BOLD,
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
"Variable playground locations:", MENU_UNSELECTED);
for (i = 0; i < PREFIX_COUNT; i++)
doset_add_menu(tmpwin, fqn_prefix_names[i], 0);
@@ -2487,7 +2509,7 @@ boolean setinitial,setfromfile;
boolean retval = FALSE;
/* Special handling of menustyle, pickup_burden, pickup_types,
disclose, runmode, msg_window, and number_pad options. */
disclose, runmode, msg_window, menu_headings, and number_pad options. */
if (!strcmp("menustyle", optname)) {
const char *style_name;
menu_item *style_pick = (menu_item *)0;
@@ -2705,6 +2727,36 @@ boolean setinitial,setfromfile;
destroy_nhwindow(tmpwin);
retval = TRUE;
}
else if (!strcmp("menu_headings", optname)) {
static const char *mhchoices[3] = {"bold", "inverse", "underline"};
char *npletters = "biu";
menu_item *mode_pick = (menu_item *)0;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
for (i = 0; i < SIZE(mhchoices); i++) {
any.a_int = i + 1;
add_menu(tmpwin, NO_GLYPH, &any, npletters[i], 0,
ATR_NONE, mhchoices[i], MENU_UNSELECTED);
}
end_menu(tmpwin, "How to highlight menu headings:");
if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
int mode = mode_pick->item.a_int - 1;
switch(mode) {
case 2:
iflags.menu_headings = ATR_ULINE;
break;
case 0:
iflags.menu_headings = ATR_BOLD;
break;
case 1:
default:
iflags.menu_headings = ATR_INVERSE;
}
free((genericptr_t)mode_pick);
}
destroy_nhwindow(tmpwin);
retval = TRUE;
}
return retval;
}
@@ -2828,6 +2880,12 @@ char *buf;
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_invert_all"))
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_headings")) {
Sprintf(buf, "%s", (iflags.menu_headings == ATR_BOLD) ?
"bold" : (iflags.menu_headings == ATR_INVERSE) ?
"inverse" : (iflags.menu_headings == ATR_ULINE) ?
"underline" : "unknown");
}
else if (!strcmp(optname, "menu_invert_page"))
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "menu_last_page"))

View File

@@ -709,7 +709,7 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */
/* if sorting, print type name (once only) */
if (qflags & INVORDER_SORT && !printed_type_name) {
any.a_obj = (struct obj *) 0;
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_INVERSE,
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
let_to_name(*pack, FALSE), MENU_UNSELECTED);
printed_type_name = TRUE;
}

View File

@@ -892,7 +892,7 @@ enhance_weapon_skill()
/* Print headings for skill types */
any.a_void = 0;
if (i == skill_ranges[pass].first)
add_menu(win, NO_GLYPH, &any, 0, 0, ATR_BOLD,
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
skill_ranges[pass].name, MENU_UNSELECTED);
if (P_RESTRICTED(i)) continue;