Expand widget init function

This commit is contained in:
twinaphex 2021-04-08 00:51:10 +02:00
parent 2e6393f082
commit e5e8e9b5d8
7 changed files with 37 additions and 8 deletions

View File

@ -2077,6 +2077,7 @@ static void gfx_widgets_context_reset(
bool gfx_widgets_init(
void *data,
void *data_disp,
void *data_anim,
void *settings_data,
uintptr_t widgets_active_ptr,
bool video_is_threaded,
@ -2086,6 +2087,7 @@ bool gfx_widgets_init(
unsigned i;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data;
gfx_display_t *p_disp = (gfx_display_t*)data_disp;
gfx_animation_t *p_anim = (gfx_animation_t*)data_anim;
settings_t *settings = (settings_t*)settings_data;
p_dispwidget->divider_width_1px = 1;
p_dispwidget->gfx_widgets_generic_tag = (uintptr_t)widgets_active_ptr;
@ -2123,7 +2125,7 @@ bool gfx_widgets_init(
const gfx_widget_t* widget = widgets[i];
if (widget->init)
widget->init(video_is_threaded, fullscreen);
widget->init(p_disp, p_anim, video_is_threaded, fullscreen);
}
if (!fifo_initialize(&p_dispwidget->msg_queue,

View File

@ -30,6 +30,7 @@
#endif
#include "gfx_animation.h"
#include "gfx_display.h"
#define DEFAULT_BACKDROP 0.75f
@ -233,7 +234,9 @@ struct gfx_widget
{
/* called when the widgets system is initialized
* -> initialize the widget here */
bool (*init)(bool video_is_threaded, bool fullscreen);
bool (*init)(gfx_display_t *p_disp,
gfx_animation_t *p_anim,
bool video_is_threaded, bool fullscreen);
/* called when the widgets system is freed
* -> free the widget here */
@ -305,6 +308,7 @@ typedef struct gfx_widget gfx_widget_t;
bool gfx_widgets_init(
void *data,
void *data_disp,
void *data_anim,
void *settings_data,
uintptr_t widgets_active_ptr,
bool video_is_threaded,

View File

@ -57,7 +57,9 @@ static void gfx_widget_achievement_popup_start(
static void gfx_widget_achievement_popup_free_current(
gfx_widget_achievement_popup_state_t* state);
static bool gfx_widget_achievement_popup_init(bool video_is_threaded, bool fullscreen)
static bool gfx_widget_achievement_popup_init(
gfx_display_t *p_disp,
bool video_is_threaded, bool fullscreen)
{
gfx_widget_achievement_popup_state_t* state = &p_w_achievement_popup_st;
memset(state, 0, sizeof(*state));

View File

@ -50,9 +50,13 @@ typedef struct gfx_widget_leaderboard_display_state gfx_widget_leaderboard_displ
static gfx_widget_leaderboard_display_state_t p_w_leaderboard_display_st;
static bool gfx_widget_leaderboard_display_init(bool video_is_threaded, bool fullscreen)
static bool gfx_widget_leaderboard_display_init(
gfx_display_t *p_disp,
gfx_animation_t *p_anim,
bool video_is_threaded, bool fullscreen)
{
gfx_widget_leaderboard_display_state_t *state = &p_w_leaderboard_display_st;
gfx_widget_leaderboard_display_state_t *state =
&p_w_leaderboard_display_st;
memset(state, 0, sizeof(*state));
return true;

View File

@ -973,12 +973,14 @@ static void gfx_widget_load_content_animation_free(void)
}
static bool gfx_widget_load_content_animation_init(
gfx_display_t *p_disp,
gfx_animation_t *p_anim,
bool video_is_threaded, bool fullscreen)
{
gfx_widget_load_content_animation_state_t *state =
&p_w_load_content_animation_st;
state->p_disp = disp_get_ptr();
state->p_disp = p_disp;
return false;
}

View File

@ -27,6 +27,8 @@
struct gfx_widget_screenshot_state
{
uintptr_t texture;
gfx_animation_t *p_anim;
unsigned texture_width;
unsigned texture_height;
@ -204,8 +206,8 @@ static void gfx_widget_screenshot_frame(void* data, void *user_data)
unsigned video_height = video_info->height;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)user_data;
gfx_display_t *p_disp = (gfx_display_t*)video_info->disp_userdata;
gfx_animation_t *p_anim = anim_get_ptr();
gfx_widget_screenshot_state_t *state = &p_w_screenshot_st;
gfx_animation_t *p_anim = state->p_anim;
gfx_widget_font_data_t* font_regular = &p_dispwidget->gfx_widget_fonts.regular;
int padding = (state->height - (font_regular->line_height * 2.0f)) / 2.0f;
@ -353,8 +355,20 @@ static void gfx_widget_screenshot_iterate(
}
}
static bool gfx_widget_screenshot_init(
gfx_display_t *p_disp,
gfx_animation_t *p_anim,
bool video_is_threaded, bool fullscreen)
{
gfx_widget_screenshot_state_t *state = &p_w_screenshot_st;
state->p_anim = p_anim;
return false;
}
const gfx_widget_t gfx_widget_screenshot = {
NULL, /* init */
gfx_widget_screenshot_init,
gfx_widget_screenshot_free,
NULL, /* context_reset*/
NULL, /* context_destroy */

View File

@ -32804,6 +32804,7 @@ static void drivers_init(struct rarch_state *p_rarch,
p_rarch->widgets_active = gfx_widgets_init(
&p_rarch->dispwidget_st,
&p_rarch->dispgfx,
&p_rarch->anim,
settings,
(uintptr_t)&p_rarch->widgets_active,
video_is_threaded,