mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(XMB) Use theme font + responsive font size
This commit is contained in:
parent
60c4ba8987
commit
90548d572b
@ -89,7 +89,6 @@ typedef struct xmb_handle
|
|||||||
float arrow_alpha;
|
float arrow_alpha;
|
||||||
float hspacing;
|
float hspacing;
|
||||||
float vspacing;
|
float vspacing;
|
||||||
float font_size;
|
|
||||||
float margin_left;
|
float margin_left;
|
||||||
float margin_top;
|
float margin_top;
|
||||||
float title_margin_left;
|
float title_margin_left;
|
||||||
@ -110,6 +109,8 @@ typedef struct xmb_handle
|
|||||||
float c_passive_alpha;
|
float c_passive_alpha;
|
||||||
float i_passive_zoom;
|
float i_passive_zoom;
|
||||||
float i_passive_alpha;
|
float i_passive_alpha;
|
||||||
|
void *font;
|
||||||
|
int font_size;
|
||||||
} xmb_handle_t;
|
} xmb_handle_t;
|
||||||
|
|
||||||
static const GLfloat rmb_vertex[] = {
|
static const GLfloat rmb_vertex[] = {
|
||||||
@ -222,7 +223,7 @@ static void xmb_draw_text(const char *str, float x,
|
|||||||
if (driver.video_data && driver.video_poke
|
if (driver.video_data && driver.video_poke
|
||||||
&& driver.video_poke->set_osd_msg)
|
&& driver.video_poke->set_osd_msg)
|
||||||
driver.video_poke->set_osd_msg(driver.video_data,
|
driver.video_poke->set_osd_msg(driver.video_data,
|
||||||
str, ¶ms, NULL);
|
str, ¶ms, xmb->font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_render_background(bool force_transparency)
|
static void xmb_render_background(bool force_transparency)
|
||||||
@ -338,15 +339,15 @@ static void xmb_render_messagebox(const char *message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = gl->win_width / 2 - strlen(list->elems[0].data) * g_settings.video.font_size / 4;
|
int x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4;
|
||||||
int y = gl->win_height / 2 - list->size * g_settings.video.font_size / 2;
|
int y = gl->win_height / 2 - list->size * xmb->font_size / 2;
|
||||||
|
|
||||||
for (i = 0; i < list->size; i++)
|
for (i = 0; i < list->size; i++)
|
||||||
{
|
{
|
||||||
const char *msg = list->elems[i].data;
|
const char *msg = list->elems[i].data;
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
xmb_draw_text(msg, x, y + i * g_settings.video.font_size, 1, 1);
|
xmb_draw_text(msg, x, y + i * xmb->font_size, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
@ -794,15 +795,16 @@ static void *xmb_init(void)
|
|||||||
strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir));
|
strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir));
|
||||||
|
|
||||||
xmb->icon_size = 128.0 * scale_factor;
|
xmb->icon_size = 128.0 * scale_factor;
|
||||||
|
xmb->font_size = 32.0 * scale_factor;
|
||||||
xmb->hspacing = 200.0 * scale_factor;
|
xmb->hspacing = 200.0 * scale_factor;
|
||||||
xmb->vspacing = 64.0 * scale_factor;
|
xmb->vspacing = 64.0 * scale_factor;
|
||||||
xmb->margin_left = 336.0 * scale_factor;
|
xmb->margin_left = 336.0 * scale_factor;
|
||||||
xmb->margin_top = (256+32) * scale_factor;
|
xmb->margin_top = (256+32) * scale_factor;
|
||||||
xmb->title_margin_left = 60 * scale_factor;
|
xmb->title_margin_left = 60 * scale_factor;
|
||||||
xmb->title_margin_top = 60 * scale_factor + g_settings.video.font_size/3;
|
xmb->title_margin_top = 60 * scale_factor + xmb->font_size/3;
|
||||||
xmb->title_margin_bottom = 60 * scale_factor - g_settings.video.font_size/3;
|
xmb->title_margin_bottom = 60 * scale_factor - xmb->font_size/3;
|
||||||
xmb->label_margin_left = 85.0 * scale_factor;
|
xmb->label_margin_left = 85.0 * scale_factor;
|
||||||
xmb->label_margin_top = g_settings.video.font_size/3.0;
|
xmb->label_margin_top = xmb->font_size/3.0;
|
||||||
xmb->setting_margin_left = 600.0 * scale_factor;
|
xmb->setting_margin_left = 600.0 * scale_factor;
|
||||||
|
|
||||||
xmb_init_core_info(menu);
|
xmb_init_core_info(menu);
|
||||||
@ -864,17 +866,40 @@ static GLuint xmb_png_texture_load(const char* file_name)
|
|||||||
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
|
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
|
||||||
|
|
||||||
return thr->cmd_data.custom_command.return_value;
|
return thr->cmd_data.custom_command.return_value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return xmb_png_texture_load_(file_name);
|
return xmb_png_texture_load_(file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
||||||
|
void **font_handle, void *video_data, const char *font_path,
|
||||||
|
float font_size)
|
||||||
|
{
|
||||||
|
if (g_settings.video.threaded
|
||||||
|
&& !g_extern.system.hw_render_callback.context_type)
|
||||||
|
{
|
||||||
|
thread_video_t *thr = (thread_video_t*)driver.video_data;
|
||||||
|
thr->cmd_data.font_init.method = gl_font_init_first;
|
||||||
|
thr->cmd_data.font_init.font_driver = font_driver;
|
||||||
|
thr->cmd_data.font_init.font_handle = font_handle;
|
||||||
|
thr->cmd_data.font_init.video_data = video_data;
|
||||||
|
thr->cmd_data.font_init.font_path = font_path;
|
||||||
|
thr->cmd_data.font_init.font_size = font_size;
|
||||||
|
thr->send_cmd_func(thr, CMD_FONT_INIT);
|
||||||
|
thr->wait_reply_func(thr, CMD_FONT_INIT);
|
||||||
|
|
||||||
|
return thr->cmd_data.font_init.return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gl_font_init_first(font_driver, font_handle, video_data,
|
||||||
|
font_path, font_size);
|
||||||
|
}
|
||||||
|
|
||||||
static void xmb_context_reset(void *data)
|
static void xmb_context_reset(void *data)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
char bgpath[PATH_MAX];
|
char bgpath[PATH_MAX];
|
||||||
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX];
|
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX], fontpath[PATH_MAX];
|
||||||
gl_t *gl = NULL;
|
gl_t *gl = NULL;
|
||||||
xmb_handle_t *xmb = NULL;
|
xmb_handle_t *xmb = NULL;
|
||||||
menu_handle_t *menu = (menu_handle_t*)data;
|
menu_handle_t *menu = (menu_handle_t*)data;
|
||||||
@ -910,6 +935,10 @@ static void xmb_context_reset(void *data)
|
|||||||
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));
|
||||||
|
|
||||||
|
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
|
||||||
|
|
||||||
|
xmb_font_init_first(&gl->font_driver, &xmb->font, gl, fontpath, xmb->font_size);
|
||||||
|
|
||||||
fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath,
|
fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath,
|
||||||
"bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path));
|
"bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path));
|
||||||
fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTINGS].path, iconpath,
|
fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTINGS].path, iconpath,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user