diff --git a/command_event.c b/command_event.c index 769a24eee1..32b3589a09 100644 --- a/command_event.c +++ b/command_event.c @@ -893,6 +893,34 @@ static bool event_save_core_config(void) return ret; } +/** + * event_save_current_config: + * + * Saves current configuration file to disk, and (optionally) + * autosave state. + **/ +void event_save_current_config(void) +{ + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (settings->config_save_on_exit && *global->path.config) + { + /* Save last core-specific config to the default config location, + * needed on consoles for core switching and reusing last good + * config for new cores. + */ + config_save_file(global->path.config); + + /* Flush out the core specific config. */ + if (*global->path.core_specific_config && + settings->core_specific_config) + config_save_file(global->path.core_specific_config); + } + + event_command(EVENT_CMD_AUTOSAVE_STATE); +} + /** * event_save_state * @path : Path to state. @@ -1440,6 +1468,9 @@ bool event_command(enum event_command cmd) if (driver->frontend_ctx && driver->frontend_ctx->set_fork) driver->frontend_ctx->set_fork(true, false); break; + case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: + event_save_current_config(); + break; case EVENT_CMD_MENU_SAVE_CONFIG: if (!event_save_core_config()) return false; diff --git a/command_event.h b/command_event.h index 79df12f7d3..02558f7425 100644 --- a/command_event.h +++ b/command_event.h @@ -128,6 +128,7 @@ enum event_command /* Unpauses retroArch. */ EVENT_CMD_PAUSE, EVENT_CMD_PAUSE_CHECKS, + EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, EVENT_CMD_MENU_SAVE_CONFIG, EVENT_CMD_MENU_PAUSE_LIBRETRO, /* Toggles menu on/off. */ diff --git a/frontend/frontend.c b/frontend/frontend.c index d6c1b1fa4e..f6e7dfa300 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -29,34 +29,6 @@ #define MAX_ARGS 32 -/** - * main_exit_save_config: - * - * Saves configuration file to disk, and (optionally) - * autosave state. - **/ -void main_exit_save_config(void) -{ - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - if (settings->config_save_on_exit && *global->path.config) - { - /* Save last core-specific config to the default config location, - * needed on consoles for core switching and reusing last good - * config for new cores. - */ - config_save_file(global->path.config); - - /* Flush out the core specific config. */ - if (*global->path.core_specific_config && - settings->core_specific_config) - config_save_file(global->path.core_specific_config); - } - - event_command(EVENT_CMD_AUTOSAVE_STATE); -} - /** * main_exit: * @@ -73,7 +45,7 @@ void main_exit(void *args) const frontend_ctx_driver_t *frontend = frontend_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); - main_exit_save_config(); + event_command(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); if (global->inited.main) { diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index aa7ac455cf..18760517ab 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1309,6 +1309,8 @@ static int mui_list_push(menu_displaylist_info_t *info, unsigned type) #endif menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); + menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c9f913bd79..49d5c2a988 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2653,6 +2653,8 @@ static int xmb_list_push(menu_displaylist_info_t *info, unsigned type) #endif menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); + menu_displaylist_parse_settings(menu, info, + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_displaylist_parse_settings(menu, info, diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 97c2bd739b..744fd063e5 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -26,6 +26,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) { switch (hash) { + case MENU_LABEL_SAVE_CURRENT_CONFIG: + return "save_current_config"; case MENU_LABEL_STATE_SLOT: return "state_slot"; case MENU_LABEL_CHEEVOS_USERNAME: @@ -688,6 +690,8 @@ const char *menu_hash_to_str_us(uint32_t hash) switch (hash) { + case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG: + return "Save Current Config"; case MENU_LABEL_VALUE_STATE_SLOT: return "State Slot"; case MENU_LABEL_VALUE_ACCOUNTS_CHEEVOS_SETTINGS: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 6a472d33f4..400b027eb2 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -1074,6 +1074,9 @@ extern "C" { #define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT 0x74b36f11U #define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC 0xac947056U +#define MENU_LABEL_SAVE_CURRENT_CONFIG 0x8840ba8bU +#define MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG 0x9a1eb42dU + const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index bb5616a11f..a2f0449212 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3146,6 +3146,14 @@ static bool setting_append_list_main_menu_options( subgroup_info.name, parent_group); + CONFIG_ACTION( + menu_hash_to_str(MENU_LABEL_SAVE_CURRENT_CONFIG), + menu_hash_to_str(MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG), + group_info.name, + subgroup_info.name, + parent_group); + menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); + CONFIG_ACTION( menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), menu_hash_to_str(MENU_LABEL_VALUE_SAVE_NEW_CONFIG),