Create menu_driver_init

This commit is contained in:
twinaphex 2017-04-29 17:23:09 +02:00
parent 5f6a342817
commit 6bae9244e8
3 changed files with 42 additions and 37 deletions

View File

@ -353,10 +353,7 @@ void drivers_init(int flags)
if (flags & DRIVER_VIDEO_MASK)
{
if (flags & DRIVER_MENU_MASK)
{
menu_driver_ctl(RARCH_MENU_CTL_INIT, NULL);
menu_driver_context_reset(video_is_threaded);
}
menu_driver_init(video_is_threaded);
}
#endif

View File

@ -458,7 +458,7 @@ void menu_driver_decrement_navigation(void)
menu_driver_ctx->navigation_decrement(menu_userdata);
}
bool menu_driver_context_reset(bool video_is_threaded)
static bool menu_driver_context_reset(bool video_is_threaded)
{
if (!menu_driver_ctx || !menu_driver_ctx->context_reset)
return false;
@ -466,6 +466,44 @@ bool menu_driver_context_reset(bool video_is_threaded)
return true;
}
static bool menu_driver_init_internal(bool video_is_threaded)
{
settings_t *settings = config_get_ptr();
menu_update_libretro_info();
if (menu_driver_data)
return true;
menu_driver_data = (menu_handle_t*)
menu_driver_ctx->init(&menu_userdata);
if (!menu_driver_data || !menu_init(menu_driver_data))
{
retroarch_fail(1, "init_menu()");
return false;
}
strlcpy(settings->arrays.menu_driver, menu_driver_ctx->ident,
sizeof(settings->arrays.menu_driver));
if (menu_driver_ctx->lists_init)
{
if (!menu_driver_ctx->lists_init(menu_driver_data))
{
retroarch_fail(1, "init_menu()");
return false;
}
}
return true;
}
bool menu_driver_init(bool video_is_threaded)
{
if (menu_driver_init_internal(video_is_threaded))
return menu_driver_context_reset(video_is_threaded);
return false;
}
bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
{
switch (state)
@ -630,35 +668,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
}
menu_driver_data = NULL;
break;
case RARCH_MENU_CTL_INIT:
{
settings_t *settings = config_get_ptr();
menu_update_libretro_info();
if (menu_driver_data)
return true;
menu_driver_data = (menu_handle_t*)
menu_driver_ctx->init(&menu_userdata);
if (!menu_driver_data || !menu_init(menu_driver_data))
{
retroarch_fail(1, "init_menu()");
return false;
}
strlcpy(settings->arrays.menu_driver, menu_driver_ctx->ident,
sizeof(settings->arrays.menu_driver));
if (menu_driver_ctx->lists_init)
{
if (!menu_driver_ctx->lists_init(menu_driver_data))
{
retroarch_fail(1, "init_menu()");
return false;
}
}
}
break;
case RARCH_MENU_CTL_LOAD_NO_CONTENT_GET:
{
bool **ptr = (bool**)data;

View File

@ -91,7 +91,6 @@ enum rarch_menu_ctl_state
RARCH_MENU_CTL_SET_PENDING_QUIT,
RARCH_MENU_CTL_SET_PENDING_SHUTDOWN,
RARCH_MENU_CTL_DEINIT,
RARCH_MENU_CTL_INIT,
RARCH_MENU_CTL_SET_PREVENT_POPULATE,
RARCH_MENU_CTL_UNSET_PREVENT_POPULATE,
RARCH_MENU_CTL_IS_PREVENT_POPULATE,
@ -400,10 +399,10 @@ bool menu_driver_list_clear(void *data);
void menu_driver_increment_navigation(void);
bool menu_driver_context_reset(bool is_threaded);
void menu_driver_decrement_navigation(void);
bool menu_driver_init(bool video_is_threaded);
extern menu_ctx_driver_t menu_ctx_xui;
extern menu_ctx_driver_t menu_ctx_rgui;
extern menu_ctx_driver_t menu_ctx_mui;