mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +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));
|
||||
|
||||
if (path_is_valid(path))
|
||||
{
|
||||
strlcpy(
|
||||
xmb->savestate_thumbnail_file_path, path,
|
||||
sizeof(xmb->savestate_thumbnail_file_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,12 +246,29 @@ static bool menu_shader_manager_save_preset_internal(
|
||||
|
||||
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));
|
||||
|
||||
/* 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. */
|
||||
if ( !string_ends_with(basename, ".cgp")
|
||||
&& !string_ends_with(basename, ".glslp")
|
||||
&& !string_ends_with(basename, ".slangp"))
|
||||
if ( !string_is_equal(ext_lower, "cgp")
|
||||
&& !string_is_equal(ext_lower, "glslp")
|
||||
&& !string_is_equal(ext_lower, "slangp"))
|
||||
{
|
||||
const char *preset_ext = video_shader_get_preset_extension(type);
|
||||
strlcat(fullname, preset_ext, sizeof(fullname));
|
||||
@ -267,8 +284,7 @@ static bool menu_shader_manager_save_preset_internal(
|
||||
if (path_is_absolute(fullname))
|
||||
{
|
||||
preset_path = fullname;
|
||||
|
||||
ret = video_shader_write_preset(preset_path,
|
||||
ret = video_shader_write_preset(preset_path,
|
||||
dir_video_shader,
|
||||
shader, save_reference);
|
||||
|
||||
@ -292,13 +308,14 @@ static bool menu_shader_manager_save_preset_internal(
|
||||
strlcpy(basedir, buffer, sizeof(basedir));
|
||||
path_basedir(basedir);
|
||||
|
||||
if (!path_is_directory(basedir)) {
|
||||
if (!path_is_directory(basedir))
|
||||
{
|
||||
ret = path_mkdir(basedir);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
RARCH_WARN("Failed to create preset directory %s.\n", basedir);
|
||||
continue;
|
||||
RARCH_WARN("Failed to create preset directory %s.\n", basedir);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,42 +244,44 @@ void filebrowser_parse(
|
||||
file_type = FILE_TYPE_PLAYLIST_COLLECTION;
|
||||
}
|
||||
|
||||
if (!is_dir && path_is_media_type(path) == RARCH_CONTENT_MUSIC)
|
||||
file_type = FILE_TYPE_MUSIC;
|
||||
else if (!is_dir &&
|
||||
(builtin_mediaplayer_enable ||
|
||||
builtin_imageviewer_enable))
|
||||
if (!is_dir)
|
||||
{
|
||||
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 (builtin_mediaplayer_enable)
|
||||
file_type = FILE_TYPE_MOVIE;
|
||||
if (builtin_mediaplayer_enable)
|
||||
file_type = FILE_TYPE_MOVIE;
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CONTENT_IMAGE:
|
||||
break;
|
||||
case RARCH_CONTENT_IMAGE:
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
if (builtin_imageviewer_enable
|
||||
&& type != DISPLAYLIST_IMAGES)
|
||||
file_type = FILE_TYPE_IMAGEVIEWER;
|
||||
else
|
||||
file_type = FILE_TYPE_IMAGE;
|
||||
if (builtin_imageviewer_enable
|
||||
&& type != DISPLAYLIST_IMAGES)
|
||||
file_type = FILE_TYPE_IMAGEVIEWER;
|
||||
else
|
||||
file_type = FILE_TYPE_IMAGE;
|
||||
#endif
|
||||
if (filebrowser_types == FILEBROWSER_SELECT_IMAGE)
|
||||
file_type = FILE_TYPE_IMAGE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (filebrowser_types == FILEBROWSER_SELECT_IMAGE)
|
||||
file_type = FILE_TYPE_IMAGE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (file_type)
|
||||
{
|
||||
case FILE_TYPE_PLAIN:
|
||||
#if 0
|
||||
enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_PLAIN_FILE;
|
||||
#endif
|
||||
files_count++;
|
||||
break;
|
||||
case FILE_TYPE_MOVIE:
|
||||
|
Loading…
x
Reference in New Issue
Block a user