(Menu) Start getting rid of void * pointer

This commit is contained in:
twinaphex 2015-02-11 20:28:54 +01:00
parent 3cb6267886
commit 4d478434c7
11 changed files with 210 additions and 175 deletions

View File

@ -1668,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame,
#ifdef HAVE_MENU
if (g_extern.is_menu
&& driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame();
driver.menu_ctx->frame(driver.menu);
#ifdef _XBOX
/* TODO - should be refactored. */

View File

@ -1586,7 +1586,7 @@ static bool gl_frame(void *data, const void *frame,
#if defined(HAVE_MENU)
if (g_extern.is_menu
&& driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame();
driver.menu_ctx->frame(driver.menu);
if (gl->menu_texture_enable)
gl_draw_texture(gl);

View File

@ -500,7 +500,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
#ifdef HAVE_MENU
if (g_extern.is_menu
&& driver.menu_ctx && driver.menu_ctx->frame)
driver.menu_ctx->frame();
driver.menu_ctx->frame(driver.menu);
#endif
if (vid->menu.active)

View File

@ -191,20 +191,20 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y)
gl->coords.color = gl->white_color_ptr;
}
static void glui_get_message(const char *message)
static void glui_get_message(menu_handle_t *menu, const char *message)
{
glui_handle_t *glui = NULL;
if (!driver.menu || !message || !*message)
if (!menu || !message || !*message)
return;
glui = (glui_handle_t*)driver.menu->userdata;
glui = (glui_handle_t*)menu->userdata;
if (glui)
strlcpy(glui->box_message, message, sizeof(glui->box_message));
}
static void glui_render_messagebox(const char *message)
static void glui_render_messagebox(menu_handle_t *menu, const char *message)
{
unsigned i;
int x, y;
@ -212,10 +212,10 @@ static void glui_render_messagebox(const char *message)
glui_handle_t *glui = NULL;
gl_t *gl = (gl_t*)video_driver_resolve(NULL);
if (!driver.menu || !gl)
if (!menu || !gl)
return;
glui = (glui_handle_t*)driver.menu->userdata;
glui = (glui_handle_t*)menu->userdata;
if (!glui)
return;
@ -242,7 +242,7 @@ end:
string_list_free(list);
}
static void glui_frame(void)
static void glui_frame(menu_handle_t *menu)
{
unsigned x, y;
size_t i;
@ -258,17 +258,17 @@ static void glui_frame(void)
const char *core_name = NULL;
const char *core_version = NULL;
if (!driver.menu || !gl)
if (!menu || !gl)
return;
glui = (glui_handle_t*)driver.menu->userdata;
glui = (glui_handle_t*)menu->userdata;
if (!glui)
return;
if (driver.menu->need_refresh
if (menu->need_refresh
&& g_extern.is_menu
&& !driver.menu->msg_force)
&& !menu->msg_force)
return;
glui->line_height = g_settings.video.font_size * 4 / 3;
@ -277,30 +277,30 @@ static void glui_frame(void)
glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width;
glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2;
driver.menu->mouse.ptr = (driver.menu->mouse.y - glui->margin) /
glui->line_height - 2 + driver.menu->begin;
menu->mouse.ptr = (menu->mouse.y - glui->margin) /
glui->line_height - 2 + menu->begin;
glViewport(0, 0, gl->win_width, gl->win_height);
if (driver.menu->mouse.wheeldown && driver.menu->begin
< menu_list_get_size(driver.menu->menu_list) - glui->term_height)
driver.menu->begin++;
if (menu->mouse.wheeldown && menu->begin
< menu_list_get_size(menu->menu_list) - glui->term_height)
menu->begin++;
if (driver.menu->mouse.wheelup && driver.menu->begin > 0)
driver.menu->begin--;
if (menu->mouse.wheelup && menu->begin > 0)
menu->begin--;
/* Do not scroll if all items are visible. */
if (menu_list_get_size(driver.menu->menu_list) <= glui->term_height)
driver.menu->begin = 0;
if (menu_list_get_size(menu->menu_list) <= glui->term_height)
menu->begin = 0;
end = (driver.menu->begin + glui->term_height <=
menu_list_get_size(driver.menu->menu_list)) ?
driver.menu->begin + glui->term_height :
menu_list_get_size(driver.menu->menu_list);
end = (menu->begin + glui->term_height <=
menu_list_get_size(menu->menu_list)) ?
menu->begin + glui->term_height :
menu_list_get_size(menu->menu_list);
glui_render_background(gl, glui, false);
menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type);
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
get_title(label, dir, menu_type, title, sizeof(title));
@ -341,7 +341,7 @@ static void glui_frame(void)
x = glui->margin;
y = glui->margin + glui->line_height * 2;
for (i = driver.menu->begin; i < end; i++, y += glui->line_height)
for (i = menu->begin; i < end; i++, y += glui->line_height)
{
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
@ -351,21 +351,21 @@ static void glui_frame(void)
bool selected = false;
menu_file_list_cbs_t *cbs = NULL;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
&entry_label, &type);
cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
i);
if (cbs && cbs->action_get_representation)
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
cbs->action_get_representation(menu->menu_list->selection_buf,
&w, type, i, label,
type_str, sizeof(type_str),
entry_label, path,
path_buf, sizeof(path_buf));
selected = (i == driver.menu->selection_ptr);
selected = (i == menu->selection_ptr);
menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
g_extern.frame_count / glui->margin, path_buf, selected);
@ -383,37 +383,37 @@ static void glui_frame(void)
#ifdef GEKKO
const char *message_queue;
if (driver.menu->msg_force)
if (menu->msg_force)
{
message_queue = msg_queue_pull(g_extern.msg_queue);
driver.menu->msg_force = false;
menu->msg_force = false;
}
else
message_queue = driver.current_msg;
glui_render_messagebox(message_queue);
glui_render_messagebox(menu, message_queue);
#endif
if (driver.menu->keyboard.display)
if (menu->keyboard.display)
{
char msg[PATH_MAX_LENGTH];
const char *str = *driver.menu->keyboard.buffer;
const char *str = *menu->keyboard.buffer;
if (!str)
str = "";
glui_render_background(gl, glui, true);
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
glui_render_messagebox(msg);
snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str);
glui_render_messagebox(menu, msg);
}
if (glui->box_message[0] != '\0')
{
glui_render_background(gl, glui, true);
glui_render_messagebox(glui->box_message);
glui_render_messagebox(menu, glui->box_message);
glui->box_message[0] = '\0';
}
if (driver.menu->mouse.enable)
glui_draw_cursor(gl, glui, driver.menu->mouse.x, driver.menu->mouse.y);
if (menu->mouse.enable)
glui_draw_cursor(gl, glui, menu->mouse.x, menu->mouse.y);
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
}

View File

@ -230,13 +230,12 @@ static void rgui_render_background(menu_handle_t *menu)
green_filler);
}
static void rgui_render_messagebox(const char *message)
static void rgui_render_messagebox(menu_handle_t *menu, const char *message)
{
size_t i;
int x, y;
unsigned width, glyphs_width, height;
struct string_list *list = NULL;
menu_handle_t *menu = driver.menu;
if (!menu || !message || !*message)
return;
@ -301,7 +300,7 @@ static void rgui_blit_cursor(menu_handle_t *menu)
color_rect(driver.menu, x - 5, y, 11, 1, 0xFFFF);
}
static void rgui_render(void)
static void rgui_render(menu_handle_t *menu)
{
size_t i, end;
char title[256], title_buf[256], title_msg[64];
@ -311,7 +310,6 @@ static void rgui_render(void)
const char *label = NULL;
const char *core_name = NULL;
const char *core_version = NULL;
menu_handle_t *menu = driver.menu;
if (!menu || (menu->need_refresh
&& g_extern.is_menu
@ -438,7 +436,7 @@ static void rgui_render(void)
else
message_queue = driver.current_msg;
rgui_render_messagebox(message_queue);
rgui_render_messagebox(menu, message_queue);
#endif
if (menu->keyboard.display)
@ -448,7 +446,7 @@ static void rgui_render(void)
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str);
rgui_render_messagebox(msg);
rgui_render_messagebox(menu, msg);
}
if (menu->mouse.enable)
@ -512,10 +510,8 @@ static void rgui_free(void *data)
free((uint8_t*)menu->font);
}
static void rgui_set_texture(void *data)
static void rgui_set_texture(menu_handle_t *menu)
{
menu_handle_t *menu = (menu_handle_t*)data;
if (!menu)
return;
if (!driver.video_data)

View File

@ -83,7 +83,7 @@ static void rmenu_render_background(void)
{
}
static void rmenu_render_messagebox(const char *message)
static void rmenu_render_messagebox(menu_handle_t *menu, const char *message)
{
struct font_params font_parms;
size_t i, j;
@ -132,7 +132,7 @@ end:
string_list_free(list);
}
static void rmenu_render(void)
static void rmenu_render(menu_handle_t *menu)
{
size_t begin, end;
size_t i, j;
@ -144,7 +144,6 @@ static void rmenu_render(void)
const char *core_name = NULL;
const char *core_version = NULL;
unsigned menu_type = 0;
menu_handle_t *menu = (menu_handle_t*)driver.menu;
if (!menu)
return;
@ -279,13 +278,12 @@ static void rmenu_render(void)
}
}
static void rmenu_set_texture(void *data)
static void rmenu_set_texture(menu_handle_t *menu)
{
menu_handle_t *menu = (menu_handle_t*)data;
if (!menu)
return;
if (menu_texture_inited)
return;
if (!driver.video_data)
return;
if (!driver.video_poke)

View File

@ -46,8 +46,8 @@
#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
#define RXUI_TERM_START_X 15
#define RXUI_TERM_START_Y 27
#define RXUI_TERM_WIDTH (((driver.menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE)))
#define RXUI_TERM_HEIGHT (((driver.menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1)
#define RXUI_TERM_WIDTH (((menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE)))
#define RXUI_TERM_HEIGHT (((menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1)
HXUIOBJ m_menulist;
HXUIOBJ m_menutitle;
@ -406,7 +406,7 @@ end:
string_list_free(list);
}
static void rmenu_xui_frame(void)
static void rmenu_xui_frame(menu_handle_t *menu)
{
XUIMessage msg;
XUIMessageRender msgRender;
@ -415,6 +415,8 @@ static void rmenu_xui_frame(void)
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
(void)menu;
vp_full.X = 0;
vp_full.Y = 0;
vp_full.Width = d3d->screen_width;
@ -462,7 +464,7 @@ static void rmenu_xui_render_background(void)
XuiElementSetShow(m_background, TRUE);
}
static void rmenu_xui_render_messagebox(const char *message)
static void rmenu_xui_render_messagebox(menu_handle_t *menu, const char *message)
{
msg_queue_clear(xui_msg_queue);
msg_queue_push(xui_msg_queue, message, 2, 1);
@ -525,20 +527,20 @@ static void rmenu_xui_set_list_text(int index, const wchar_t* leftText,
}
}
static void rmenu_xui_render(void)
static void rmenu_xui_render(menu_handle_t *menu)
{
size_t end, i;
char title[PATH_MAX_LENGTH];
const char *dir = NULL, *label = NULL;
unsigned menu_type = 0;
if (!driver.menu || driver.menu->need_refresh &&
g_extern.is_menu && !driver.menu->msg_force)
if (!menu || menu->need_refresh &&
g_extern.is_menu && !menu->msg_force)
return;
rmenu_xui_render_background();
menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type);
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
if (XuiHandleIsValid(m_menutitle))
{
@ -570,7 +572,7 @@ static void rmenu_xui_render(void)
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
}
end = menu_list_get_size(driver.menu->menu_list);
end = menu_list_get_size(menu->menu_list);
for (i = 0; i < end; i++)
{
wchar_t msg_left[PATH_MAX_LENGTH], msg_right[PATH_MAX_LENGTH];
@ -579,15 +581,15 @@ static void rmenu_xui_render(void)
unsigned type = 0, w = 0;
menu_file_list_cbs_t *cbs = NULL;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
&entry_label, &type);
cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
i);
if (cbs && cbs->action_get_representation)
cbs->action_get_representation(driver.menu->menu_list->selection_buf,
cbs->action_get_representation(menu->menu_list->selection_buf,
&w, type, i, label,
type_str, sizeof(type_str),
entry_label, path,
@ -597,16 +599,16 @@ static void rmenu_xui_render(void)
mbstowcs(msg_right, type_str, sizeof(msg_right) / sizeof(wchar_t));
rmenu_xui_set_list_text(i, msg_left, msg_right);
}
XuiListSetCurSelVisible(m_menulist, driver.menu->selection_ptr);
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
if (driver.menu->keyboard.display)
if (menu->keyboard.display)
{
char msg[1024];
const char *str = *driver.menu->keyboard.buffer;
const char *str = *menu->keyboard.buffer;
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
rmenu_xui_render_messagebox(msg);
snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str);
rmenu_xui_render_messagebox(menu, msg);
}
}

View File

@ -375,9 +375,14 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb,
gl->coords.color = gl->white_color_ptr;
}
static void xmb_get_message(const char *message)
static void xmb_get_message(menu_handle_t *menu, const char *message)
{
xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;
xmb_handle_t *xmb = NULL;
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb || !message || !*message)
return;
@ -385,13 +390,18 @@ static void xmb_get_message(const char *message)
strlcpy(xmb->box_message, message, sizeof(xmb->box_message));
}
static void xmb_render_messagebox(const char *message)
static void xmb_render_messagebox(menu_handle_t *menu, const char *message)
{
int x, y;
unsigned i;
struct string_list *list = NULL;
gl_t *gl = (gl_t*)video_driver_resolve(NULL);
xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;
xmb_handle_t *xmb = NULL;
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!gl || !xmb)
return;
@ -456,7 +466,7 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu)
}
}
static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
{
int i;
@ -473,13 +483,14 @@ static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, siz
if (dir == -1)
ia = 0;
menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL);
}
}
static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
static void xmb_list_open_new(menu_handle_t *menu,
xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
{
int i;
@ -514,9 +525,9 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz
if (i == current)
ia = xmb->i_active_alpha;
menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL);
}
xmb->old_depth = xmb->depth;
@ -678,19 +689,19 @@ static void xmb_list_open(xmb_handle_t *xmb)
xmb->active_category_old = driver.menu->cat_selection_ptr;
}
static void xmb_list_switch(xmb_handle_t *xmb)
static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb)
{
unsigned j;
int dir = 0;
xmb->depth = file_list_get_size(driver.menu->menu_list->menu_stack);
xmb->depth = file_list_get_size(menu->menu_list->menu_stack);
if (xmb->depth > xmb->old_depth)
dir = 1;
else if (xmb->depth < xmb->old_depth)
dir = -1;
for (j = 0; j < driver.menu->num_categories; j++)
for (j = 0; j < menu->num_categories; j++)
{
float ia = 0;
xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node;
@ -703,25 +714,25 @@ static void xmb_list_switch(xmb_handle_t *xmb)
else if (xmb->depth <= 1)
ia = xmb->c_passive_alpha;
menu_animation_push(driver.menu->animation, XMB_DELAY, ia,
menu_animation_push(menu->animation, XMB_DELAY, ia,
&node->alpha, EASING_IN_OUT_QUAD, NULL);
}
xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
xmb_list_open_new(xmb, driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr);
xmb_list_open_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
xmb_list_open_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr);
switch (xmb->depth)
{
case 1:
menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2),
menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2),
&xmb->x, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha,
menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha,
EASING_IN_OUT_QUAD, NULL);
break;
case 2:
menu_animation_push(driver.menu->animation, XMB_DELAY,
menu_animation_push(menu->animation, XMB_DELAY,
xmb->icon_size*-(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL);
menu_animation_push(driver.menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha,
menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha,
EASING_IN_OUT_QUAD, NULL);
break;
}
@ -732,7 +743,13 @@ static void xmb_list_switch(xmb_handle_t *xmb)
static void xmb_populate_entries(void *data, const char *path,
const char *label, unsigned k)
{
xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;
menu_handle_t *menu = driver.menu;
xmb_handle_t *xmb = NULL;
if (!menu)
return;
xmb = (xmb_handle_t*)driver.menu->userdata;
if (!xmb)
return;
@ -748,7 +765,7 @@ static void xmb_populate_entries(void *data, const char *path,
if (driver.menu->cat_selection_ptr != xmb->active_category_old)
xmb_list_open(xmb);
else
xmb_list_switch(xmb);
xmb_list_switch(menu, xmb);
}
static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
@ -916,20 +933,20 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
}
}
static void xmb_frame(void)
static void xmb_frame(menu_handle_t *menu)
{
int i, depth;
char title_msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH];
const char *core_name = NULL;
const char *core_version = NULL;
xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata;
xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata;
gl_t *gl = (gl_t*)video_driver_resolve(NULL);
if (!xmb || !gl)
return;
menu_animation_update(driver.menu->animation, 0.002);
menu_animation_update(menu->animation, 0.002);
glViewport(0, 0, gl->win_width, gl->win_height);
@ -974,22 +991,22 @@ static void xmb_frame(void)
xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->active_item_factor,
xmb->arrow_alpha, 0, 1);
depth = file_list_get_size(driver.menu->menu_list->menu_stack);
depth = file_list_get_size(menu->menu_list->menu_stack);
xmb_draw_items(xmb, gl,
xmb->selection_buf_old,
xmb->menu_stack_old,
xmb->selection_ptr_old,
depth > 1 ? driver.menu->cat_selection_ptr :
depth > 1 ? menu->cat_selection_ptr :
xmb->cat_selection_ptr_old);
xmb_draw_items(xmb, gl,
driver.menu->menu_list->selection_buf,
driver.menu->menu_list->menu_stack,
driver.menu->selection_ptr,
driver.menu->cat_selection_ptr);
menu->menu_list->selection_buf,
menu->menu_list->menu_stack,
menu->selection_ptr,
menu->cat_selection_ptr);
for (i = 0; i < driver.menu->num_categories; i++)
for (i = 0; i < menu->num_categories; i++)
{
xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node;
@ -1005,34 +1022,34 @@ static void xmb_frame(void)
#ifdef GEKKO
const char *message_queue;
if (driver.menu->msg_force)
if (menu->msg_force)
{
message_queue = msg_queue_pull(g_extern.msg_queue);
driver.menu->msg_force = false;
menu->msg_force = false;
}
else
message_queue = driver.current_msg;
xmb_render_messagebox(message_queue);
xmb_render_messagebox(menu, message_queue);
#endif
if (driver.menu->keyboard.display)
if (menu->keyboard.display)
{
char msg[PATH_MAX_LENGTH];
const char *str = *driver.menu->keyboard.buffer;
const char *str = *menu->keyboard.buffer;
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s",
driver.menu->keyboard.label, str);
menu->keyboard.label, str);
xmb_render_background(gl, xmb, true);
xmb_render_messagebox(msg);
xmb_render_messagebox(menu, msg);
}
if (xmb->box_message[0] != '\0')
{
xmb_render_background(gl, xmb, true);
xmb_render_messagebox(xmb->box_message);
xmb_render_messagebox(menu, xmb->box_message);
xmb->box_message[0] = '\0';
}
@ -1280,7 +1297,7 @@ static void xmb_context_reset(void *data)
if (!info_list)
return;
for (i = 1; i < driver.menu->num_categories; i++)
for (i = 1; i < menu->num_categories; i++)
{
node = xmb_node_for_core(xmb, i - 1);

View File

@ -181,10 +181,10 @@ typedef struct menu_file_list_cbs
typedef struct menu_ctx_driver
{
void (*set_texture)(void*);
void (*render_messagebox)(const char*);
void (*render)(void);
void (*frame)(void);
void (*set_texture)(menu_handle_t *menu);
void (*render_messagebox)(menu_handle_t *menu, const char *msg);
void (*render)(menu_handle_t *menu);
void (*frame)(menu_handle_t *menu);
void* (*init)(void);
void (*free)(void*);
void (*context_reset)(void*);

View File

@ -215,6 +215,10 @@ static int archive_load(void)
static int load_or_open_zip_iterate(unsigned action)
{
char msg[PATH_MAX_LENGTH];
menu_handle_t *menu = driver.menu;
if (!menu)
return -1;
snprintf(msg, sizeof(msg), "Opening compressed file\n"
" \n"
@ -226,7 +230,7 @@ static int load_or_open_zip_iterate(unsigned action)
&& driver.menu_ctx->render_messagebox)
{
if (*msg && msg[0] != '\0')
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
}
switch (action)
@ -3685,12 +3689,13 @@ static int action_iterate_help(const char *label, unsigned action)
};
char desc[ARRAY_SIZE(binds)][64];
char msg[PATH_MAX_LENGTH];
menu_handle_t *menu = driver.menu;
if (!driver.menu)
if (!menu)
return 0;
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
for (i = 0; i < ARRAY_SIZE(binds); i++)
{
@ -3727,10 +3732,10 @@ static int action_iterate_help(const char *label, unsigned action)
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6]);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox)
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
if (action == MENU_ACTION_OK)
menu_list_pop(driver.menu->menu_list->menu_stack, NULL);
menu_list_pop(menu->menu_list->menu_stack, NULL);
return 0;
}
@ -3741,23 +3746,26 @@ static int action_iterate_info(const char *label, unsigned action)
char needle[PATH_MAX_LENGTH];
unsigned info_type = 0;
rarch_setting_t *current_setting = NULL;
file_list_t *list = (file_list_t*)driver.menu->menu_list->selection_buf;
file_list_t *list = NULL;
menu_handle_t *menu = driver.menu;
if (!driver.menu)
if (!menu)
return 0;
list = (file_list_t*)menu->menu_list->selection_buf;
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
current_setting = (rarch_setting_t*)setting_data_find_setting(
driver.menu->list_settings,
list->list[driver.menu->selection_ptr].label);
menu->list_settings,
list->list[menu->selection_ptr].label);
if (current_setting)
strlcpy(needle, current_setting->name, sizeof(needle));
else if ((current_setting = (rarch_setting_t*)setting_data_find_setting(
driver.menu->list_settings,
list->list[driver.menu->selection_ptr].label)))
menu->list_settings,
list->list[menu->selection_ptr].label)))
{
if (current_setting)
strlcpy(needle, current_setting->name, sizeof(needle));
@ -3765,8 +3773,8 @@ static int action_iterate_info(const char *label, unsigned action)
else
{
const char *lbl = NULL;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr, NULL, &lbl,
menu_list_get_at_offset(list,
menu->selection_ptr, NULL, &lbl,
&info_type);
if (lbl)
@ -3779,11 +3787,11 @@ static int action_iterate_info(const char *label, unsigned action)
driver.menu_ctx->render_messagebox)
{
if (*msg && msg[0] != '\0')
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
}
if (action == MENU_ACTION_OK)
menu_list_pop(driver.menu->menu_list->menu_stack, &driver.menu->selection_ptr);
menu_list_pop(menu->menu_list->menu_stack, &menu->selection_ptr);
return 0;
}
@ -3814,8 +3822,12 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
unsigned type = 0;
rarch_viewport_t *custom = (rarch_viewport_t*)
&g_extern.console.screen.viewports.custom_vp;
menu_handle_t *menu = driver.menu;
menu_list_get_last_stack(driver.menu->menu_list, NULL, NULL, &type);
if (!menu)
return -1;
menu_list_get_last_stack(menu->menu_list, NULL, NULL, &type);
geom = (struct retro_game_geometry*)&g_extern.system.av_info.geometry;
@ -3878,24 +3890,24 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
break;
case MENU_ACTION_CANCEL:
menu_list_pop_stack(driver.menu->menu_list);
menu_list_pop_stack(menu->menu_list);
if (!strcmp(label, "custom_viewport_2"))
{
menu_list_push_stack(driver.menu->menu_list, "", "",
menu_list_push_stack(menu->menu_list, "", "",
MENU_SETTINGS_CUSTOM_VIEWPORT,
driver.menu->selection_ptr);
menu->selection_ptr);
}
break;
case MENU_ACTION_OK:
menu_list_pop_stack(driver.menu->menu_list);
menu_list_pop_stack(menu->menu_list);
if (type == MENU_SETTINGS_CUSTOM_VIEWPORT
&& !g_settings.video.scale_integer)
{
menu_list_push_stack(driver.menu->menu_list, "",
"custom_viewport_2", 0, driver.menu->selection_ptr);
menu_list_push_stack(menu->menu_list, "",
"custom_viewport_2", 0, menu->selection_ptr);
}
break;
@ -3926,17 +3938,17 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
break;
case MENU_ACTION_MESSAGE:
driver.menu->msg_force = true;
menu->msg_force = true;
break;
default:
break;
}
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type);
menu_list_get_last_stack(menu->menu_list, NULL, &label, &type);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
if (g_settings.video.scale_integer)
{
@ -3967,7 +3979,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
if (driver.video_data && driver.menu_ctx &&
driver.menu_ctx->render_messagebox)
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
if (!custom->width)
custom->width = stride_x;
@ -3998,12 +4010,17 @@ static int action_iterate_custom_bind_keyboard(const char *label, unsigned actio
static int action_iterate_message(const char *label, unsigned action)
{
menu_handle_t *menu = driver.menu;
if (!menu)
return -1;
if (driver.video_data && driver.menu_ctx
&& driver.menu_ctx->render_messagebox)
driver.menu_ctx->render_messagebox(driver.menu->message_contents);
driver.menu_ctx->render_messagebox(menu, menu->message_contents);
if (action == MENU_ACTION_OK)
menu_list_pop_stack(driver.menu->menu_list);
menu_list_pop_stack(menu->menu_list);
return 0;
}
@ -4055,13 +4072,18 @@ static int action_iterate_main(const char *label, unsigned action)
unsigned type_offset = 0;
const char *label_offset = NULL;
const char *path_offset = NULL;
menu_file_list_cbs_t *cbs = NULL;
menu_handle_t *menu = driver.menu;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
if (!menu)
return 0;
cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
menu->selection_ptr);
menu_list_get_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr, &path_offset, &label_offset, &type_offset);
menu_list_get_at_offset(menu->menu_list->selection_buf,
menu->selection_ptr, &path_offset, &label_offset, &type_offset);
mouse_iterate(action);
@ -4090,7 +4112,7 @@ static int action_iterate_main(const char *label, unsigned action)
return action_iterate_custom_bind(label, action);
}
if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE)
if (menu->need_refresh && action != MENU_ACTION_MESSAGE)
action = MENU_ACTION_REFRESH;
switch (action)
@ -4101,20 +4123,20 @@ static int action_iterate_main(const char *label, unsigned action)
ret = cbs->action_up_or_down(type_offset, label_offset, action);
break;
case MENU_ACTION_SCROLL_UP:
menu_navigation_descend_alphabet(driver.menu, &driver.menu->selection_ptr);
menu_navigation_descend_alphabet(menu, &menu->selection_ptr);
break;
case MENU_ACTION_SCROLL_DOWN:
menu_navigation_ascend_alphabet(driver.menu, &driver.menu->selection_ptr);
menu_navigation_ascend_alphabet(menu, &menu->selection_ptr);
break;
case MENU_ACTION_CANCEL:
if (cbs && cbs->action_cancel)
return cbs->action_cancel(path_offset, label_offset, type_offset, driver.menu->selection_ptr);
return cbs->action_cancel(path_offset, label_offset, type_offset, menu->selection_ptr);
break;
case MENU_ACTION_OK:
if (cbs && cbs->action_ok)
return cbs->action_ok(path_offset, label_offset, type_offset, driver.menu->selection_ptr);
return cbs->action_ok(path_offset, label_offset, type_offset, menu->selection_ptr);
break;
case MENU_ACTION_START:
if (cbs && cbs->action_start)
@ -4132,12 +4154,12 @@ static int action_iterate_main(const char *label, unsigned action)
case MENU_ACTION_REFRESH:
if (cbs && cbs->action_refresh)
ret = cbs->action_refresh(driver.menu->menu_list->selection_buf,
driver.menu->menu_list->menu_stack);
ret = cbs->action_refresh(menu->menu_list->selection_buf,
menu->menu_list->menu_stack);
break;
case MENU_ACTION_MESSAGE:
driver.menu->msg_force = true;
menu->msg_force = true;
break;
case MENU_ACTION_SEARCH:
@ -4157,13 +4179,13 @@ static int action_iterate_main(const char *label, unsigned action)
ret = mouse_post_iterate(cbs, path_offset, label_offset, type_offset, action);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
/* Have to defer it so we let settings refresh. */
if (driver.menu->push_start_screen)
if (menu->push_start_screen)
{
menu_list_push_stack(driver.menu->menu_list, "", "help", 0, 0);
driver.menu->push_start_screen = false;
menu_list_push_stack(menu->menu_list, "", "help", 0, 0);
menu->push_start_screen = false;
}
return ret;

View File

@ -363,7 +363,7 @@ int menu_input_bind_iterate(void *data)
if (driver.video_data && driver.menu_ctx &&
driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
input_config_bind_map[
@ -371,7 +371,7 @@ int menu_input_bind_iterate(void *data)
if (driver.video_data && driver.menu_ctx
&& driver.menu_ctx->render_messagebox)
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
driver.block_input = true;
menu_input_poll_bind_state(&binds);
@ -406,18 +406,18 @@ int menu_input_bind_iterate_keyboard(void *data)
if (driver.video_data && driver.menu_ctx &&
driver.menu_ctx->render)
driver.menu_ctx->render();
driver.menu_ctx->render(menu);
current = rarch_get_time_usec();
timeout = (driver.menu->binds.timeout_end - current) / 1000000;
timeout = (menu->binds.timeout_end - current) / 1000000;
snprintf(msg, sizeof(msg), "[%s]\npress keyboard\n(timeout %d seconds)",
input_config_bind_map[
driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
timeout);
if (driver.video_data && driver.menu_ctx
&& driver.menu_ctx->render_messagebox)
driver.menu_ctx->render_messagebox(msg);
driver.menu_ctx->render_messagebox(menu, msg);
if (timeout <= 0)
{