Cut down on code duplication

This commit is contained in:
twinaphex 2017-11-26 06:12:51 +01:00
parent bd1e06bbb7
commit 99fcc63b38
1 changed files with 40 additions and 109 deletions

View File

@ -1996,117 +1996,48 @@ static void menu_input_st_string_cb_cheat_file_save_as(
menu_input_dialog_end();
}
static int action_ok_shader_preset_save_as(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_PRESET_FILENAME);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)idx;
line.cb = menu_input_st_string_cb_save_preset;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
#define default_action_dialog_start(funcname, _label_setting, _idx, _cb) \
static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \
{ \
menu_input_ctx_line_t line; \
line.label = label; \
line.label_setting = _label_setting; \
line.type = type; \
line.idx = (_idx); \
line.cb = _cb; \
if (!menu_input_dialog_start(&line)) \
return -1; \
return 0; \
}
static int action_ok_enable_settings(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)entry_idx;
line.cb = menu_input_st_string_cb_enable_settings;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
static int action_ok_wifi(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = "Passphrase";
line.label_setting = label;
line.type = type;
line.idx = (unsigned)idx;
line.cb = menu_input_wifi_cb;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
static int action_ok_cheat_file_save_as(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)idx;
line.cb = menu_input_st_string_cb_cheat_file_save_as;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
static int action_ok_cheat(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_CHEAT);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)idx;
line.cb = menu_input_st_cheat_cb;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
static int action_ok_disable_kiosk_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)entry_idx;
line.cb = menu_input_st_string_cb_disable_kiosk_mode;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
static int action_ok_rename_entry(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MSG_INPUT_RENAME_ENTRY);
line.label_setting = label;
line.type = type;
line.idx = (unsigned)entry_idx;
line.cb = menu_input_st_string_cb_rename_entry;
if (!menu_input_dialog_start(&line))
return -1;
return 0;
}
default_action_dialog_start(action_ok_shader_preset_save_as,
msg_hash_to_str(MSG_INPUT_PRESET_FILENAME),
(unsigned)idx,
menu_input_st_string_cb_save_preset)
default_action_dialog_start(action_ok_enable_settings,
msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD),
(unsigned)entry_idx,
menu_input_st_string_cb_enable_settings)
default_action_dialog_start(action_ok_wifi,
"Passphrase",
(unsigned)idx,
menu_input_wifi_cb)
default_action_dialog_start(action_ok_cheat_file_save_as,
msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME),
(unsigned)idx,
menu_input_st_string_cb_cheat_file_save_as)
default_action_dialog_start(action_ok_cheat,
msg_hash_to_str(MSG_INPUT_CHEAT),
(unsigned)idx,
menu_input_st_cheat_cb)
default_action_dialog_start(action_ok_disable_kiosk_mode,
msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD),
(unsigned)entry_idx,
menu_input_st_string_cb_disable_kiosk_mode)
default_action_dialog_start(action_ok_rename_entry,
msg_hash_to_str(MSG_INPUT_RENAME_ENTRY),
(unsigned)entry_idx,
menu_input_st_string_cb_rename_entry)
enum
{