(Menu) Add SD_FLAG_EXIT to signal to the menu that we want to cleanly

exit out of the menu
This commit is contained in:
twinaphex 2014-09-14 22:39:33 +02:00
parent d6659cd4d6
commit 3d689bd40f
5 changed files with 68 additions and 27 deletions

View File

@ -215,7 +215,7 @@ static int menu_common_setting_set_perf(unsigned setting, unsigned action,
} }
static void menu_common_setting_set_current_path_selection( static int menu_common_setting_set_current_path_selection(
rarch_setting_t *setting, const char *start_path, rarch_setting_t *setting, const char *start_path,
const char *label, unsigned type, const char *label, unsigned type,
unsigned action) unsigned action)
@ -234,18 +234,28 @@ static void menu_common_setting_set_current_path_selection(
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
static void menu_common_setting_set_current_string_path( static int menu_common_setting_set_current_string_path(
rarch_setting_t *setting, const char *dir, const char *path) rarch_setting_t *setting, const char *dir, const char *path)
{ {
fill_pathname_join(setting->value.string, dir, path, setting->size); fill_pathname_join(setting->value.string, dir, path, setting->size);
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
void menu_common_set_current_string_based_on_label( int menu_common_set_current_string_based_on_label(
const char *label, const char *str) const char *label, const char *str)
{ {
if (!strcmp(label, "video_shader_preset_save_as")) if (!strcmp(label, "video_shader_preset_save_as"))
@ -256,27 +266,38 @@ void menu_common_set_current_string_based_on_label(
driver.menu_ctx->backend->shader_manager_save_preset(str, false); driver.menu_ctx->backend->shader_manager_save_preset(str, false);
#endif #endif
} }
return 0;
} }
void menu_common_setting_set_current_string( int menu_common_setting_set_current_string(
rarch_setting_t *setting, const char *str) rarch_setting_t *setting, const char *str)
{ {
strlcpy(setting->value.string, str, setting->size); strlcpy(setting->value.string, str, setting->size);
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
static void handle_setting(rarch_setting_t *setting, static int handle_setting(rarch_setting_t *setting,
unsigned id, const char *label, unsigned action) unsigned id, const char *label, unsigned action)
{ {
if (setting->type == ST_BOOL) if (setting->type == ST_BOOL)
menu_action_setting_boolean(setting, action); return menu_action_setting_boolean(setting, action);
else if (setting->type == ST_UINT) if (setting->type == ST_UINT)
menu_action_setting_unsigned_integer(setting, id, action); return menu_action_setting_unsigned_integer(setting, id, action);
else if (setting->type == ST_FLOAT) if (setting->type == ST_FLOAT)
menu_action_setting_fraction(setting, action); return menu_action_setting_fraction(setting, action);
else if (setting->type == ST_DIR) if (setting->type == ST_PATH)
return menu_common_setting_set_current_path_selection(setting,
setting->default_value.string, setting->name, id, action);
if (setting->type == ST_DIR)
{ {
if (action == MENU_ACTION_START) if (action == MENU_ACTION_START)
{ {
@ -284,12 +305,14 @@ static void handle_setting(rarch_setting_t *setting,
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
} }
return 0;
} }
else if (setting->type == ST_PATH)
menu_common_setting_set_current_path_selection(setting, if (setting->type == ST_STRING)
setting->default_value.string, setting->name, id, action);
else if (setting->type == ST_STRING)
{ {
if ( if (
(setting->flags & SD_FLAG_ALLOW_INPUT) || (setting->flags & SD_FLAG_ALLOW_INPUT) ||
@ -304,6 +327,8 @@ static void handle_setting(rarch_setting_t *setting,
else else
menu_action_setting_driver(setting, action); menu_action_setting_driver(setting, action);
} }
return 0;
} }
static int menu_setting_set(unsigned id, const char *label, static int menu_setting_set(unsigned id, const char *label,
@ -316,7 +341,7 @@ static int menu_setting_set(unsigned id, const char *label,
); );
if (setting) if (setting)
handle_setting(setting, id, label, action); return handle_setting(setting, id, label, action);
else else
{ {
setting = (rarch_setting_t*)get_last_setting( setting = (rarch_setting_t*)get_last_setting(
@ -350,7 +375,7 @@ static int menu_setting_set(unsigned id, const char *label,
} }
} }
handle_setting(setting, id, label, action); return handle_setting(setting, id, label, action);
} }
else if (!strcmp(label, "video_shader_num_passes")) else if (!strcmp(label, "video_shader_num_passes"))
{ {

View File

@ -18,7 +18,7 @@
#include "menu_input_line_cb.h" #include "menu_input_line_cb.h"
#include "menu_action.h" #include "menu_action.h"
void menu_action_setting_boolean( int menu_action_setting_boolean(
rarch_setting_t *setting, unsigned action) rarch_setting_t *setting, unsigned action)
{ {
if ( if (
@ -55,9 +55,14 @@ void menu_action_setting_boolean(
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
void menu_action_setting_unsigned_integer( int menu_action_setting_unsigned_integer(
rarch_setting_t *setting, unsigned id, unsigned action) rarch_setting_t *setting, unsigned id, unsigned action)
{ {
if (id == MENU_FILE_LINEFEED) if (id == MENU_FILE_LINEFEED)
@ -106,9 +111,14 @@ void menu_action_setting_unsigned_integer(
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
void menu_action_setting_fraction( int menu_action_setting_fraction(
rarch_setting_t *setting, unsigned action) rarch_setting_t *setting, unsigned action)
{ {
if (!strcmp(setting->name, "video_refresh_rate_auto")) if (!strcmp(setting->name, "video_refresh_rate_auto"))
@ -188,6 +198,11 @@ void menu_action_setting_fraction(
if (setting->change_handler) if (setting->change_handler)
setting->change_handler(setting); setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT)
return -1;
return 0;
} }
void menu_action_setting_driver( void menu_action_setting_driver(

View File

@ -19,13 +19,13 @@
#include "../../settings_data.h" #include "../../settings_data.h"
void menu_action_setting_boolean( int menu_action_setting_boolean(
rarch_setting_t *setting, unsigned action); rarch_setting_t *setting, unsigned action);
void menu_action_setting_fraction( int menu_action_setting_fraction(
rarch_setting_t *setting, unsigned action); rarch_setting_t *setting, unsigned action);
void menu_action_setting_unsigned_integer( int menu_action_setting_unsigned_integer(
rarch_setting_t *setting, unsigned id, unsigned action); rarch_setting_t *setting, unsigned id, unsigned action);
void menu_action_setting_driver( void menu_action_setting_driver(

View File

@ -2375,11 +2375,11 @@ rarch_setting_t *setting_data_get_mainmenu(bool regenerate)
} }
if (g_extern.main_is_init && !g_extern.libretro_dummy) if (g_extern.main_is_init && !g_extern.libretro_dummy)
{ {
CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(lists[9], "savestate", "Save State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT)
CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) CONFIG_BOOL(lists[10], "loadstate", "Load State", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_EXIT)
CONFIG_BOOL(lists[11], "take_screenshot", "Take Screenshot", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[11], "take_screenshot", "Take Screenshot", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION)
CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[12], "resume_content", "Resume Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT)
CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[13], "restart_content", "Restart Content", false, "", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) WITH_FLAGS(SD_FLAG_EXIT)
} }
#ifndef HAVE_DYNAMIC #ifndef HAVE_DYNAMIC
CONFIG_BOOL(lists[14], "restart_retroarch", "Restart RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION) CONFIG_BOOL(lists[14], "restart_retroarch", "Restart RetroArch", false, "", "",GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_FLAGS(SD_FLAG_PUSH_ACTION)

View File

@ -55,6 +55,7 @@ enum setting_flags
SD_FLAG_ALLOW_INPUT = (1 << 5), SD_FLAG_ALLOW_INPUT = (1 << 5),
SD_FLAG_PUSH_ACTION = (1 << 6), SD_FLAG_PUSH_ACTION = (1 << 6),
SD_FLAG_IS_DRIVER = (1 << 7), SD_FLAG_IS_DRIVER = (1 << 7),
SD_FLAG_EXIT = (1 << 8),
}; };
typedef struct rarch_setting_t typedef struct rarch_setting_t