diff --git a/file_path_special.h b/file_path_special.h index 29321181a7..fd77b10964 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -50,6 +50,9 @@ enum file_path_enum FILE_PATH_INDEX_DIRS_URL, FILE_PATH_INDEX_URL, FILE_PATH_INDEX_EXTENDED_URL, + FILE_PATH_CGP_EXTENSION, + FILE_PATH_GLSLP_EXTENSION, + FILE_PATH_SLANGP_EXTENSION, FILE_PATH_SRM_EXTENSION, FILE_PATH_UPS_EXTENSION, FILE_PATH_OPT_EXTENSION, diff --git a/file_path_str.c b/file_path_str.c index 18575d1cc3..b18a5b7d04 100644 --- a/file_path_str.c +++ b/file_path_str.c @@ -37,6 +37,12 @@ const char *file_path_str(enum file_path_enum enum_idx) return "[ERROR]"; case FILE_PATH_LOG_INFO: return "[INFO]"; + case FILE_PATH_CGP_EXTENSION: + return ".cgp"; + case FILE_PATH_GLSLP_EXTENSION: + return ".glslp"; + case FILE_PATH_SLANGP_EXTENSION: + return ".slangp"; case FILE_PATH_AUTO_EXTENSION: return ".auto"; case FILE_PATH_BSV_EXTENSION: diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 5990e73c23..04986ba77b 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -23,6 +23,7 @@ #include "menu_driver.h" #include "menu_shader.h" +#include "../file_path_special.h" #include "../configuration.h" #include "../runloop.h" #include "../verbosity.h" @@ -61,15 +62,15 @@ void menu_shader_manager_init(menu_handle_t *menu) if (config_path) { fill_pathname_base_ext(menu->default_glslp, config_path, - ".glslp", + file_path_str(FILE_PATH_GLSLP_EXTENSION), sizeof(menu->default_glslp)); fill_pathname_base_ext(menu->default_cgp, config_path, - ".cgp", + file_path_str(FILE_PATH_CGP_EXTENSION), sizeof(menu->default_cgp)); fill_pathname_base_ext(menu->default_slangp, config_path, - ".slangp", + file_path_str(FILE_PATH_SLANGP_EXTENSION), sizeof(menu->default_slangp)); } else @@ -82,7 +83,8 @@ void menu_shader_manager_init(menu_handle_t *menu) sizeof(menu->default_slangp)); } - switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(settings->path.shader)))) + switch (msg_hash_to_file_type(msg_hash_calculate( + path_get_extension(settings->path.shader)))) { case FILE_TYPE_SHADER_PRESET_GLSLP: case FILE_TYPE_SHADER_PRESET_CGP: @@ -247,20 +249,26 @@ void menu_shader_manager_save_preset( strlcpy(buffer, basename, sizeof(buffer)); /* Append extension automatically as appropriate. */ - if ( !strstr(basename, ".cgp") - && !strstr(basename, ".glslp") - && !strstr(basename, ".slangp")) + if ( !strstr(basename, file_path_str(FILE_PATH_CGP_EXTENSION)) + && !strstr(basename, file_path_str(FILE_PATH_GLSLP_EXTENSION)) + && !strstr(basename, file_path_str(FILE_PATH_SLANGP_EXTENSION))) { switch (type) { case RARCH_SHADER_GLSL: - strlcat(buffer, ".glslp", sizeof(buffer)); + strlcat(buffer, + file_path_str(FILE_PATH_GLSLP_EXTENSION), + sizeof(buffer)); break; case RARCH_SHADER_SLANG: - strlcat(buffer, ".slangp", sizeof(buffer)); + strlcat(buffer, + file_path_str(FILE_PATH_SLANGP_EXTENSION), + sizeof(buffer)); break; case RARCH_SHADER_CG: - strlcat(buffer, ".cgp", sizeof(buffer)); + strlcat(buffer, + file_path_str(FILE_PATH_CGP_EXTENSION), + sizeof(buffer)); break; } }