mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
(XMB) Encapsulate everything inside xmb_handle_t struct
This commit is contained in:
parent
de130dd516
commit
84a35d4176
@ -59,37 +59,68 @@ typedef struct
|
|||||||
float y;
|
float y;
|
||||||
} xmb_node_t;
|
} xmb_node_t;
|
||||||
|
|
||||||
xmb_node_t *xmb_nodes;
|
|
||||||
|
|
||||||
char xmb_title[256] = "";
|
char xmb_title[256] = "";
|
||||||
char xmb_oldtitle[256] = "";
|
char xmb_oldtitle[256] = "";
|
||||||
int xmb_depth = 0;
|
|
||||||
int selptr = -1;
|
int selptr = -1;
|
||||||
int oldselptr = -1;
|
int oldselptr = -1;
|
||||||
|
|
||||||
unsigned line_height, glyph_width, xmb_margin, xmb_term_width, xmb_term_height;
|
|
||||||
GLuint xmb_bg = 0;
|
|
||||||
char box_message[PATH_MAX];
|
|
||||||
|
|
||||||
float xmb_alpha = 1.0f;
|
enum
|
||||||
|
{
|
||||||
|
RMB_TEXTURE_MAIN = 0,
|
||||||
|
RMB_TEXTURE_FONT,
|
||||||
|
RMB_TEXTURE_BG,
|
||||||
|
RMB_TEXTURE_SETTINGS,
|
||||||
|
RMB_TEXTURE_SETTING,
|
||||||
|
RMB_TEXTURE_SUBSETTING,
|
||||||
|
RMB_TEXTURE_ARROW,
|
||||||
|
RMB_TEXTURE_RUN,
|
||||||
|
RMB_TEXTURE_RESUME,
|
||||||
|
RMB_TEXTURE_SAVESTATE,
|
||||||
|
RMB_TEXTURE_LOADSTATE,
|
||||||
|
RMB_TEXTURE_SCREENSHOT,
|
||||||
|
RMB_TEXTURE_RELOAD,
|
||||||
|
RMB_TEXTURE_LAST
|
||||||
|
};
|
||||||
|
|
||||||
char icon_dir[4];
|
struct xmb_texture_item
|
||||||
|
{
|
||||||
|
GLuint id;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
int xmb_icon_size = 96;
|
typedef struct xmb_handle
|
||||||
float xmb_hspacing = 150.0;
|
{
|
||||||
float xmb_vspacing = 48.0;
|
int xmb_depth;
|
||||||
float xmb_font_size = 18;
|
GLuint xmb_bg;
|
||||||
float xmb_margin_left = 224;
|
unsigned line_height;
|
||||||
float xmb_margin_top = 192;
|
unsigned glyph_width;
|
||||||
float xmb_title_margin_left = 15.0;
|
unsigned xmb_margin;
|
||||||
float xmb_title_margin_top = 30.0;
|
unsigned xmb_term_width;
|
||||||
float xmb_label_margin_left = 64;
|
unsigned xmb_term_height;
|
||||||
float xmb_label_margin_top = 6.0;
|
char icon_dir[4];
|
||||||
float xmb_setting_margin_left = 400;
|
char box_message[PATH_MAX];
|
||||||
|
struct xmb_texture_item textures[RMB_TEXTURE_LAST];
|
||||||
|
int xmb_icon_size;
|
||||||
|
float xmb_alpha;
|
||||||
|
float xmb_hspacing;
|
||||||
|
float xmb_vspacing;
|
||||||
|
float xmb_font_size;
|
||||||
|
float xmb_margin_left;
|
||||||
|
float xmb_margin_top;
|
||||||
|
float xmb_title_margin_left;
|
||||||
|
float xmb_title_margin_top;
|
||||||
|
float xmb_label_margin_left;
|
||||||
|
float xmb_label_margin_top;
|
||||||
|
float xmb_setting_margin_left;
|
||||||
|
float xmb_above_item_offset;
|
||||||
|
float xmb_active_item_factor;
|
||||||
|
float xmb_under_item_offset;
|
||||||
|
xmb_node_t *xmb_nodes;
|
||||||
|
} xmb_handle_t;
|
||||||
|
|
||||||
float xmb_above_item_offset = -1.0;
|
static xmb_handle_t *xmb_menu_data;
|
||||||
float xmb_active_item_factor = 2.75;
|
|
||||||
float xmb_under_item_offset = 4.0;
|
|
||||||
|
|
||||||
static const GLfloat vertex[] = {
|
static const GLfloat vertex[] = {
|
||||||
0, 0,
|
0, 0,
|
||||||
@ -105,37 +136,17 @@ static const GLfloat tex_coord[] = {
|
|||||||
1, 0,
|
1, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
TEXTURE_MAIN = 0,
|
|
||||||
TEXTURE_FONT,
|
|
||||||
TEXTURE_BG,
|
|
||||||
TEXTURE_SETTINGS,
|
|
||||||
TEXTURE_SETTING,
|
|
||||||
TEXTURE_SUBSETTING,
|
|
||||||
TEXTURE_ARROW,
|
|
||||||
TEXTURE_RUN,
|
|
||||||
TEXTURE_RESUME,
|
|
||||||
TEXTURE_SAVESTATE,
|
|
||||||
TEXTURE_LOADSTATE,
|
|
||||||
TEXTURE_SCREENSHOT,
|
|
||||||
TEXTURE_RELOAD,
|
|
||||||
TEXTURE_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xmb_texture_item
|
|
||||||
{
|
|
||||||
GLuint id;
|
|
||||||
char path[PATH_MAX];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xmb_texture_item textures[TEXTURE_LAST];
|
|
||||||
|
|
||||||
static void xmb_draw_icon(GLuint texture, float x, float y,
|
static void xmb_draw_icon(GLuint texture, float x, float y,
|
||||||
float alpha, float rotation, float scale)
|
float alpha, float rotation, float scale)
|
||||||
{
|
{
|
||||||
if (alpha > xmb_alpha)
|
struct gl_coords coords;
|
||||||
alpha = xmb_alpha;
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
|
if (!xmb)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (alpha > xmb->xmb_alpha)
|
||||||
|
alpha = xmb->xmb_alpha;
|
||||||
|
|
||||||
if (alpha == 0)
|
if (alpha == 0)
|
||||||
return;
|
return;
|
||||||
@ -145,8 +156,8 @@ static void xmb_draw_icon(GLuint texture, float x, float y,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (x < -xmb_icon_size || x > gl->win_width + xmb_icon_size
|
if (x < -xmb->xmb_icon_size || x > gl->win_width + xmb->xmb_icon_size
|
||||||
|| y < -xmb_icon_size || y > gl->win_height + xmb_icon_size)
|
|| y < -xmb->xmb_icon_size || y > gl->win_height + xmb->xmb_icon_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLfloat color[] = {
|
GLfloat color[] = {
|
||||||
@ -159,9 +170,8 @@ static void xmb_draw_icon(GLuint texture, float x, float y,
|
|||||||
if (gl->shader && gl->shader->use)
|
if (gl->shader && gl->shader->use)
|
||||||
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
||||||
|
|
||||||
glViewport(x, gl->win_height - y, xmb_icon_size, xmb_icon_size);
|
glViewport(x, gl->win_height - y, xmb->xmb_icon_size, xmb->xmb_icon_size);
|
||||||
|
|
||||||
struct gl_coords coords;
|
|
||||||
coords.vertices = 4;
|
coords.vertices = 4;
|
||||||
coords.vertex = vertex;
|
coords.vertex = vertex;
|
||||||
coords.tex_coord = tex_coord;
|
coords.tex_coord = tex_coord;
|
||||||
@ -191,9 +201,15 @@ static void xmb_draw_icon(GLuint texture, float x, float y,
|
|||||||
static void xmb_draw_text(const char *str, float x,
|
static void xmb_draw_text(const char *str, float x,
|
||||||
float y, float scale, float alpha)
|
float y, float scale, float alpha)
|
||||||
{
|
{
|
||||||
if (alpha > xmb_alpha)
|
uint8_t a8 = 0;
|
||||||
alpha = xmb_alpha;
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
uint8_t a8 = 255 * alpha;
|
|
||||||
|
if (!xmb)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (alpha > xmb->xmb_alpha)
|
||||||
|
alpha = xmb->xmb_alpha;
|
||||||
|
a8 = 255 * alpha;
|
||||||
if (a8 == 0)
|
if (a8 == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -202,8 +218,8 @@ static void xmb_draw_text(const char *str, float x,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (x < -xmb_icon_size || x > gl->win_width + xmb_icon_size
|
if (x < -xmb->xmb_icon_size || x > gl->win_width + xmb->xmb_icon_size
|
||||||
|| y < -xmb_icon_size || y > gl->win_height + xmb_icon_size)
|
|| y < -xmb->xmb_icon_size || y > gl->win_height + xmb->xmb_icon_size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||||
@ -224,6 +240,11 @@ static void xmb_draw_text(const char *str, float x,
|
|||||||
|
|
||||||
static void xmb_render_background(void)
|
static void xmb_render_background(void)
|
||||||
{
|
{
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
|
if (!xmb)
|
||||||
|
return;
|
||||||
|
|
||||||
GLfloat black_color[] = {
|
GLfloat black_color[] = {
|
||||||
0.0f, 0.0f, 0.0f, 0.8f,
|
0.0f, 0.0f, 0.0f, 0.8f,
|
||||||
0.0f, 0.0f, 0.0f, 0.8f,
|
0.0f, 0.0f, 0.0f, 0.8f,
|
||||||
@ -256,8 +277,8 @@ static void xmb_render_background(void)
|
|||||||
|
|
||||||
gl->coords.vertex = vertex;
|
gl->coords.vertex = vertex;
|
||||||
gl->coords.tex_coord = tex_coord;
|
gl->coords.tex_coord = tex_coord;
|
||||||
gl->coords.color = xmb_bg ? gl->white_color_ptr : black_color;
|
gl->coords.color = xmb->xmb_bg ? gl->white_color_ptr : black_color;
|
||||||
glBindTexture(GL_TEXTURE_2D, xmb_bg);
|
glBindTexture(GL_TEXTURE_2D, xmb->xmb_bg);
|
||||||
|
|
||||||
if (gl->shader && gl->shader->use)
|
if (gl->shader && gl->shader->use)
|
||||||
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
||||||
@ -275,18 +296,21 @@ static void xmb_get_message(const char *message)
|
|||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
(void)i;
|
(void)i;
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
if (!driver.menu || !message || !*message)
|
if (!driver.menu || !message || !*message)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strlcpy(box_message, message, sizeof(box_message));
|
strlcpy(xmb->box_message, message, sizeof(xmb->box_message));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_render_messagebox(const char *message)
|
static void xmb_render_messagebox(const char *message)
|
||||||
{
|
{
|
||||||
|
unsigned i;
|
||||||
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
if (!driver.menu || !gl)
|
if (!driver.menu || !gl || !xmb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct string_list *list = string_split(message, "\n");
|
struct string_list *list = string_split(message, "\n");
|
||||||
@ -298,43 +322,46 @@ static void xmb_render_messagebox(const char *message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned i;
|
int x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->glyph_width / 2;
|
||||||
int x = gl->win_width / 2 - strlen(list->elems[0].data) * glyph_width / 2;
|
int y = gl->win_height / 2 - list->size * xmb->line_height / 2;
|
||||||
int y = gl->win_height / 2 - list->size * line_height / 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;
|
||||||
xmb_draw_text(msg, x, y + i * xmb_vspacing, 1, 1);
|
xmb_draw_text(msg, x, y + i * xmb->xmb_vspacing, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_free(list);
|
string_list_free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xmb_selection_pointer_changed()
|
static void xmb_selection_pointer_changed(void)
|
||||||
{
|
{
|
||||||
int num_nodes = file_list_get_size(driver.menu->selection_buf);
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
int num_nodes = file_list_get_size(driver.menu->selection_buf);
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
|
if (!xmb)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < num_nodes; i++)
|
for (i = 0; i < num_nodes; i++)
|
||||||
{
|
{
|
||||||
float iy;
|
float iy;
|
||||||
float ia = 0.5;
|
float ia = 0.5;
|
||||||
float iz = 0.5;
|
float iz = 0.5;
|
||||||
xmb_node_t *node = (xmb_node_t*)&xmb_nodes[i];
|
xmb_node_t *node = (xmb_node_t*)&xmb->xmb_nodes[i];
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
iy = (i < selptr) ? xmb_vspacing *
|
iy = (i < selptr) ? xmb->xmb_vspacing *
|
||||||
(i - selptr + xmb_above_item_offset) :
|
(i - selptr + xmb->xmb_above_item_offset) :
|
||||||
xmb_vspacing * (i - selptr + xmb_under_item_offset);
|
xmb->xmb_vspacing * (i - selptr + xmb->xmb_under_item_offset);
|
||||||
|
|
||||||
if (i == selptr)
|
if (i == selptr)
|
||||||
{
|
{
|
||||||
ia = 1.0;
|
ia = 1.0;
|
||||||
iz = 1.0;
|
iz = 1.0;
|
||||||
iy = xmb_vspacing * xmb_active_item_factor;
|
iy = xmb->xmb_vspacing * xmb->xmb_active_item_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
|
add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL);
|
||||||
@ -347,17 +374,19 @@ static void xmb_selection_pointer_changed()
|
|||||||
|
|
||||||
static void xmb_screen_changed(void)
|
static void xmb_screen_changed(void)
|
||||||
{
|
{
|
||||||
int num_nodes = file_list_get_size(driver.menu->selection_buf);
|
int i;
|
||||||
|
|
||||||
xmb_nodes = (xmb_node_t*)
|
|
||||||
calloc(num_nodes, sizeof(xmb_node_t));
|
|
||||||
|
|
||||||
const char *dir = NULL;
|
const char *dir = NULL;
|
||||||
const char *label = NULL;
|
const char *label = NULL;
|
||||||
unsigned menu_type = 0;
|
unsigned menu_type = 0;
|
||||||
file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);
|
int num_nodes = file_list_get_size(driver.menu->selection_buf);
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
int i;
|
if (!xmb)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xmb->xmb_nodes = (xmb_node_t*)calloc(num_nodes, sizeof(xmb_node_t));
|
||||||
|
|
||||||
|
file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);
|
||||||
|
|
||||||
for (i = 0; i < num_nodes; i++)
|
for (i = 0; i < num_nodes; i++)
|
||||||
{
|
{
|
||||||
@ -381,14 +410,14 @@ static void xmb_screen_changed(void)
|
|||||||
|
|
||||||
snprintf(name, sizeof(name), "%s", path_buf);
|
snprintf(name, sizeof(name), "%s", path_buf);
|
||||||
|
|
||||||
float iy = (i < selptr) ? xmb_vspacing *
|
float iy = (i < selptr) ? xmb->xmb_vspacing *
|
||||||
(i - selptr + xmb_above_item_offset) :
|
(i - selptr + xmb->xmb_above_item_offset) :
|
||||||
xmb_vspacing * (i - selptr + xmb_under_item_offset);
|
xmb->xmb_vspacing * (i - selptr + xmb->xmb_under_item_offset);
|
||||||
|
|
||||||
if (i == selptr)
|
if (i == selptr)
|
||||||
iy = xmb_vspacing * xmb_active_item_factor;
|
iy = xmb->xmb_vspacing * xmb->xmb_active_item_factor;
|
||||||
|
|
||||||
xmb_node_t *node = (xmb_node_t*)&xmb_nodes[i];
|
xmb_node_t *node = (xmb_node_t*)&xmb->xmb_nodes[i];
|
||||||
strlcpy(node->name, name, sizeof(node->name));
|
strlcpy(node->name, name, sizeof(node->name));
|
||||||
strlcpy(node->value, value, sizeof(node->value));
|
strlcpy(node->value, value, sizeof(node->value));
|
||||||
node->alpha = i == selptr ? 1.0 : 0.5;
|
node->alpha = i == selptr ? 1.0 : 0.5;
|
||||||
@ -401,6 +430,10 @@ static void xmb_screen_changed(void)
|
|||||||
|
|
||||||
static void xmb_frame(void)
|
static void xmb_frame(void)
|
||||||
{
|
{
|
||||||
|
const char *dir = NULL;
|
||||||
|
const char *label = NULL;
|
||||||
|
unsigned menu_type = 0;
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
||||||
|
|
||||||
if (!driver.menu || !gl)
|
if (!driver.menu || !gl)
|
||||||
@ -417,9 +450,6 @@ static void xmb_frame(void)
|
|||||||
|
|
||||||
xmb_render_background();
|
xmb_render_background();
|
||||||
|
|
||||||
const char *dir = NULL;
|
|
||||||
const char *label = NULL;
|
|
||||||
unsigned menu_type = 0;
|
|
||||||
file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);
|
file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);
|
||||||
|
|
||||||
if (!strcmp(xmb_title, ""))
|
if (!strcmp(xmb_title, ""))
|
||||||
@ -468,7 +498,7 @@ static void xmb_frame(void)
|
|||||||
|
|
||||||
for (i = 0; i < file_list_get_size(driver.menu->selection_buf); i++)
|
for (i = 0; i < file_list_get_size(driver.menu->selection_buf); i++)
|
||||||
{
|
{
|
||||||
xmb_node_t *node = (xmb_node_t*)&xmb_nodes[i];
|
xmb_node_t *node = (xmb_node_t*)&xmb->xmb_nodes[i];
|
||||||
|
|
||||||
/*float iy;
|
/*float iy;
|
||||||
float ia = 0.5;
|
float ia = 0.5;
|
||||||
@ -484,29 +514,30 @@ static void xmb_frame(void)
|
|||||||
iy = xmb_vspacing * xmb_active_item_factor;
|
iy = xmb_vspacing * xmb_active_item_factor;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
xmb_draw_icon(textures[TEXTURE_SETTING].id,
|
xmb_draw_icon(xmb->textures[RMB_TEXTURE_SETTING].id,
|
||||||
xmb_margin_left + xmb_hspacing - xmb_icon_size/2.0,
|
xmb->xmb_margin_left + xmb->xmb_hspacing - xmb->xmb_icon_size/2.0,
|
||||||
xmb_margin_top + node->y + xmb_icon_size/2.0,
|
xmb->xmb_margin_top + node->y + xmb->xmb_icon_size/2.0,
|
||||||
node->alpha,
|
node->alpha,
|
||||||
0,
|
0,
|
||||||
node->zoom);
|
node->zoom);
|
||||||
|
|
||||||
xmb_draw_text(node->name,
|
xmb_draw_text(node->name,
|
||||||
xmb_margin_left + xmb_hspacing + xmb_label_margin_left,
|
xmb->xmb_margin_left + xmb->xmb_hspacing + xmb->xmb_label_margin_left,
|
||||||
xmb_margin_top + node->y + xmb_label_margin_top,
|
xmb->xmb_margin_top + node->y + xmb->xmb_label_margin_top,
|
||||||
1,
|
1,
|
||||||
node->alpha);
|
node->alpha);
|
||||||
|
|
||||||
xmb_draw_text(node->value,
|
xmb_draw_text(node->value,
|
||||||
xmb_margin_left + xmb_hspacing + xmb_label_margin_left + xmb_setting_margin_left,
|
xmb->xmb_margin_left + xmb->xmb_hspacing +
|
||||||
xmb_margin_top + node->y + xmb_label_margin_top,
|
xmb->xmb_label_margin_left + xmb->xmb_setting_margin_left,
|
||||||
|
xmb->xmb_margin_top + node->y + xmb->xmb_label_margin_top,
|
||||||
1,
|
1,
|
||||||
node->alpha);
|
node->alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
xmb_draw_icon(textures[TEXTURE_SETTINGS].id,
|
xmb_draw_icon(xmb->textures[RMB_TEXTURE_SETTINGS].id,
|
||||||
xmb_margin_left + xmb_hspacing - xmb_icon_size/2.0,
|
xmb->xmb_margin_left + xmb->xmb_hspacing - xmb->xmb_icon_size / 2.0,
|
||||||
xmb_margin_top + xmb_icon_size/2.0,
|
xmb->xmb_margin_top + xmb->xmb_icon_size / 2.0,
|
||||||
1.0,
|
1.0,
|
||||||
0,
|
0,
|
||||||
1.0);
|
1.0);
|
||||||
@ -531,15 +562,16 @@ static void xmb_frame(void)
|
|||||||
const char *str = *driver.menu->keyboard.buffer;
|
const char *str = *driver.menu->keyboard.buffer;
|
||||||
if (!str)
|
if (!str)
|
||||||
str = "";
|
str = "";
|
||||||
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
snprintf(msg, sizeof(msg), "%s\n%s",
|
||||||
|
driver.menu->keyboard.label, str);
|
||||||
xmb_render_messagebox(msg);
|
xmb_render_messagebox(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (box_message[0] != '\0')
|
if (xmb->box_message[0] != '\0')
|
||||||
{
|
{
|
||||||
xmb_render_background();
|
xmb_render_background();
|
||||||
xmb_render_messagebox(box_message);
|
xmb_render_messagebox(xmb->box_message);
|
||||||
box_message[0] = '\0';
|
xmb->box_message[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||||
@ -559,7 +591,7 @@ static void xmb_init_core_info(void *data)
|
|||||||
|
|
||||||
static void *xmb_init(void)
|
static void *xmb_init(void)
|
||||||
{
|
{
|
||||||
menu_handle_t *menu;
|
menu_handle_t *menu = NULL;
|
||||||
const video_driver_t *video_driver = NULL;
|
const video_driver_t *video_driver = NULL;
|
||||||
gl_t *gl = (gl_t*)driver_video_resolve(&video_driver);
|
gl_t *gl = (gl_t*)driver_video_resolve(&video_driver);
|
||||||
|
|
||||||
@ -574,9 +606,32 @@ static void *xmb_init(void)
|
|||||||
if (!menu)
|
if (!menu)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
xmb_menu_data = (xmb_handle_t*)calloc(1, sizeof(*xmb_menu_data));
|
||||||
|
|
||||||
|
if (!xmb_menu_data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
xmb_menu_data->xmb_icon_size = 96;
|
||||||
|
xmb_menu_data->xmb_hspacing = 150.0;
|
||||||
|
xmb_menu_data->xmb_vspacing = 48.0;
|
||||||
|
xmb_menu_data->xmb_font_size = 18;
|
||||||
|
xmb_menu_data->xmb_margin_left = 224;
|
||||||
|
xmb_menu_data->xmb_margin_top = 192;
|
||||||
|
xmb_menu_data->xmb_title_margin_left = 15.0;
|
||||||
|
xmb_menu_data->xmb_title_margin_top = 30.0;
|
||||||
|
xmb_menu_data->xmb_label_margin_left = 64;
|
||||||
|
xmb_menu_data->xmb_label_margin_top = 6.0;
|
||||||
|
xmb_menu_data->xmb_setting_margin_left = 400;
|
||||||
|
xmb_menu_data->xmb_above_item_offset = -1.0;
|
||||||
|
xmb_menu_data->xmb_active_item_factor = 2.75;
|
||||||
|
xmb_menu_data->xmb_under_item_offset = 4.0;
|
||||||
|
xmb_menu_data->xmb_alpha = 1.0f;
|
||||||
|
xmb_menu_data->xmb_depth = 0;
|
||||||
|
xmb_menu_data->xmb_bg = 0;
|
||||||
|
|
||||||
xmb_init_core_info(menu);
|
xmb_init_core_info(menu);
|
||||||
|
|
||||||
strcpy(icon_dir, "96");
|
strcpy(xmb_menu_data->icon_dir, "96");
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
@ -590,6 +645,10 @@ static void xmb_free(void *data)
|
|||||||
|
|
||||||
if (g_extern.core_info)
|
if (g_extern.core_info)
|
||||||
core_info_list_free(g_extern.core_info);
|
core_info_list_free(g_extern.core_info);
|
||||||
|
|
||||||
|
if (xmb_menu_data)
|
||||||
|
free(xmb_menu_data);
|
||||||
|
|
||||||
g_extern.core_info = NULL;
|
g_extern.core_info = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,59 +698,59 @@ static GLuint xmb_png_texture_load(const char* file_name)
|
|||||||
|
|
||||||
static void xmb_context_reset(void *data)
|
static void xmb_context_reset(void *data)
|
||||||
{
|
{
|
||||||
|
int k;
|
||||||
|
char bgpath[PATH_MAX];
|
||||||
|
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX];
|
||||||
menu_handle_t *menu = (menu_handle_t*)data;
|
menu_handle_t *menu = (menu_handle_t*)data;
|
||||||
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
||||||
|
xmb_handle_t *xmb = (xmb_handle_t*)xmb_menu_data;
|
||||||
|
|
||||||
(void)gl;
|
(void)gl;
|
||||||
|
|
||||||
driver.gfx_use_rgba = true;
|
driver.gfx_use_rgba = true;
|
||||||
|
|
||||||
if (!menu)
|
if (!menu || !xmb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int k;
|
|
||||||
char bgpath[PATH_MAX];
|
|
||||||
char mediapath[PATH_MAX], themepath[PATH_MAX], iconpath[PATH_MAX];
|
|
||||||
|
|
||||||
fill_pathname_join(bgpath, g_settings.assets_directory,
|
fill_pathname_join(bgpath, g_settings.assets_directory,
|
||||||
"xmb", sizeof(bgpath));
|
"xmb", sizeof(bgpath));
|
||||||
|
|
||||||
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
||||||
|
|
||||||
if (path_file_exists(bgpath))
|
if (path_file_exists(bgpath))
|
||||||
xmb_bg = xmb_png_texture_load(bgpath);
|
xmb->xmb_bg = xmb_png_texture_load(bgpath);
|
||||||
|
|
||||||
fill_pathname_join(mediapath, g_settings.assets_directory,
|
fill_pathname_join(mediapath, g_settings.assets_directory,
|
||||||
"lakka", sizeof(mediapath));
|
"lakka", sizeof(mediapath));
|
||||||
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
|
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
|
||||||
fill_pathname_join(iconpath, themepath, 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(textures[TEXTURE_BG].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_BG].path, iconpath,
|
||||||
"bg.png", sizeof(textures[TEXTURE_BG].path));
|
"bg.png", sizeof(xmb->textures[RMB_TEXTURE_BG].path));
|
||||||
fill_pathname_join(textures[TEXTURE_SETTINGS].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_SETTINGS].path, iconpath,
|
||||||
"settings.png", sizeof(textures[TEXTURE_SETTINGS].path));
|
"settings.png", sizeof(xmb->textures[RMB_TEXTURE_SETTINGS].path));
|
||||||
fill_pathname_join(textures[TEXTURE_SETTING].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_SETTING].path, iconpath,
|
||||||
"setting.png", sizeof(textures[TEXTURE_SETTING].path));
|
"setting.png", sizeof(xmb->textures[RMB_TEXTURE_SETTING].path));
|
||||||
fill_pathname_join(textures[TEXTURE_SUBSETTING].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_SUBSETTING].path, iconpath,
|
||||||
"subsetting.png", sizeof(textures[TEXTURE_SUBSETTING].path));
|
"subsetting.png", sizeof(xmb->textures[RMB_TEXTURE_SUBSETTING].path));
|
||||||
fill_pathname_join(textures[TEXTURE_ARROW].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_ARROW].path, iconpath,
|
||||||
"arrow.png", sizeof(textures[TEXTURE_ARROW].path));
|
"arrow.png", sizeof(xmb->textures[RMB_TEXTURE_ARROW].path));
|
||||||
fill_pathname_join(textures[TEXTURE_RUN].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_RUN].path, iconpath,
|
||||||
"run.png", sizeof(textures[TEXTURE_RUN].path));
|
"run.png", sizeof(xmb->textures[RMB_TEXTURE_RUN].path));
|
||||||
fill_pathname_join(textures[TEXTURE_RESUME].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_RESUME].path, iconpath,
|
||||||
"resume.png", sizeof(textures[TEXTURE_RESUME].path));
|
"resume.png", sizeof(xmb->textures[RMB_TEXTURE_RESUME].path));
|
||||||
fill_pathname_join(textures[TEXTURE_SAVESTATE].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_SAVESTATE].path, iconpath,
|
||||||
"savestate.png", sizeof(textures[TEXTURE_SAVESTATE].path));
|
"savestate.png", sizeof(xmb->textures[RMB_TEXTURE_SAVESTATE].path));
|
||||||
fill_pathname_join(textures[TEXTURE_LOADSTATE].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_LOADSTATE].path, iconpath,
|
||||||
"loadstate.png", sizeof(textures[TEXTURE_LOADSTATE].path));
|
"loadstate.png", sizeof(xmb->textures[RMB_TEXTURE_LOADSTATE].path));
|
||||||
fill_pathname_join(textures[TEXTURE_SCREENSHOT].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_SCREENSHOT].path, iconpath,
|
||||||
"screenshot.png", sizeof(textures[TEXTURE_SCREENSHOT].path));
|
"screenshot.png", sizeof(xmb->textures[RMB_TEXTURE_SCREENSHOT].path));
|
||||||
fill_pathname_join(textures[TEXTURE_RELOAD].path, iconpath,
|
fill_pathname_join(xmb->textures[RMB_TEXTURE_RELOAD].path, iconpath,
|
||||||
"reload.png", sizeof(textures[TEXTURE_RELOAD].path));
|
"reload.png", sizeof(xmb->textures[RMB_TEXTURE_RELOAD].path));
|
||||||
|
|
||||||
for (k = 0; k < TEXTURE_LAST; k++)
|
for (k = 0; k < RMB_TEXTURE_LAST; k++)
|
||||||
textures[k].id = xmb_png_texture_load(textures[k].path);
|
xmb->textures[k].id = xmb_png_texture_load(xmb->textures[k].path);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_ctx_driver_t menu_ctx_xmb = {
|
menu_ctx_driver_t menu_ctx_xmb = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user