yn_function menu code cleanup
This commit is contained in:
47
src/cmd.c
47
src/cmd.c
@@ -105,6 +105,7 @@ staticfn int dotravel(void);
|
|||||||
staticfn int dotravel_target(void);
|
staticfn int dotravel_target(void);
|
||||||
staticfn int doclicklook(void);
|
staticfn int doclicklook(void);
|
||||||
staticfn boolean yn_menuable_resp(const char *);
|
staticfn boolean yn_menuable_resp(const char *);
|
||||||
|
staticfn void yn_func_menu_opt(winid, char, const char *, char);
|
||||||
staticfn boolean yn_function_menu(const char *, const char *, char, char *);
|
staticfn boolean yn_function_menu(const char *, const char *, char, char *);
|
||||||
staticfn int domouseaction(void);
|
staticfn int domouseaction(void);
|
||||||
staticfn int doterrain(void);
|
staticfn int doterrain(void);
|
||||||
@@ -4966,6 +4967,20 @@ yn_menuable_resp(const char *resp)
|
|||||||
&& (resp == ynchars || resp == ynqchars || resp == ynaqchars);
|
&& (resp == ynchars || resp == ynqchars || resp == ynaqchars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
staticfn void
|
||||||
|
yn_func_menu_opt(winid win, char key, const char *text, char def)
|
||||||
|
{
|
||||||
|
anything any;
|
||||||
|
|
||||||
|
any = cg.zeroany;
|
||||||
|
any.a_char = key;
|
||||||
|
add_menu(win, &nul_glyphinfo, &any, key, 0,
|
||||||
|
ATR_NONE, NO_COLOR, text,
|
||||||
|
(def == key) ? MENU_ITEMFLAGS_SELECTED
|
||||||
|
: MENU_ITEMFLAGS_NONE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* use a menu to ask a specific response to a query.
|
/* use a menu to ask a specific response to a query.
|
||||||
returns TRUE if the menu was shown to the user.
|
returns TRUE if the menu was shown to the user.
|
||||||
puts the response char into res. */
|
puts the response char into res. */
|
||||||
@@ -4979,36 +4994,16 @@ yn_function_menu(
|
|||||||
if (yn_menuable_resp(resp)) {
|
if (yn_menuable_resp(resp)) {
|
||||||
winid win = create_nhwindow(NHW_MENU);
|
winid win = create_nhwindow(NHW_MENU);
|
||||||
menu_item *sel;
|
menu_item *sel;
|
||||||
anything any;
|
|
||||||
int n;
|
int n;
|
||||||
char keybuf[QBUFSZ];
|
char keybuf[QBUFSZ];
|
||||||
|
|
||||||
start_menu(win, MENU_BEHAVE_STANDARD);
|
start_menu(win, MENU_BEHAVE_STANDARD);
|
||||||
any = cg.zeroany;
|
yn_func_menu_opt(win, 'y', "Yes", def);
|
||||||
any.a_char = 'y';
|
yn_func_menu_opt(win, 'n', "No", def);
|
||||||
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
|
if (resp == ynaqchars)
|
||||||
ATR_NONE, NO_COLOR, "Yes",
|
yn_func_menu_opt(win, 'a', "All", def);
|
||||||
(def == any.a_char) ? MENU_ITEMFLAGS_SELECTED
|
if (resp == ynqchars || resp == ynaqchars)
|
||||||
: MENU_ITEMFLAGS_NONE);
|
yn_func_menu_opt(win, 'q', "Quit", def);
|
||||||
any.a_char = 'n';
|
|
||||||
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
|
|
||||||
ATR_NONE, NO_COLOR, "No",
|
|
||||||
(def == any.a_char) ? MENU_ITEMFLAGS_SELECTED
|
|
||||||
: MENU_ITEMFLAGS_NONE);
|
|
||||||
if (resp == ynaqchars) {
|
|
||||||
any.a_char = 'a';
|
|
||||||
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
|
|
||||||
ATR_NONE, NO_COLOR, "All",
|
|
||||||
(def == any.a_char) ? MENU_ITEMFLAGS_SELECTED
|
|
||||||
: MENU_ITEMFLAGS_NONE);
|
|
||||||
}
|
|
||||||
if (resp == ynqchars || resp == ynaqchars) {
|
|
||||||
any.a_char = 'q';
|
|
||||||
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
|
|
||||||
ATR_NONE, NO_COLOR, "Quit",
|
|
||||||
(def == any.a_char) ? MENU_ITEMFLAGS_SELECTED
|
|
||||||
: MENU_ITEMFLAGS_NONE);
|
|
||||||
}
|
|
||||||
end_menu(win, query);
|
end_menu(win, query);
|
||||||
n = select_menu(win, PICK_ONE, &sel);
|
n = select_menu(win, PICK_ONE, &sel);
|
||||||
destroy_nhwindow(win);
|
destroy_nhwindow(win);
|
||||||
|
|||||||
Reference in New Issue
Block a user