Simplify adding menu headings
This commit is contained in:
@@ -177,6 +177,8 @@ extern boolean bones_include_name(const char *);
|
||||
|
||||
/* ### botl.c ### */
|
||||
|
||||
extern void add_menu_heading(winid, const char *);
|
||||
extern void add_menu_str(winid, const char *);
|
||||
extern char *do_statusline1(void);
|
||||
extern void check_gold_symbol(void);
|
||||
extern char *do_statusline2(void);
|
||||
|
||||
@@ -1050,7 +1050,7 @@ disp_artifact_discoveries(winid tmpwin) /* supplied by dodiscover() */
|
||||
continue; /* for WIN_ERR, we just count */
|
||||
|
||||
if (i == 0)
|
||||
putstr(tmpwin, iflags.menu_headings, "Artifacts");
|
||||
add_menu_heading(tmpwin, "Artifacts");
|
||||
m = artidisco[i];
|
||||
otyp = artilist[m].otyp;
|
||||
algnstr = align_str(artilist[m].alignment);
|
||||
@@ -1071,7 +1071,7 @@ dump_artifact_info(winid tmpwin)
|
||||
int m;
|
||||
char buf[BUFSZ], buf2[BUFSZ];
|
||||
|
||||
putstr(tmpwin, iflags.menu_headings, "Artifacts");
|
||||
add_menu_heading(tmpwin, "Artifacts");
|
||||
for (m = 1; m <= NROFARTIFACTS; ++m) {
|
||||
Snprintf(buf2, sizeof buf2,
|
||||
"[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */
|
||||
|
||||
23
src/botl.c
23
src/botl.c
@@ -19,6 +19,26 @@ static const char *rank(void);
|
||||
static void bot_via_windowport(void);
|
||||
static void stat_update_time(void);
|
||||
|
||||
void
|
||||
add_menu_heading(winid tmpwin, const char *buf)
|
||||
{
|
||||
anything any = cg.zeroany;
|
||||
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, 0,
|
||||
buf, MENU_ITEMFLAGS_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
add_menu_str(winid tmpwin, const char *buf)
|
||||
{
|
||||
anything any = cg.zeroany;
|
||||
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
ATR_NONE, 0,
|
||||
buf, MENU_ITEMFLAGS_NONE);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_strength_str(void)
|
||||
{
|
||||
@@ -1127,8 +1147,7 @@ cond_menu(void)
|
||||
clr, mbuf, MENU_ITEMFLAGS_SKIPINVERT);
|
||||
any = cg.zeroany;
|
||||
Sprintf(mbuf, "sorted %s", menutitle[gc.condmenu_sortorder]);
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr, mbuf, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin, mbuf);
|
||||
for (i = 0; i < SIZE(condtests); i++) {
|
||||
idx = sequence[i];
|
||||
Sprintf(mbuf, "cond_%-14s", condtests[idx].useroption);
|
||||
|
||||
@@ -695,9 +695,7 @@ doextlist(void)
|
||||
results menu. */
|
||||
if (!menushown[pass]) {
|
||||
Strcpy(buf, headings[pass]);
|
||||
add_menu(menuwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr, buf,
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(menuwin, buf);
|
||||
menushown[pass] = 1;
|
||||
}
|
||||
/* longest ef_txt at present is "wizrumorcheck" (13 chars);
|
||||
|
||||
@@ -2427,10 +2427,8 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn)
|
||||
s_level *slev;
|
||||
dungeon *dptr;
|
||||
branch *br;
|
||||
anything any;
|
||||
struct lchoice lchoices;
|
||||
winid win = create_nhwindow(NHW_MENU);
|
||||
int clr = 0;
|
||||
|
||||
if (bymenu) {
|
||||
start_menu(win, MENU_BEHAVE_STANDARD);
|
||||
@@ -2461,9 +2459,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn)
|
||||
dptr->depth_start + dptr->entry_lev - 1);
|
||||
}
|
||||
if (bymenu) {
|
||||
any = cg.zeroany;
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr, buf, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, buf);
|
||||
} else
|
||||
putstr(win, 0, buf);
|
||||
|
||||
@@ -3654,9 +3650,10 @@ print_mapseen(
|
||||
gd.dungeons[dnum].dname, depthstart,
|
||||
depthstart + gd.dungeons[dnum].dunlev_ureached - 1);
|
||||
any = cg.zeroany;
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
!final ? iflags.menu_headings : ATR_NONE, NO_COLOR,
|
||||
buf, MENU_ITEMFLAGS_NONE);
|
||||
if (final)
|
||||
add_menu_str(win, buf);
|
||||
else
|
||||
add_menu_heading(win, buf);
|
||||
}
|
||||
|
||||
/* calculate level number */
|
||||
|
||||
@@ -2764,8 +2764,10 @@ list_vanquished(char defquery, boolean ask)
|
||||
mlet = mons[i].mlet;
|
||||
if (class_header && mlet != prev_mlet) {
|
||||
Strcpy(buf, def_monsyms[(int) mlet].explain);
|
||||
putstr(klwin, ask ? 0 : iflags.menu_headings,
|
||||
upstart(buf));
|
||||
if (ask)
|
||||
putstr(klwin, 0, upstart(buf));
|
||||
else
|
||||
add_menu_heading(klwin, upstart(buf));
|
||||
prev_mlet = mlet;
|
||||
}
|
||||
if (UniqCritterIndx(i)) {
|
||||
@@ -2973,8 +2975,10 @@ list_genocided(char defquery, boolean ask)
|
||||
mlet = mons[mndx].mlet;
|
||||
if (class_header && mlet != prev_mlet) {
|
||||
Strcpy(buf, def_monsyms[(int) mlet].explain);
|
||||
putstr(klwin, ask ? 0 : iflags.menu_headings,
|
||||
upstart(buf));
|
||||
if (ask)
|
||||
putstr(klwin, 0, upstart(buf));
|
||||
else
|
||||
add_menu_heading(klwin, upstart(buf));
|
||||
prev_mlet = mlet;
|
||||
}
|
||||
Sprintf(buf, " %s", makeplural(mons[mndx].pmnames[NEUTRAL]));
|
||||
|
||||
22
src/invent.c
22
src/invent.c
@@ -3438,9 +3438,7 @@ display_pickinv(
|
||||
} else if (xtra_choice) {
|
||||
/* wizard override ID and xtra_choice are mutually exclusive */
|
||||
if (flags.sortpack)
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
"Miscellaneous", MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, "Miscellaneous");
|
||||
any.a_char = HANDS_SYM; /* '-' */
|
||||
add_menu(win, &nul_glyphinfo, &any, HANDS_SYM, 0, ATR_NONE,
|
||||
clr, xtra_choice, MENU_ITEMFLAGS_NONE);
|
||||
@@ -3476,11 +3474,9 @@ display_pickinv(
|
||||
any = cg.zeroany; /* all bits zero */
|
||||
ilet = otmp->invlet;
|
||||
if (flags.sortpack && !classcount) {
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
add_menu_heading(win,
|
||||
let_to_name(*invlet, FALSE,
|
||||
(want_reply && iflags.menu_head_objsym)),
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
(want_reply && iflags.menu_head_objsym)));
|
||||
classcount++;
|
||||
}
|
||||
if (wizid)
|
||||
@@ -3515,8 +3511,7 @@ display_pickinv(
|
||||
if (iflags.force_invmenu && lets && want_reply
|
||||
&& (int) strlen(lets) < inv_cnt(TRUE)) {
|
||||
any = cg.zeroany;
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr, "Special", MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, "Special");
|
||||
any.a_char = '*';
|
||||
add_menu(win, &nul_glyphinfo, &any, '*', 0, ATR_NONE, clr,
|
||||
"(list everything)", MENU_ITEMFLAGS_NONE);
|
||||
@@ -3645,10 +3640,8 @@ display_used_invlets(char avoidlet)
|
||||
if (!flags.sortpack || otmp->oclass == *invlet) {
|
||||
if (flags.sortpack && !classcount) {
|
||||
any = cg.zeroany; /* zero */
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
let_to_name(*invlet, FALSE, FALSE),
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win,
|
||||
let_to_name(*invlet, FALSE, FALSE));
|
||||
classcount++;
|
||||
}
|
||||
any.a_char = ilet;
|
||||
@@ -5365,8 +5358,7 @@ invdisp_nothing(const char *hdr, const char *txt)
|
||||
any = cg.zeroany;
|
||||
win = create_nhwindow(NHW_MENU);
|
||||
start_menu(win, MENU_BEHAVE_STANDARD);
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr,
|
||||
hdr, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, hdr);
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
|
||||
"", MENU_ITEMFLAGS_NONE);
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, txt,
|
||||
|
||||
17
src/o_init.c
17
src/o_init.c
@@ -711,7 +711,7 @@ dodiscovered(void) /* 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, iflags.menu_headings, "Unique items");
|
||||
add_menu_heading(tmpwin, "Unique items");
|
||||
++uniq_ct;
|
||||
Sprintf(buf, " %s", OBJ_NAME(objects[uniq_objs[i]]));
|
||||
putstr(tmpwin, 0, buf);
|
||||
@@ -751,8 +751,8 @@ dodiscovered(void) /* free after Robert Viduya */
|
||||
}
|
||||
if (!alphabetized || alphabyclass) {
|
||||
/* header for new class */
|
||||
putstr(tmpwin, iflags.menu_headings,
|
||||
let_to_name(oclass, FALSE, FALSE));
|
||||
add_menu_heading(tmpwin,
|
||||
let_to_name(oclass, FALSE, FALSE));
|
||||
prev_class = oclass;
|
||||
}
|
||||
}
|
||||
@@ -777,7 +777,7 @@ dodiscovered(void) /* free after Robert Viduya */
|
||||
classes, we normally don't need a header; but it we showed
|
||||
any unique items or any artifacts then we do need one */
|
||||
if ((uniq_ct || arti_ct) && alphabetized && !alphabyclass)
|
||||
putstr(tmpwin, iflags.menu_headings, "Discovered items");
|
||||
add_menu_heading(tmpwin, "Discovered items");
|
||||
qsort(sorted_lines, sorted_ct, sizeof (char *), discovered_cmp);
|
||||
for (j = 0; j < sorted_ct; ++j) {
|
||||
p = sorted_lines[j];
|
||||
@@ -951,8 +951,7 @@ doclassdisco(void)
|
||||
ct = 0;
|
||||
switch (c) {
|
||||
case 'u':
|
||||
putstr(tmpwin, iflags.menu_headings,
|
||||
upstart(strcpy(buf, unique_items)));
|
||||
add_menu_heading(tmpwin, upstart(strcpy(buf, unique_items)));
|
||||
for (i = 0; i < SIZE(uniq_objs); i++)
|
||||
if (objects[uniq_objs[i]].oc_name_known) {
|
||||
++ct;
|
||||
@@ -1060,10 +1059,8 @@ rename_disco(void)
|
||||
|
||||
if (oclass != prev_class) {
|
||||
any.a_int = 0;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
let_to_name(oclass, FALSE, FALSE),
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin,
|
||||
let_to_name(oclass, FALSE, FALSE));
|
||||
prev_class = oclass;
|
||||
}
|
||||
any.a_int = dis;
|
||||
|
||||
@@ -5887,10 +5887,8 @@ handler_autopickup_exception(void)
|
||||
if (numapes) {
|
||||
ape = ga.apelist;
|
||||
any = cg.zeroany;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
"Always pickup '<'; never pickup '>'",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin,
|
||||
"Always pickup '<'; never pickup '>'");
|
||||
for (i = 0; i < numapes && ape; i++) {
|
||||
any.a_void = (opt_idx == 1) ? 0 : ape;
|
||||
/* length of pattern plus quotes (plus '<'/'>') is
|
||||
@@ -8490,9 +8488,7 @@ doset_simple_menu(void)
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
|
||||
0, "", MENU_ITEMFLAGS_NONE);
|
||||
Sprintf(buf, " %-30s ", OptS_type[section]);
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, 0,
|
||||
buf /*OptS_type[section]*/, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin, buf);
|
||||
for (i = 0; (name = allopt[i].name) != 0; i++) {
|
||||
if (allopt[i].section != section)
|
||||
continue;
|
||||
@@ -8744,8 +8740,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
|
||||
indexoffset = 1;
|
||||
any = cg.zeroany;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr,
|
||||
"Booleans (selecting will toggle value):", MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin,
|
||||
"Booleans (selecting will toggle value):");
|
||||
any.a_int = 0;
|
||||
/* first list any other non-modifiable booleans, then modifiable ones */
|
||||
for (pass = 0; pass <= 1; pass++)
|
||||
@@ -8778,9 +8774,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
any = cg.zeroany;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr,
|
||||
"Compounds (selecting will prompt for new value):",
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin,
|
||||
"Compounds (selecting will prompt for new value):");
|
||||
|
||||
for (pass = startpass; pass <= endpass; pass++)
|
||||
for (i = 0; (name = allopt[i].name) != 0; i++) {
|
||||
@@ -8799,9 +8794,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
any = cg.zeroany;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
"Other settings:", MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin, "Other settings:");
|
||||
|
||||
for (pass = startpass; pass <= endpass; pass++)
|
||||
for (i = 0; (name = allopt[i].name) != 0; i++) {
|
||||
@@ -8821,9 +8814,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
any = cg.zeroany;
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
"Variable playground locations:", MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin,
|
||||
"Variable playground locations:");
|
||||
for (i = 0; i < PREFIX_COUNT; i++)
|
||||
doset_add_menu(tmpwin, fqn_prefix_names[i], fmtstr_doset, -1, 0);
|
||||
#endif
|
||||
|
||||
@@ -1077,12 +1077,10 @@ query_objlist(const char *qstr, /* query string */
|
||||
/* if sorting, print type name (once only) */
|
||||
if (sorted && !printed_type_name) {
|
||||
any = cg.zeroany;
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
add_menu_heading(win,
|
||||
let_to_name(*pack, FALSE,
|
||||
((how != PICK_NONE)
|
||||
&& iflags.menu_head_objsym)),
|
||||
MENU_ITEMFLAGS_NONE);
|
||||
&& iflags.menu_head_objsym)));
|
||||
printed_type_name = TRUE;
|
||||
}
|
||||
|
||||
@@ -1109,8 +1107,7 @@ query_objlist(const char *qstr, /* query string */
|
||||
if (sorted && n > 1) {
|
||||
Sprintf(buf, "%s Creatures",
|
||||
digests(u.ustuck->data) ? "Swallowed" : "Engulfed");
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings,
|
||||
clr, buf, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, buf);
|
||||
}
|
||||
fake_hero_object = cg.zeroobj;
|
||||
fake_hero_object.quan = 1L; /* not strictly necessary... */
|
||||
|
||||
@@ -1763,8 +1763,7 @@ dospellmenu(
|
||||
if (wizard)
|
||||
Sprintf(eos(buf), "%c%6s", sep, "turns");
|
||||
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr, buf, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(tmpwin, buf);
|
||||
for (i = 0; i < MAXSPELL && spellid(i) != NO_SPELL; i++) {
|
||||
splnum = !gs.spl_orderindx ? i : gs.spl_orderindx[i];
|
||||
Sprintf(buf, fmt, spellname(splnum), spellev(splnum),
|
||||
|
||||
@@ -1226,9 +1226,7 @@ enhance_weapon_skill(void)
|
||||
/* Print headings for skill types */
|
||||
any = cg.zeroany;
|
||||
if (i == skill_ranges[pass].first)
|
||||
add_menu(win, &nul_glyphinfo, &any, 0, 0,
|
||||
iflags.menu_headings, clr,
|
||||
skill_ranges[pass].name, MENU_ITEMFLAGS_NONE);
|
||||
add_menu_heading(win, skill_ranges[pass].name);
|
||||
|
||||
if (P_RESTRICTED(i))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user