Create fill_pathname_application_directory

This commit is contained in:
twinaphex 2016-06-11 19:21:58 +02:00
parent 89e3ce381d
commit 6989d60cdc
3 changed files with 55 additions and 27 deletions

View File

@ -40,6 +40,9 @@
#include <retro_assert.h> #include <retro_assert.h>
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
#include "configuration.h"
#include "file_path_special.h"
#include "verbosity.h" #include "verbosity.h"
void fill_pathname_expand_special(char *out_path, void fill_pathname_expand_special(char *out_path,
@ -257,3 +260,35 @@ void fill_pathname_application_path(char *s, size_t len)
#endif #endif
} }
#endif #endif
#ifdef HAVE_XMB
const char *xmb_theme_ident(void);
#endif
void fill_pathname_application_directory(char *s, size_t len, enum application_directory type)
{
switch (type)
{
case APPLICATION_DIRECTORY_ASSETS_XMB:
#ifdef HAVE_XMB
{
char s1[PATH_MAX_LENGTH] = {0};
char s2[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
fill_pathname_join(
s1,
settings->directory.assets,
"xmb",
sizeof(s1));
fill_pathname_join(s2,
s1, xmb_theme_ident(), sizeof(s2));
strlcpy(s, s2, len);
}
#endif
break;
case APPLICATION_DIRECTORY_NONE:
default:
break;
}
}

View File

@ -22,6 +22,14 @@
#include <boolean.h> #include <boolean.h>
enum application_directory
{
APPLICATION_DIRECTORY_NONE = 0,
APPLICATION_DIRECTORY_ASSETS_XMB
};
bool fill_pathname_application_data(char *s, size_t len); bool fill_pathname_application_data(char *s, size_t len);
void fill_pathname_application_directory(char *s, size_t len, enum application_directory type);
#endif #endif

View File

@ -45,6 +45,7 @@
#include "../../configuration.h" #include "../../configuration.h"
#include "../../retroarch.h" #include "../../retroarch.h"
#include "../../system.h" #include "../../system.h"
#include "../../file_path_special.h"
#include "../../tasks/tasks_internal.h" #include "../../tasks/tasks_internal.h"
@ -310,7 +311,7 @@ float gradient_dark[16] = {
0.0, 0.0, 0.0, 1.00, 0.0, 0.0, 0.0, 1.00,
}; };
static const char *xmb_theme_ident(void) const char *xmb_theme_ident(void)
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
switch (settings->menu.xmb_theme) switch (settings->menu.xmb_theme)
@ -386,16 +387,15 @@ static float *xmb_gradient_ident(void)
static void xmb_fill_default_background_path(xmb_handle_t *xmb, static void xmb_fill_default_background_path(xmb_handle_t *xmb,
char *path, size_t size) char *path, size_t size)
{ {
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0}; char themepath[PATH_MAX_LENGTH] = {0};
char iconpath[PATH_MAX_LENGTH] = {0}; char iconpath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
strlcpy(xmb->icon.dir, "png", sizeof(xmb->icon.dir)); strlcpy(xmb->icon.dir, "png", sizeof(xmb->icon.dir));
fill_pathname_join(mediapath, settings->directory.assets, fill_pathname_application_directory(themepath, sizeof(themepath),
"xmb", sizeof(mediapath)); APPLICATION_DIRECTORY_ASSETS_XMB);
fill_pathname_join(themepath, mediapath, xmb_theme_ident(), sizeof(themepath));
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath)); fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath)); fill_pathname_slash(iconpath, sizeof(iconpath));
@ -1411,17 +1411,12 @@ static void xmb_context_reset_horizontal_list(
static void xmb_refresh_horizontal_list(xmb_handle_t *xmb) static void xmb_refresh_horizontal_list(xmb_handle_t *xmb)
{ {
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0}; char themepath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
fill_pathname_join( fill_pathname_application_directory(themepath, sizeof(themepath),
mediapath, APPLICATION_DIRECTORY_ASSETS_XMB);
settings->directory.assets,
"xmb",
sizeof(mediapath));
fill_pathname_join(themepath, mediapath, xmb_theme_ident(), sizeof(themepath));
xmb_context_destroy_horizontal_list(xmb); xmb_context_destroy_horizontal_list(xmb);
if (xmb->horizontal_list) if (xmb->horizontal_list)
@ -2289,19 +2284,14 @@ static void xmb_frame(void *data)
static void xmb_font(xmb_handle_t *xmb) static void xmb_font(xmb_handle_t *xmb)
{ {
menu_display_ctx_font_t font_info; menu_display_ctx_font_t font_info;
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0}; char themepath[PATH_MAX_LENGTH] = {0};
char fontpath[PATH_MAX_LENGTH] = {0}; char fontpath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
int font_size = menu_display_get_font_size(); int font_size = menu_display_get_font_size();
fill_pathname_join( fill_pathname_application_directory(themepath, sizeof(themepath),
mediapath, APPLICATION_DIRECTORY_ASSETS_XMB);
settings->directory.assets,
"xmb",
sizeof(mediapath));
fill_pathname_join(themepath,
mediapath, xmb_theme_ident(), sizeof(themepath));
if (string_is_empty(settings->menu.xmb_font)) if (string_is_empty(settings->menu.xmb_font))
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath)); fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
else else
@ -2806,7 +2796,6 @@ static void xmb_context_reset_background(const char *iconpath)
static void xmb_context_reset(void *data) static void xmb_context_reset(void *data)
{ {
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0}; char themepath[PATH_MAX_LENGTH] = {0};
char iconpath[PATH_MAX_LENGTH] = {0}; char iconpath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -2818,12 +2807,8 @@ static void xmb_context_reset(void *data)
xmb_fill_default_background_path(xmb, xmb_fill_default_background_path(xmb,
xmb->background_file_path, sizeof(xmb->background_file_path)); xmb->background_file_path, sizeof(xmb->background_file_path));
fill_pathname_join( fill_pathname_application_directory(themepath, sizeof(themepath),
mediapath, APPLICATION_DIRECTORY_ASSETS_XMB);
settings->directory.assets,
"xmb",
sizeof(mediapath));
fill_pathname_join(themepath, mediapath, xmb_theme_ident(), sizeof(themepath));
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath)); fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath)); fill_pathname_slash(iconpath, sizeof(iconpath));