From 556e6702ef354914c867a69927cd70062c274ef5 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Tue, 2 Aug 2022 17:54:38 +0200 Subject: [PATCH] Start downscaling on file_path_special.c --- file_path_special.c | 97 +++++---------------------------------- file_path_special.h | 5 -- menu/drivers/materialui.c | 57 +++++++++++++++++------ 3 files changed, 55 insertions(+), 104 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index afa5086a84..39b1b9d05e 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -151,14 +151,6 @@ void fill_pathname_application_special(char *s, { switch (type) { - case APPLICATION_SPECIAL_DIRECTORY_AUTOCONFIG: - { - settings_t *settings = config_get_ptr(); - const char *dir_autoconfig = settings->paths.directory_autoconfig; - const char *joypad_driver = settings->arrays.input_joypad_driver; - fill_pathname_join(s, dir_autoconfig, joypad_driver, len); - } - break; case APPLICATION_SPECIAL_DIRECTORY_CONFIG: { settings_t *settings = config_get_ptr(); @@ -234,16 +226,17 @@ void fill_pathname_application_special(char *s, } else if (string_is_equal(menu_ident, "glui")) { - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI); + 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)); } else if (string_is_equal(menu_ident, "ozone")) { - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_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)); @@ -264,32 +257,16 @@ 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")) + 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, "glui")) - { - /* Type APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS - * contains no core system icons so we use the icon directory - * from ozone here */ - fill_pathname_application_special(s, len, APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS); - } - else if (string_is_equal(menu_ident, "ozone")) + 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); else if (len) s[0] = '\0'; #endif } - break; - case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE: -#ifdef HAVE_OZONE - { - settings_t *settings = config_get_ptr(); - const char *dir_assets = settings->paths.directory_assets; - fill_pathname_join(s, dir_assets, "ozone", - len); - } -#endif break; case APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS: #ifdef HAVE_OZONE @@ -337,10 +314,8 @@ void fill_pathname_application_special(char *s, char rgui_dir[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(rgui_dir, dir_assets, "rgui", sizeof(rgui_dir)); + fill_pathname_join(s, rgui_dir, "font", len); } #endif break; @@ -352,57 +327,7 @@ void fill_pathname_application_special(char *s, 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); - } -#endif - break; - case APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI: -#ifdef HAVE_MATERIALUI - { - settings_t *settings = config_get_ptr(); - const char *dir_assets = settings->paths.directory_assets; - - fill_pathname_join(s, dir_assets, "glui", len); - } -#endif - break; - case APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS: -#ifdef HAVE_MATERIALUI - fill_pathname_application_special(s, len, - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI); -#endif - break; - case APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT: -#ifdef HAVE_MATERIALUI - { - char s1[PATH_MAX_LENGTH]; - s1[0] = '\0'; - - switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE)) - { - case RETRO_LANGUAGE_ARABIC: - case RETRO_LANGUAGE_PERSIAN: - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); - fill_pathname_join(s, s1, "fallback-font.ttf", len); - break; - case RETRO_LANGUAGE_CHINESE_SIMPLIFIED: - case RETRO_LANGUAGE_CHINESE_TRADITIONAL: - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); - fill_pathname_join(s, s1, "chinese-fallback-font.ttf", len); - break; - case RETRO_LANGUAGE_KOREAN: - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); - fill_pathname_join(s, s1, "korean-fallback-font.ttf", len); - break; - default: - fill_pathname_application_special(s1, sizeof(s1), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI); - fill_pathname_join(s, s1, FILE_PATH_TTF_FONT, len); - } + fill_pathname_join(s, s1, xmb_theme_ident(), len); } #endif break; diff --git a/file_path_special.h b/file_path_special.h index a303f7ca49..85d017943e 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -119,19 +119,14 @@ RETRO_BEGIN_DECLS enum application_special_type { APPLICATION_SPECIAL_NONE = 0, - APPLICATION_SPECIAL_DIRECTORY_AUTOCONFIG, APPLICATION_SPECIAL_DIRECTORY_CONFIG, APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG, APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG_AR_FONT, APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG_CJK_FONT, - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI, - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT, - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS, APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT, - APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE, APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS, APPLICATION_SPECIAL_DIRECTORY_ASSETS_RGUI_FONT, APPLICATION_SPECIAL_DIRECTORY_ASSETS_SOUNDS, diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index bd77dbc321..5b20d244ed 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -7729,6 +7729,8 @@ static void materialui_init_font( { char fontpath[PATH_MAX_LENGTH]; const char *wideglyph_str = msg_hash_get_wideglyph_str(); + settings_t *settings = config_get_ptr(); + const char *dir_assets = settings->paths.directory_assets; fontpath[0] = '\0'; /* We assume the average glyph aspect ratio is close to 3:4 */ @@ -7739,8 +7741,40 @@ static void materialui_init_font( gfx_display_font_free(font_data->font); font_data->font = NULL; } - fill_pathname_application_special( - fontpath, sizeof(fontpath), APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT); + { + char s1[PATH_MAX_LENGTH]; + s1[0] = '\0'; + + switch (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE)) + { + case RETRO_LANGUAGE_ARABIC: + case RETRO_LANGUAGE_PERSIAN: + fill_pathname_application_special(s1, sizeof(s1), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); + fill_pathname_join(fontpath, s1, "fallback-font.ttf", + sizeof(fontpath)); + break; + case RETRO_LANGUAGE_CHINESE_SIMPLIFIED: + case RETRO_LANGUAGE_CHINESE_TRADITIONAL: + fill_pathname_application_special(s1, sizeof(s1), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); + fill_pathname_join(fontpath, s1, "chinese-fallback-font.ttf", + sizeof(fontpath)); + break; + case RETRO_LANGUAGE_KOREAN: + fill_pathname_application_special(s1, sizeof(s1), + APPLICATION_SPECIAL_DIRECTORY_ASSETS_PKG); + fill_pathname_join(fontpath, s1, "korean-fallback-font.ttf", + sizeof(fontpath)); + break; + default: + fill_pathname_join(s1, dir_assets, "glui", sizeof(s1)); + fill_pathname_join(fontpath, s1, FILE_PATH_TTF_FONT, + sizeof(fontpath)); + break; + } + } + font_data->font = gfx_display_font_file(p_disp, fontpath, font_size, video_is_threaded); @@ -7926,6 +7960,7 @@ static void *materialui_init(void **userdata, bool video_is_threaded) gfx_display_t *p_disp = disp_get_ptr(); menu_handle_t *menu = (menu_handle_t*) calloc(1, sizeof(*menu)); + const char *dir_assets = NULL; if (!menu) return NULL; @@ -7936,17 +7971,15 @@ static void *materialui_init(void **userdata, bool video_is_threaded) return NULL; } - mui = (materialui_handle_t*) - calloc(1, sizeof(materialui_handle_t)); + dir_assets = settings->paths.directory_assets; - if (!mui) + if (!(mui = (materialui_handle_t*)calloc(1, sizeof(materialui_handle_t)))) goto error; *userdata = mui; /* Initialise thumbnail path data */ - mui->thumbnail_path_data = gfx_thumbnail_path_init(); - if (!mui->thumbnail_path_data) + if (!(mui->thumbnail_path_data = gfx_thumbnail_path_init())) goto error; /* Get DPI/screen-size-aware base unit size for @@ -7986,8 +8019,7 @@ static void *materialui_init(void **userdata, bool video_is_threaded) materialui_prepare_colors(mui, (enum materialui_color_theme)mui->color_theme); /* Initialise screensaver */ - mui->screensaver = menu_screensaver_init(); - if (!mui->screensaver) + if (!(mui->screensaver = menu_screensaver_init())) goto error; /* Initial ticker configuration */ @@ -8052,14 +8084,13 @@ static void *materialui_init(void **userdata, bool video_is_threaded) fill_pathname_application_special(mui->sysicons_path, sizeof(mui->sysicons_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_OZONE_ICONS); - fill_pathname_application_special(mui->icons_path, - sizeof(mui->icons_path), - APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI); + fill_pathname_join(mui->icons_path, dir_assets, "glui", + sizeof(mui->icons_path)); p_anim->updatetime_cb = materialui_menu_animation_update_time; /* set word_wrap function pointer */ - mui->word_wrap = msg_hash_get_wideglyph_str() ? word_wrap_wideglyph : word_wrap; + mui->word_wrap = msg_hash_get_wideglyph_str() ? word_wrap_wideglyph : word_wrap; return menu; error: