Pass userdata to messagebox callback

This commit is contained in:
twinaphex 2015-12-10 14:40:56 +01:00
parent f374e12143
commit 2930997c25
8 changed files with 12 additions and 30 deletions

View File

@ -355,10 +355,9 @@ static void mui_draw_scrollbar(unsigned width, unsigned height, float *coord_col
}
}
static void mui_get_message(const char *message)
static void mui_get_message(void *data, const char *message)
{
menu_handle_t *menu = menu_driver_get_ptr();
mui_handle_t *mui = menu ? (mui_handle_t*)menu->userdata : NULL;
mui_handle_t *mui = (mui_handle_t*)data;
if (!mui || !message || !*message)
return;

View File

@ -346,7 +346,7 @@ int menu_iterate_render(void)
if (BIT64_GET(menu->state, MENU_STATE_RENDER_MESSAGEBOX) && menu->menu_state.msg[0] != '\0')
{
if (driver->render_messagebox)
driver->render_messagebox(menu->menu_state.msg);
driver->render_messagebox(menu->userdata, menu->menu_state.msg);
if (ui_companion_is_on_foreground())
{

View File

@ -297,15 +297,13 @@ static void rgui_render_background(void)
green_filler);
}
static void rgui_set_message(const char *message)
static void rgui_set_message(void *data, const char *message)
{
menu_handle_t *menu = menu_driver_get_ptr();
rgui_t *rgui = NULL;
rgui_t *rgui = (rgui_t*)data;
if (!menu || !menu->userdata || !message || !*message)
if (!rgui || !message || !*message)
return;
rgui = (rgui_t*)menu->userdata;
strlcpy(rgui->msgbox, message, sizeof(rgui->msgbox));
rgui->force_redraw = true;
}

View File

@ -69,15 +69,11 @@ struct texture_image *menu_texture;
static bool render_normal = true;
static bool menu_texture_inited =false;
static void rmenu_render_messagebox(const char *message)
static void rmenu_render_messagebox(void *data, const char *message)
{
struct font_params font_parms;
size_t i, j;
struct string_list *list = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
if (!message || !*message)
return;

View File

@ -465,7 +465,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(void *data, const char *message)
{
msg_queue_clear(xui_msg_queue);
msg_queue_push(xui_msg_queue, message, 2, 1);

View File

@ -458,15 +458,9 @@ static void xmb_draw_text(xmb_handle_t *xmb,
video_driver_set_osd_msg(str, &params, disp_buf);
}
static void xmb_messagebox(const char *message)
static void xmb_messagebox(void *data, const char *message)
{
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb || !message || !*message)
return;

View File

@ -886,11 +886,6 @@ static void zarch_zui_draw_cursor(float x, float y)
{
}
static void zarch_get_message(const char *message)
{
}
static void zarch_render(void)
{
int bottom;
@ -1327,7 +1322,7 @@ static bool zarch_menu_init_list(void *data)
menu_ctx_driver_t menu_ctx_zarch = {
NULL,
zarch_get_message,
NULL,
zarch_iterate,
zarch_render,
zarch_frame,

View File

@ -251,7 +251,7 @@ typedef struct
typedef struct menu_ctx_driver
{
void (*set_texture)(void);
void (*render_messagebox)(const char *msg);
void (*render_messagebox)(void *data, const char *msg);
int (*iterate)(enum menu_action action);
void (*render)(void);
void (*frame)(void);