Simplify command_event_save_current_config

This commit is contained in:
twinaphex 2021-08-12 18:16:50 +02:00
parent 28417a02b7
commit ccb8ecec4d

View File

@ -12980,40 +12980,47 @@ static void command_event_save_current_config(
struct rarch_state *p_rarch,
enum override_type type)
{
char msg[128];
msg[0] = '\0';
switch (type)
{
case OVERRIDE_NONE:
if (path_is_empty(RARCH_PATH_CONFIG))
strcpy_literal(msg, "[Config]: Config directory not set, cannot save configuration.");
else
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
{
if (path_is_empty(RARCH_PATH_CONFIG))
{
char msg[128];
msg[0] = '\0';
strcpy_literal(msg, "[Config]: Config directory not set, cannot save configuration.");
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
else
{
char msg[256];
msg[0] = '\0';
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg));
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
}
break;
case OVERRIDE_GAME:
case OVERRIDE_CORE:
case OVERRIDE_CONTENT_DIR:
if (config_save_overrides(type, &runloop_state.system))
{
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
char msg[128];
msg[0] = '\0';
if (config_save_overrides(type, &runloop_state.system))
{
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
/* set overrides to active so the original config can be
restored after closing content */
runloop_state.overrides_active = true;
}
else
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
RARCH_LOG("[Config - Overrides]: %s\n", msg);
/* set overrides to active so the original config can be
restored after closing content */
runloop_state.overrides_active = true;
}
else
{
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ERROR_SAVING), sizeof(msg));
RARCH_ERR("[Config - Overrides]: %s\n", msg);
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
break;
}
if (!string_is_empty(msg))
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
#endif