(XMB) Refactor icon code

This commit is contained in:
twinaphex 2016-04-21 09:14:25 +02:00
parent 4f2d1d7c93
commit ba91ae5909
1 changed files with 69 additions and 72 deletions

View File

@ -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;
@ -424,36 +429,6 @@ static void xmb_draw_icon_predone(xmb_handle_t *xmb,
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;
float x = xmb->x + xmb->categories.x_pos +
xmb->margins.screen.left + xmb->margins.screen.left +
xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0, xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0;
xmb->margins.screen.top + xmb->icon.size / 2.0, float y = xmb->margins.screen.top + xmb->icon.size / 2.0;
width, float rotation = 0;
height, float scale_factor = node->zoom;
0,
node->zoom, rotate_draw.matrix = &mymat;
&item_color[0]); 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);
} }