mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
Simplify menu_filebrowser.c and menu_shader.c code
This commit is contained in:
parent
421bcb07d3
commit
923dc52f87
@ -1041,11 +1041,9 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
|
|||||||
strlcat(path, ".png", sizeof(path));
|
strlcat(path, ".png", sizeof(path));
|
||||||
|
|
||||||
if (path_is_valid(path))
|
if (path_is_valid(path))
|
||||||
{
|
|
||||||
strlcpy(
|
strlcpy(
|
||||||
xmb->savestate_thumbnail_file_path, path,
|
xmb->savestate_thumbnail_file_path, path,
|
||||||
sizeof(xmb->savestate_thumbnail_file_path));
|
sizeof(xmb->savestate_thumbnail_file_path));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,12 +246,29 @@ static bool menu_shader_manager_save_preset_internal(
|
|||||||
|
|
||||||
if (!string_is_empty(basename))
|
if (!string_is_empty(basename))
|
||||||
{
|
{
|
||||||
|
/* We are comparing against a fixed list of file
|
||||||
|
* extensions, the longest (slangp) being 6 characters
|
||||||
|
* in length. We therefore only need to extract the first
|
||||||
|
* 7 characters from the extension of the input path
|
||||||
|
* to correctly validate a match */
|
||||||
|
char ext_lower[8];
|
||||||
|
const char *ext = NULL;
|
||||||
|
|
||||||
|
ext_lower[0] = '\0';
|
||||||
|
|
||||||
strlcpy(fullname, basename, sizeof(fullname));
|
strlcpy(fullname, basename, sizeof(fullname));
|
||||||
|
|
||||||
|
/* Get file extension */
|
||||||
|
ext = strrchr(basename, '.');
|
||||||
|
|
||||||
|
/* Copy and convert to lower case */
|
||||||
|
strlcpy(ext_lower, ext, sizeof(ext_lower));
|
||||||
|
string_to_lower(ext_lower);
|
||||||
|
|
||||||
/* Append extension automatically as appropriate. */
|
/* Append extension automatically as appropriate. */
|
||||||
if ( !string_ends_with(basename, ".cgp")
|
if ( !string_is_equal(ext_lower, "cgp")
|
||||||
&& !string_ends_with(basename, ".glslp")
|
&& !string_is_equal(ext_lower, "glslp")
|
||||||
&& !string_ends_with(basename, ".slangp"))
|
&& !string_is_equal(ext_lower, "slangp"))
|
||||||
{
|
{
|
||||||
const char *preset_ext = video_shader_get_preset_extension(type);
|
const char *preset_ext = video_shader_get_preset_extension(type);
|
||||||
strlcat(fullname, preset_ext, sizeof(fullname));
|
strlcat(fullname, preset_ext, sizeof(fullname));
|
||||||
@ -267,8 +284,7 @@ static bool menu_shader_manager_save_preset_internal(
|
|||||||
if (path_is_absolute(fullname))
|
if (path_is_absolute(fullname))
|
||||||
{
|
{
|
||||||
preset_path = fullname;
|
preset_path = fullname;
|
||||||
|
ret = video_shader_write_preset(preset_path,
|
||||||
ret = video_shader_write_preset(preset_path,
|
|
||||||
dir_video_shader,
|
dir_video_shader,
|
||||||
shader, save_reference);
|
shader, save_reference);
|
||||||
|
|
||||||
@ -292,13 +308,14 @@ static bool menu_shader_manager_save_preset_internal(
|
|||||||
strlcpy(basedir, buffer, sizeof(basedir));
|
strlcpy(basedir, buffer, sizeof(basedir));
|
||||||
path_basedir(basedir);
|
path_basedir(basedir);
|
||||||
|
|
||||||
if (!path_is_directory(basedir)) {
|
if (!path_is_directory(basedir))
|
||||||
|
{
|
||||||
ret = path_mkdir(basedir);
|
ret = path_mkdir(basedir);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
RARCH_WARN("Failed to create preset directory %s.\n", basedir);
|
RARCH_WARN("Failed to create preset directory %s.\n", basedir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,42 +244,44 @@ void filebrowser_parse(
|
|||||||
file_type = FILE_TYPE_PLAYLIST_COLLECTION;
|
file_type = FILE_TYPE_PLAYLIST_COLLECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir && path_is_media_type(path) == RARCH_CONTENT_MUSIC)
|
if (!is_dir)
|
||||||
file_type = FILE_TYPE_MUSIC;
|
|
||||||
else if (!is_dir &&
|
|
||||||
(builtin_mediaplayer_enable ||
|
|
||||||
builtin_imageviewer_enable))
|
|
||||||
{
|
{
|
||||||
switch (path_is_media_type(path))
|
enum rarch_content_type path_type = path_is_media_type(path);
|
||||||
|
|
||||||
|
if (path_type == RARCH_CONTENT_MUSIC)
|
||||||
|
file_type = FILE_TYPE_MUSIC;
|
||||||
|
else if (
|
||||||
|
builtin_mediaplayer_enable ||
|
||||||
|
builtin_imageviewer_enable)
|
||||||
{
|
{
|
||||||
case RARCH_CONTENT_MOVIE:
|
switch (path_type)
|
||||||
|
{
|
||||||
|
case RARCH_CONTENT_MOVIE:
|
||||||
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
|
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
|
||||||
if (builtin_mediaplayer_enable)
|
if (builtin_mediaplayer_enable)
|
||||||
file_type = FILE_TYPE_MOVIE;
|
file_type = FILE_TYPE_MOVIE;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case RARCH_CONTENT_IMAGE:
|
case RARCH_CONTENT_IMAGE:
|
||||||
#ifdef HAVE_IMAGEVIEWER
|
#ifdef HAVE_IMAGEVIEWER
|
||||||
if (builtin_imageviewer_enable
|
if (builtin_imageviewer_enable
|
||||||
&& type != DISPLAYLIST_IMAGES)
|
&& type != DISPLAYLIST_IMAGES)
|
||||||
file_type = FILE_TYPE_IMAGEVIEWER;
|
file_type = FILE_TYPE_IMAGEVIEWER;
|
||||||
else
|
else
|
||||||
file_type = FILE_TYPE_IMAGE;
|
file_type = FILE_TYPE_IMAGE;
|
||||||
#endif
|
#endif
|
||||||
if (filebrowser_types == FILEBROWSER_SELECT_IMAGE)
|
if (filebrowser_types == FILEBROWSER_SELECT_IMAGE)
|
||||||
file_type = FILE_TYPE_IMAGE;
|
file_type = FILE_TYPE_IMAGE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (file_type)
|
switch (file_type)
|
||||||
{
|
{
|
||||||
case FILE_TYPE_PLAIN:
|
case FILE_TYPE_PLAIN:
|
||||||
#if 0
|
|
||||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_PLAIN_FILE;
|
|
||||||
#endif
|
|
||||||
files_count++;
|
files_count++;
|
||||||
break;
|
break;
|
||||||
case FILE_TYPE_MOVIE:
|
case FILE_TYPE_MOVIE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user