mirror of
https://github.com/libretro/RetroArch
synced 2025-03-12 04:14:23 +00:00
Refactor file path special (#14275)
* First pass - unique variable names * (file_path_special.c) fill_pathname_application_special() - no longer a recursive function, other optimizations * Buildfix * Put another HAVE_XMB ifdef around xmb_theme_ident * Remove unused variables * Remove more unused variables and use fill_pathname_join instead of strlcpy at the end
This commit is contained in:
parent
bde84b926f
commit
08cc1c986a
@ -168,13 +168,12 @@ void fill_pathname_application_special(char *s,
|
||||
#ifdef HAVE_XMB
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
s1[0] = '\0';
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||
fill_pathname_join(s2, s1, "png", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s1, s8, xmb_theme_ident(), sizeof(s1));
|
||||
fill_pathname_join(s, s1, "png", len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -189,12 +188,13 @@ void fill_pathname_application_special(char *s,
|
||||
else
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
fill_pathname_join(s, s1, FILE_PATH_BACKGROUND_IMAGE, len);
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
char s3[PATH_MAX_LENGTH];
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s1, s8, xmb_theme_ident(), sizeof(s1));
|
||||
fill_pathname_join(s3, s1, "png", sizeof(s3));
|
||||
fill_pathname_join(s, s3, FILE_PATH_BACKGROUND_IMAGE, len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -202,44 +202,43 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_SOUNDS:
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *menu_ident = settings->arrays.menu_driver;
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
s1[0] = '\0';
|
||||
|
||||
#ifdef HAVE_XMB
|
||||
if (string_is_equal(menu_ident, "xmb"))
|
||||
{
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||
|
||||
if (!string_is_empty(s1))
|
||||
strlcat(s1, "/sounds", sizeof(s1));
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
char s4[PATH_MAX_LENGTH];
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s4, s8, xmb_theme_ident(), sizeof(s4));
|
||||
fill_pathname_join(s, s4, "sounds", len);
|
||||
}
|
||||
else if (string_is_equal(menu_ident, "glui"))
|
||||
else
|
||||
#endif
|
||||
#ifdef HAVE_MATERIALUI
|
||||
if (string_is_equal(menu_ident, "glui"))
|
||||
{
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s1, dir_assets, "glui", sizeof(s1));
|
||||
|
||||
if (!string_is_empty(s1))
|
||||
strlcat(s1, "/sounds", sizeof(s1));
|
||||
char s4[PATH_MAX_LENGTH];
|
||||
fill_pathname_join(s4, dir_assets, "glui", sizeof(s4));
|
||||
fill_pathname_join(s, s4, "sounds", len);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_OZONE
|
||||
else if (string_is_equal(menu_ident, "ozone"))
|
||||
{
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s1, dir_assets, "ozone",
|
||||
sizeof(s1));
|
||||
|
||||
if (!string_is_empty(s1))
|
||||
strlcat(s1, "/sounds", sizeof(s1));
|
||||
char s4[PATH_MAX_LENGTH];
|
||||
fill_pathname_join(s4, dir_assets, "ozone",
|
||||
sizeof(s4));
|
||||
fill_pathname_join(s, s4, "sounds", len);
|
||||
}
|
||||
|
||||
if (string_is_empty(s1))
|
||||
else
|
||||
#endif
|
||||
{
|
||||
fill_pathname_join(
|
||||
s1, dir_assets, "sounds", sizeof(s1));
|
||||
|
||||
strlcpy(s, s1, len);
|
||||
s, dir_assets, "sounds", len);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -250,11 +249,36 @@ void fill_pathname_application_special(char *s,
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *menu_ident = settings->arrays.menu_driver;
|
||||
|
||||
if (string_is_equal(menu_ident, "xmb"))
|
||||
fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
else if ( string_is_equal(menu_ident, "ozone")
|
||||
|| string_is_equal(menu_ident, "glui"))
|
||||
fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS);
|
||||
#ifdef HAVE_XMB
|
||||
if (string_is_equal(menu_ident, "xmb"))
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s1, s8, xmb_theme_ident(), sizeof(s1));
|
||||
fill_pathname_join(s, s1, "png", len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ( string_is_equal(menu_ident, "ozone")
|
||||
|| string_is_equal(menu_ident, "glui"))
|
||||
{
|
||||
char s5[PATH_MAX_LENGTH];
|
||||
char s6[PATH_MAX_LENGTH];
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
#if defined(WIIU) || defined(VITA)
|
||||
/* Smaller 46x46 icons look better on low-DPI devices */
|
||||
fill_pathname_join(s5, dir_assets, "ozone", sizeof(s5));
|
||||
fill_pathname_join(s6, "png", "icons", sizeof(s6));
|
||||
#else
|
||||
/* Otherwise, use large 256x256 icons */
|
||||
fill_pathname_join(s5, dir_assets, "xmb", sizeof(s5));
|
||||
fill_pathname_join(s6, "monochrome", "png", sizeof(s6));
|
||||
#endif
|
||||
fill_pathname_join(s, s5, s6, len);
|
||||
}
|
||||
else if (len)
|
||||
s[0] = '\0';
|
||||
#endif
|
||||
@ -264,21 +288,21 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS:
|
||||
#ifdef HAVE_OZONE
|
||||
{
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
char tmp2[PATH_MAX_LENGTH];
|
||||
char s5[PATH_MAX_LENGTH];
|
||||
char s6[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
|
||||
#if defined(WIIU) || defined(VITA)
|
||||
/* Smaller 46x46 icons look better on low-DPI devices */
|
||||
fill_pathname_join(tmp, dir_assets, "ozone", sizeof(tmp));
|
||||
fill_pathname_join(tmp2, "png", "icons", sizeof(tmp2));
|
||||
fill_pathname_join(s5, dir_assets, "ozone", sizeof(s5));
|
||||
fill_pathname_join(s6, "png", "icons", sizeof(s6));
|
||||
#else
|
||||
/* Otherwise, use large 256x256 icons */
|
||||
fill_pathname_join(tmp, dir_assets, "xmb", sizeof(tmp));
|
||||
fill_pathname_join(tmp2, "monochrome", "png", sizeof(tmp2));
|
||||
fill_pathname_join(s5, dir_assets, "xmb", sizeof(s5));
|
||||
fill_pathname_join(s6, "monochrome", "png", sizeof(s6));
|
||||
#endif
|
||||
fill_pathname_join(s, tmp, tmp2, len);
|
||||
fill_pathname_join(s, s5, s6, len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -286,11 +310,11 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_RGUI_FONT:
|
||||
#ifdef HAVE_RGUI
|
||||
{
|
||||
char rgui_dir[PATH_MAX_LENGTH];
|
||||
char s7[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(rgui_dir, dir_assets, "rgui", sizeof(rgui_dir));
|
||||
fill_pathname_join(s, rgui_dir, "font", len);
|
||||
fill_pathname_join(s7, dir_assets, "rgui", sizeof(s7));
|
||||
fill_pathname_join(s, s7, "font", len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -298,11 +322,11 @@ void fill_pathname_application_special(char *s,
|
||||
case APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB:
|
||||
#ifdef HAVE_XMB
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s1, dir_assets, "xmb", sizeof(s1));
|
||||
fill_pathname_join(s, s1, xmb_theme_ident(), len);
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s, s8, xmb_theme_ident(), len);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@ -316,32 +340,37 @@ void fill_pathname_application_special(char *s,
|
||||
strlcpy(s, path_menu_xmb_font, len);
|
||||
else
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
s1[0] = '\0';
|
||||
char s9[PATH_MAX_LENGTH];
|
||||
|
||||
switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE))
|
||||
{
|
||||
case RETRO_LANGUAGE_ARABIC:
|
||||
case RETRO_LANGUAGE_PERSIAN:
|
||||
fill_pathname_join(s1,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s1));
|
||||
fill_pathname_join(s, s1, "fallback-font.ttf", len);
|
||||
fill_pathname_join(s9,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s9));
|
||||
fill_pathname_join(s, s9, "fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_CHINESE_SIMPLIFIED:
|
||||
case RETRO_LANGUAGE_CHINESE_TRADITIONAL:
|
||||
fill_pathname_join(s1,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s1));
|
||||
fill_pathname_join(s, s1, "chinese-fallback-font.ttf", len);
|
||||
fill_pathname_join(s9,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s9));
|
||||
fill_pathname_join(s, s9, "chinese-fallback-font.ttf", len);
|
||||
break;
|
||||
case RETRO_LANGUAGE_KOREAN:
|
||||
fill_pathname_join(s1,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s1));
|
||||
fill_pathname_join(s, s1, "korean-fallback-font.ttf", len);
|
||||
fill_pathname_join(s9,
|
||||
settings->paths.directory_assets, "pkg", sizeof(s9));
|
||||
fill_pathname_join(s, s9, "korean-fallback-font.ttf", len);
|
||||
break;
|
||||
default:
|
||||
fill_pathname_application_special(s1, sizeof(s1),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB);
|
||||
fill_pathname_join(s, s1, FILE_PATH_TTF_FONT, len);
|
||||
{
|
||||
char s8[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_assets = settings->paths.directory_assets;
|
||||
fill_pathname_join(s8, dir_assets, "xmb", sizeof(s8));
|
||||
fill_pathname_join(s9, s8, xmb_theme_ident(), sizeof(s9));
|
||||
fill_pathname_join(s, s9, FILE_PATH_TTF_FONT, len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -349,27 +378,21 @@ void fill_pathname_application_special(char *s,
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS:
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
char s10[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_thumbnails = settings->paths.directory_thumbnails;
|
||||
fill_pathname_join(s1, dir_thumbnails, "discord", sizeof(s1));
|
||||
fill_pathname_join(s2, s1, "avatars", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
fill_pathname_join(s10, dir_thumbnails, "discord", sizeof(s10));
|
||||
fill_pathname_join(s, s10, "avatars", len);
|
||||
}
|
||||
break;
|
||||
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES:
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
char s2[PATH_MAX_LENGTH];
|
||||
char s12[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *dir_thumbnails = settings->paths.directory_thumbnails;
|
||||
fill_pathname_join(s1, dir_thumbnails, "cheevos", len);
|
||||
fill_pathname_join(s2, s1, "badges", sizeof(s2));
|
||||
fill_pathname_slash(s2, sizeof(s2));
|
||||
strlcpy(s, s2, len);
|
||||
fill_pathname_join(s12, dir_thumbnails, "cheevos", len);
|
||||
fill_pathname_join(s, s12, "badges", len);
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user