mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-08 18:36:28 +00:00
Add init_list to menu driver callbacks
This commit is contained in:
parent
fbc4ce4cd9
commit
167cd269ae
@ -437,6 +437,7 @@ ifeq ($(HAVE_MENU_COMMON), 1)
|
||||
menu/menu_display.o \
|
||||
menu/menu_displaylist.o \
|
||||
menu/menu_animation.o \
|
||||
menu/drivers/menu_generic.o \
|
||||
menu/drivers/null.o
|
||||
endif
|
||||
|
||||
|
@ -789,6 +789,7 @@ MENU
|
||||
#include "../menu/intl/menu_hash_us.c"
|
||||
|
||||
#include "../menu/drivers/null.c"
|
||||
#include "../menu/drivers/menu_generic.c"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu_animation.h"
|
||||
@ -836,6 +838,7 @@ menu_ctx_driver_t menu_ctx_glui = {
|
||||
glui_get_message,
|
||||
glui_render,
|
||||
glui_frame,
|
||||
generic_menu_init_list,
|
||||
glui_init,
|
||||
glui_free,
|
||||
glui_context_reset,
|
||||
|
46
menu/drivers/menu_generic.c
Normal file
46
menu/drivers/menu_generic.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_displaylist.h"
|
||||
#include "../menu_hash.h"
|
||||
#include "../menu_list.h"
|
||||
|
||||
bool generic_menu_init_list(void *data)
|
||||
{
|
||||
menu_displaylist_info_t info = {0};
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
|
||||
if (!menu || !menu_list)
|
||||
return false;
|
||||
|
||||
info.list = menu_list->selection_buf;
|
||||
info.type = MENU_SETTINGS;
|
||||
info.flags = SL_FLAG_MAIN_MENU | SL_FLAG_MAIN_MENU_SETTINGS;
|
||||
strlcpy(info.label, menu_hash_to_str(MENU_VALUE_MAIN_MENU), sizeof(info.label));
|
||||
|
||||
menu_list_push(menu_list->menu_stack,
|
||||
info.path, info.label, info.type, info.flags, 0);
|
||||
menu_displaylist_push_list(&info, DISPLAYLIST_MAIN_MENU);
|
||||
|
||||
return true;
|
||||
}
|
25
menu/drivers/menu_generic.h
Normal file
25
menu/drivers/menu_generic.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _MENU_GENERIC_H
|
||||
#define _MENU_GENERIC_H
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
bool generic_menu_init_list(void *data);
|
||||
|
||||
#endif
|
@ -28,6 +28,7 @@ menu_ctx_driver_t menu_ctx_null = {
|
||||
NULL, /* render_messagebox */
|
||||
NULL, /* render */
|
||||
NULL, /* frame */
|
||||
NULL, /* init_list */
|
||||
NULL, /* init */
|
||||
NULL, /* free */
|
||||
NULL, /* context_reset */
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <file/file_path.h>
|
||||
#include <retro_inline.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../../general.h"
|
||||
|
||||
#include "../menu.h"
|
||||
@ -852,6 +854,7 @@ menu_ctx_driver_t menu_ctx_rgui = {
|
||||
rgui_set_message,
|
||||
rgui_render,
|
||||
NULL,
|
||||
generic_menu_init_list,
|
||||
rgui_init,
|
||||
rgui_free,
|
||||
NULL,
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu_entry.h"
|
||||
@ -328,6 +330,7 @@ menu_ctx_driver_t menu_ctx_rmenu = {
|
||||
rmenu_render_messagebox,
|
||||
rmenu_render,
|
||||
NULL,
|
||||
generic_menu_init_list,
|
||||
rmenu_init,
|
||||
rmenu_free,
|
||||
rmenu_context_reset,
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <file/file_path.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu.h"
|
||||
#include "../menu_entry.h"
|
||||
@ -695,6 +697,7 @@ menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
||||
rmenu_xui_render_messagebox,
|
||||
rmenu_xui_render,
|
||||
rmenu_xui_frame,
|
||||
generic_menu_init_list,
|
||||
rmenu_xui_init,
|
||||
rmenu_xui_free,
|
||||
NULL,
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <string/string_list.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu_entry.h"
|
||||
@ -2547,6 +2549,7 @@ menu_ctx_driver_t menu_ctx_xmb = {
|
||||
xmb_render_messagebox_internal,
|
||||
xmb_render,
|
||||
xmb_frame,
|
||||
generic_menu_init_list,
|
||||
xmb_init,
|
||||
xmb_free,
|
||||
xmb_context_reset,
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <retro_log.h>
|
||||
#include <retro_stat.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
|
||||
#include "../menu.h"
|
||||
#include "../menu_entry.h"
|
||||
#include "../menu_display.h"
|
||||
@ -1008,6 +1010,7 @@ menu_ctx_driver_t menu_ctx_zarch = {
|
||||
zarch_get_message,
|
||||
zarch_render,
|
||||
zarch_frame,
|
||||
generic_menu_init_list,
|
||||
zarch_init,
|
||||
zarch_free,
|
||||
zarch_context_reset,
|
||||
|
@ -3043,31 +3043,3 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu_displaylist_init:
|
||||
* @menu : Menu handle.
|
||||
*
|
||||
* Creates and initializes menu display list.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool menu_displaylist_init(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
menu_displaylist_info_t info = {0};
|
||||
if (!menu || !menu_list)
|
||||
return false;
|
||||
|
||||
info.list = menu_list->selection_buf;
|
||||
info.type = MENU_SETTINGS;
|
||||
info.flags = SL_FLAG_MAIN_MENU | SL_FLAG_MAIN_MENU_SETTINGS;
|
||||
strlcpy(info.label, menu_hash_to_str(MENU_VALUE_MAIN_MENU), sizeof(info.label));
|
||||
|
||||
menu_list_push(menu_list->menu_stack,
|
||||
info.path, info.label, info.type, info.flags, 0);
|
||||
menu_displaylist_push_list(&info, DISPLAYLIST_MAIN_MENU);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -113,16 +113,6 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type);
|
||||
|
||||
int menu_displaylist_push(file_list_t *list, file_list_t *menu_list);
|
||||
|
||||
/**
|
||||
* menu_displaylist_init:
|
||||
* @menu : Menu handle.
|
||||
*
|
||||
* Creates and initializes menu display list.
|
||||
*
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool menu_displaylist_init(void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -163,6 +163,22 @@ static void init_menu_fallback(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
menu_handle_t *menu_driver_get_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver || !driver->menu)
|
||||
return NULL;
|
||||
return driver->menu;
|
||||
}
|
||||
|
||||
const menu_ctx_driver_t *menu_ctx_driver_get_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver || !driver->menu_ctx)
|
||||
return NULL;
|
||||
return driver->menu_ctx;
|
||||
}
|
||||
|
||||
void init_menu(void)
|
||||
{
|
||||
const char *video_driver;
|
||||
@ -192,25 +208,11 @@ void init_menu(void)
|
||||
if (!(driver->menu = (menu_handle_t*)menu_init(driver->menu_ctx)))
|
||||
rarch_fail(1, "init_menu()");
|
||||
|
||||
if (!(menu_displaylist_init(driver->menu)))
|
||||
rarch_fail(1, "init_menu()");
|
||||
if (driver->menu_ctx->init_list)
|
||||
if (!driver->menu_ctx->init_list(driver->menu))
|
||||
rarch_fail(1, "init_menu()");
|
||||
}
|
||||
|
||||
menu_handle_t *menu_driver_get_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver || !driver->menu)
|
||||
return NULL;
|
||||
return driver->menu;
|
||||
}
|
||||
|
||||
const menu_ctx_driver_t *menu_ctx_driver_get_ptr(void)
|
||||
{
|
||||
driver_t *driver = driver_get_ptr();
|
||||
if (!driver || !driver->menu_ctx)
|
||||
return NULL;
|
||||
return driver->menu_ctx;
|
||||
}
|
||||
|
||||
void menu_driver_list_free(file_list_t *list, size_t idx, size_t list_size)
|
||||
{
|
||||
|
@ -110,6 +110,7 @@ typedef struct menu_ctx_driver
|
||||
void (*render_messagebox)(const char *msg);
|
||||
void (*render)(void);
|
||||
void (*frame)(void);
|
||||
bool (*init_list)(void*);
|
||||
void* (*init)(void);
|
||||
void (*free)(void*);
|
||||
void (*context_reset)(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user