mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 11:18:25 +00:00
commit
ab41c7ba9c
@ -30,6 +30,7 @@
|
||||
#include "../../gfx/font_driver.h"
|
||||
#include "../../gfx/video_texture.h"
|
||||
#include <compat/posix_string.h>
|
||||
#include "retroarch_logger.h"
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
@ -202,17 +203,11 @@ static void glui_render_messagebox(const char *message)
|
||||
uint32_t normal_color;
|
||||
int x, y;
|
||||
struct string_list *list = NULL;
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
if (!menu || !menu->userdata)
|
||||
return;
|
||||
|
||||
list = (struct string_list*)string_split(message, "\n");
|
||||
@ -247,14 +242,11 @@ static void glui_render(void)
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata)
|
||||
return;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
menu_animation_update(menu->animation, menu->dt / IDEAL_DT);
|
||||
|
||||
menu->frame_buf.width = global->video_data.width;
|
||||
@ -377,7 +369,7 @@ static void glui_frame(void)
|
||||
global_t *global = global_get_ptr();
|
||||
const struct font_renderer *font_driver = NULL;
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata)
|
||||
return;
|
||||
|
||||
gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
@ -387,9 +379,6 @@ static void glui_frame(void)
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
if (menu->need_refresh
|
||||
&& runloop->is_menu
|
||||
&& !menu->msg_force)
|
||||
@ -575,14 +564,18 @@ static void glui_context_bg_destroy(glui_handle_t *glui)
|
||||
|
||||
static void glui_context_destroy(void)
|
||||
{
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata || !gl || !driver)
|
||||
return;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
menu_display_free_main_font(menu);
|
||||
|
||||
glui_context_bg_destroy(glui);
|
||||
}
|
||||
|
||||
@ -591,13 +584,10 @@ static bool glui_load_wallpaper(void *data)
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata)
|
||||
return false;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return false;
|
||||
|
||||
glui_context_bg_destroy(glui);
|
||||
|
||||
@ -614,14 +604,10 @@ static float glui_get_scroll(void)
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata)
|
||||
return 0;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
|
||||
if (!glui)
|
||||
return 0;
|
||||
|
||||
half = (global->video_data.height / glui->line_height) / 2;
|
||||
|
||||
if (menu->navigation.selection_ptr < half)
|
||||
@ -677,30 +663,19 @@ static void glui_populate_entries(const char *path,
|
||||
|
||||
static void glui_context_reset(void)
|
||||
{
|
||||
gl_t *gl = NULL;
|
||||
glui_handle_t *glui = NULL;
|
||||
driver_t *driver = driver_get_ptr();
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
glui_handle_t *glui = NULL;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *font_path = NULL;
|
||||
|
||||
if (!menu)
|
||||
if (!menu || !menu->userdata || !settings)
|
||||
return;
|
||||
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
glui = (glui_handle_t*)menu->userdata;
|
||||
font_path = settings->video.font_path;
|
||||
|
||||
if (!glui)
|
||||
return;
|
||||
|
||||
gl = (gl_t*)video_driver_get_ptr(NULL);
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
menu_display_font_init_first(
|
||||
(const void**)&driver->font_osd_driver,
|
||||
&menu->font.buf,
|
||||
gl,
|
||||
NULL,
|
||||
menu->font.size);
|
||||
if (!menu_display_init_main_font(menu, font_path, menu->font.size))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
|
||||
glui_context_bg_destroy(glui);
|
||||
|
||||
|
@ -1571,12 +1571,8 @@ static void xmb_context_reset(void)
|
||||
|
||||
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
|
||||
|
||||
menu_display_font_init_first(
|
||||
(const void**)&driver->font_osd_driver,
|
||||
&menu->font.buf,
|
||||
gl,
|
||||
fontpath,
|
||||
menu->font.size);
|
||||
if (!menu_display_init_main_font(menu, fontpath, menu->font.size))
|
||||
RARCH_WARN("Failed to load font.");
|
||||
|
||||
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath,
|
||||
"settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path));
|
||||
@ -1915,8 +1911,7 @@ static void xmb_context_destroy(void)
|
||||
glDeleteTextures(1, &node->content_icon);
|
||||
}
|
||||
|
||||
if (menu->font.buf)
|
||||
driver->font_osd_driver->free(menu->font.buf);
|
||||
menu_display_free_main_font(menu);
|
||||
}
|
||||
|
||||
static void xmb_toggle(bool menu_on)
|
||||
|
@ -157,6 +157,41 @@ bool menu_display_font_flush_block(menu_handle_t *menu,
|
||||
font_driver, NULL);
|
||||
}
|
||||
|
||||
void menu_display_free_main_font(menu_handle_t *menu)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (menu->font.buf)
|
||||
{
|
||||
driver->font_osd_driver->free(menu->font.buf);
|
||||
menu->font.buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool menu_display_init_main_font(menu_handle_t *menu,
|
||||
const char *font_path, float font_size)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
void *video = video_driver_get_ptr(NULL);
|
||||
bool result;
|
||||
|
||||
if (menu->font.buf)
|
||||
menu_display_free_main_font(menu);
|
||||
|
||||
if (!font_path[0])
|
||||
font_path = NULL;
|
||||
|
||||
result = menu_display_font_init_first(
|
||||
(const void**)&driver->font_osd_driver, &menu->font.buf, video,
|
||||
font_path, font_size);
|
||||
|
||||
if (result)
|
||||
menu->font.size = font_size;
|
||||
else
|
||||
menu->font.buf = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void menu_display_set_viewport(menu_handle_t *menu)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
@ -44,6 +44,11 @@ bool menu_display_font_bind_block(menu_handle_t *menu,
|
||||
bool menu_display_font_flush_block(menu_handle_t *menu,
|
||||
const struct font_renderer *font_driver);
|
||||
|
||||
/** Shortcuts to handle menu->font.buf */
|
||||
bool menu_display_init_main_font(menu_handle_t *menu,
|
||||
const char *font_path, float font_size);
|
||||
void menu_display_free_main_font(menu_handle_t *menu);
|
||||
|
||||
void menu_display_set_viewport(menu_handle_t *menu);
|
||||
|
||||
void menu_display_unset_viewport(menu_handle_t *menu);
|
||||
|
Loading…
Reference in New Issue
Block a user