Add toggle extended command
Allows the user to configure a key binding to toggle any boolean option, for example: BIND=':toggle(price_quotes) BIND=v:toggle(autodig) The option must be settable in-game.
This commit is contained in:
@@ -390,6 +390,7 @@ staticfn boolean parse_role_opt(int, boolean, const char *, char *, char **);
|
||||
staticfn char *get_cnf_role_opt(int);
|
||||
staticfn unsigned int longest_option_name(int, int);
|
||||
staticfn int doset_simple_menu(void);
|
||||
staticfn void reset_needed_visuals(void);
|
||||
staticfn void doset_add_menu(winid, const char *, const char *, int, int);
|
||||
staticfn int handle_add_list_remove(const char *, int);
|
||||
staticfn void all_options_conds(strbuf_t *);
|
||||
@@ -9012,6 +9013,15 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
goto rerun;
|
||||
}
|
||||
|
||||
reset_needed_visuals();
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
#undef HELP_IDX
|
||||
|
||||
staticfn void
|
||||
reset_needed_visuals(void)
|
||||
{
|
||||
if (go.opt_need_glyph_reset) {
|
||||
reset_glyphmap(gm_optionchange);
|
||||
}
|
||||
@@ -9039,11 +9049,13 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
if (disp.botl || disp.botlx) {
|
||||
bot();
|
||||
}
|
||||
return ECMD_OK;
|
||||
go.opt_need_redraw = FALSE;
|
||||
go.opt_need_glyph_reset = FALSE;
|
||||
go.opt_reset_customcolors = FALSE;
|
||||
go.opt_reset_customsymbols = FALSE;
|
||||
go.opt_update_basic_palette = FALSE;
|
||||
}
|
||||
|
||||
#undef HELP_IDX
|
||||
|
||||
/* doset(#optionsfull command) menu entries for compound options */
|
||||
staticfn void
|
||||
doset_add_menu(
|
||||
@@ -9304,6 +9316,29 @@ dotogglepickup(void)
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
/* toggle any (settable in-game) boolean option by name */
|
||||
int
|
||||
toggle_bool_option(const char *p)
|
||||
{
|
||||
int i;
|
||||
int ret = ECMD_FAIL;
|
||||
|
||||
for (i = 0; i < OPTCOUNT; i++)
|
||||
if (!strncmpi(allopt[i].name, p, strlen(p))
|
||||
&& allopt[i].opttyp == BoolOpt
|
||||
&& allopt[i].setwhere == set_in_game
|
||||
&& allopt[i].addr != 0) {
|
||||
char buf[BUFSZ];
|
||||
|
||||
Sprintf(buf, "%s%s", *allopt[i].addr ? "!" : "", allopt[i].name);
|
||||
if (parseoptions(buf, FALSE, FALSE))
|
||||
ret = ECMD_OK;
|
||||
|
||||
reset_needed_visuals();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
add_autopickup_exception(const char *mapping)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user