Create menu context wrapper functions

This commit is contained in:
twinaphex 2015-03-22 05:21:14 +01:00
parent a635c8c80d
commit 0fd8fb77e9
5 changed files with 92 additions and 29 deletions

View File

@ -68,16 +68,6 @@ static void draw_frame(void)
rarch_render_cached_frame(); rarch_render_cached_frame();
} }
void menu_context_reset(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->context_reset)
driver->menu_ctx->context_reset();
}
/** /**
* menu_update_libretro_info: * menu_update_libretro_info:
* @info : Pointer to system info * @info : Pointer to system info
@ -93,7 +83,7 @@ static void menu_update_libretro_info(struct retro_system_info *info)
rarch_main_command(RARCH_CMD_CORE_INFO_INIT); rarch_main_command(RARCH_CMD_CORE_INFO_INIT);
rarch_main_command(RARCH_CMD_LOAD_CORE_PERSIST); rarch_main_command(RARCH_CMD_LOAD_CORE_PERSIST);
menu_context_reset(); menu_driver_context_reset();
} }
static void menu_environment_get(int *argc, char *argv[], static void menu_environment_get(int *argc, char *argv[],
@ -442,8 +432,7 @@ int menu_iterate(retro_input_t input,
if (runloop->is_menu && !runloop->is_idle) if (runloop->is_menu && !runloop->is_idle)
draw_frame(); draw_frame();
if (driver->menu_ctx && driver->menu_ctx->set_texture) menu_driver_set_texture();
driver->menu_ctx->set_texture();
if (ret) if (ret)
return -1; return -1;

View File

@ -193,8 +193,6 @@ void menu_free(void *data);
**/ **/
bool menu_load_content(void); bool menu_load_content(void);
void menu_context_reset(void);
void menu_update_system_info(menu_handle_t *menu, bool *load_no_content); void menu_update_system_info(menu_handle_t *menu, bool *load_no_content);
void menu_apply_deferred_settings(void); void menu_apply_deferred_settings(void);

View File

@ -165,7 +165,7 @@ void init_menu(void)
rarch_fail(1, "init_menu()"); rarch_fail(1, "init_menu()");
} }
menu_context_reset(); menu_driver_context_reset();
} }
menu_handle_t *menu_driver_get_ptr(void) menu_handle_t *menu_driver_get_ptr(void)
@ -175,3 +175,73 @@ menu_handle_t *menu_driver_get_ptr(void)
return NULL; return NULL;
return driver->menu; return driver->menu;
} }
void menu_driver_navigation_increment(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->navigation_increment)
driver->menu_ctx->navigation_increment();
}
void menu_driver_navigation_decrement(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->navigation_decrement)
driver->menu_ctx->navigation_decrement();
}
void menu_driver_navigation_clear(bool pending_push)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->navigation_clear)
driver->menu_ctx->navigation_clear(pending_push);
}
void menu_driver_navigation_set(bool scroll)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->navigation_set)
driver->menu_ctx->navigation_set(scroll);
}
void menu_driver_navigation_set_last(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->navigation_set_last)
driver->menu_ctx->navigation_set_last();
}
void menu_driver_set_texture(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->set_texture)
driver->menu_ctx->set_texture();
}
void menu_driver_context_reset(void)
{
driver_t *driver = driver_get_ptr();
if (!driver)
return;
if (driver->menu_ctx && driver->menu_ctx->context_reset)
driver->menu_ctx->context_reset();
}

View File

@ -288,6 +288,20 @@ void init_menu(void);
menu_handle_t *menu_driver_get_ptr(void); menu_handle_t *menu_driver_get_ptr(void);
void menu_driver_navigation_increment(void);
void menu_driver_navigation_decrement(void);
void menu_driver_navigation_clear(bool pending_push);
void menu_driver_navigation_set(bool scroll);
void menu_driver_navigation_set_last(void);
void menu_driver_set_texture(void);
void menu_driver_context_reset(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -30,14 +30,12 @@
**/ **/
void menu_navigation_clear(menu_navigation_t *nav, bool pending_push) void menu_navigation_clear(menu_navigation_t *nav, bool pending_push)
{ {
driver_t *driver = driver_get_ptr();
if (!nav) if (!nav)
return; return;
nav->selection_ptr = 0; nav->selection_ptr = 0;
if (driver->menu_ctx && driver->menu_ctx->navigation_clear) menu_driver_navigation_clear(pending_push);
driver->menu_ctx->navigation_clear(pending_push);
} }
/** /**
@ -65,8 +63,7 @@ void menu_navigation_decrement(menu_navigation_t *nav, unsigned scroll_speed)
menu_navigation_set(nav, 0, true); menu_navigation_set(nav, 0, true);
} }
if (driver->menu_ctx && driver->menu_ctx->navigation_decrement) menu_driver_navigation_decrement();
driver->menu_ctx->navigation_decrement();
} }
/** /**
@ -94,8 +91,7 @@ void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed)
menu_list_get_size(driver->menu->menu_list) - 1, true); menu_list_get_size(driver->menu->menu_list) - 1, true);
} }
if (driver->menu_ctx && driver->menu_ctx->navigation_increment) menu_driver_navigation_increment();
driver->menu_ctx->navigation_increment();
} }
/** /**
@ -108,14 +104,12 @@ void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed)
void menu_navigation_set(menu_navigation_t *nav, void menu_navigation_set(menu_navigation_t *nav,
size_t idx, bool scroll) size_t idx, bool scroll)
{ {
driver_t *driver = driver_get_ptr();
if (!nav) if (!nav)
return; return;
nav->selection_ptr = idx; nav->selection_ptr = idx;
if (driver->menu_ctx && driver->menu_ctx->navigation_set) menu_driver_navigation_set(scroll);
driver->menu_ctx->navigation_set(scroll);
} }
/** /**
@ -125,15 +119,13 @@ void menu_navigation_set(menu_navigation_t *nav,
**/ **/
void menu_navigation_set_last(menu_navigation_t *nav) void menu_navigation_set_last(menu_navigation_t *nav)
{ {
driver_t *driver = driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
if (!menu || !nav) if (!menu || !nav)
return; return;
nav->selection_ptr = menu_list_get_size(menu->menu_list) - 1; nav->selection_ptr = menu_list_get_size(menu->menu_list) - 1;
if (driver->menu_ctx && driver->menu_ctx->navigation_set_last) menu_driver_navigation_set_last();
driver->menu_ctx->navigation_set_last();
} }
/** /**