Simplify add_menu, part 7

This commit is contained in:
Pasi Kallinen
2023-11-03 22:04:55 +02:00
parent 70c47c4054
commit 06235b7841
+21 -51
View File
@@ -409,15 +409,10 @@ ask_do_tutorial(void)
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0, add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
ATR_NONE, 0, "No, just start play", MENU_ITEMFLAGS_NONE); ATR_NONE, 0, "No, just start play", MENU_ITEMFLAGS_NONE);
any = cg.zeroany; add_menu_str(win, "");
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, buf);
ATR_NONE, 0, "", MENU_ITEMFLAGS_NONE);
add_menu(win, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, 0, buf, MENU_ITEMFLAGS_NONE);
if (pass++) /* we'll get here after <space> or <return> */ if (pass++) /* we'll get here after <space> or <return> */
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "(Please choose 'y' or 'n'.)");
ATR_NONE, 0, "(Please choose 'y' or 'n'.)",
MENU_ITEMFLAGS_NONE);
end_menu(win, "Do you want a tutorial?"); end_menu(win, "Do you want a tutorial?");
@@ -5199,9 +5194,7 @@ handler_menustyle(void)
: MENU_ITEMFLAGS_NONE); : MENU_ITEMFLAGS_NONE);
/* second line is prefixed by spaces that "c - " would use */ /* second line is prefixed by spaces that "c - " would use */
Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, menutype[i][2]); Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, menutype[i][2]);
any.a_int = 0; add_menu_str(tmpwin, buf);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf,
MENU_ITEMFLAGS_NONE);
} }
end_menu(tmpwin, "Select menustyle:"); end_menu(tmpwin, "Select menustyle:");
n = select_menu(tmpwin, PICK_ONE, &style_pick); n = select_menu(tmpwin, PICK_ONE, &style_pick);
@@ -5461,9 +5454,7 @@ handler_msg_window(void)
: MENU_ITEMFLAGS_NONE); : MENU_ITEMFLAGS_NONE);
/* second line is prefixed by spaces that "c - " would use */ /* second line is prefixed by spaces that "c - " would use */
Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, msgwind[i][2]); Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, msgwind[i][2]);
any.a_char = '\0'; add_menu_str(tmpwin, buf);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf,
MENU_ITEMFLAGS_NONE);
} }
end_menu(tmpwin, "Select message history display type:"); end_menu(tmpwin, "Select message history display type:");
n = select_menu(tmpwin, PICK_ONE, &window_pick); n = select_menu(tmpwin, PICK_ONE, &window_pick);
@@ -5754,18 +5745,14 @@ handler_whatis_coord(void)
0, ATR_NONE, clr, "none (no coordinates displayed)", 0, ATR_NONE, clr, "none (no coordinates displayed)",
(gpc == GPCOORDS_NONE) (gpc == GPCOORDS_NONE)
? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE);
any.a_long = 0L; add_menu_str(tmpwin, "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
"", MENU_ITEMFLAGS_NONE);
Sprintf(buf, "map: upper-left: <%d,%d>, lower-right: <%d,%d>%s", Sprintf(buf, "map: upper-left: <%d,%d>, lower-right: <%d,%d>%s",
1, 0, COLNO - 1, ROWNO - 1, 1, 0, COLNO - 1, ROWNO - 1,
flags.verbose ? "; column 0 unused, off left edge" : ""); flags.verbose ? "; column 0 unused, off left edge" : "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu_str(tmpwin, buf);
ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
if (strcmp(windowprocs.name, "tty")) /* only show for non-tty */ if (strcmp(windowprocs.name, "tty")) /* only show for non-tty */
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, add_menu_str(tmpwin,
"screen: row is offset to accommodate tty interface's use of top line", "screen: row is offset to accommodate tty interface's use of top line");
MENU_ITEMFLAGS_NONE);
#if COLNO == 80 #if COLNO == 80
#define COL80ARG flags.verbose ? "; column 80 is not used" : "" #define COL80ARG flags.verbose ? "; column 80 is not used" : ""
#else #else
@@ -5774,10 +5761,8 @@ handler_whatis_coord(void)
Sprintf(buf, "screen: upper-left: [%02d,%02d], lower-right: [%d,%d]%s", Sprintf(buf, "screen: upper-left: [%02d,%02d], lower-right: [%d,%d]%s",
0 + 2, 1, ROWNO - 1 + 2, COLNO - 1, COL80ARG); 0 + 2, 1, ROWNO - 1 + 2, COLNO - 1, COL80ARG);
#undef COL80ARG #undef COL80ARG
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, add_menu_str(tmpwin, buf);
buf, MENU_ITEMFLAGS_NONE); add_menu_str(tmpwin, "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
"", MENU_ITEMFLAGS_NONE);
end_menu(tmpwin, end_menu(tmpwin,
"Select coordinate display when auto-describing a map position:"); "Select coordinate display when auto-describing a map position:");
if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) { if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) {
@@ -8473,9 +8458,7 @@ doset_simple_menu(void)
the player might not know how to type them; keep this simple */ the player might not know how to type them; keep this simple */
Strcpy(buf, "Use command '#optionsfull'" Strcpy(buf, "Use command '#optionsfull'"
" to get the complete options list."); " to get the complete options list.");
any = cg.zeroany; add_menu_str(tmpwin, buf);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
0, buf, MENU_ITEMFLAGS_NONE);
} }
any = cg.zeroany; any = cg.zeroany;
any.a_int = -2 + 1; any.a_int = -2 + 1;
@@ -8485,8 +8468,7 @@ doset_simple_menu(void)
for (section = OptS_General; section < OptS_Advanced; section++) { for (section = OptS_General; section < OptS_Advanced; section++) {
any = cg.zeroany; any = cg.zeroany;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(tmpwin, "");
0, "", MENU_ITEMFLAGS_NONE);
Sprintf(buf, " %-30s ", OptS_type[section]); Sprintf(buf, " %-30s ", OptS_type[section]);
add_menu_heading(tmpwin, buf); add_menu_heading(tmpwin, buf);
for (i = 0; (name = allopt[i].name) != 0; i++) { for (i = 0; (name = allopt[i].name) != 0; i++) {
@@ -8537,13 +8519,9 @@ doset_simple_menu(void)
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, 0, buf, MENU_ITEMFLAGS_NONE); ATR_NONE, 0, buf, MENU_ITEMFLAGS_NONE);
if (gs.simple_options_help && allopt[i].descr) { if (gs.simple_options_help && allopt[i].descr) {
any = cg.zeroany;
Sprintf(buf, " %s", allopt[i].descr); Sprintf(buf, " %s", allopt[i].descr);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu_str(tmpwin, buf);
ATR_NONE, 0, buf, MENU_ITEMFLAGS_NONE); add_menu_str(tmpwin, "");
any = cg.zeroany;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
0, "", MENU_ITEMFLAGS_NONE);
} }
} }
} }
@@ -8709,9 +8687,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
for (i = 0; i < SIZE(helptext); ++i) { for (i = 0; i < SIZE(helptext); ++i) {
if (helptext[i]) { if (helptext[i]) {
Sprintf(buf, "%4s%.75s", "", helptext[i]); Sprintf(buf, "%4s%.75s", "", helptext[i]);
any.a_int = 0; add_menu_str(tmpwin, buf);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, FALSE, clr,
buf, MENU_ITEMFLAGS_NONE);
} else { } else {
any.a_int = '?' + 1; /* processing pick_list subtracts 1 */ any.a_int = '?' + 1; /* processing pick_list subtracts 1 */
add_menu(tmpwin, &nul_glyphinfo, &any, '?', '?', ATR_NONE, add_menu(tmpwin, &nul_glyphinfo, &any, '?', '?', ATR_NONE,
@@ -8771,9 +8747,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE); ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
} }
any = cg.zeroany;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu_str(tmpwin, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
add_menu_heading(tmpwin, add_menu_heading(tmpwin,
"Compounds (selecting will prompt for new value):"); "Compounds (selecting will prompt for new value):");
@@ -8791,9 +8766,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
} }
} }
any = cg.zeroany; add_menu_str(tmpwin, "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
add_menu_heading(tmpwin, "Other settings:"); add_menu_heading(tmpwin, "Other settings:");
for (pass = startpass; pass <= endpass; pass++) for (pass = startpass; pass <= endpass; pass++)
@@ -8811,9 +8784,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
} }
#ifdef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
any = cg.zeroany; add_menu_str(tmpwin, "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
add_menu_heading(tmpwin, add_menu_heading(tmpwin,
"Variable playground locations:"); "Variable playground locations:");
for (i = 0; i < PREFIX_COUNT; i++) for (i = 0; i < PREFIX_COUNT; i++)
@@ -9712,8 +9683,7 @@ choose_classes_menu(const char *prompt,
if (category == 1 && next_accelerator <= 'z') { if (category == 1 && next_accelerator <= 'z') {
/* for objects, add "A - ' ' all classes", after a separator */ /* for objects, add "A - ' ' all classes", after a separator */
any = cg.zeroany; any = cg.zeroany;
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
any.a_int = (int) ' '; any.a_int = (int) ' ';
Sprintf(buf, "%c %s", (char) any.a_int, "all classes of objects"); Sprintf(buf, "%c %s", (char) any.a_int, "all classes of objects");
/* we won't preselect this even if the incoming list is empty; /* we won't preselect this even if the incoming list is empty;