mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Add more menu_display_ctl actions
This commit is contained in:
parent
28f3ea355a
commit
dd106ee8d2
@ -972,6 +972,7 @@ static void mui_font(void)
|
||||
{
|
||||
int font_size;
|
||||
char mediapath[PATH_MAX_LENGTH], fontpath[PATH_MAX_LENGTH];
|
||||
menu_display_ctx_font_t font_info;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
|
||||
@ -981,7 +982,10 @@ static void mui_font(void)
|
||||
fill_pathname_join(fontpath, mediapath,
|
||||
"Roboto-Regular.ttf", sizeof(fontpath));
|
||||
|
||||
if (!menu_display_init_main_font(fontpath, font_size))
|
||||
font_info.path = fontpath;
|
||||
font_info.size = font_size;
|
||||
|
||||
if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
}
|
||||
|
||||
@ -1096,7 +1100,7 @@ static void mui_context_destroy(void *data)
|
||||
for (i = 0; i < MUI_TEXTURE_LAST; i++)
|
||||
menu_display_texture_unload((uintptr_t*)&mui->textures.list[i].id);
|
||||
|
||||
menu_display_free_main_font();
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL);
|
||||
|
||||
mui_context_bg_destroy(mui);
|
||||
}
|
||||
|
@ -1869,6 +1869,7 @@ static void xmb_font(xmb_handle_t *xmb)
|
||||
int font_size;
|
||||
char mediapath[PATH_MAX_LENGTH],
|
||||
themepath[PATH_MAX_LENGTH], fontpath[PATH_MAX_LENGTH];
|
||||
menu_display_ctx_font_t font_info;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
|
||||
@ -1882,7 +1883,10 @@ static void xmb_font(xmb_handle_t *xmb)
|
||||
else
|
||||
strlcpy(fontpath, settings->menu.xmb_font,sizeof(fontpath));
|
||||
|
||||
if (!menu_display_init_main_font(fontpath, font_size))
|
||||
font_info.path = fontpath;
|
||||
font_info.size = font_size;
|
||||
|
||||
if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
}
|
||||
|
||||
@ -2562,7 +2566,7 @@ static void xmb_context_destroy(void *data)
|
||||
xmb_context_destroy_horizontal_list(xmb);
|
||||
xmb_context_bg_destroy(xmb);
|
||||
|
||||
menu_display_free_main_font();
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL);
|
||||
}
|
||||
|
||||
static void xmb_toggle(void *userdata, bool menu_on)
|
||||
|
@ -209,6 +209,7 @@ static void zarch_zui_font(void)
|
||||
{
|
||||
int font_size;
|
||||
char mediapath[PATH_MAX_LENGTH], fontpath[PATH_MAX_LENGTH];
|
||||
menu_display_ctx_font_t font_info;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
|
||||
@ -216,7 +217,10 @@ static void zarch_zui_font(void)
|
||||
fill_pathname_join(mediapath, settings->assets_directory, "zarch", sizeof(mediapath));
|
||||
fill_pathname_join(fontpath, mediapath, "Roboto-Condensed.ttf", sizeof(fontpath));
|
||||
|
||||
if (!menu_display_init_main_font(fontpath, font_size))
|
||||
font_info.path = fontpath;
|
||||
font_info.size = font_size;
|
||||
|
||||
if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
}
|
||||
|
||||
@ -1116,22 +1120,19 @@ static void zarch_free(void *data)
|
||||
font_driver_bind_block(NULL, NULL);
|
||||
}
|
||||
|
||||
static void zarch_context_bg_destroy(zui_t *zui)
|
||||
static void zarch_context_bg_destroy(void *data)
|
||||
{
|
||||
zui_t *zui = (zui_t*)data;
|
||||
if (!zui)
|
||||
return;
|
||||
menu_display_texture_unload((uintptr_t*)&zui->textures.bg.id);
|
||||
menu_display_texture_unload((uintptr_t*)&zui->textures.white);
|
||||
}
|
||||
|
||||
static void zarch_context_destroy(void *data)
|
||||
{
|
||||
zui_t *zui = (zui_t*)data;
|
||||
|
||||
if (!zui)
|
||||
return;
|
||||
|
||||
menu_display_free_main_font();
|
||||
|
||||
zarch_context_bg_destroy(zui);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL);
|
||||
zarch_context_bg_destroy(data);
|
||||
}
|
||||
|
||||
static bool zarch_load_image(void *userdata,
|
||||
@ -1173,6 +1174,7 @@ static void zarch_allocate_white_texture(zui_t *zui)
|
||||
|
||||
static void zarch_context_reset(void *data)
|
||||
{
|
||||
menu_display_ctx_font_t font_info;
|
||||
const char *font_path = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
zui_t *zui = (zui_t*)data;
|
||||
@ -1180,9 +1182,13 @@ static void zarch_context_reset(void *data)
|
||||
if (!zui || !settings)
|
||||
return;
|
||||
|
||||
font_path = settings->video.font_enable ? settings->video.font_path : NULL;
|
||||
font_info.path = NULL;
|
||||
font_info.size = zui->font_size;
|
||||
|
||||
if (!menu_display_init_main_font(font_path, zui->font_size))
|
||||
if (settings->video.font_enable)
|
||||
font_info.path = settings->video.font_path;
|
||||
|
||||
if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
|
||||
zarch_context_bg_destroy(zui);
|
||||
|
@ -89,17 +89,6 @@ static bool menu_display_font_init_first(void **font_handle,
|
||||
font_path, font_size);
|
||||
}
|
||||
|
||||
void menu_display_free_main_font(void)
|
||||
{
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (disp && disp->font.buf)
|
||||
{
|
||||
font_driver_free(disp->font.buf);
|
||||
disp->font.buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *menu_video_get_ident(void)
|
||||
{
|
||||
#ifdef HAVE_THREADS
|
||||
@ -153,30 +142,6 @@ static bool menu_display_driver_init_first(menu_display_t *disp)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool menu_display_init_main_font(const char *font_path, float font_size)
|
||||
{
|
||||
bool ret;
|
||||
void *video = video_driver_get_ptr(false);
|
||||
menu_display_t *disp = menu_display_get_ptr();
|
||||
|
||||
if (!disp)
|
||||
return false;
|
||||
|
||||
if (disp->font.buf)
|
||||
menu_display_free_main_font();
|
||||
|
||||
ret = menu_display_font_init_first(
|
||||
&disp->font.buf, video,
|
||||
font_path, font_size);
|
||||
|
||||
if (ret)
|
||||
disp->font.size = font_size;
|
||||
else
|
||||
disp->font.buf = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
{
|
||||
unsigned width, height;
|
||||
@ -206,6 +171,24 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
return false;
|
||||
menu_disp->blend_end();
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_FONT_MAIN_DEINIT:
|
||||
if (disp && disp->font.buf)
|
||||
font_driver_free(disp->font.buf);
|
||||
disp->font.buf = NULL;
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_FONT_MAIN_INIT:
|
||||
{
|
||||
menu_display_ctx_font_t *font = (menu_display_ctx_font_t*)data;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL);
|
||||
|
||||
if (!font || !menu_display_font_init_first(
|
||||
&disp->font.buf, video_driver_get_ptr(false), font->path, font->size))
|
||||
return false;
|
||||
|
||||
disp->font.size = font->size;
|
||||
}
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_FONT_BIND_BLOCK:
|
||||
if (!disp)
|
||||
return false;
|
||||
|
@ -68,6 +68,8 @@ enum menu_display_ctl_state
|
||||
MENU_DISPLAY_CTL_SET_FONT_BUF,
|
||||
MENU_DISPLAY_CTL_FONT_FB,
|
||||
MENU_DISPLAY_CTL_SET_FONT_FB,
|
||||
MENU_DISPLAY_CTL_FONT_MAIN_DEINIT,
|
||||
MENU_DISPLAY_CTL_FONT_MAIN_INIT,
|
||||
MENU_DISPLAY_CTL_FONT_BIND_BLOCK,
|
||||
MENU_DISPLAY_CTL_BLEND_BEGIN,
|
||||
MENU_DISPLAY_CTL_BLEND_END
|
||||
@ -126,9 +128,11 @@ typedef struct menu_display_ctx_driver
|
||||
const char *ident;
|
||||
} menu_display_ctx_driver_t;
|
||||
|
||||
bool menu_display_init_main_font(const char *font_path, float font_size);
|
||||
|
||||
void menu_display_free_main_font(void);
|
||||
typedef struct menu_display_ctx_font
|
||||
{
|
||||
const char *path;
|
||||
float size;
|
||||
} menu_display_ctx_font_t;
|
||||
|
||||
bool menu_display_ctl(enum menu_display_ctl_state state, void *data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user