Add Save Current Config to Menu

This commit is contained in:
twinaphex 2015-11-11 02:57:20 +01:00
parent 7bcd7d1d3d
commit 38f30c8f10
8 changed files with 52 additions and 29 deletions

View File

@ -893,6 +893,34 @@ static bool event_save_core_config(void)
return ret; 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 * event_save_state
* @path : Path to 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) if (driver->frontend_ctx && driver->frontend_ctx->set_fork)
driver->frontend_ctx->set_fork(true, false); driver->frontend_ctx->set_fork(true, false);
break; break;
case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG:
event_save_current_config();
break;
case EVENT_CMD_MENU_SAVE_CONFIG: case EVENT_CMD_MENU_SAVE_CONFIG:
if (!event_save_core_config()) if (!event_save_core_config())
return false; return false;

View File

@ -128,6 +128,7 @@ enum event_command
/* Unpauses retroArch. */ /* Unpauses retroArch. */
EVENT_CMD_PAUSE, EVENT_CMD_PAUSE,
EVENT_CMD_PAUSE_CHECKS, EVENT_CMD_PAUSE_CHECKS,
EVENT_CMD_MENU_SAVE_CURRENT_CONFIG,
EVENT_CMD_MENU_SAVE_CONFIG, EVENT_CMD_MENU_SAVE_CONFIG,
EVENT_CMD_MENU_PAUSE_LIBRETRO, EVENT_CMD_MENU_PAUSE_LIBRETRO,
/* Toggles menu on/off. */ /* Toggles menu on/off. */

View File

@ -29,34 +29,6 @@
#define MAX_ARGS 32 #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: * main_exit:
* *
@ -73,7 +45,7 @@ void main_exit(void *args)
const frontend_ctx_driver_t *frontend = frontend_get_ptr(); const frontend_ctx_driver_t *frontend = frontend_get_ptr();
const ui_companion_driver_t *ui = ui_companion_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) if (global->inited.main)
{ {

View File

@ -1309,6 +1309,8 @@ static int mui_list_push(menu_displaylist_info_t *info, unsigned type)
#endif #endif
menu_displaylist_parse_settings(menu, info, menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); 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_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false);
menu_displaylist_parse_settings(menu, info, menu_displaylist_parse_settings(menu, info,

View File

@ -2653,6 +2653,8 @@ static int xmb_list_push(menu_displaylist_info_t *info, unsigned type)
#endif #endif
menu_displaylist_parse_settings(menu, info, menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false); 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_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false); menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false);
menu_displaylist_parse_settings(menu, info, menu_displaylist_parse_settings(menu, info,

View File

@ -26,6 +26,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash)
{ {
switch (hash) switch (hash)
{ {
case MENU_LABEL_SAVE_CURRENT_CONFIG:
return "save_current_config";
case MENU_LABEL_STATE_SLOT: case MENU_LABEL_STATE_SLOT:
return "state_slot"; return "state_slot";
case MENU_LABEL_CHEEVOS_USERNAME: case MENU_LABEL_CHEEVOS_USERNAME:
@ -688,6 +690,8 @@ const char *menu_hash_to_str_us(uint32_t hash)
switch (hash) switch (hash)
{ {
case MENU_LABEL_VALUE_SAVE_CURRENT_CONFIG:
return "Save Current Config";
case MENU_LABEL_VALUE_STATE_SLOT: case MENU_LABEL_VALUE_STATE_SLOT:
return "State Slot"; return "State Slot";
case MENU_LABEL_VALUE_ACCOUNTS_CHEEVOS_SETTINGS: case MENU_LABEL_VALUE_ACCOUNTS_CHEEVOS_SETTINGS:

View File

@ -1074,6 +1074,9 @@ extern "C" {
#define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT 0x74b36f11U #define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT 0x74b36f11U
#define MENU_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC 0xac947056U #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); const char *menu_hash_to_str_de(uint32_t hash);
int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len);

View File

@ -3146,6 +3146,14 @@ static bool setting_append_list_main_menu_options(
subgroup_info.name, subgroup_info.name,
parent_group); 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( CONFIG_ACTION(
menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG),
menu_hash_to_str(MENU_LABEL_VALUE_SAVE_NEW_CONFIG), menu_hash_to_str(MENU_LABEL_VALUE_SAVE_NEW_CONFIG),