Override config + appendconfig fixes (#14920)

This commit is contained in:
sonninnos 2023-01-29 01:12:08 +02:00 committed by GitHub
parent 74d0123b9f
commit 6378d8e0f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 61 deletions

View File

@ -1062,9 +1062,6 @@ bool command_event_save_config(
return true; return true;
} }
if (runloop_get_flags() & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
return false;
if (!string_is_empty(str)) if (!string_is_empty(str))
{ {
snprintf(s, len, "%s \"%s\".", snprintf(s, len, "%s \"%s\".",
@ -1574,12 +1571,16 @@ void command_event_save_current_config(enum override_type type)
if (path_is_empty(RARCH_PATH_CONFIG)) if (path_is_empty(RARCH_PATH_CONFIG))
{ {
strlcpy(msg, "[Config]: Config directory not set, cannot save configuration.", sizeof(msg)); strlcpy(msg, "Config directory not set, cannot save configuration.", sizeof(msg));
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
} }
else else
{ {
command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg)); if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_ACTIVE_NOT_SAVING), sizeof(msg));
else
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); runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
} }
} }

View File

@ -3334,6 +3334,7 @@ static bool config_load_file(global_t *global,
unsigned i; unsigned i;
char tmp_str[PATH_MAX_LENGTH]; char tmp_str[PATH_MAX_LENGTH];
static bool first_load = true; static bool first_load = true;
bool without_overrides = false;
unsigned msg_color = 0; unsigned msg_color = 0;
char *save = NULL; char *save = NULL;
char *override_username = NULL; char *override_username = NULL;
@ -3353,11 +3354,20 @@ static bool config_load_file(global_t *global,
struct config_size_setting *size_settings = NULL; struct config_size_setting *size_settings = NULL;
struct config_array_setting *array_settings = NULL; struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL; struct config_path_setting *path_settings = NULL;
config_file_t *conf = path ? config_file_new_from_path_to_string(path) : open_default_config_file(); config_file_t *conf = NULL;
uint16_t rarch_flags = retroarch_get_flags(); uint16_t rarch_flags = retroarch_get_flags();
tmp_str[0] = '\0'; tmp_str[0] = '\0';
/* Override config comparison must be compared to config before overrides */
if (string_is_equal(path, "without-overrides"))
{
path = path_get(RARCH_PATH_CONFIG);
without_overrides = true;
}
conf = (path) ? config_file_new_from_path_to_string(path) : open_default_config_file();
if (!conf) if (!conf)
{ {
first_load = false; first_load = false;
@ -3413,7 +3423,7 @@ static bool config_load_file(global_t *global,
check_verbosity_settings(conf, settings); check_verbosity_settings(conf, settings);
} }
if (!path_is_empty(RARCH_PATH_CONFIG_OVERRIDE)) if (!path_is_empty(RARCH_PATH_CONFIG_OVERRIDE) && !without_overrides)
{ {
/* Don't destroy append_config_path, store in temporary /* Don't destroy append_config_path, store in temporary
* variable. */ * variable. */
@ -4126,6 +4136,11 @@ bool config_load_override(void *data)
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
if (!string_is_empty(path_get(RARCH_PATH_CONFIG_OVERRIDE)))
runloop_state_get_ptr()->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
else
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
return true; return true;
} }
@ -4175,6 +4190,11 @@ bool config_load_override_file(const char *config_path)
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
if (!string_is_empty(path_get(RARCH_PATH_CONFIG_OVERRIDE)))
runloop_state_get_ptr()->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
else
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
return true; return true;
} }
@ -4188,6 +4208,7 @@ bool config_load_override_file(const char *config_path)
*/ */
bool config_unload_override(void) bool config_unload_override(void)
{ {
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
path_clear(RARCH_PATH_CONFIG_OVERRIDE); path_clear(RARCH_PATH_CONFIG_OVERRIDE);
/* Toggle has_save_path to false so it resets */ /* Toggle has_save_path to false so it resets */
@ -5110,7 +5131,7 @@ int8_t config_save_overrides(enum override_type type, void *data, bool remove)
/* Load the original config file in memory */ /* Load the original config file in memory */
config_load_file(global_get_ptr(), config_load_file(global_get_ptr(),
path_get(RARCH_PATH_CONFIG), settings); "without-overrides", settings);
bool_settings = populate_settings_bool(settings, &bool_settings_size); bool_settings = populate_settings_bool(settings, &bool_settings_size);
tmp_i = sizeof(settings->bools) / sizeof(settings->bools.placeholder); tmp_i = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
@ -5344,20 +5365,26 @@ int8_t config_save_overrides(enum override_type type, void *data, bool remove)
{ {
if (filestream_delete(override_path) == 0) if (filestream_delete(override_path) == 0)
{ {
config_load_override(&runloop_state_get_ptr()->system);
ret = -1; ret = -1;
RARCH_LOG("[Overrides]: %s: \"%s\".\n", RARCH_LOG("[Overrides]: %s: \"%s\".\n",
"Deleting", "Deleted", override_path);
override_path);
} }
} }
else if (conf->modified) else if (conf->modified)
{ {
ret = config_file_write(conf, override_path, true); ret = config_file_write(conf, override_path, true);
path_set(RARCH_PATH_CONFIG_OVERRIDE, override_path);
RARCH_LOG("[Overrides]: %s: \"%s\".\n", if (ret)
"Saving", {
override_path); path_set(RARCH_PATH_CONFIG_OVERRIDE, override_path);
RARCH_LOG("[Overrides]: %s: \"%s\".\n",
"Saved", override_path);
}
else
{
RARCH_LOG("[Overrides]: %s: \"%s\".\n",
"Failed to save", override_path);
}
} }
} }

View File

@ -13702,6 +13702,10 @@ MSG_HASH(
MSG_OVERRIDES_NOT_SAVED, MSG_OVERRIDES_NOT_SAVED,
"Nothing to save. Overrides not saved." "Nothing to save. Overrides not saved."
) )
MSG_HASH(
MSG_OVERRIDES_ACTIVE_NOT_SAVING,
"Not saving. Overrides active."
)
MSG_HASH( MSG_HASH(
MSG_PAUSED, MSG_PAUSED,
"Paused." "Paused."

View File

@ -3786,12 +3786,14 @@ static int action_ok_remap_file_flush(const char *path,
static int action_ok_override_unload(const char *path, static int action_ok_override_unload(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
#ifdef HAVE_CONFIGFILE
if (!config_unload_override()) if (!config_unload_override())
return 0; return 0;
runloop_msg_queue_push( runloop_msg_queue_push(
msg_hash_to_str(MSG_OVERRIDES_UNLOADED_SUCCESSFULLY), msg_hash_to_str(MSG_OVERRIDES_UNLOADED_SUCCESSFULLY),
1, 100, true, 1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
#endif
return 0; return 0;
} }

View File

@ -13747,48 +13747,45 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
content_dir_name[0] = '\0'; content_dir_name[0] = '\0';
override_path[0] = '\0'; override_path[0] = '\0';
if (!string_is_empty(rarch_path_override)) fill_pathname_application_special(config_directory,
sizeof(config_directory),
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
if (has_content)
{ {
fill_pathname_application_special(config_directory, /* Game-specific path */
sizeof(config_directory), fill_pathname_join_special_ext(override_path,
APPLICATION_SPECIAL_DIRECTORY_CONFIG); config_directory, core_name,
path_basename_nocompression(rarch_path_basename),
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
if (has_content) game_override_remove = path_is_valid(override_path);
{ override_path[0] = '\0';
/* Game-specific path */
fill_pathname_join_special_ext(override_path,
config_directory, core_name,
path_basename_nocompression(rarch_path_basename),
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
game_override_remove = path_is_valid(override_path); /* Contentdir-specific path */
override_path[0] = '\0'; fill_pathname_parent_dir_name(content_dir_name,
rarch_path_basename, sizeof(content_dir_name));
fill_pathname_join_special_ext(override_path,
config_directory, core_name,
content_dir_name,
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
/* Contentdir-specific path */ content_dir_override_remove = path_is_valid(override_path);
fill_pathname_parent_dir_name(content_dir_name, override_path[0] = '\0';
rarch_path_basename, sizeof(content_dir_name)); }
fill_pathname_join_special_ext(override_path,
config_directory, core_name,
content_dir_name,
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
content_dir_override_remove = path_is_valid(override_path); {
override_path[0] = '\0'; /* Core-specific path */
} fill_pathname_join_special_ext(override_path,
config_directory, core_name,
core_name,
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
{ core_override_remove = path_is_valid(override_path);
/* Core-specific path */ override_path[0] = '\0';
fill_pathname_join_special_ext(override_path,
config_directory, core_name,
core_name,
FILE_PATH_CONFIG_EXTENSION,
sizeof(override_path));
core_override_remove = path_is_valid(override_path);
override_path[0] = '\0';
}
} }
/* Show currently 'active' override file */ /* Show currently 'active' override file */

View File

@ -338,6 +338,7 @@ enum msg_hash_enums
MSG_COULD_NOT_READ_STATE_FROM_MOVIE, MSG_COULD_NOT_READ_STATE_FROM_MOVIE,
MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE, MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE,
MSG_OVERRIDES_NOT_SAVED, MSG_OVERRIDES_NOT_SAVED,
MSG_OVERRIDES_ACTIVE_NOT_SAVING,
MSG_OVERRIDES_SAVED_SUCCESSFULLY, MSG_OVERRIDES_SAVED_SUCCESSFULLY,
MSG_OVERRIDES_REMOVED_SUCCESSFULLY, MSG_OVERRIDES_REMOVED_SUCCESSFULLY,
MSG_OVERRIDES_UNLOADED_SUCCESSFULLY, MSG_OVERRIDES_UNLOADED_SUCCESSFULLY,

View File

@ -2616,7 +2616,6 @@ bool command_event(enum event_command cmd, void *data)
{ {
/* Reload the original config */ /* Reload the original config */
config_unload_override(); config_unload_override();
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
if (!settings->bools.video_fullscreen) if (!settings->bools.video_fullscreen)
{ {
@ -6223,7 +6222,6 @@ bool retroarch_main_init(int argc, char *argv[])
{ {
/* Reload the original config */ /* Reload the original config */
config_unload_override(); config_unload_override();
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
} }
#endif #endif
@ -6947,7 +6945,6 @@ bool retroarch_main_quit(void)
{ {
/* Reload the original config */ /* Reload the original config */
config_unload_override(); config_unload_override();
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
} }
#endif #endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)

View File

@ -3968,7 +3968,6 @@ void runloop_event_deinit_core(void)
{ {
/* Reload the original config */ /* Reload the original config */
config_unload_override(); config_unload_override();
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
} }
#endif #endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
@ -4525,12 +4524,7 @@ bool runloop_event_init_core(
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
if (auto_overrides_enable) if (auto_overrides_enable)
{ config_load_override(&runloop_st->system);
if (config_load_override(&runloop_st->system))
runloop_st->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
}
#endif #endif
/* Cannot access these settings-related parameters /* Cannot access these settings-related parameters