(Menu) Start refactoring main menu actions
This commit is contained in:
parent
0c91b1a1ba
commit
d9a10e9ab2
|
@ -165,12 +165,10 @@ void file_list_get_last(const file_list_t *list,
|
||||||
file_list_get_at_offset(list, list->size - 1, path, file_type, setting);
|
file_list_get_at_offset(list, list->size - 1, path, file_type, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *file_list_get_last_setting(const file_list_t *list, int index)
|
void *file_list_get_last_setting(const file_list_t *list, int index, void *settings)
|
||||||
{
|
{
|
||||||
rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list();
|
if (settings)
|
||||||
|
return (rarch_setting_t*)setting_data_find_setting(settings,
|
||||||
if (setting_data)
|
|
||||||
return (rarch_setting_t*)setting_data_find_setting(setting_data,
|
|
||||||
list->list[index].label);
|
list->list[index].label);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@ void file_list_sort_on_alt(file_list_t *list);
|
||||||
|
|
||||||
bool file_list_search(const file_list_t *list, const char *needle, size_t *index);
|
bool file_list_search(const file_list_t *list, const char *needle, size_t *index);
|
||||||
|
|
||||||
void *file_list_get_last_setting(const file_list_t *list, int index);
|
void *file_list_get_last_setting(const file_list_t *list, int index,
|
||||||
|
void *settings);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,7 +683,10 @@ static int menu_info_screen_iterate(unsigned action, rarch_setting_t *setting)
|
||||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||||
driver.menu_ctx->render();
|
driver.menu_ctx->render();
|
||||||
|
|
||||||
current_setting = (rarch_setting_t*)file_list_get_last_setting(driver.menu->selection_buf, driver.menu->selection_ptr);
|
current_setting = (rarch_setting_t*)file_list_get_last_setting(
|
||||||
|
driver.menu->selection_buf,
|
||||||
|
driver.menu->selection_ptr,
|
||||||
|
setting_data_get_list());
|
||||||
|
|
||||||
if (current_setting)
|
if (current_setting)
|
||||||
setting_data_get_description(current_setting, msg, sizeof(msg));
|
setting_data_get_description(current_setting, msg, sizeof(msg));
|
||||||
|
@ -3056,12 +3059,38 @@ static unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2] = {
|
||||||
static unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480;
|
static unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void handle_setting(rarch_setting_t *setting,
|
||||||
|
unsigned id, unsigned action)
|
||||||
|
{
|
||||||
|
if (setting->type == ST_BOOL)
|
||||||
|
menu_common_setting_set_current_boolean(setting, action);
|
||||||
|
else if (setting->type == ST_UINT)
|
||||||
|
menu_common_setting_set_current_unsigned_integer(setting, action);
|
||||||
|
else if (setting->type == ST_FLOAT)
|
||||||
|
menu_common_setting_set_current_fraction(setting, action);
|
||||||
|
else if (setting->type == ST_DIR)
|
||||||
|
{
|
||||||
|
if (action == MENU_ACTION_START)
|
||||||
|
{
|
||||||
|
*setting->value.string = '\0';
|
||||||
|
|
||||||
|
if (setting->change_handler)
|
||||||
|
setting->change_handler(setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (setting->type == ST_PATH)
|
||||||
|
menu_common_setting_set_current_path_selection(setting, setting->default_value.string, id, action);
|
||||||
|
}
|
||||||
|
|
||||||
static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t *setting)
|
static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t *setting)
|
||||||
{
|
{
|
||||||
struct retro_perf_counter **counters;
|
struct retro_perf_counter **counters;
|
||||||
unsigned port = driver.menu->current_pad;
|
unsigned port = driver.menu->current_pad;
|
||||||
|
|
||||||
setting = (rarch_setting_t*)file_list_get_last_setting(driver.menu->selection_buf, driver.menu->selection_ptr);
|
setting = (rarch_setting_t*)file_list_get_last_setting(
|
||||||
|
driver.menu->selection_buf, driver.menu->selection_ptr,
|
||||||
|
setting_data_get_list()
|
||||||
|
);
|
||||||
|
|
||||||
if (id >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_PERF_COUNTERS_END)
|
if (id >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && id <= MENU_SETTINGS_PERF_COUNTERS_END)
|
||||||
{
|
{
|
||||||
|
@ -3114,24 +3143,17 @@ static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (setting && setting->type == ST_BOOL)
|
else if (setting)
|
||||||
menu_common_setting_set_current_boolean(setting, action);
|
handle_setting(setting, id, action);
|
||||||
else if (setting && setting->type == ST_UINT)
|
else
|
||||||
menu_common_setting_set_current_unsigned_integer(setting, action);
|
|
||||||
else if (setting && setting->type == ST_FLOAT)
|
|
||||||
menu_common_setting_set_current_fraction(setting, action);
|
|
||||||
else if (setting && setting->type == ST_DIR)
|
|
||||||
{
|
{
|
||||||
if (action == MENU_ACTION_START)
|
setting = (rarch_setting_t*)file_list_get_last_setting(
|
||||||
{
|
driver.menu->selection_buf, driver.menu->selection_ptr,
|
||||||
*setting->value.string = '\0';
|
setting_data_get_mainmenu(true)
|
||||||
|
);
|
||||||
|
|
||||||
if (setting->change_handler)
|
if (setting)
|
||||||
setting->change_handler(setting);
|
handle_setting(setting, id, action);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (setting && setting->type == ST_PATH)
|
|
||||||
menu_common_setting_set_current_path_selection(setting, setting->default_value.string, id, action);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (id)
|
switch (id)
|
||||||
|
@ -3213,13 +3235,6 @@ static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_SETTINGS_QUIT_RARCH:
|
|
||||||
if (action == MENU_ACTION_OK)
|
|
||||||
{
|
|
||||||
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_SAVE_CONFIG:
|
case MENU_SETTINGS_SAVE_CONFIG:
|
||||||
if (action == MENU_ACTION_OK)
|
if (action == MENU_ACTION_OK)
|
||||||
menu_save_new_config();
|
menu_save_new_config();
|
||||||
|
@ -3670,6 +3685,7 @@ static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3775,6 +3791,25 @@ static void menu_common_setting_set_label_st_uint(rarch_setting_t *setting,
|
||||||
snprintf(type_str, type_str_size, "%d", *setting->value.unsigned_integer);
|
snprintf(type_str, type_str_size, "%d", *setting->value.unsigned_integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_setting_label(char *type_str,
|
||||||
|
size_t type_str_size, rarch_setting_t *setting)
|
||||||
|
{
|
||||||
|
if (setting->type == ST_BOOL)
|
||||||
|
menu_common_setting_set_label_st_bool(setting, type_str, type_str_size);
|
||||||
|
else if (setting->type == ST_UINT)
|
||||||
|
menu_common_setting_set_label_st_uint(setting, type_str, type_str_size);
|
||||||
|
else if (setting->type == ST_FLOAT)
|
||||||
|
menu_common_setting_set_label_st_float(setting, type_str, type_str_size);
|
||||||
|
else if (setting->type == ST_DIR)
|
||||||
|
strlcpy(type_str, *setting->value.string ? setting->value.string : setting->dir.empty_path, type_str_size);
|
||||||
|
else if (setting->type == ST_PATH)
|
||||||
|
strlcpy(type_str, path_basename(setting->value.string), type_str_size);
|
||||||
|
else if (setting->type == ST_STRING)
|
||||||
|
strlcpy(type_str, setting->value.string, type_str_size);
|
||||||
|
else if (setting->type == ST_GROUP)
|
||||||
|
strlcpy(type_str, "...", type_str_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void menu_common_setting_set_label(char *type_str,
|
static void menu_common_setting_set_label(char *type_str,
|
||||||
size_t type_str_size, unsigned *w, unsigned type, unsigned index)
|
size_t type_str_size, unsigned *w, unsigned type, unsigned index)
|
||||||
{
|
{
|
||||||
|
@ -3796,20 +3831,37 @@ static void menu_common_setting_set_label(char *type_str,
|
||||||
|
|
||||||
input_get_bind_string(type_str, &g_settings.input.binds[driver.menu->current_pad][type - MENU_SETTINGS_BIND_BEGIN], auto_bind, type_str_size);
|
input_get_bind_string(type_str, &g_settings.input.binds[driver.menu->current_pad][type - MENU_SETTINGS_BIND_BEGIN], auto_bind, type_str_size);
|
||||||
}
|
}
|
||||||
else if (setting && setting->type == ST_BOOL)
|
else if (setting)
|
||||||
menu_common_setting_set_label_st_bool(setting, type_str, type_str_size);
|
handle_setting_label(type_str, type_str_size, setting);
|
||||||
else if (setting && setting->type == ST_UINT)
|
else
|
||||||
menu_common_setting_set_label_st_uint(setting, type_str, type_str_size);
|
{
|
||||||
else if (setting && setting->type == ST_FLOAT)
|
setting_data = (rarch_setting_t*)setting_data_get_mainmenu(true);
|
||||||
menu_common_setting_set_label_st_float(setting, type_str, type_str_size);
|
|
||||||
else if (setting && setting->type == ST_DIR)
|
setting = (rarch_setting_t*)setting_data_find_setting(setting_data,
|
||||||
strlcpy(type_str, *setting->value.string ? setting->value.string : setting->dir.empty_path, type_str_size);
|
driver.menu->selection_buf->list[index].label);
|
||||||
else if (setting && setting->type == ST_PATH)
|
|
||||||
strlcpy(type_str, path_basename(setting->value.string), type_str_size);
|
if (setting)
|
||||||
else if (setting && setting->type == ST_STRING)
|
{
|
||||||
strlcpy(type_str, setting->value.string, type_str_size);
|
if (type == MENU_SETTINGS_CONFIG)
|
||||||
else if (setting && setting->type == ST_GROUP)
|
{
|
||||||
strlcpy(type_str, "...", type_str_size);
|
if (*g_extern.config_path)
|
||||||
|
fill_pathname_base(type_str, g_extern.config_path,
|
||||||
|
type_str_size);
|
||||||
|
else
|
||||||
|
strlcpy(type_str, "<default>", type_str_size);
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
type == MENU_SETTINGS_SAVESTATE_SAVE ||
|
||||||
|
type == MENU_SETTINGS_SAVESTATE_LOAD)
|
||||||
|
{
|
||||||
|
if (g_settings.state_slot < 0)
|
||||||
|
strlcpy(type_str, "-1 (auto)", type_str_size);
|
||||||
|
else
|
||||||
|
snprintf(type_str, type_str_size, "%d", g_settings.state_slot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handle_setting_label(type_str, type_str_size, setting);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -3845,13 +3897,6 @@ static void menu_common_setting_set_label(char *type_str,
|
||||||
strlcpy(type_str, "(DIR)", type_str_size);
|
strlcpy(type_str, "(DIR)", type_str_size);
|
||||||
*w = 5;
|
*w = 5;
|
||||||
break;
|
break;
|
||||||
case MENU_SETTINGS_SAVESTATE_SAVE:
|
|
||||||
case MENU_SETTINGS_SAVESTATE_LOAD:
|
|
||||||
if (g_settings.state_slot < 0)
|
|
||||||
strlcpy(type_str, "-1 (auto)", type_str_size);
|
|
||||||
else
|
|
||||||
snprintf(type_str, type_str_size, "%d", g_settings.state_slot);
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_DISK_INDEX:
|
case MENU_SETTINGS_DISK_INDEX:
|
||||||
{
|
{
|
||||||
const struct retro_disk_control_callback *control = &g_extern.system.disk_control;
|
const struct retro_disk_control_callback *control = &g_extern.system.disk_control;
|
||||||
|
@ -3863,26 +3908,12 @@ static void menu_common_setting_set_label(char *type_str,
|
||||||
snprintf(type_str, type_str_size, "%u", current + 1);
|
snprintf(type_str, type_str_size, "%u", current + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MENU_SETTINGS_CONFIG:
|
|
||||||
if (*g_extern.config_path)
|
|
||||||
fill_pathname_base(type_str, g_extern.config_path, type_str_size);
|
|
||||||
else
|
|
||||||
strlcpy(type_str, "<default>", type_str_size);
|
|
||||||
break;
|
|
||||||
case MENU_SETTINGS_OPEN_FILEBROWSER:
|
|
||||||
case MENU_SETTINGS_OPEN_FILEBROWSER_DEFERRED_CORE:
|
|
||||||
case MENU_SETTINGS_OPEN_HISTORY:
|
|
||||||
case MENU_SETTINGS_CORE_OPTIONS:
|
|
||||||
case MENU_SETTINGS_CORE_INFO:
|
|
||||||
case MENU_SETTINGS_CUSTOM_VIEWPORT:
|
case MENU_SETTINGS_CUSTOM_VIEWPORT:
|
||||||
case MENU_SETTINGS_TOGGLE_FULLSCREEN:
|
case MENU_SETTINGS_TOGGLE_FULLSCREEN:
|
||||||
case MENU_SETTINGS_DISK_OPTIONS:
|
case MENU_SETTINGS_DISK_OPTIONS:
|
||||||
case MENU_SETTINGS_SHADER_PRESET:
|
case MENU_SETTINGS_SHADER_PRESET:
|
||||||
case MENU_SETTINGS_SHADER_PRESET_SAVE:
|
case MENU_SETTINGS_SHADER_PRESET_SAVE:
|
||||||
case MENU_SETTINGS_CORE:
|
|
||||||
case MENU_SETTINGS_DISK_APPEND:
|
case MENU_SETTINGS_DISK_APPEND:
|
||||||
case MENU_SETTINGS_OPTIONS:
|
|
||||||
case MENU_SETTINGS_PERFORMANCE_COUNTERS:
|
|
||||||
case MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND:
|
case MENU_SETTINGS_PERFORMANCE_COUNTERS_FRONTEND:
|
||||||
case MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO:
|
case MENU_SETTINGS_PERFORMANCE_COUNTERS_LIBRETRO:
|
||||||
case MENU_SETTINGS_CUSTOM_BIND_ALL:
|
case MENU_SETTINGS_CUSTOM_BIND_ALL:
|
||||||
|
@ -3970,6 +4001,7 @@ static void menu_common_setting_set_label(char *type_str,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu_ctx_driver_backend_t menu_ctx_backend_common = {
|
const menu_ctx_driver_backend_t menu_ctx_backend_common = {
|
||||||
|
|
|
@ -124,6 +124,7 @@ enum basic_event
|
||||||
RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE,
|
RARCH_CMD_VIDEO_SET_NONBLOCKING_STATE,
|
||||||
RARCH_CMD_VIDEO_SET_ASPECT_RATIO,
|
RARCH_CMD_VIDEO_SET_ASPECT_RATIO,
|
||||||
RARCH_CMD_RESET_CONTEXT,
|
RARCH_CMD_RESET_CONTEXT,
|
||||||
|
RARCH_CMD_QUIT_RETROARCH,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum menu_enums
|
enum menu_enums
|
||||||
|
|
|
@ -3364,6 +3364,12 @@ void rarch_main_command(unsigned action)
|
||||||
uninit_drivers();
|
uninit_drivers();
|
||||||
init_drivers();
|
init_drivers();
|
||||||
break;
|
break;
|
||||||
|
case RARCH_CMD_QUIT_RETROARCH:
|
||||||
|
#ifdef HAVE_MENU
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU);
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_GAME);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1350,6 +1350,14 @@ static void general_write_handler(const void *data)
|
||||||
if (!setting)
|
if (!setting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!strcmp(setting->name, "quit_retroarch"))
|
||||||
|
{
|
||||||
|
if (*setting->value.boolean)
|
||||||
|
{
|
||||||
|
rarch_cmd = RARCH_CMD_QUIT_RETROARCH;
|
||||||
|
*setting->value.boolean = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!strcmp(setting->name, "fps_show"))
|
if (!strcmp(setting->name, "fps_show"))
|
||||||
g_settings.fps_show = *setting->value.boolean;
|
g_settings.fps_show = *setting->value.boolean;
|
||||||
else if (!strcmp(setting->name, "pause_nonactive"))
|
else if (!strcmp(setting->name, "pause_nonactive"))
|
||||||
|
|
Loading…
Reference in New Issue