allow loading of parent-dir specific presets

This commit is contained in:
radius 2018-01-28 16:22:50 -05:00
parent 5783030b5c
commit 940efa8d73
3 changed files with 39 additions and 8 deletions

View File

@ -36,6 +36,8 @@
- LOCALIZATION: Update Spanish translation.
- NETPLAY: Add menu option to select different MITM (relay) server locations.
- OSX: Modify HID buttons detection algorithm.
- SHADERS: Allow saving of shader presets based on the parent directory (Saving one for */foo/bar/mario.sfc* would result in *shaders/presets/corename/bar.ext*). We decided it's safer to still isolate the presets to a single core because different cores may treat video output differently.
- SHADERS: Don't save the path to the current preset to the main config. This was causing weird behavior, instead it will try to load *currentconfig.ext* and it will save a preset with that name when select *apply shader preset*. The resulting shader will restore properly after restarting and even after core/parent/game specific presets are loaded
- SOLARIS: Initial port.
- SWITCH: Initial Nintendo Switch port, based on libtransistor SDK.
- PS3: Enable Cheevos.

View File

@ -1070,8 +1070,6 @@ static struct config_path_setting *populate_settings_path(settings_t *settings,
settings->paths.path_core_options, false, NULL, true);
SETTING_PATH("libretro_info_path",
settings->paths.path_libretro_info, false, NULL, true);
SETTING_PATH("video_shader",
settings->paths.path_shader, false, NULL, true);
SETTING_PATH("content_database_path",
settings->paths.path_content_database, false, NULL, true);
SETTING_PATH("cheat_database_path",
@ -3227,10 +3225,19 @@ bool config_load_shader_preset(void)
char *shader_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *parent_path = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char *parent_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for parent-dir-specific configuration (prefix+suffix) */
char parent_name[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(parent_name, path_get(RARCH_PATH_BASENAME), sizeof(parent_name));
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
@ -3288,6 +3295,33 @@ bool config_load_shader_preset(void)
goto success;
}
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
{
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, parent path */
fill_pathname_join_special_ext(parent_path,
shader_directory, core_name,
parent_name,
file_path_str((enum file_path_enum)(idx)),
path_size);
/* Create a new config file from parent path */
new_conf = config_file_new(parent_path);
if (!new_conf)
{
RARCH_LOG("Shaders: no parent-dir-specific preset found at %s.\n", parent_path);
continue;
}
/* Core shader preset exists, load it. */
RARCH_LOG("Shaders: parent-dir-specific shader preset found at %s.\n", parent_path);
path_set(RARCH_PATH_DEFAULT_SHADER_PRESET, settings->paths.path_shader);
strlcpy(settings->paths.path_shader, parent_path, sizeof(settings->paths.path_shader));
goto success;
}
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
{
if (!check_shader_compatibility((enum file_path_enum)(idx)))

View File

@ -1918,12 +1918,7 @@ static int generic_action_ok_shader_preset_save(const char *path,
break;
case ACTION_OK_SHADER_PRESET_SAVE_PARENT:
{
strlcpy(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp));
path_basedir(tmp);
char* last_slash = find_last_slash(tmp);
last_slash[0] = '\0';
last_slash = find_last_slash(tmp);
strlcpy(tmp, last_slash + 1, sizeof(tmp));
fill_pathname_parent_dir_name(tmp, path_get(RARCH_PATH_BASENAME), sizeof(tmp));
fill_pathname_join(file, directory, tmp, sizeof(file));
}
break;