Get rid of hardcoded menu_entries_common_is_settings_entry

This commit is contained in:
twinaphex 2015-06-08 02:03:50 +02:00
parent 2a8704d2d2
commit 229c19225f
7 changed files with 118 additions and 96 deletions

View File

@ -130,60 +130,6 @@ int cb_core_updater_download(void *data, size_t len)
}
#endif
int menu_entries_common_is_settings_entry(uint32_t label_hash)
{
switch (label_hash)
{
case MENU_LABEL_DRIVER_SETTINGS:
case MENU_LABEL_CORE_SETTINGS:
case MENU_LABEL_CONFIGURATION_SETTINGS:
case MENU_LABEL_LOGGING_SETTINGS:
case MENU_LABEL_SAVING_SETTINGS:
case MENU_LABEL_REWIND_SETTINGS:
case MENU_LABEL_VIDEO_SETTINGS:
case MENU_LABEL_RECORDING_SETTINGS:
case MENU_LABEL_FRAME_THROTTLE_SETTINGS:
case MENU_LABEL_SHADER_SETTINGS:
case MENU_LABEL_ONSCREEN_DISPLAY_SETTINGS:
case MENU_LABEL_AUDIO_SETTINGS:
case MENU_LABEL_INPUT_SETTINGS:
case MENU_LABEL_INPUT_USER_1_BINDS:
case MENU_LABEL_INPUT_USER_2_BINDS:
case MENU_LABEL_INPUT_USER_3_BINDS:
case MENU_LABEL_INPUT_USER_4_BINDS:
case MENU_LABEL_INPUT_USER_5_BINDS:
case MENU_LABEL_INPUT_USER_6_BINDS:
case MENU_LABEL_INPUT_USER_7_BINDS:
case MENU_LABEL_INPUT_USER_8_BINDS:
case MENU_LABEL_INPUT_USER_9_BINDS:
case MENU_LABEL_INPUT_USER_10_BINDS:
case MENU_LABEL_INPUT_USER_11_BINDS:
case MENU_LABEL_INPUT_USER_12_BINDS:
case MENU_LABEL_INPUT_USER_13_BINDS:
case MENU_LABEL_INPUT_USER_14_BINDS:
case MENU_LABEL_INPUT_USER_15_BINDS:
case MENU_LABEL_INPUT_USER_16_BINDS:
case MENU_LABEL_INPUT_HOTKEY_SETTINGS:
case MENU_LABEL_OVERLAY_SETTINGS:
case MENU_LABEL_ONSCREEN_KEYBOARD_OVERLAY_SETTINGS:
case MENU_LABEL_MENU_SETTINGS:
case MENU_LABEL_UI_SETTINGS:
case MENU_LABEL_PATCH_SETTINGS:
case MENU_LABEL_PLAYLIST_SETTINGS:
case MENU_LABEL_CORE_UPDATER_SETTINGS:
case MENU_LABEL_NETWORK_SETTINGS:
case MENU_LABEL_ARCHIVE_SETTINGS:
case MENU_LABEL_USER_SETTINGS:
case MENU_LABEL_DIRECTORY_SETTINGS:
case MENU_LABEL_PRIVACY_SETTINGS:
break;
default:
return 0;
}
return 1;
}
#if 0
#define DEBUG_LOG
#endif

View File

@ -45,8 +45,6 @@ int action_right_cheat(unsigned type, const char *label,
void menu_entries_common_load_content(bool persist);
int menu_entries_common_is_settings_entry(uint32_t label_hash);
int menu_entries_cbs_init_bind_left(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx,
const char *elem0, const char *elem1, const char *menu_label,

View File

@ -637,15 +637,16 @@ int menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
uint32_t label_hash, uint32_t menu_label_hash)
{
settings_t *settings = config_get_ptr();
rarch_setting_t *setting = menu_setting_find(elem0);
if (!cbs)
return -1;
cbs->action_deferred_push = deferred_push_default;
if ((strlen(elem1) != 0) && !!strcmp(elem0, elem1))
if (setting)
{
if (menu_entries_common_is_settings_entry(label_hash))
if (!strcmp(setting->parent_group, "Main Menu") && setting->type == ST_GROUP)
{
if (!settings->menu.collapse_subgroups_enable)
{

View File

@ -347,10 +347,11 @@ static int menu_entries_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *c
const char *label, uint32_t label_hash, const char *elem0)
{
unsigned i;
rarch_setting_t *setting = menu_setting_find(label);
if (label)
if (setting)
{
if (menu_entries_common_is_settings_entry(label_hash))
if (!strcmp(setting->parent_group, "Main Menu") && setting->type == ST_GROUP)
{
cbs->action_left = action_left_scroll;
return 0;

View File

@ -420,10 +420,11 @@ static int menu_entries_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *
const char *label, uint32_t label_hash, uint32_t menu_label_hash, const char *elem0)
{
unsigned i;
rarch_setting_t *setting = menu_setting_find(label);
if (label)
if (setting)
{
if (menu_entries_common_is_settings_entry(label_hash))
if (!strcmp(setting->parent_group, "Settings") && setting->type == ST_GROUP)
{
cbs->action_right = action_right_scroll;
return 0;

View File

@ -46,6 +46,7 @@ static int action_get_title_default(const char *path, const char *label,
struct string_list *list_label = string_split(label, "|");
struct string_list *list_path = string_split(path, "|");
driver_t *driver = driver_get_ptr();
rarch_setting_t *setting = NULL;
*elem0 = *elem1 = *elem0_path = *elem1_path = 0;
@ -77,15 +78,20 @@ static int action_get_title_default(const char *path, const char *label,
RARCH_LOG("label %s, elem0 %s, elem1 %s\n", label, elem0, elem1);
#endif
if (menu_entries_common_is_settings_entry(hash) == 1)
setting = menu_setting_find(label);
if (setting)
{
strlcpy(s, string_to_upper(elem0), len);
if (elem1[0] != '\0')
if (!strcmp(setting->parent_group, "Main Menu") && setting->type == ST_GROUP)
{
strlcat(s, " - ", len);
strlcat(s, string_to_upper(elem1), len);
strlcpy(s, string_to_upper(elem0), len);
if (elem1[0] != '\0')
{
strlcat(s, " - ", len);
strlcat(s, string_to_upper(elem1), len);
}
return 0;
}
return 0;
}
switch (hash)

View File

@ -3629,7 +3629,7 @@ static bool setting_append_list_main_menu_options(
"Save State",
group_info.name,
subgroup_info.name,
parent_group);
"N/A");
(*list)[list_info->index - 1].action_left = &setting_action_left_savestates;
(*list)[list_info->index - 1].action_right = &setting_action_right_savestates;
(*list)[list_info->index - 1].action_start = &setting_action_start_savestates;
@ -3643,7 +3643,7 @@ static bool setting_append_list_main_menu_options(
"Load State",
group_info.name,
subgroup_info.name,
parent_group);
"N/A");
(*list)[list_info->index - 1].action_left = &setting_action_left_savestates;
(*list)[list_info->index - 1].action_right = &setting_action_left_savestates;
(*list)[list_info->index - 1].action_start = &setting_action_start_savestates;
@ -3739,6 +3739,9 @@ static bool setting_append_list_driver_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Driver Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name,
subgroup_info, parent_group);
@ -3876,6 +3879,8 @@ static bool setting_append_list_core_options(
START_GROUP(group_info, "Core Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info,
parent_group);
@ -3938,6 +3943,8 @@ static bool setting_append_list_configuration_options(
START_GROUP(group_info, "Configuration Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info,
parent_group);
@ -4009,6 +4016,8 @@ static bool setting_append_list_saving_options(
START_GROUP(group_info, "Saving Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info,
parent_group);
@ -4127,6 +4136,8 @@ static bool setting_append_list_logging_options(
START_GROUP(group_info, "Logging Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info,
parent_group);
@ -4194,6 +4205,8 @@ static bool setting_append_list_frame_throttling_options(
START_GROUP(group_info, "Frame Throttle Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -4251,6 +4264,8 @@ static bool setting_append_list_rewind_options(
START_GROUP(group_info, "Rewind Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
@ -4310,6 +4325,8 @@ static bool setting_append_list_recording_options(
START_GROUP(group_info, "Recording Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -4413,6 +4430,9 @@ static bool setting_append_list_video_options(
(void)global;
START_GROUP(group_info, "Video Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(settings->fps_show,
@ -4990,6 +5010,9 @@ static bool setting_append_list_font_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Onscreen Display Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "Messages", group_info.name, subgroup_info, parent_group);
#ifndef RARCH_CONSOLE
@ -5075,6 +5098,9 @@ static bool setting_append_list_audio_options(
global_t *global = global_get_ptr();
START_GROUP(group_info, "Audio Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
(void)global;
@ -5136,6 +5162,8 @@ static bool setting_append_list_audio_options(
END_SUB_GROUP(list, list_info, parent_group);
parent_group = "Settings";
START_SUB_GROUP(
list,
list_info,
@ -5227,6 +5255,8 @@ static bool setting_append_list_audio_options(
END_SUB_GROUP(list, list_info, parent_group);
parent_group = "Settings";
START_SUB_GROUP(
list,
list_info,
@ -5290,6 +5320,9 @@ static bool setting_append_list_input_hotkey_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Input Hotkey Binds", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info,
parent_group);
@ -5326,6 +5359,9 @@ static bool setting_append_list_input_options(
global_t *global = global_get_ptr();
START_GROUP(group_info, "Input Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_UINT(
@ -5607,6 +5643,9 @@ static bool setting_append_list_overlay_options(
global_t *global = global_get_ptr();
START_GROUP(group_info, "Onscreen Overlay Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -5686,6 +5725,9 @@ static bool setting_append_list_osk_overlay_options(
global_t *global = global_get_ptr();
START_GROUP(group_info, "Onscreen Keyboard Overlay Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -5731,6 +5773,9 @@ static bool setting_append_list_menu_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Menu Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_PATH(
@ -6017,6 +6062,9 @@ static bool setting_append_list_ui_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "UI Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -6103,6 +6151,9 @@ static bool setting_append_list_archive_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Archive Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_UINT(
@ -6195,6 +6246,8 @@ static bool setting_append_list_netplay_options(
START_GROUP(group_info, "Network Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "Netplay", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -6356,6 +6409,9 @@ static bool setting_append_list_patch_options(
rarch_setting_group_info_t subgroup_info = {0};
START_GROUP(group_info, "Patch Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info);
CONFIG_BOOL(
@ -6411,6 +6467,9 @@ static bool setting_append_list_playlist_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Playlist Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "History", group_info.name, subgroup_info, parent_group);
CONFIG_BOOL(
@ -6454,6 +6513,9 @@ static bool setting_append_list_user_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "User Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_STRING(
@ -6508,6 +6570,8 @@ static bool setting_append_list_directory_options(
START_GROUP(group_info, "Directory Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info, parent_group);
CONFIG_DIR(
@ -6934,6 +6998,9 @@ static bool setting_append_list_privacy_options(
settings_t *settings = config_get_ptr();
START_GROUP(group_info, "Privacy Settings", parent_group);
parent_group = "Settings";
START_SUB_GROUP(list, list_info, "State",
group_info.name, subgroup_info, parent_group);
@ -6996,6 +7063,8 @@ static bool setting_append_list_input_player_options(
START_GROUP(group_info, group_lbl[user], parent_group);
parent_group = "Settings";
START_SUB_GROUP(
list,
list_info,
@ -7093,49 +7162,49 @@ rarch_setting_t *menu_setting_new(unsigned mask)
if (mask & SL_FLAG_DRIVER_OPTIONS)
{
if (!setting_append_list_driver_options(&list, list_info, "Settings"))
if (!setting_append_list_driver_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_CORE_OPTIONS)
{
if (!setting_append_list_core_options(&list, list_info, "Settings"))
if (!setting_append_list_core_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_CONFIGURATION_OPTIONS)
{
if (!setting_append_list_configuration_options(&list, list_info, "Settings"))
if (!setting_append_list_configuration_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_LOGGING_OPTIONS)
{
if (!setting_append_list_logging_options(&list, list_info, "Settings"))
if (!setting_append_list_logging_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_SAVING_OPTIONS)
{
if (!setting_append_list_saving_options(&list, list_info, "Settings"))
if (!setting_append_list_saving_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_REWIND_OPTIONS)
{
if (!setting_append_list_rewind_options(&list, list_info, "Settings"))
if (!setting_append_list_rewind_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_VIDEO_OPTIONS)
{
if (!setting_append_list_video_options(&list, list_info, "Settings"))
if (!setting_append_list_video_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_AUDIO_OPTIONS)
{
if (!setting_append_list_audio_options(&list, list_info, "Settings"))
if (!setting_append_list_audio_options(&list, list_info, "Main Menu"))
goto error;
}
@ -7144,110 +7213,110 @@ rarch_setting_t *menu_setting_new(unsigned mask)
unsigned user;
settings_t *settings = config_get_ptr();
if (!setting_append_list_input_options(&list, list_info, "Settings"))
if (!setting_append_list_input_options(&list, list_info, "Main Menu"))
goto error;
for (user = 0; user < settings->input.max_users; user++)
setting_append_list_input_player_options(&list, list_info, "Settings", user);
setting_append_list_input_player_options(&list, list_info, "Main Menu", user);
}
if (mask & SL_FLAG_INPUT_HOTKEY_OPTIONS)
{
if (!setting_append_list_input_hotkey_options(&list, list_info, "Settings"))
if (!setting_append_list_input_hotkey_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_RECORDING_OPTIONS)
{
if (!setting_append_list_recording_options(&list, list_info, "Settings"))
if (!setting_append_list_recording_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_FRAME_THROTTLE_OPTIONS)
{
if (!setting_append_list_frame_throttling_options(&list, list_info, "Settings"))
if (!setting_append_list_frame_throttling_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_FONT_OPTIONS)
{
if (!setting_append_list_font_options(&list, list_info, "Settings"))
if (!setting_append_list_font_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_OVERLAY_OPTIONS)
{
if (!setting_append_list_overlay_options(&list, list_info, "Settings"))
if (!setting_append_list_overlay_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_OSK_OVERLAY_OPTIONS)
{
if (!setting_append_list_osk_overlay_options(&list, list_info, "Settings"))
if (!setting_append_list_osk_overlay_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_MENU_OPTIONS)
{
if (!setting_append_list_menu_options(&list, list_info, "Settings"))
if (!setting_append_list_menu_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_UI_OPTIONS)
{
if (!setting_append_list_ui_options(&list, list_info, "Settings"))
if (!setting_append_list_ui_options(&list, list_info, "Main Menu"))
goto error;
}
#if 0
if (mask & SL_FLAG_PATCH_OPTIONS)
{
if (!setting_append_list_patch_options(&list, list_info, "Settings"))
if (!setting_append_list_patch_options(&list, list_info, "Main Menu"))
goto error;
}
#endif
if (mask & SL_FLAG_PLAYLIST_OPTIONS)
{
if (!setting_append_list_playlist_options(&list, list_info, "Settings"))
if (!setting_append_list_playlist_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_CORE_UPDATER_OPTIONS)
{
if (!setting_append_list_core_updater_options(&list, list_info, "Settings"))
if (!setting_append_list_core_updater_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_NETPLAY_OPTIONS)
{
if (!setting_append_list_netplay_options(&list, list_info, "Settings"))
if (!setting_append_list_netplay_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_ARCHIVE_OPTIONS)
{
if (!setting_append_list_archive_options(&list, list_info, "Settings"))
if (!setting_append_list_archive_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_USER_OPTIONS)
{
if (!setting_append_list_user_options(&list, list_info, "Settings"))
if (!setting_append_list_user_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_DIRECTORY_OPTIONS)
{
if (!setting_append_list_directory_options(&list, list_info, "Settings"))
if (!setting_append_list_directory_options(&list, list_info, "Main Menu"))
goto error;
}
if (mask & SL_FLAG_PRIVACY_OPTIONS)
{
if (!setting_append_list_privacy_options(&list, list_info, "Settings"))
if (!setting_append_list_privacy_options(&list, list_info, "Main Menu"))
goto error;
}