Simplify add_menu, part 9

This commit is contained in:
Pasi Kallinen
2023-11-03 22:32:36 +02:00
parent bc9518ca16
commit 4dd9602f4b
2 changed files with 18 additions and 40 deletions
+3 -6
View File
@@ -1408,13 +1408,10 @@ restore_menu(
clear_nhwindow(bannerwin); clear_nhwindow(bannerwin);
/* COPYRIGHT_BANNER_[ABCD] */ /* COPYRIGHT_BANNER_[ABCD] */
for (k = 1; k <= 4; ++k) for (k = 1; k <= 4; ++k)
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(tmpwin, copyright_banner_line(k));
clr, copyright_banner_line(k), MENU_ITEMFLAGS_NONE); add_menu_str(tmpwin, "");
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, "",
MENU_ITEMFLAGS_NONE);
} }
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(tmpwin, "Select one of your saved games");
clr, "Select one of your saved games", MENU_ITEMFLAGS_NONE);
for (k = 0; saved[k]; ++k) { for (k = 0; saved[k]; ++k) {
any.a_int = k + 1; any.a_int = k + 1;
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
+15 -34
View File
@@ -1915,8 +1915,7 @@ role_menu_extra(int which, winid where, boolean preselect)
any.a_int = 0; any.a_int = 0;
/* use four spaces of padding to fake a grayed out menu choice */ /* use four spaces of padding to fake a grayed out menu choice */
Sprintf(buf, "%4s%s forces %s", "", constrainer, forcedvalue); Sprintf(buf, "%4s%s forces %s", "", constrainer, forcedvalue);
add_menu(where, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf, add_menu_str(where, buf);
MENU_ITEMFLAGS_NONE);
} else if (what) { } else if (what) {
any.a_int = RS_menu_arg(which); any.a_int = RS_menu_arg(which);
Sprintf(buf, "Pick%s %s first", (f >= 0) ? " another" : "", what); Sprintf(buf, "Pick%s %s first", (f >= 0) ? " another" : "", what);
@@ -2296,8 +2295,7 @@ genl_player_setup(int screenheight)
role_menu_extra(ROLE_RANDOM, win, TRUE); role_menu_extra(ROLE_RANDOM, win, TRUE);
any = cg.zeroany; /* separator, not a choice */ any = cg.zeroany; /* separator, not a choice */
if (excess < 1 || excess > 2) if (excess < 1 || excess > 2)
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
role_menu_extra(RS_RACE, win, FALSE); role_menu_extra(RS_RACE, win, FALSE);
role_menu_extra(RS_GENDER, win, FALSE); role_menu_extra(RS_GENDER, win, FALSE);
role_menu_extra(RS_ALGNMNT, win, FALSE); role_menu_extra(RS_ALGNMNT, win, FALSE);
@@ -2391,8 +2389,7 @@ genl_player_setup(int screenheight)
/* add miscellaneous menu entries */ /* add miscellaneous menu entries */
role_menu_extra(ROLE_RANDOM, win, TRUE); role_menu_extra(ROLE_RANDOM, win, TRUE);
any.a_int = 0; /* separator, not a choice */ any.a_int = 0; /* separator, not a choice */
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
role_menu_extra(RS_ROLE, win, FALSE); role_menu_extra(RS_ROLE, win, FALSE);
role_menu_extra(RS_GENDER, win, FALSE); role_menu_extra(RS_GENDER, win, FALSE);
role_menu_extra(RS_ALGNMNT, win, FALSE); role_menu_extra(RS_ALGNMNT, win, FALSE);
@@ -2480,8 +2477,7 @@ genl_player_setup(int screenheight)
/* add miscellaneous menu entries */ /* add miscellaneous menu entries */
role_menu_extra(ROLE_RANDOM, win, TRUE); role_menu_extra(ROLE_RANDOM, win, TRUE);
any.a_int = 0; /* separator, not a choice */ any.a_int = 0; /* separator, not a choice */
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
role_menu_extra(RS_ROLE, win, FALSE); role_menu_extra(RS_ROLE, win, FALSE);
role_menu_extra(RS_RACE, win, FALSE); role_menu_extra(RS_RACE, win, FALSE);
role_menu_extra(RS_ALGNMNT, win, FALSE); role_menu_extra(RS_ALGNMNT, win, FALSE);
@@ -2565,8 +2561,7 @@ genl_player_setup(int screenheight)
setup_algnmenu(win, TRUE, ROLE, RACE, GEND); setup_algnmenu(win, TRUE, ROLE, RACE, GEND);
role_menu_extra(ROLE_RANDOM, win, TRUE); role_menu_extra(ROLE_RANDOM, win, TRUE);
any.a_int = 0; /* separator, not a choice */ any.a_int = 0; /* separator, not a choice */
add_menu(win, &nul_glyphinfo, &any, 0, 0, add_menu_str(win, "");
ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE);
role_menu_extra(RS_ROLE, win, FALSE); role_menu_extra(RS_ROLE, win, FALSE);
role_menu_extra(RS_RACE, win, FALSE); role_menu_extra(RS_RACE, win, FALSE);
role_menu_extra(RS_GENDER, win, FALSE); role_menu_extra(RS_GENDER, win, FALSE);
@@ -2709,36 +2704,27 @@ static boolean
reset_role_filtering(void) reset_role_filtering(void)
{ {
winid win; winid win;
anything any; int i, n;
int i, n, clr = 0;
char filterprompt[QBUFSZ]; char filterprompt[QBUFSZ];
menu_item *selected = 0; menu_item *selected = 0;
win = create_nhwindow(NHW_MENU); win = create_nhwindow(NHW_MENU);
start_menu(win, MENU_BEHAVE_STANDARD); start_menu(win, MENU_BEHAVE_STANDARD);
any = cg.zeroany;
/* no extra blank line preceding this entry; end_menu supplies one */ /* no extra blank line preceding this entry; end_menu supplies one */
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, add_menu_str(win, "Unacceptable roles");
"Unacceptable roles", MENU_ITEMFLAGS_NONE);
setup_rolemenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE); setup_rolemenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE);
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(win, "");
clr, "", MENU_ITEMFLAGS_NONE); add_menu_str(win, "Unacceptable races");
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
clr, "Unacceptable races", MENU_ITEMFLAGS_NONE);
setup_racemenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE); setup_racemenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE);
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(win, "");
clr, "", MENU_ITEMFLAGS_NONE); add_menu_str(win, "Unacceptable genders");
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
clr, "Unacceptable genders", MENU_ITEMFLAGS_NONE);
setup_gendmenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE); setup_gendmenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE);
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, add_menu_str(win, "");
clr, "", MENU_ITEMFLAGS_NONE); add_menu_str(win, "Unacceptable alignments");
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE,
clr, "Unacceptable alignments", MENU_ITEMFLAGS_NONE);
setup_algnmenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE); setup_algnmenu(win, FALSE, ROLE_NONE, ROLE_NONE, ROLE_NONE);
Sprintf(filterprompt, "Pick all that apply%s", Sprintf(filterprompt, "Pick all that apply%s",
@@ -2797,9 +2783,7 @@ plsel_startmenu(int ttyrows, int aspect)
{ {
char qbuf[QBUFSZ]; char qbuf[QBUFSZ];
winid win; winid win;
anything any;
const char *rolename; const char *rolename;
int clr = 0;
/* whatever aspect was just chosen might force others (Orc => chaotic, /* whatever aspect was just chosen might force others (Orc => chaotic,
Samurai => Human+lawful, Valkyrie => female) */ Samurai => Human+lawful, Valkyrie => female) */
@@ -2830,12 +2814,9 @@ plsel_startmenu(int ttyrows, int aspect)
panic("could not create role selection window"); panic("could not create role selection window");
start_menu(win, MENU_BEHAVE_STANDARD); start_menu(win, MENU_BEHAVE_STANDARD);
any = cg.zeroany; add_menu_str(win, qbuf);
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
qbuf, MENU_ITEMFLAGS_NONE);
if (maybe_skip_seps(ttyrows, aspect) != 2) if (maybe_skip_seps(ttyrows, aspect) != 2)
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, add_menu_str(win, "");
"", MENU_ITEMFLAGS_NONE);
return win; return win;
} }