mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Qt: limit shader preset/pass selection to the appropriate extensions
This commit is contained in:
parent
e9c68597ff
commit
4d09ddde1c
@ -1136,11 +1136,16 @@ enum rarch_shader_type video_shader_get_type_from_ext(
|
|||||||
{
|
{
|
||||||
enum gfx_ctx_api api = video_context_driver_get_api();
|
enum gfx_ctx_api api = video_context_driver_get_api();
|
||||||
|
|
||||||
|
if (string_is_empty(ext))
|
||||||
|
return RARCH_SHADER_NONE;
|
||||||
|
|
||||||
|
if (strlen(ext) > 1 && ext[0] == '.')
|
||||||
|
ext++;
|
||||||
|
|
||||||
*is_preset = false;
|
*is_preset = false;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
string_is_equal(ext, "cg") ||
|
string_is_equal_case_insensitive(ext, "cg")
|
||||||
string_is_equal(ext, "CG")
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
switch (api)
|
switch (api)
|
||||||
|
@ -27,6 +27,7 @@ extern "C" {
|
|||||||
#include "../../../configuration.h"
|
#include "../../../configuration.h"
|
||||||
#include "../../../retroarch.h"
|
#include "../../../retroarch.h"
|
||||||
#include "../../../paths.h"
|
#include "../../../paths.h"
|
||||||
|
#include "../../../file_path_special.h"
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
#include "../../../menu/menu_shader.h"
|
#include "../../../menu/menu_shader.h"
|
||||||
#endif
|
#endif
|
||||||
@ -384,12 +385,14 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
QString path;
|
QString path;
|
||||||
|
QString filter;
|
||||||
QByteArray pathArray;
|
QByteArray pathArray;
|
||||||
struct video_shader *menu_shader = NULL;
|
struct video_shader *menu_shader = NULL;
|
||||||
struct video_shader *video_shader = NULL;
|
struct video_shader *video_shader = NULL;
|
||||||
const char *pathData = NULL;
|
const char *pathData = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
enum rarch_shader_type type = RARCH_SHADER_NONE;
|
||||||
|
bool is_preset = false;
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return;
|
return;
|
||||||
@ -399,7 +402,27 @@ void ShaderParamsDialog::onShaderLoadPresetClicked()
|
|||||||
if (!menu_shader)
|
if (!menu_shader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader);
|
filter = "Shader Preset (";
|
||||||
|
|
||||||
|
/* NOTE: Maybe we should have a way to get a list of all shader types instead of hard-coding this? */
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_CG) &&
|
||||||
|
video_shader_get_type_from_ext(file_path_str(FILE_PATH_CGP_EXTENSION), &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal("*") + file_path_str(FILE_PATH_CGP_EXTENSION);
|
||||||
|
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_GLSL) &&
|
||||||
|
video_shader_get_type_from_ext(file_path_str(FILE_PATH_GLSLP_EXTENSION), &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_GLSLP_EXTENSION);
|
||||||
|
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_SLANG) &&
|
||||||
|
video_shader_get_type_from_ext(file_path_str(FILE_PATH_SLANGP_EXTENSION), &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_SLANGP_EXTENSION);
|
||||||
|
|
||||||
|
filter += ")";
|
||||||
|
|
||||||
|
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter);
|
||||||
|
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
@ -417,12 +440,14 @@ void ShaderParamsDialog::onShaderAddPassClicked()
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
QString path;
|
QString path;
|
||||||
|
QString filter;
|
||||||
QByteArray pathArray;
|
QByteArray pathArray;
|
||||||
struct video_shader *menu_shader = NULL;
|
struct video_shader *menu_shader = NULL;
|
||||||
struct video_shader *video_shader = NULL;
|
struct video_shader *video_shader = NULL;
|
||||||
struct video_shader_pass *shader_pass = NULL;
|
struct video_shader_pass *shader_pass = NULL;
|
||||||
const char *pathData = NULL;
|
const char *pathData = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool is_preset = false;
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return;
|
return;
|
||||||
@ -432,7 +457,27 @@ void ShaderParamsDialog::onShaderAddPassClicked()
|
|||||||
if (!menu_shader)
|
if (!menu_shader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader);
|
filter = "Shader (";
|
||||||
|
|
||||||
|
/* NOTE: Maybe we should have a way to get a list of all shader types instead of hard-coding this? */
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_CG) &&
|
||||||
|
video_shader_get_type_from_ext(".cg", &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal("*.cg");
|
||||||
|
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_GLSL) &&
|
||||||
|
video_shader_get_type_from_ext(".glsl", &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal(" *.glsl");
|
||||||
|
|
||||||
|
if (video_shader_is_supported(RARCH_SHADER_SLANG) &&
|
||||||
|
video_shader_get_type_from_ext(".slang", &is_preset)
|
||||||
|
!= RARCH_SHADER_NONE)
|
||||||
|
filter += QLatin1Literal(" *.slang");
|
||||||
|
|
||||||
|
filter += ")";
|
||||||
|
|
||||||
|
path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter);
|
||||||
|
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user