mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 21:41:03 +00:00
(menu_shader.c) Cleanups
This commit is contained in:
parent
2b5b67d663
commit
8ea1305d75
@ -58,11 +58,10 @@ void menu_shader_manager_free(void)
|
||||
**/
|
||||
bool menu_shader_manager_init(void)
|
||||
{
|
||||
bool found = false;
|
||||
bool is_preset = false;
|
||||
config_file_t *conf = NULL;
|
||||
char *new_path = NULL;
|
||||
const char *path_shader = retroarch_get_shader_preset();
|
||||
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
||||
|
||||
menu_shader_manager_free();
|
||||
|
||||
@ -72,16 +71,17 @@ bool menu_shader_manager_init(void)
|
||||
if (!menu_driver_shader || !path_shader)
|
||||
return false;
|
||||
|
||||
type = video_shader_get_type_from_ext(path_get_extension(path_shader),
|
||||
&is_preset);
|
||||
|
||||
if (is_preset)
|
||||
{
|
||||
conf = config_file_read(path_shader);
|
||||
found = config_file_exists(path_shader);
|
||||
new_path = strdup(path_shader);
|
||||
}
|
||||
else
|
||||
{
|
||||
enum rarch_shader_type type = video_shader_get_type_from_ext(
|
||||
path_get_extension(path_shader),
|
||||
&is_preset);
|
||||
|
||||
if (video_shader_is_supported(type))
|
||||
{
|
||||
strlcpy(menu_driver_shader->pass[0].source.path, path_shader,
|
||||
@ -91,7 +91,8 @@ bool menu_shader_manager_init(void)
|
||||
else
|
||||
{
|
||||
char preset_path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool found = false;
|
||||
const char *shader_dir =
|
||||
*settings->paths.directory_video_shader ?
|
||||
settings->paths.directory_video_shader :
|
||||
@ -101,39 +102,38 @@ bool menu_shader_manager_init(void)
|
||||
|
||||
fill_pathname_join(preset_path, shader_dir,
|
||||
"menu.glslp", sizeof(preset_path));
|
||||
conf = config_file_read(preset_path);
|
||||
|
||||
if (!conf)
|
||||
found = config_file_exists(preset_path);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
fill_pathname_join(preset_path, shader_dir,
|
||||
"menu.cgp", sizeof(preset_path));
|
||||
conf = config_file_read(preset_path);
|
||||
found = config_file_read(preset_path);
|
||||
}
|
||||
|
||||
if (!conf)
|
||||
if (!found)
|
||||
{
|
||||
fill_pathname_join(preset_path, shader_dir,
|
||||
"menu.slangp", sizeof(preset_path));
|
||||
conf = config_file_read(preset_path);
|
||||
found = config_file_read(preset_path);
|
||||
}
|
||||
|
||||
new_path = strdup(preset_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!string_is_empty(new_path) && conf &&
|
||||
video_shader_read_conf_cgp(conf, menu_driver_shader)
|
||||
)
|
||||
if (!string_is_empty(new_path) && found)
|
||||
{
|
||||
config_file_t *conf = config_file_read(new_path);
|
||||
video_shader_read_conf_cgp(conf, menu_driver_shader);
|
||||
video_shader_resolve_relative(menu_driver_shader, new_path);
|
||||
video_shader_resolve_parameters(conf, menu_driver_shader);
|
||||
config_file_free(conf);
|
||||
}
|
||||
|
||||
if (new_path)
|
||||
free(new_path);
|
||||
if (conf)
|
||||
config_file_free(conf);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -161,7 +161,7 @@ bool menu_shader_manager_set_preset(void *data,
|
||||
}
|
||||
|
||||
/* Makes sure that we use Menu Preset shader on driver reinit.
|
||||
* Only do this when the cgp actually works to avoid potential errors. */
|
||||
* Only do this when the preset actually works to avoid potential errors. */
|
||||
strlcpy(settings->paths.path_shader,
|
||||
preset_path ? preset_path : "",
|
||||
sizeof(settings->paths.path_shader));
|
||||
|
Loading…
x
Reference in New Issue
Block a user