(Menu) Implement action_cancel

This commit is contained in:
twinaphex 2015-01-09 04:43:24 +01:00
parent 82025586fe
commit 3aca3bceb9
5 changed files with 56 additions and 15 deletions

View File

@ -614,8 +614,8 @@ static int menu_common_iterate(unsigned action)
break;
case MENU_ACTION_CANCEL:
apply_deferred_settings();
menu_list_pop_stack(driver.menu->menu_list);
if (cbs && cbs->action_cancel)
return cbs->action_cancel(path_offset, label_offset, type_offset, driver.menu->selection_ptr);
break;
case MENU_ACTION_OK:

View File

@ -58,6 +58,10 @@ static void process_setting_handler(
if (setting->action_ok)
setting->action_ok(setting, action);
break;
case MENU_ACTION_CANCEL:
if (setting->action_cancel)
setting->action_cancel(setting, action);
break;
case MENU_ACTION_START:
if (setting->action_start)
setting->action_start(setting);

View File

@ -531,6 +531,7 @@ void menu_common_list_delete(void *data, size_t idx,
{
cbs->action_start = NULL;
cbs->action_ok = NULL;
cbs->action_cancel = NULL;
cbs->action_toggle = NULL;
cbs->action_deferred_push = NULL;
free(list->list[idx].actiondata);

View File

@ -799,6 +799,20 @@ static int action_ok_lookup_setting(const char *path,
return menu_action_setting_set(type, label, MENU_ACTION_OK);
}
static int action_cancel_lookup_setting(const char *path,
const char *label, unsigned type, size_t idx)
{
return menu_action_setting_set(type, label, MENU_ACTION_CANCEL);
}
static int action_cancel_pop_default(const char *path,
const char *label, unsigned type, size_t idx)
{
apply_deferred_settings();
menu_list_pop_stack(driver.menu->menu_list);
return 0;
}
static int action_ok_save_new_config(const char *path,
const char *label, unsigned type, size_t idx)
{
@ -2589,6 +2603,18 @@ static void menu_entries_cbs_init_bind_content_list_switch(menu_file_list_cbs_t
cbs->action_content_list_switch = deferred_push_content_list;
}
static void menu_entries_cbs_init_bind_cancel(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx)
{
if (!cbs)
return;
cbs->action_cancel = action_cancel_lookup_setting;
/* TODO - add some stuff here. */
cbs->action_cancel = action_cancel_pop_default;
}
static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx)
{
@ -2819,6 +2845,7 @@ void menu_entries_cbs_init(void *data,
if (cbs)
{
menu_entries_cbs_init_bind_ok(cbs, path, label, type, idx);
menu_entries_cbs_init_bind_cancel(cbs, path, label, type, idx);
menu_entries_cbs_init_bind_start(cbs, path, label, type, idx);
menu_entries_cbs_init_bind_content_list_switch(cbs, path, label, type, idx);
menu_entries_cbs_init_bind_toggle(cbs, path, label, type, idx);

View File

@ -1333,6 +1333,7 @@ rarch_setting_t setting_data_action_setting(const char* name,
result.action_start = NULL;
result.action_toggle = NULL;
result.action_ok = setting_data_action_action_ok;
result.action_cancel = NULL;
return result;
}
@ -1372,6 +1373,7 @@ rarch_setting_t setting_data_float_setting(const char* name,
result.action_start = setting_data_fraction_action_start_default;
result.action_toggle = setting_data_fraction_action_toggle_default;
result.action_ok = setting_data_fraction_action_ok_default;
result.action_cancel = NULL;
return result;
}
@ -1394,6 +1396,7 @@ rarch_setting_t setting_data_bool_setting(const char* name,
result.action_start = setting_data_bool_action_start_default;
result.action_toggle= setting_data_bool_action_toggle_default;
result.action_ok = setting_data_bool_action_ok_default;
result.action_cancel= NULL;
return result;
}
@ -1430,6 +1433,7 @@ rarch_setting_t setting_data_uint_setting(const char* name,
result.action_start = setting_data_uint_action_start_default;
result.action_toggle = setting_data_uint_action_toggle_default;
result.action_ok = setting_data_uint_action_ok_default;
result.action_cancel = NULL;
return result;
}
@ -1495,8 +1499,9 @@ rarch_setting_t setting_data_bind_setting(const char* name,
result.index = idx;
result.index_offset = idx_offset;
result.action_start = setting_data_bind_action_start;
result.action_ok = setting_data_bind_action_ok;
result.action_start = setting_data_bind_action_start;
result.action_ok = setting_data_bind_action_ok;
result.action_cancel = NULL;
return result;
}
@ -2997,10 +3002,12 @@ static void setting_data_add_special_callbacks(
case ST_UINT:
(*list)[idx].action_start = setting_data_uint_action_start_linefeed;
(*list)[idx].action_ok = setting_data_uint_action_ok_linefeed;
(*list)[idx].action_cancel = NULL;
break;
case ST_STRING:
(*list)[idx].action_start = setting_data_string_action_start_allow_input;
(*list)[idx].action_ok = setting_data_string_action_ok_allow_input;
(*list)[idx].action_cancel = NULL;
break;
default:
break;
@ -3177,8 +3184,8 @@ static bool setting_data_append_list_main_menu_options(
group_info.name,
subgroup_info.name);
(*list)[list_info->index - 1].action_toggle = &setting_data_action_toggle_savestates;
(*list)[list_info->index - 1].action_start = &setting_data_action_start_savestates;
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
(*list)[list_info->index - 1].action_start = &setting_data_action_start_savestates;
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
(*list)[list_info->index - 1].get_string_representation = &get_string_representation_savestate;
settings_list_current_add_cmd (list, list_info, RARCH_CMD_SAVE_STATE);
@ -3188,8 +3195,8 @@ static bool setting_data_append_list_main_menu_options(
group_info.name,
subgroup_info.name);
(*list)[list_info->index - 1].action_toggle = &setting_data_action_toggle_savestates;
(*list)[list_info->index - 1].action_start = &setting_data_action_start_savestates;
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
(*list)[list_info->index - 1].action_start = &setting_data_action_start_savestates;
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
(*list)[list_info->index - 1].get_string_representation = &get_string_representation_savestate;
settings_list_current_add_cmd (list, list_info, RARCH_CMD_LOAD_STATE);
@ -3206,7 +3213,7 @@ static bool setting_data_append_list_main_menu_options(
group_info.name,
subgroup_info.name);
settings_list_current_add_cmd (list, list_info, RARCH_CMD_RESUME);
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
(*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_exit;
CONFIG_ACTION(
"restart_content",
@ -4714,18 +4721,20 @@ static bool setting_data_append_list_input_options(
label_bind_all[user],
group_info.name,
subgroup_info.name);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_ok = &setting_data_action_ok_bind_all;
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_ok = &setting_data_action_ok_bind_all;
(*list)[list_info->index - 1].action_cancel = NULL;
CONFIG_ACTION(
key_bind_defaults[user],
label_bind_defaults[user],
group_info.name,
subgroup_info.name);
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_ok = &setting_data_action_ok_bind_defaults;
(*list)[list_info->index - 1].index = user + 1;
(*list)[list_info->index - 1].index_offset = user;
(*list)[list_info->index - 1].action_ok = &setting_data_action_ok_bind_defaults;
(*list)[list_info->index - 1].action_cancel = NULL;
}
START_SUB_GROUP(