From c4880ca8404417f6808a2d1ca6bcc463df256b06 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Fri, 13 Aug 2021 16:16:10 +0100 Subject: [PATCH] Add option to disable core option categories --- config.def.h | 4 ++++ configuration.c | 1 + configuration.h | 1 + core_option_manager.c | 12 +++++++++--- core_option_manager.h | 8 +++++++- intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 1 + menu/menu_setting.c | 11 +++++++++-- msg_hash.h | 1 + retroarch.c | 25 ++++++++++++++++++++++--- 12 files changed, 71 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 5eca3a88a8..06b969aac9 100644 --- a/config.def.h +++ b/config.def.h @@ -276,6 +276,10 @@ #endif #define DEFAULT_CHECK_FIRMWARE_BEFORE_LOADING false +/* Specifies whether cores are allowed to + * present core options in category submenus */ +#define DEFAULT_CORE_OPTION_CATEGORY_ENABLE true + /* Specifies whether to cache core info * into a single (compressed) file for improved * load times on platforms with slow IO */ diff --git a/configuration.c b/configuration.c index cdefeac66c..43ecf76636 100644 --- a/configuration.c +++ b/configuration.c @@ -1523,6 +1523,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("input_descriptor_hide_unbound", &settings->bools.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false); SETTING_BOOL("load_dummy_on_core_shutdown", &settings->bools.load_dummy_on_core_shutdown, true, DEFAULT_LOAD_DUMMY_ON_CORE_SHUTDOWN, false); SETTING_BOOL("check_firmware_before_loading", &settings->bools.check_firmware_before_loading, true, DEFAULT_CHECK_FIRMWARE_BEFORE_LOADING, false); + SETTING_BOOL("core_option_category_enable", &settings->bools.core_option_category_enable, true, DEFAULT_CORE_OPTION_CATEGORY_ENABLE, false); #if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP SETTING_BOOL("core_info_cache_enable", &settings->bools.core_info_cache_enable, false, DEFAULT_CORE_INFO_CACHE_ENABLE, false); #else diff --git a/configuration.h b/configuration.h index 7ff805481c..d2fd45ee6e 100644 --- a/configuration.h +++ b/configuration.h @@ -794,6 +794,7 @@ typedef struct settings bool network_remote_enable_user[MAX_USERS]; bool load_dummy_on_core_shutdown; bool check_firmware_before_loading; + bool core_option_category_enable; bool core_info_cache_enable; #ifndef HAVE_DYNAMIC bool always_reload_core_on_run_content; diff --git a/core_option_manager.c b/core_option_manager.c index 6a2e563a8d..e99c5ffd98 100644 --- a/core_option_manager.c +++ b/core_option_manager.c @@ -1051,16 +1051,22 @@ static bool core_option_manager_parse_option( * @src_conf_path : Filesystem path from which to load * initial config settings. * @options_v2 : Pointer to retro_core_options_v2 struct + * @categorized : Flag specifying whether core option + * category information should be read + * from @options_v2 * * Creates and initializes a core manager handle. Parses * information from a retro_core_options_v2 struct. + * If @categorized is false, all option category + * assignments will be ignored. * * Returns: handle to new core manager handle if successful, * otherwise NULL. **/ core_option_manager_t *core_option_manager_new( const char *conf_path, const char *src_conf_path, - const struct retro_core_options_v2 *options_v2) + const struct retro_core_options_v2 *options_v2, + bool categorized) { const struct retro_core_option_v2_category *option_cat = NULL; const struct retro_core_option_v2_definition *option_def = NULL; @@ -1107,9 +1113,9 @@ core_option_manager_t *core_option_manager_new( if (!string_is_empty(src_conf_path)) config_src = config_file_new_from_path_to_string(src_conf_path); - /* Get number of categories + /* Get number of categories, if required * > Note: 'option_cat->info == NULL' is valid */ - if (option_cats) + if (categorized && option_cats) { for (option_cat = option_cats; !string_is_empty(option_cat->key) && diff --git a/core_option_manager.h b/core_option_manager.h index 7c5c06489c..c7c6405b10 100644 --- a/core_option_manager.h +++ b/core_option_manager.h @@ -174,16 +174,22 @@ core_option_manager_t *core_option_manager_new_vars( * @src_conf_path : Filesystem path from which to load * initial config settings. * @options_v2 : Pointer to retro_core_options_v2 struct + * @categorized : Flag specifying whether core option + * category information should be read + * from @options_v2 * * Creates and initializes a core manager handle. Parses * information from a retro_core_options_v2 struct. + * If @categorized is false, all option category + * assignments will be ignored. * * Returns: handle to new core manager handle if successful, * otherwise NULL. **/ core_option_manager_t *core_option_manager_new( const char *conf_path, const char *src_conf_path, - const struct retro_core_options_v2 *options_v2); + const struct retro_core_options_v2 *options_v2, + bool categorized); /** * core_option_manager_free: diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 00d70199d6..ccebb03cb3 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1180,6 +1180,10 @@ MSG_HASH( MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE, "check_for_missing_firmware" ) +MSG_HASH( + MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE, + "core_option_category_enable" + ) MSG_HASH( MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE, "core_info_cache_enable" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index ed9b3ffdcc..1a4780fb43 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2948,6 +2948,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE, "Check if all the required firmware is present before attempting to load content." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CORE_OPTION_CATEGORY_ENABLE, + "Core Option Categories" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CORE_OPTION_CATEGORY_ENABLE, + "Allow cores to present options in category-based submenus. NOTE: Core must be reloaded for changes to take effect." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CORE_INFO_CACHE_ENABLE, "Cache Core Info Files" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index a23ce429a4..82ba188398 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -361,6 +361,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_adaptive_vsync, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_allow_rotate, MENU_ENUM_SUBLABEL_VIDEO_ALLOW_ROTATE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_dummy_on_core_shutdown, MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_dummy_check_missing_firmware, MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_option_category_enable, MENU_ENUM_SUBLABEL_CORE_OPTION_CATEGORY_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_info_cache_enable, MENU_ENUM_SUBLABEL_CORE_INFO_CACHE_ENABLE) #ifndef HAVE_DYNAMIC DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_always_reload_core_on_run_content, MENU_ENUM_SUBLABEL_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT) @@ -3528,6 +3529,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_dummy_check_missing_firmware); break; + case MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_option_category_enable); + break; case MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_info_cache_enable); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index bb9fe6f5c4..69527f1844 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -8913,6 +8913,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE, PARSE_ONLY_BOOL}, #ifndef HAVE_DYNAMIC {MENU_ENUM_LABEL_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, PARSE_ONLY_BOOL}, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index e0fba1629f..8b7f40ad9a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9636,9 +9636,9 @@ static bool setting_append_list( { unsigned i, listing = 0; #ifndef HAVE_DYNAMIC - struct bool_entry bool_entries[8]; + struct bool_entry bool_entries[9]; #else - struct bool_entry bool_entries[7]; + struct bool_entry bool_entries[8]; #endif START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS), parent_group); @@ -9693,6 +9693,13 @@ static bool setting_append_list( bool_entries[listing].flags = SD_FLAG_ADVANCED; listing++; + bool_entries[listing].target = &settings->bools.core_option_category_enable; + bool_entries[listing].name_enum_idx = MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE; + bool_entries[listing].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_CORE_OPTION_CATEGORY_ENABLE; + bool_entries[listing].default_value = DEFAULT_CORE_OPTION_CATEGORY_ENABLE; + bool_entries[listing].flags = SD_FLAG_NONE; + listing++; + bool_entries[listing].target = &settings->bools.core_info_cache_enable; bool_entries[listing].name_enum_idx = MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE; bool_entries[listing].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_CORE_INFO_CACHE_ENABLE; diff --git a/msg_hash.h b/msg_hash.h index 95bf05956c..f7741c91a9 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2152,6 +2152,7 @@ enum msg_hash_enums MENU_LABEL(DUMMY_ON_CORE_SHUTDOWN), MENU_LABEL(CHECK_FOR_MISSING_FIRMWARE), + MENU_LABEL(CORE_OPTION_CATEGORY_ENABLE), MENU_LABEL(CORE_INFO_CACHE_ENABLE), #ifndef HAVE_DYNAMIC MENU_LABEL(ALWAYS_RELOAD_CORE_ON_RUN_CONTENT), diff --git a/retroarch.c b/retroarch.c index ab09ee63e3..d31658379f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -16601,6 +16601,8 @@ static bool rarch_environment_cb(unsigned cmd, void *data) { const struct retro_core_options_v2 *options_v2 = (const struct retro_core_options_v2 *)data; + bool categories_enabled = + settings->bools.core_option_category_enable; if (runloop_state.core_options) retroarch_deinit_core_options(p_rarch, @@ -16608,6 +16610,12 @@ static bool rarch_environment_cb(unsigned cmd, void *data) if (options_v2) rarch_init_core_options(p_rarch, options_v2); + + /* Return value does not indicate success. + * Callback returns 'true' if core option + * categories are supported/enabled, + * otherwise 'false'. */ + return categories_enabled; } break; @@ -16620,6 +16628,8 @@ static bool rarch_environment_cb(unsigned cmd, void *data) struct retro_core_options_v2 *options_v2 = core_option_manager_convert_v2_intl( (const struct retro_core_options_v2_intl*)data); + bool categories_enabled = + settings->bools.core_option_category_enable; if (runloop_state.core_options) retroarch_deinit_core_options(p_rarch, @@ -16633,6 +16643,12 @@ static bool rarch_environment_cb(unsigned cmd, void *data) /* Clean up */ core_option_manager_free_converted(options_v2); } + + /* Return value does not indicate success. + * Callback returns 'true' if core option + * categories are supported/enabled, + * otherwise 'false'. */ + return categories_enabled; } break; @@ -36010,12 +36026,14 @@ static void rarch_init_core_options( struct rarch_state *p_rarch, const struct retro_core_options_v2 *options_v2) { + settings_t *settings = p_rarch->configuration_settings; + bool categories_enabled = settings->bools.core_option_category_enable; char options_path[PATH_MAX_LENGTH]; char src_options_path[PATH_MAX_LENGTH]; /* Ensure these are NULL-terminated */ - options_path[0] = '\0'; - src_options_path[0] = '\0'; + options_path[0] = '\0'; + src_options_path[0] = '\0'; /* Get core options file path */ rarch_init_core_options_path(p_rarch, @@ -36025,7 +36043,8 @@ static void rarch_init_core_options( if (!string_is_empty(options_path)) runloop_state.core_options = core_option_manager_new(options_path, - src_options_path, options_v2); + src_options_path, options_v2, + categories_enabled); } void retroarch_init_task_queue(void)