(XMB) Refactor icon code
This commit is contained in:
parent
4f2d1d7c93
commit
ba91ae5909
|
@ -370,12 +370,17 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current)
|
||||||
return iy;
|
return iy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_draw_icon_predone(xmb_handle_t *xmb,
|
static void xmb_draw_icon(
|
||||||
|
xmb_handle_t *xmb,
|
||||||
math_matrix_4x4 *mymat,
|
math_matrix_4x4 *mymat,
|
||||||
uintptr_t texture,
|
uintptr_t texture,
|
||||||
float x, float y,
|
float x,
|
||||||
unsigned width, unsigned height,
|
float y,
|
||||||
float alpha, float rotation, float scale_factor,
|
unsigned width,
|
||||||
|
unsigned height,
|
||||||
|
float alpha,
|
||||||
|
float rotation,
|
||||||
|
float scale_factor,
|
||||||
float *color)
|
float *color)
|
||||||
{
|
{
|
||||||
menu_display_ctx_draw_t draw;
|
menu_display_ctx_draw_t draw;
|
||||||
|
@ -396,64 +401,34 @@ static void xmb_draw_icon_predone(xmb_handle_t *xmb,
|
||||||
coords.tex_coord = NULL;
|
coords.tex_coord = NULL;
|
||||||
coords.lut_tex_coord = NULL;
|
coords.lut_tex_coord = NULL;
|
||||||
|
|
||||||
draw.width = xmb->icon.size;
|
draw.width = xmb->icon.size;
|
||||||
draw.height = xmb->icon.size;
|
draw.height = xmb->icon.size;
|
||||||
draw.coords = &coords;
|
draw.coords = &coords;
|
||||||
draw.matrix_data = mymat;
|
draw.matrix_data = mymat;
|
||||||
draw.texture = texture;
|
draw.texture = texture;
|
||||||
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||||
|
|
||||||
if (settings->menu.xmb_shadows)
|
if (settings->menu.xmb_shadows)
|
||||||
{
|
{
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
shadow[i] = 0;
|
shadow[i] = 0;
|
||||||
|
|
||||||
menu_display_set_alpha(shadow, color[3] / 4);
|
menu_display_set_alpha(shadow, color[3] / 4);
|
||||||
|
|
||||||
coords.color = shadow;
|
coords.color = shadow;
|
||||||
draw.x = x + 2;
|
draw.x = x + 2;
|
||||||
draw.y = height - y - 2;
|
draw.y = height - y - 2;
|
||||||
|
|
||||||
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
coords.color = (const float*)color;
|
coords.color = (const float*)color;
|
||||||
draw.x = x;
|
draw.x = x;
|
||||||
draw.y = height - y;
|
draw.y = height - y;
|
||||||
|
|
||||||
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_draw_icon(xmb_handle_t *xmb,
|
|
||||||
uintptr_t texture,
|
|
||||||
float x, float y,
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
float rotation, float scale_factor,
|
|
||||||
float *color)
|
|
||||||
{
|
|
||||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
|
||||||
math_matrix_4x4 mymat;
|
|
||||||
|
|
||||||
if (
|
|
||||||
x < -xmb->icon.size/2 ||
|
|
||||||
x > width ||
|
|
||||||
y < xmb->icon.size/2 ||
|
|
||||||
y > height + xmb->icon.size)
|
|
||||||
return;
|
|
||||||
|
|
||||||
rotate_draw.matrix = &mymat;
|
|
||||||
rotate_draw.rotation = rotation;
|
|
||||||
rotate_draw.scale_x = scale_factor;
|
|
||||||
rotate_draw.scale_y = scale_factor;
|
|
||||||
rotate_draw.scale_z = 1;
|
|
||||||
rotate_draw.scale_enable = true;
|
|
||||||
|
|
||||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
|
||||||
|
|
||||||
xmb_draw_icon_predone(xmb, &mymat, texture, x, y,
|
|
||||||
width, height, 1.0, rotation, scale_factor, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color,
|
static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color,
|
||||||
unsigned width, unsigned height)
|
unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
|
@ -1706,22 +1681,33 @@ static void xmb_draw_items(xmb_handle_t *xmb,
|
||||||
? xmb->alpha : node->alpha);
|
? xmb->alpha : node->alpha);
|
||||||
|
|
||||||
if (color[3] != 0)
|
if (color[3] != 0)
|
||||||
xmb_draw_icon(
|
{
|
||||||
xmb,
|
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||||
icon,
|
math_matrix_4x4 mymat;
|
||||||
icon_x,
|
uintptr_t texture = icon;
|
||||||
icon_y,
|
float x = icon_x;
|
||||||
width,
|
float y = icon_y;
|
||||||
height,
|
float rotation = 0;
|
||||||
0,
|
float scale_factor = node->zoom;
|
||||||
node->zoom,
|
|
||||||
&color[0]);
|
rotate_draw.matrix = &mymat;
|
||||||
|
rotate_draw.rotation = rotation;
|
||||||
|
rotate_draw.scale_x = scale_factor;
|
||||||
|
rotate_draw.scale_y = scale_factor;
|
||||||
|
rotate_draw.scale_z = 1;
|
||||||
|
rotate_draw.scale_enable = true;
|
||||||
|
|
||||||
|
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||||
|
|
||||||
|
xmb_draw_icon(xmb, &mymat, texture, x, y,
|
||||||
|
width, height, 1.0, rotation, scale_factor, &color[0]);
|
||||||
|
}
|
||||||
|
|
||||||
menu_display_set_alpha(color, node->alpha > xmb->alpha
|
menu_display_set_alpha(color, node->alpha > xmb->alpha
|
||||||
? xmb->alpha : node->alpha);
|
? xmb->alpha : node->alpha);
|
||||||
|
|
||||||
if (texture_switch != 0 && color[3] != 0)
|
if (texture_switch != 0 && color[3] != 0)
|
||||||
xmb_draw_icon_predone(xmb, &mymat,
|
xmb_draw_icon(xmb, &mymat,
|
||||||
texture_switch,
|
texture_switch,
|
||||||
node->x + xmb->margins.screen.left
|
node->x + xmb->margins.screen.left
|
||||||
+ xmb->icon.spacing.horizontal
|
+ xmb->icon.spacing.horizontal
|
||||||
|
@ -1918,7 +1904,7 @@ static void xmb_frame(void *data)
|
||||||
menu_display_set_alpha(coord_color2,
|
menu_display_set_alpha(coord_color2,
|
||||||
1.00f > xmb->alpha ? xmb->alpha : 1.00f);
|
1.00f > xmb->alpha ? xmb->alpha : 1.00f);
|
||||||
if (settings->menu.timedate_enable && coord_color2[3] != 0)
|
if (settings->menu.timedate_enable && coord_color2[3] != 0)
|
||||||
xmb_draw_icon_predone(xmb, &mymat,
|
xmb_draw_icon(xmb, &mymat,
|
||||||
xmb->textures.list[XMB_TEXTURE_CLOCK],
|
xmb->textures.list[XMB_TEXTURE_CLOCK],
|
||||||
width - xmb->icon.size, xmb->icon.size,width,
|
width - xmb->icon.size, xmb->icon.size,width,
|
||||||
height, 1, 0, 1, &coord_color2[0]);
|
height, 1, 0, 1, &coord_color2[0]);
|
||||||
|
@ -1945,7 +1931,7 @@ static void xmb_frame(void *data)
|
||||||
xmb->textures.arrow.alpha > xmb->alpha
|
xmb->textures.arrow.alpha > xmb->alpha
|
||||||
? xmb->alpha : xmb->textures.arrow.alpha);
|
? xmb->alpha : xmb->textures.arrow.alpha);
|
||||||
if (coord_color2[3] != 0)
|
if (coord_color2[3] != 0)
|
||||||
xmb_draw_icon_predone(
|
xmb_draw_icon(
|
||||||
xmb,
|
xmb,
|
||||||
&mymat,
|
&mymat,
|
||||||
xmb->textures.list[XMB_TEXTURE_ARROW],
|
xmb->textures.list[XMB_TEXTURE_ARROW],
|
||||||
|
@ -1975,18 +1961,29 @@ static void xmb_frame(void *data)
|
||||||
node->alpha > xmb->alpha ? xmb->alpha : node->alpha);
|
node->alpha > xmb->alpha ? xmb->alpha : node->alpha);
|
||||||
|
|
||||||
if (item_color[3] != 0)
|
if (item_color[3] != 0)
|
||||||
xmb_draw_icon(
|
{
|
||||||
xmb,
|
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||||
node->icon,
|
math_matrix_4x4 mymat;
|
||||||
xmb->x + xmb->categories.x_pos +
|
uintptr_t texture = node->icon;
|
||||||
xmb->margins.screen.left +
|
float x = xmb->x + xmb->categories.x_pos +
|
||||||
xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0,
|
xmb->margins.screen.left +
|
||||||
xmb->margins.screen.top + xmb->icon.size / 2.0,
|
xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0;
|
||||||
width,
|
float y = xmb->margins.screen.top + xmb->icon.size / 2.0;
|
||||||
height,
|
float rotation = 0;
|
||||||
0,
|
float scale_factor = node->zoom;
|
||||||
node->zoom,
|
|
||||||
&item_color[0]);
|
rotate_draw.matrix = &mymat;
|
||||||
|
rotate_draw.rotation = rotation;
|
||||||
|
rotate_draw.scale_x = scale_factor;
|
||||||
|
rotate_draw.scale_y = scale_factor;
|
||||||
|
rotate_draw.scale_z = 1;
|
||||||
|
rotate_draw.scale_enable = true;
|
||||||
|
|
||||||
|
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||||
|
|
||||||
|
xmb_draw_icon(xmb, &mymat, texture, x, y,
|
||||||
|
width, height, 1.0, rotation, scale_factor, &item_color[0]);
|
||||||
|
}
|
||||||
|
|
||||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue