Merge pull request #9812 from libretro/menu-actionok-refactors

Menu actionok refactors
This commit is contained in:
Twinaphex 2019-12-02 21:11:33 +01:00 committed by GitHub
commit f0a9f4e6a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -349,7 +349,10 @@ int generic_action_ok_displaylist_push(const char *path,
char *menu_driver = settings->arrays.menu_driver;
if (!menu || string_is_equal(menu_driver, "null"))
goto end;
{
menu_displaylist_info_free(&info);
return menu_cbs_exit();
}
#ifdef HAVE_AUDIOMIXER
if (settings->bools.audio_enable_menu && settings->bools.audio_enable_menu_ok)
@ -705,13 +708,6 @@ int generic_action_ok_displaylist_push(const char *path,
}
break;
case ACTION_OK_DL_CHEAT_FILE:
filebrowser_clear_type();
info.type = type;
info.directory_ptr = idx;
info_path = settings->paths.path_cheat_database;
info_label = label;
dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE;
break;
case ACTION_OK_DL_CHEAT_FILE_APPEND:
filebrowser_clear_type();
info.type = type;
@ -852,7 +848,7 @@ int generic_action_ok_displaylist_push(const char *path,
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DATABASE_MANAGER_LIST;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
}
break;
case ACTION_OK_DL_CURSOR_MANAGER_LIST:
@ -865,8 +861,9 @@ int generic_action_ok_displaylist_push(const char *path,
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_CURSOR_MANAGER_LIST;
dl_type = DISPLAYLIST_GENERIC;
dl_type = DISPLAYLIST_GENERIC;
break;
/* Pending clear */
case ACTION_OK_DL_CORE_UPDATER_LIST:
info.type = type;
info.directory_ptr = idx;
@ -894,17 +891,6 @@ int generic_action_ok_displaylist_push(const char *path,
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_PL_THUMBNAILS_UPDATER_LIST;
dl_type = DISPLAYLIST_PENDING_CLEAR;
break;
case ACTION_OK_DL_CORE_CONTENT_DIRS_SUBDIR_LIST:
fill_pathname_join_delim(tmp, path, label, ';',
sizeof(tmp));
info.type = type;
info.directory_ptr = idx;
info_path = tmp;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_CORE_CONTENT_DIRS_LIST:
info.type = type;
info.directory_ptr = idx;
@ -931,6 +917,18 @@ int generic_action_ok_displaylist_push(const char *path,
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST;
dl_type = DISPLAYLIST_PENDING_CLEAR;
break;
case ACTION_OK_DL_CORE_CONTENT_DIRS_SUBDIR_LIST:
fill_pathname_join_delim(tmp, path, label, ';',
sizeof(tmp));
info.type = type;
info.directory_ptr = idx;
info_path = tmp;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_CORE_CONTENT_DIRS_SUBDIR_LIST;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DEFERRED_CORE_LIST:
info.directory_ptr = idx;
info_path = settings->paths.directory_libretro;
@ -965,15 +963,13 @@ int generic_action_ok_displaylist_push(const char *path,
setting->max = (int) pow(2,pow((double) 2,cheat_manager_state.working_cheat.memory_search_size))-1;
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_ADDRESS_BIT_POSITION);
if (setting)
{
{
int max_bit_position = cheat_manager_state.working_cheat.memory_search_size<3 ? 7 : 0 ;
setting->max = max_bit_position ;
}
setting = menu_setting_find_enum(MENU_ENUM_LABEL_CHEAT_ADDRESS);
if (setting)
{
cheat_manager_state.browse_address = *setting->value.target.unsigned_integer ;
}
action_ok_dl_lbl(action_ok_dl_to_enum(action_type), DISPLAYLIST_GENERIC);
break ;
}
@ -992,6 +988,12 @@ int generic_action_ok_displaylist_push(const char *path,
break ;
}
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
{
unsigned player_no = type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN;
action_ok_dl_lbl(action_ok_dl_to_enum(action_type), DISPLAYLIST_GENERIC);
info.type = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN + player_no;
}
break;
case ACTION_OK_DL_ACCOUNTS_LIST:
case ACTION_OK_DL_INPUT_SETTINGS_LIST:
case ACTION_OK_DL_LATENCY_SETTINGS_LIST:
@ -1071,20 +1073,6 @@ int generic_action_ok_displaylist_push(const char *path,
break;
}
/* second pass */
switch (action_type)
{
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
{
unsigned player_no = type - MENU_SETTINGS_AUDIO_MIXER_STREAM_BEGIN;
info.type = MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN + player_no;
}
break;
default:
break;
}
if (info_label)
info.label = strdup(info_label);
if (info_path)
@ -1099,7 +1087,6 @@ int generic_action_ok_displaylist_push(const char *path,
}
}
end:
menu_displaylist_info_free(&info);
return menu_cbs_exit();
}
@ -4883,8 +4870,9 @@ default_action_ok_dl_push(action_ok_push_content_list, FILEBROWSER_SELECT_FILE,
default_action_ok_dl_push(action_ok_push_scan_file, FILEBROWSER_SCAN_FILE, ACTION_OK_DL_CONTENT_LIST, settings->paths.directory_menu_content)
#ifdef HAVE_NETWORKING
struct netplay_host_list *lan_hosts;
int lan_room_count;
/* TODO/FIXME - globals - remove */
static struct netplay_host_list *lan_hosts = NULL;
static int lan_room_count = 0;
void netplay_refresh_rooms_menu(file_list_t *list)
{
@ -5264,61 +5252,22 @@ static int action_ok_push_dropdown_setting_core_options_item_special(const char
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
/* TODO/FIXME */
static int action_ok_push_dropdown_setting_string_options_item_special(const char *path,
static int action_ok_push_dropdown_setting_core_options_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
core_option_manager_t *coreopts = NULL;
int core_option_idx = (int)atoi(label);
if (!setting)
rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts);
if (!coreopts)
return -1;
strlcpy(setting->value.target.string, path,
setting->size);
if (setting->change_handler)
setting->change_handler(setting);
core_option_manager_set_val(coreopts, core_option_idx, idx);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
/* TODO/FIXME */
static int action_ok_push_dropdown_setting_int_item_special(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
if (!setting)
return -1;
*setting->value.target.integer = (int32_t)(idx + setting->offset_by);
if (setting->change_handler)
setting->change_handler(setting);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
/* TODO/FIXME */
static int action_ok_push_dropdown_setting_float_item_special(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
float val = (float)atof(path);
if (!setting)
return -1;
*setting->value.target.fraction = (float)val;
if (setting->change_handler)
setting->change_handler(setting);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_uint_item_special(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
@ -5347,23 +5296,9 @@ static int action_ok_push_dropdown_setting_uint_item_special(const char *path,
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_core_options_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
core_option_manager_t *coreopts = NULL;
int core_option_idx = (int)atoi(label);
rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts);
if (!coreopts)
return -1;
core_option_manager_set_val(coreopts, core_option_idx, idx);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_string_options_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
static int generic_action_ok_dropdown_setting(const char *path, const char *label,
unsigned type, size_t idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
@ -5371,72 +5306,33 @@ static int action_ok_push_dropdown_setting_string_options_item(const char *path,
if (!setting)
return -1;
strlcpy(setting->value.target.string, path,
setting->size);
if (setting->change_handler)
setting->change_handler(setting);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_int_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
if (!setting)
return -1;
*setting->value.target.integer = (int32_t)(idx + setting->offset_by);
if (setting->change_handler)
setting->change_handler(setting);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_float_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
float val = (float)atof(path);
if (!setting)
return -1;
*setting->value.target.fraction = (float)val;
if (setting->change_handler)
setting->change_handler(setting);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_uint_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
unsigned value;
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(label);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
if (!setting)
return -1;
value = (unsigned)(idx + setting->offset_by);
#if 0
if (!string_is_empty(path))
switch (setting_get_type(setting))
{
unsigned path_value = atoi(path);
if (path_value != value)
value = path_value;
case ST_INT:
*setting->value.target.integer = (int32_t)(idx + setting->offset_by);
break;
case ST_UINT:
{
unsigned value = (unsigned)(idx + setting->offset_by);
*setting->value.target.unsigned_integer = value;
}
break;
case ST_FLOAT:
{
float val = (float)atof(path);
*setting->value.target.fraction = (float)val;
}
break;
case ST_STRING:
case ST_STRING_OPTIONS:
case ST_PATH:
case ST_DIR:
strlcpy(setting->value.target.string, path,
setting->size);
break;
default:
break;
}
#endif
*setting->value.target.unsigned_integer = value;
if (setting->change_handler)
setting->change_handler(setting);
@ -5444,6 +5340,12 @@ static int action_ok_push_dropdown_setting_uint_item(const char *path,
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_action_ok_dropdown_setting(path, label, type, idx);
}
static int action_ok_push_dropdown_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5578,6 +5480,7 @@ static int action_ok_push_dropdown_item_playlist_default_core(const char *path,
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_playlist_label_display_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5591,32 +5494,29 @@ static int action_ok_push_dropdown_item_playlist_label_display_mode(const char *
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_playlist_right_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
static int generic_set_thumbnail_mode(enum playlist_thumbnail_id thumbnail_id, size_t idx)
{
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
playlist_set_thumbnail_mode(playlist, PLAYLIST_THUMBNAIL_RIGHT, (enum playlist_thumbnail_mode)idx);
playlist_set_thumbnail_mode(playlist, thumbnail_id, (enum playlist_thumbnail_mode)idx);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_playlist_right_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
return generic_set_thumbnail_mode(PLAYLIST_THUMBNAIL_RIGHT, idx);
}
static int action_ok_push_dropdown_item_playlist_left_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
playlist_set_thumbnail_mode(playlist, PLAYLIST_THUMBNAIL_LEFT, (enum playlist_thumbnail_mode)idx);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
return generic_set_thumbnail_mode(PLAYLIST_THUMBNAIL_LEFT, idx);
}
static int action_ok_push_dropdown_item_manual_content_scan_system_name(const char *path,
@ -5808,6 +5708,15 @@ default_action_ok_help(action_ok_help_scanning_content, MENU_ENUM_LABEL_HELP_SCA
default_action_ok_help(action_ok_help_change_virtual_gamepad, MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD)
default_action_ok_help(action_ok_help_load_content, MENU_ENUM_LABEL_HELP_LOADING_CONTENT, MENU_DIALOG_HELP_LOADING_CONTENT)
static int generic_dropdown_box_list(size_t idx, unsigned lbl)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
lbl);
return 0;
}
static int action_ok_video_resolution(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5835,74 +5744,54 @@ static int action_ok_video_resolution(const char *path,
width, height);
runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
#else
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION);
#endif
return 0;
#else
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION);
#endif
}
static int action_ok_playlist_default_core(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE);
return 0;
}
static int action_ok_playlist_label_display_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE);
return 0;
}
static int action_ok_playlist_right_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_RIGHT_THUMBNAIL_MODE);
return 0;
}
static int action_ok_playlist_left_thumbnail_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LEFT_THUMBNAIL_MODE);
return 0;
}
static int action_ok_manual_content_scan_system_name(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME);
return 0;
}
static int action_ok_manual_content_scan_core_name(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, idx, 0,
return generic_dropdown_box_list(idx,
ACTION_OK_DL_DROPDOWN_BOX_LIST_MANUAL_CONTENT_SCAN_CORE_NAME);
return 0;
}
static int action_ok_manual_content_scan_start(const char *path,
@ -7099,29 +6988,17 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
case MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_core_options_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_string_options_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_INT_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_int_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_float_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_uint_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM_SPECIAL:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_core_options_item_special);
break;
case MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM:
case MENU_SETTING_DROPDOWN_SETTING_INT_ITEM:
case MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM:
case MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM:
case MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM_SPECIAL:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_string_options_item_special);
break;
case MENU_SETTING_DROPDOWN_SETTING_INT_ITEM_SPECIAL:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_int_item_special);
break;
case MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM_SPECIAL:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_float_item_special);
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting);
break;
case MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM_SPECIAL:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_uint_item_special);