mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Override config + appendconfig fixes (#14920)
This commit is contained in:
parent
74d0123b9f
commit
6378d8e0f8
11
command.c
11
command.c
@ -1062,9 +1062,6 @@ bool command_event_save_config(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (runloop_get_flags() & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
|
||||
return false;
|
||||
|
||||
if (!string_is_empty(str))
|
||||
{
|
||||
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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -3334,6 +3334,7 @@ static bool config_load_file(global_t *global,
|
||||
unsigned i;
|
||||
char tmp_str[PATH_MAX_LENGTH];
|
||||
static bool first_load = true;
|
||||
bool without_overrides = false;
|
||||
unsigned msg_color = 0;
|
||||
char *save = 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_array_setting *array_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();
|
||||
|
||||
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)
|
||||
{
|
||||
first_load = false;
|
||||
@ -3413,7 +3423,7 @@ static bool config_load_file(global_t *global,
|
||||
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
|
||||
* 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_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;
|
||||
}
|
||||
|
||||
@ -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_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;
|
||||
}
|
||||
|
||||
@ -4188,6 +4208,7 @@ bool config_load_override_file(const char *config_path)
|
||||
*/
|
||||
bool config_unload_override(void)
|
||||
{
|
||||
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
path_clear(RARCH_PATH_CONFIG_OVERRIDE);
|
||||
|
||||
/* 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 */
|
||||
config_load_file(global_get_ptr(),
|
||||
path_get(RARCH_PATH_CONFIG), settings);
|
||||
"without-overrides", settings);
|
||||
|
||||
bool_settings = populate_settings_bool(settings, &bool_settings_size);
|
||||
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)
|
||||
{
|
||||
config_load_override(&runloop_state_get_ptr()->system);
|
||||
ret = -1;
|
||||
RARCH_LOG("[Overrides]: %s: \"%s\".\n",
|
||||
"Deleting",
|
||||
override_path);
|
||||
"Deleted", override_path);
|
||||
}
|
||||
}
|
||||
else if (conf->modified)
|
||||
{
|
||||
ret = config_file_write(conf, override_path, true);
|
||||
path_set(RARCH_PATH_CONFIG_OVERRIDE, override_path);
|
||||
RARCH_LOG("[Overrides]: %s: \"%s\".\n",
|
||||
"Saving",
|
||||
override_path);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13702,6 +13702,10 @@ MSG_HASH(
|
||||
MSG_OVERRIDES_NOT_SAVED,
|
||||
"Nothing to save. Overrides not saved."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_OVERRIDES_ACTIVE_NOT_SAVING,
|
||||
"Not saving. Overrides active."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_PAUSED,
|
||||
"Paused."
|
||||
|
@ -3786,12 +3786,14 @@ static int action_ok_remap_file_flush(const char *path,
|
||||
static int action_ok_override_unload(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
if (!config_unload_override())
|
||||
return 0;
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_OVERRIDES_UNLOADED_SUCCESSFULLY),
|
||||
1, 100, true,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13747,48 +13747,45 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
content_dir_name[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,
|
||||
sizeof(config_directory),
|
||||
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
|
||||
/* 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));
|
||||
|
||||
if (has_content)
|
||||
{
|
||||
/* 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);
|
||||
override_path[0] = '\0';
|
||||
|
||||
game_override_remove = path_is_valid(override_path);
|
||||
override_path[0] = '\0';
|
||||
/* Contentdir-specific path */
|
||||
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 */
|
||||
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));
|
||||
content_dir_override_remove = path_is_valid(override_path);
|
||||
override_path[0] = '\0';
|
||||
}
|
||||
|
||||
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-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);
|
||||
override_path[0] = '\0';
|
||||
}
|
||||
core_override_remove = path_is_valid(override_path);
|
||||
override_path[0] = '\0';
|
||||
}
|
||||
|
||||
/* Show currently 'active' override file */
|
||||
|
@ -338,6 +338,7 @@ enum msg_hash_enums
|
||||
MSG_COULD_NOT_READ_STATE_FROM_MOVIE,
|
||||
MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE,
|
||||
MSG_OVERRIDES_NOT_SAVED,
|
||||
MSG_OVERRIDES_ACTIVE_NOT_SAVING,
|
||||
MSG_OVERRIDES_SAVED_SUCCESSFULLY,
|
||||
MSG_OVERRIDES_REMOVED_SUCCESSFULLY,
|
||||
MSG_OVERRIDES_UNLOADED_SUCCESSFULLY,
|
||||
|
@ -2616,7 +2616,6 @@ bool command_event(enum event_command cmd, void *data)
|
||||
{
|
||||
/* Reload the original config */
|
||||
config_unload_override();
|
||||
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
|
||||
if (!settings->bools.video_fullscreen)
|
||||
{
|
||||
@ -6223,7 +6222,6 @@ bool retroarch_main_init(int argc, char *argv[])
|
||||
{
|
||||
/* Reload the original config */
|
||||
config_unload_override();
|
||||
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -6947,7 +6945,6 @@ bool retroarch_main_quit(void)
|
||||
{
|
||||
/* Reload the original config */
|
||||
config_unload_override();
|
||||
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
|
||||
|
@ -3968,7 +3968,6 @@ void runloop_event_deinit_core(void)
|
||||
{
|
||||
/* Reload the original config */
|
||||
config_unload_override();
|
||||
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
}
|
||||
#endif
|
||||
#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
|
||||
if (auto_overrides_enable)
|
||||
{
|
||||
if (config_load_override(&runloop_st->system))
|
||||
runloop_st->flags |= RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
else
|
||||
runloop_st->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;
|
||||
}
|
||||
config_load_override(&runloop_st->system);
|
||||
#endif
|
||||
|
||||
/* Cannot access these settings-related parameters
|
||||
|
Loading…
x
Reference in New Issue
Block a user