There is only one menu driver now

This commit is contained in:
twinaphex 2015-01-26 10:54:13 +01:00
parent 1cc5d31f1d
commit 04062497de
16 changed files with 655 additions and 639 deletions

View File

@ -288,27 +288,25 @@ ifeq ($(HAVE_NEON),1)
endif
ifeq ($(HAVE_RGUI), 1)
OBJ += menu/drivers_display/rgui.o
OBJ += menu/drivers/rgui.o
DEFINES += -DHAVE_MENU -DHAVE_RGUI
HAVE_MENU_COMMON = 1
ifeq ($(HAVE_GLUI), 1)
OBJ += menu/drivers_display/glui.o
OBJ += menu/drivers/glui.o
DEFINES += -DHAVE_GLUI
endif
ifeq ($(HAVE_XMB), 1)
OBJ += menu/drivers_display/xmb.o
OBJ += menu/drivers/xmb.o
DEFINES += -DHAVE_XMB
endif
ifeq ($(HAVE_LAKKA), 1)
OBJ += menu/drivers_backend/menu_lakka_backend.o \
menu/drivers_display/lakka.o
OBJ += menu/drivers/lakka.o
DEFINES += -DHAVE_LAKKA
endif
endif
ifeq ($(HAVE_MENU_COMMON), 1)
OBJ += menu/drivers_backend/menu_common_backend.o \
menu/menu_input.o \
OBJ += menu/menu_input.o \
menu/menu.o \
menu/menu_common_list.o \
menu/menu_navigation.o \

View File

@ -694,41 +694,38 @@ MENU
#include "../menu/menu_navigation.c"
#include "../menu/menu_animation.c"
#include "../menu/menu_database.c"
#include "../menu/drivers_backend/menu_common_backend.c"
#endif
#ifdef HAVE_RMENU
#include "../menu/drivers_display/rmenu.c"
#include "../menu/drivers/rmenu.c"
#endif
#ifdef HAVE_RGUI
#include "../menu/drivers_display/rgui.c"
#include "../menu/drivers/rgui.c"
#endif
#ifdef HAVE_RMENU_XUI
#include "../menu/drivers_display/rmenu_xui.cpp"
#include "../menu/drivers/rmenu_xui.cpp"
#endif
#ifdef HAVE_OPENGL
#ifdef HAVE_LAKKA
#include "../menu/drivers_backend/menu_lakka_backend.c"
#include "../menu/drivers_display/lakka.c"
#include "../menu/drivers/lakka.c"
#endif
#ifdef HAVE_XMB
#include "../menu/drivers_display/xmb.c"
#include "../menu/drivers/xmb.c"
#endif
#ifdef HAVE_GLUI
#include "../menu/drivers_display/glui.c"
#include "../menu/drivers/glui.c"
#endif
#endif
#ifdef IOS
#include "../menu/drivers_display/ios.c"
#include "../menu/drivers/ios.c"
#endif
#ifdef HAVE_COMMAND

View File

@ -14,6 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
@ -25,6 +26,7 @@
#include "../../gfx/gl_common.h"
#include "../../gfx/video_thread_wrapper.h"
#include <compat/posix_string.h>
#include "../menu_input.h"
#include "shared.h"
@ -39,6 +41,24 @@ typedef struct glui_handle
GLuint bg;
} glui_handle_t;
static int glui_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
static void glui_blit_line(float x, float y, const char *message, bool green)
{
struct font_params params = {0};
@ -653,6 +673,6 @@ menu_ctx_driver_t menu_ctx_glui = {
NULL,
glui_init_core_info,
glui_update_core_info,
&menu_ctx_backend_common,
glui_entry_iterate,
"glui",
};

View File

@ -13,12 +13,50 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "../menu_driver.h"
#include "../menu.h"
#include "../../general.h"
#include "ios.h"
#include "../menu_input.h"
#ifdef 1
static int ios_entry_iterate(unsigned action)
{
ios_handle_t *ios = NULL;
if (!driver.menu)
return 0;
ios = (ios_handle_t*)driver.menu->userdata;
if (ios->switch_to_ios)
ios->switch_to_ios();
return 0;
}
#else
static int ios_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
#endif
static void *ios_init(void)
{
@ -49,18 +87,6 @@ static void ios_free(void *data)
return;
}
static int menu_ios_iterate(unsigned action)
{
ios_handle_t *ios = NULL;
if (!driver.menu)
return 0;
ios = (ios_handle_t*)driver.menu->userdata;
if (ios->switch_to_ios)
ios->switch_to_ios();
return 0;
}
static void ios_update_core_info(void *data)
{
@ -68,12 +94,6 @@ static void ios_update_core_info(void *data)
menu_update_libretro_info(&g_extern.menu.info);
}
menu_ctx_driver_backend_t menu_ctx_backend_ios = {
menu_ios_iterate,
"menu_ios",
};
menu_ctx_driver_t menu_ctx_ios = {
NULL, // set_texture
NULL, // render_messagebox
@ -101,6 +121,6 @@ menu_ctx_driver_t menu_ctx_ios = {
NULL, // list_set_selection
NULL, // init_core_info
ios_update_core_info, // ios_update_core_info
&menu_ctx_backend_ios, // backend
ios_entry_iterate,
"ios",
};

View File

@ -22,19 +22,24 @@
#include <string.h>
#include <limits.h>
#include "../menu.h"
#include "../../general.h"
#include <file/file_path.h>
#include <file/dir_list.h>
#include "../../gfx/gl_common.h"
#include "../../gfx/video_thread_wrapper.h"
#include <compat/posix_string.h>
#include "shared.h"
#include "../../settings_data.h"
#include "lakka.h"
#include "../menu.h"
#include "../menu_animation.h"
#include "../menu_action.h"
#include "shared.h"
#include "../../retroarch.h"
static const GLfloat lakka_vertex[] = {
0, 0,
@ -50,6 +55,489 @@ static const GLfloat lakka_tex_coord[] = {
1, 0,
};
/* Move the categories left or right depending
* on the menu_active_category variable. */
static void lakka_switch_categories(lakka_handle_t *lakka)
{
int i, j;
/* Translation */
add_tween(LAKKA_DELAY,
-lakka->menu_active_category * lakka->hspacing,
&lakka->all_categories_x, &inOutQuad, NULL);
/* Alpha tweening */
for (i = 0; i < lakka->num_categories; i++)
{
float ca, cz;
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
continue;
ca = (i == lakka->menu_active_category)
? lakka->c_active_alpha : lakka->c_passive_alpha;
cz = (i == lakka->menu_active_category)
? lakka->c_active_zoom : lakka->c_passive_zoom;
add_tween(LAKKA_DELAY, ca, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, cz, &category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
{
float ia = 0;
if (i == lakka->menu_active_category)
{
ia = lakka->i_passive_alpha;
if (j == category->active_item)
ia = lakka->i_active_alpha;
}
add_tween(LAKKA_DELAY, ia,
&category->items[j].alpha,&inOutQuad, NULL);
}
}
}
static void lakka_switch_items(lakka_handle_t *lakka)
{
int j;
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
for (j = 0; j < active_category->num_items; j++)
{
float iy;
float ia = lakka->i_passive_alpha;
float iz = lakka->i_passive_zoom;
menu_item_t *active_item = (menu_item_t*)&active_category->items[j];
if (!active_item)
continue;
iy = (j < active_category->active_item) ? lakka->vspacing *
(j - active_category->active_item + lakka->above_item_offset) :
lakka->vspacing * (j - active_category->active_item + lakka->under_item_offset);
if (j == active_category->active_item)
{
ia = lakka->i_active_alpha;
iz = lakka->i_active_zoom;
iy = lakka->vspacing * lakka->active_item_factor;
}
add_tween(LAKKA_DELAY, ia, &active_item->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, iz, &active_item->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, iy, &active_item->y, &inOutQuad, NULL);
}
}
static void lakka_switch_subitems(lakka_handle_t *lakka)
{
int k;
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
menu_item_t *item = (menu_item_t*)
&active_category->items[active_category->active_item];
for (k = 0; k < item->num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
if (!subitem)
continue;
if (k < item->active_subitem)
{
/* Above items */
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * (k - item->active_subitem +
lakka->above_subitem_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k == item->active_subitem)
{
/* Active item */
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * lakka->active_item_factor,
&subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k > item->active_subitem)
{
/* Under items */
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * (k - item->active_subitem +
lakka->under_item_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
static void lakka_reset_submenu(lakka_handle_t *lakka, int i, int j)
{
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
return;
category->items[category->active_item].active_subitem = 0;
int k;
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (!subitem)
continue;
subitem->alpha = 0;
subitem->zoom = (k == category->items[j].active_subitem) ?
lakka->i_active_zoom : lakka->i_passive_zoom;
subitem->y = k == 0 ?
lakka->vspacing * lakka->active_item_factor :
lakka->vspacing * (k + lakka->under_item_offset);
}
}
static bool lakka_on_active_rom(lakka_handle_t *lakka)
{
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
return !(g_extern.main_is_init
&& !g_extern.libretro_dummy
&& (!strcmp(g_extern.fullpath,
active_category->items[
active_category->active_item].rom)));
}
static void lakka_open_submenu(lakka_handle_t *lakka)
{
int i, j, k;
add_tween(LAKKA_DELAY, -lakka->hspacing * (lakka->menu_active_category+1),
&lakka->all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&lakka->arrow_alpha, &inOutQuad, NULL);
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
if (lakka->menu_active_category > 0 && lakka_on_active_rom(lakka))
lakka_reset_submenu(lakka, lakka->menu_active_category,
active_category->active_item);
for (i = 0; i < lakka->num_categories; i++)
{
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
continue;
float ca = (i == lakka->menu_active_category)
? lakka->c_active_alpha : 0;
add_tween(LAKKA_DELAY, ca, &category->alpha, &inOutQuad, NULL);
if (i != lakka->menu_active_category)
continue;
for (j = 0; j < category->num_items; j++)
{
if (j == category->active_item)
{
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (k == category->items[j].active_subitem)
{
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else
{
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
else
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
static void lakka_close_submenu(lakka_handle_t *lakka)
{
int i, j, k;
add_tween(LAKKA_DELAY, -lakka->hspacing * lakka->menu_active_category,
&lakka->all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.0, &lakka->arrow_alpha, &inOutQuad, NULL);
for (i = 0; i < lakka->num_categories; i++)
{
float ca, cz;
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
bool is_active_category = (i == lakka->menu_active_category);
if (!category)
continue;
ca = is_active_category ? lakka->c_active_alpha : lakka->c_passive_alpha;
cz = is_active_category ? lakka->c_active_zoom : lakka->c_passive_zoom;
add_tween(LAKKA_DELAY, ca,
&category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, cz,
&category->zoom, &inOutQuad, NULL);
if (i == lakka->menu_active_category)
{
for (j = 0; j < category->num_items; j++)
{
if (j == category->active_item)
{
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&category->items[j].alpha, &inOutQuad, NULL);
for (k = 0; k < category->items[j].num_subitems; k++)
add_tween(LAKKA_DELAY, 0,
&category->items[j].subitems[k].alpha,
&inOutQuad, NULL);
}
else
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
else
{
for (j = 0; j < category->num_items; j++)
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
static int lakka_entry_iterate(unsigned action)
{
menu_category_t *active_category = NULL;
menu_item_t *active_item = NULL;
menu_subitem_t * active_subitem = NULL;
lakka_handle_t *lakka = NULL;
if (!driver.menu)
return 0;
lakka = (lakka_handle_t*)driver.menu->userdata;
if (!lakka)
return 0;
active_category = (menu_category_t*)&lakka->categories[lakka->menu_active_category];
if (active_category)
active_item = (menu_item_t*)
&active_category->items[active_category->active_item];
if (active_item)
active_subitem = (menu_subitem_t*)
&active_item->subitems[active_item->active_subitem];
if (!active_category || !active_item)
return 0;
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (action && (action == MENU_ACTION_OK
|| action == MENU_ACTION_LEFT
|| action == MENU_ACTION_RIGHT)
&& (lakka->depth == 1) && (lakka->menu_active_category == 0)
&& active_subitem->setting)
{
rarch_setting_t *setting = (rarch_setting_t*)
active_subitem->setting;
menu_action_handle_setting(setting, 0, action);
}
switch (action)
{
case MENU_ACTION_TOGGLE:
if (g_extern.main_is_init && !g_extern.libretro_dummy)
{
lakka->global_alpha = 0.0;
lakka->global_scale = 2.0;
}
break;
case MENU_ACTION_LEFT:
if ((lakka->depth == 0) && (lakka->menu_active_category > 0))
{
lakka->menu_active_category--;
lakka_switch_categories(lakka);
}
else if ((lakka->depth == 1) && (lakka->menu_active_category > 0)
&& (active_item->active_subitem == 1
|| active_item->active_subitem == 2)
&& g_settings.state_slot > -1)
{
g_settings.state_slot--;
}
break;
case MENU_ACTION_RIGHT:
if (lakka->depth == 0 &&
(lakka->menu_active_category < lakka->num_categories-1))
{
lakka->menu_active_category++;
lakka_switch_categories(lakka);
}
else if (lakka->depth == 1 && lakka->menu_active_category > 0
&& (active_item->active_subitem == 1
|| active_item->active_subitem == 2)
&& g_settings.state_slot < 255)
{
g_settings.state_slot++;
}
break;
case MENU_ACTION_DOWN:
if (lakka->depth == 0
&& (active_category->active_item <
(active_category->num_items - 1)))
{
active_category->active_item++;
lakka_switch_items(lakka);
}
/* If we are on subitems level, and we do not
* exceed the number of subitems, and we
* are in settings or content is launched. */
if (lakka->depth == 1
&& (active_item->active_subitem <
(active_item->num_subitems -1))
&& (lakka->menu_active_category == 0
|| ((active_item->active_subitem <
(active_item->num_subitems - 1))
&&
(g_extern.main_is_init && !g_extern.libretro_dummy)
&& (!strcmp(g_extern.fullpath, active_item->rom)))))
{
active_item->active_subitem++;
lakka_switch_subitems(lakka);
}
break;
case MENU_ACTION_UP:
if (lakka->depth == 0 && active_category->active_item > 0)
{
active_category->active_item--;
lakka_switch_items(lakka);
}
if (lakka->depth == 1 && active_item->active_subitem > 0)
{
active_item->active_subitem--;
lakka_switch_subitems(lakka);
}
break;
case MENU_ACTION_OK:
if (lakka->depth == 1 && lakka->menu_active_category > 0)
{
switch (active_item->active_subitem)
{
case 0:
if (g_extern.main_is_init && !g_extern.libretro_dummy
&& (!strcmp(g_extern.fullpath, active_item->rom)))
rarch_main_command(RARCH_CMD_RESUME);
else
{
strlcpy(g_extern.fullpath,
active_item->rom, sizeof(g_extern.fullpath));
strlcpy(g_settings.libretro,
active_category->libretro,
sizeof(g_settings.libretro));
#ifdef HAVE_DYNAMIC
rarch_main_command(RARCH_CMD_LOAD_CORE);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
#endif
}
return -1;
break;
case 1:
rarch_main_command(RARCH_CMD_SAVE_STATE);
return -1;
break;
case 2:
rarch_main_command(RARCH_CMD_LOAD_STATE);
return -1;
break;
case 3:
rarch_main_command(RARCH_CMD_TAKE_SCREENSHOT);
break;
case 4:
rarch_main_command(RARCH_CMD_RESET);
return -1;
break;
}
}
else if (lakka->depth == 0 && active_item->num_subitems)
{
lakka_open_submenu(lakka);
lakka->depth = 1;
}
else if (lakka->depth == 0 &&
(lakka->menu_active_category == 0 &&
(active_category->active_item ==
(active_category->num_items - 1))))
{
add_tween(LAKKA_DELAY, 1.0, &lakka->global_alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0, &lakka->global_scale, &inOutQuad, NULL);
rarch_main_command(RARCH_CMD_QUIT_RETROARCH);
return -1;
}
break;
case MENU_ACTION_CANCEL:
if (lakka->depth == 1)
{
lakka_close_submenu(lakka);
lakka->depth = 0;
}
break;
default:
break;
}
if (driver.menu_ctx && driver.menu_ctx->iterate)
driver.menu_ctx->iterate(driver.menu, action);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
return 0;
}
static char *str_replace (const char *string,
const char *substr, const char *replacement)
{
@ -1360,6 +1848,6 @@ menu_ctx_driver_t menu_ctx_lakka = {
NULL,
lakka_init_core_info,
lakka_update_core_info,
&menu_ctx_backend_lakka,
lakka_entry_iterate,
"lakka",
};

View File

@ -22,6 +22,7 @@
#include <limits.h>
#include "../menu.h"
#include "../menu_input.h"
#include "../../retroarch.h"
#include <compat/posix_string.h>
#include <file/file_path.h>
@ -42,6 +43,24 @@ typedef struct rgui_handle
#define RGUI_TERM_WIDTH (((driver.menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE)))
#define RGUI_TERM_HEIGHT (((driver.menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1)
static int rgui_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf)
{
int y, x;
@ -651,6 +670,6 @@ menu_ctx_driver_t menu_ctx_rgui = {
NULL,
NULL,
rgui_update_core_info,
&menu_ctx_backend_common,
rgui_entry_iterate,
"rgui",
};

View File

@ -22,6 +22,7 @@
#include <limits.h>
#include "../menu_driver.h"
#include "../menu_input.h"
#include "../menu.h"
#include "../../general.h"
#include "../../config.def.h"
@ -63,6 +64,24 @@ struct texture_image *menu_texture;
static bool render_normal = true;
static bool menu_texture_inited =false;
static int rmenu_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
static void rmenu_render_background(void)
{
}
@ -362,6 +381,6 @@ menu_ctx_driver_t menu_ctx_rmenu = {
NULL,
NULL,
rmenu_update_core_info,
&menu_ctx_backend_common,
rmenu_entry_iterate,
"rmenu",
};

View File

@ -16,6 +16,10 @@
*/
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <xtl.h>
#include <xui.h>
#include <xuiapp.h>
@ -23,6 +27,7 @@
#include "../menu_driver.h"
#include "../menu.h"
#include "../menu_list.h"
#include "../menu_input.h"
#include "../../gfx/video_context_driver.h"
@ -53,6 +58,24 @@ HXUIOBJ root_menu;
HXUIOBJ current_menu;
static msg_queue_t *xui_msg_queue;
static int rmenu_xui_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
class CRetroArch : public CXuiModule
{
protected:
@ -683,6 +706,6 @@ menu_ctx_driver_t menu_ctx_rmenu_xui = {
rmenu_xui_list_set_selection,
NULL,
rmenu_xui_update_core_info,
&menu_ctx_backend_common,
rmenu_xui_entry_iterate,
"rmenu_xui",
};

View File

@ -19,7 +19,7 @@
#include "../../settings_data.h"
#include <time.h>
static void get_title(const char *label, const char *dir,
static INLINE void get_title(const char *label, const char *dir,
unsigned menu_type, char *title, size_t sizeof_title)
{
if (!strcmp(label, "core_list"))
@ -169,7 +169,7 @@ static void get_title(const char *label, const char *dir,
}
}
static void disp_timedate_set_label(char *label, size_t label_size,
static INLINE void disp_timedate_set_label(char *label, size_t label_size,
unsigned time_mode)
{
time_t time_;
@ -192,7 +192,7 @@ static void disp_timedate_set_label(char *label, size_t label_size,
}
}
static void disp_set_label(file_list_t* list,
static INLINE void disp_set_label(file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *type_str, size_t type_str_size,

View File

@ -21,6 +21,7 @@
#include <limits.h>
#include "../menu.h"
#include "../menu_input.h"
#include <file/file_path.h>
#include "../../gfx/gl_common.h"
#include "../../gfx/video_thread_wrapper.h"
@ -137,6 +138,24 @@ static const GLfloat rmb_tex_coord[] = {
1, 0,
};
static int xmb_entry_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
static char *xmb_str_replace (const char *string,
const char *substr, const char *replacement)
{
@ -1545,6 +1564,6 @@ menu_ctx_driver_t menu_ctx_xmb = {
xmb_list_set_selection,
xmb_init_core_info,
xmb_update_core_info,
&menu_ctx_backend_common,
xmb_entry_iterate,
"xmb",
};

View File

@ -1,46 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* 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 <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "../menu_input.h"
static int menu_common_iterate(unsigned action)
{
const char *label = NULL;
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
driver.menu->selection_ptr);
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);
return -1;
}
menu_ctx_driver_backend_t menu_ctx_backend_common = {
menu_common_iterate,
"menu_common",
};

View File

@ -1,529 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
* Copyright (C) 2014-2015 - Jean-André Santoni
*
* 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 <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include "../menu_action.h"
#include "../menu_navigation.h"
#include "../../driver.h"
#include "../../file_ext.h"
#include "../../input/input_common.h"
#include "../../config.def.h"
#include "../../input/keyboard_line.h"
#include "../../settings_data.h"
#include "../../retroarch.h"
#include "../drivers_display/lakka.h"
#include "../menu_animation.h"
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
/* Move the categories left or right depending
* on the menu_active_category variable. */
static void lakka_switch_categories(lakka_handle_t *lakka)
{
int i, j;
/* Translation */
add_tween(LAKKA_DELAY,
-lakka->menu_active_category * lakka->hspacing,
&lakka->all_categories_x, &inOutQuad, NULL);
/* Alpha tweening */
for (i = 0; i < lakka->num_categories; i++)
{
float ca, cz;
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
continue;
ca = (i == lakka->menu_active_category)
? lakka->c_active_alpha : lakka->c_passive_alpha;
cz = (i == lakka->menu_active_category)
? lakka->c_active_zoom : lakka->c_passive_zoom;
add_tween(LAKKA_DELAY, ca, &category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, cz, &category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
{
float ia = 0;
if (i == lakka->menu_active_category)
{
ia = lakka->i_passive_alpha;
if (j == category->active_item)
ia = lakka->i_active_alpha;
}
add_tween(LAKKA_DELAY, ia,
&category->items[j].alpha,&inOutQuad, NULL);
}
}
}
static void lakka_switch_items(lakka_handle_t *lakka)
{
int j;
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
for (j = 0; j < active_category->num_items; j++)
{
float iy;
float ia = lakka->i_passive_alpha;
float iz = lakka->i_passive_zoom;
menu_item_t *active_item = (menu_item_t*)&active_category->items[j];
if (!active_item)
continue;
iy = (j < active_category->active_item) ? lakka->vspacing *
(j - active_category->active_item + lakka->above_item_offset) :
lakka->vspacing * (j - active_category->active_item + lakka->under_item_offset);
if (j == active_category->active_item)
{
ia = lakka->i_active_alpha;
iz = lakka->i_active_zoom;
iy = lakka->vspacing * lakka->active_item_factor;
}
add_tween(LAKKA_DELAY, ia, &active_item->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, iz, &active_item->zoom, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, iy, &active_item->y, &inOutQuad, NULL);
}
}
static void lakka_switch_subitems(lakka_handle_t *lakka)
{
int k;
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
menu_item_t *item = (menu_item_t*)
&active_category->items[active_category->active_item];
for (k = 0; k < item->num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
if (!subitem)
continue;
if (k < item->active_subitem)
{
/* Above items */
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * (k - item->active_subitem +
lakka->above_subitem_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k == item->active_subitem)
{
/* Active item */
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * lakka->active_item_factor,
&subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else if (k > item->active_subitem)
{
/* Under items */
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->vspacing * (k - item->active_subitem +
lakka->under_item_offset), &subitem->y, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
static void lakka_reset_submenu(lakka_handle_t *lakka, int i, int j)
{
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
return;
category->items[category->active_item].active_subitem = 0;
int k;
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (!subitem)
continue;
subitem->alpha = 0;
subitem->zoom = (k == category->items[j].active_subitem) ?
lakka->i_active_zoom : lakka->i_passive_zoom;
subitem->y = k == 0 ?
lakka->vspacing * lakka->active_item_factor :
lakka->vspacing * (k + lakka->under_item_offset);
}
}
static bool lakka_on_active_rom(lakka_handle_t *lakka)
{
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
return !(g_extern.main_is_init
&& !g_extern.libretro_dummy
&& (!strcmp(g_extern.fullpath,
active_category->items[
active_category->active_item].rom)));
}
static void lakka_open_submenu(lakka_handle_t *lakka)
{
int i, j, k;
add_tween(LAKKA_DELAY, -lakka->hspacing * (lakka->menu_active_category+1),
&lakka->all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&lakka->arrow_alpha, &inOutQuad, NULL);
menu_category_t *active_category = (menu_category_t*)
&lakka->categories[lakka->menu_active_category];
if (lakka->menu_active_category > 0 && lakka_on_active_rom(lakka))
lakka_reset_submenu(lakka, lakka->menu_active_category,
active_category->active_item);
for (i = 0; i < lakka->num_categories; i++)
{
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
if (!category)
continue;
float ca = (i == lakka->menu_active_category)
? lakka->c_active_alpha : 0;
add_tween(LAKKA_DELAY, ca, &category->alpha, &inOutQuad, NULL);
if (i != lakka->menu_active_category)
continue;
for (j = 0; j < category->num_items; j++)
{
if (j == category->active_item)
{
for (k = 0; k < category->items[j].num_subitems; k++)
{
menu_subitem_t *subitem = (menu_subitem_t*)
&category->items[j].subitems[k];
if (k == category->items[j].active_subitem)
{
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_active_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
else
{
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&subitem->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, lakka->i_passive_zoom,
&subitem->zoom, &inOutQuad, NULL);
}
}
}
else
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
static void lakka_close_submenu(lakka_handle_t *lakka)
{
int i, j, k;
add_tween(LAKKA_DELAY, -lakka->hspacing * lakka->menu_active_category,
&lakka->all_categories_x, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 0.0, &lakka->arrow_alpha, &inOutQuad, NULL);
for (i = 0; i < lakka->num_categories; i++)
{
float ca, cz;
menu_category_t *category = (menu_category_t*)&lakka->categories[i];
bool is_active_category = (i == lakka->menu_active_category);
if (!category)
continue;
ca = is_active_category ? lakka->c_active_alpha : lakka->c_passive_alpha;
cz = is_active_category ? lakka->c_active_zoom : lakka->c_passive_zoom;
add_tween(LAKKA_DELAY, ca,
&category->alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, cz,
&category->zoom, &inOutQuad, NULL);
if (i == lakka->menu_active_category)
{
for (j = 0; j < category->num_items; j++)
{
if (j == category->active_item)
{
add_tween(LAKKA_DELAY, lakka->i_active_alpha,
&category->items[j].alpha, &inOutQuad, NULL);
for (k = 0; k < category->items[j].num_subitems; k++)
add_tween(LAKKA_DELAY, 0,
&category->items[j].subitems[k].alpha,
&inOutQuad, NULL);
}
else
add_tween(LAKKA_DELAY, lakka->i_passive_alpha,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
else
{
for (j = 0; j < category->num_items; j++)
add_tween(LAKKA_DELAY, 0,
&category->items[j].alpha, &inOutQuad, NULL);
}
}
}
static int menu_lakka_iterate(unsigned action)
{
menu_category_t *active_category = NULL;
menu_item_t *active_item = NULL;
menu_subitem_t * active_subitem = NULL;
lakka_handle_t *lakka = NULL;
if (!driver.menu)
return 0;
lakka = (lakka_handle_t*)driver.menu->userdata;
if (!lakka)
return 0;
active_category = (menu_category_t*)&lakka->categories[lakka->menu_active_category];
if (active_category)
active_item = (menu_item_t*)
&active_category->items[active_category->active_item];
if (active_item)
active_subitem = (menu_subitem_t*)
&active_item->subitems[active_item->active_subitem];
if (!active_category || !active_item)
return 0;
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
driver.menu_ctx->set_texture(driver.menu);
if (action && (action == MENU_ACTION_OK
|| action == MENU_ACTION_LEFT
|| action == MENU_ACTION_RIGHT)
&& (lakka->depth == 1) && (lakka->menu_active_category == 0)
&& active_subitem->setting)
{
rarch_setting_t *setting = (rarch_setting_t*)
active_subitem->setting;
menu_action_handle_setting(setting, 0, action);
}
switch (action)
{
case MENU_ACTION_TOGGLE:
if (g_extern.main_is_init && !g_extern.libretro_dummy)
{
lakka->global_alpha = 0.0;
lakka->global_scale = 2.0;
}
break;
case MENU_ACTION_LEFT:
if ((lakka->depth == 0) && (lakka->menu_active_category > 0))
{
lakka->menu_active_category--;
lakka_switch_categories(lakka);
}
else if ((lakka->depth == 1) && (lakka->menu_active_category > 0)
&& (active_item->active_subitem == 1
|| active_item->active_subitem == 2)
&& g_settings.state_slot > -1)
{
g_settings.state_slot--;
}
break;
case MENU_ACTION_RIGHT:
if (lakka->depth == 0 &&
(lakka->menu_active_category < lakka->num_categories-1))
{
lakka->menu_active_category++;
lakka_switch_categories(lakka);
}
else if (lakka->depth == 1 && lakka->menu_active_category > 0
&& (active_item->active_subitem == 1
|| active_item->active_subitem == 2)
&& g_settings.state_slot < 255)
{
g_settings.state_slot++;
}
break;
case MENU_ACTION_DOWN:
if (lakka->depth == 0
&& (active_category->active_item <
(active_category->num_items - 1)))
{
active_category->active_item++;
lakka_switch_items(lakka);
}
/* If we are on subitems level, and we do not
* exceed the number of subitems, and we
* are in settings or content is launched. */
if (lakka->depth == 1
&& (active_item->active_subitem <
(active_item->num_subitems -1))
&& (lakka->menu_active_category == 0
|| ((active_item->active_subitem <
(active_item->num_subitems - 1))
&&
(g_extern.main_is_init && !g_extern.libretro_dummy)
&& (!strcmp(g_extern.fullpath, active_item->rom)))))
{
active_item->active_subitem++;
lakka_switch_subitems(lakka);
}
break;
case MENU_ACTION_UP:
if (lakka->depth == 0 && active_category->active_item > 0)
{
active_category->active_item--;
lakka_switch_items(lakka);
}
if (lakka->depth == 1 && active_item->active_subitem > 0)
{
active_item->active_subitem--;
lakka_switch_subitems(lakka);
}
break;
case MENU_ACTION_OK:
if (lakka->depth == 1 && lakka->menu_active_category > 0)
{
switch (active_item->active_subitem)
{
case 0:
if (g_extern.main_is_init && !g_extern.libretro_dummy
&& (!strcmp(g_extern.fullpath, active_item->rom)))
rarch_main_command(RARCH_CMD_RESUME);
else
{
strlcpy(g_extern.fullpath,
active_item->rom, sizeof(g_extern.fullpath));
strlcpy(g_settings.libretro,
active_category->libretro,
sizeof(g_settings.libretro));
#ifdef HAVE_DYNAMIC
rarch_main_command(RARCH_CMD_LOAD_CORE);
rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT);
#endif
}
return -1;
break;
case 1:
rarch_main_command(RARCH_CMD_SAVE_STATE);
return -1;
break;
case 2:
rarch_main_command(RARCH_CMD_LOAD_STATE);
return -1;
break;
case 3:
rarch_main_command(RARCH_CMD_TAKE_SCREENSHOT);
break;
case 4:
rarch_main_command(RARCH_CMD_RESET);
return -1;
break;
}
}
else if (lakka->depth == 0 && active_item->num_subitems)
{
lakka_open_submenu(lakka);
lakka->depth = 1;
}
else if (lakka->depth == 0 &&
(lakka->menu_active_category == 0 &&
(active_category->active_item ==
(active_category->num_items - 1))))
{
add_tween(LAKKA_DELAY, 1.0, &lakka->global_alpha, &inOutQuad, NULL);
add_tween(LAKKA_DELAY, 1.0, &lakka->global_scale, &inOutQuad, NULL);
rarch_main_command(RARCH_CMD_QUIT_RETROARCH);
return -1;
}
break;
case MENU_ACTION_CANCEL:
if (lakka->depth == 1)
{
lakka_close_submenu(lakka);
lakka->depth = 0;
}
break;
default:
break;
}
if (driver.menu_ctx && driver.menu_ctx->iterate)
driver.menu_ctx->iterate(driver.menu, action);
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
driver.menu_ctx->render();
return 0;
}
menu_ctx_driver_backend_t menu_ctx_backend_lakka = {
menu_lakka_iterate,
"menu_lakka",
};

View File

@ -127,9 +127,8 @@ bool menu_load_content(void)
if (driver.menu)
driver.menu->msg_force = true;
if (driver.menu_ctx && driver.menu_ctx->backend &&
driver.menu_ctx->backend->iterate)
driver.menu_ctx->backend->iterate(MENU_ACTION_NOOP);
if (driver.menu_ctx && driver.menu_ctx->entry_iterate)
driver.menu_ctx->entry_iterate(MENU_ACTION_NOOP);
draw_frame();
@ -472,9 +471,8 @@ int menu_iterate(retro_input_t input,
*/
action = menu_input_frame(trigger_input);
if (driver.menu_ctx && driver.menu_ctx->backend
&& driver.menu_ctx->backend->iterate)
ret = driver.menu_ctx->backend->iterate(action);
if (driver.menu_ctx && driver.menu_ctx->entry_iterate)
ret = driver.menu_ctx->entry_iterate(action);
if (g_extern.is_menu)
draw_frame();

View File

@ -159,15 +159,6 @@ typedef struct menu_file_list_cbs
int (*action_up_or_down)(unsigned type, const char *label, unsigned action);
} menu_file_list_cbs_t;
typedef struct menu_ctx_driver_backend
{
int (*iterate)(unsigned);
const char *ident;
} menu_ctx_driver_backend_t;
extern menu_ctx_driver_backend_t menu_ctx_backend_common;
extern menu_ctx_driver_backend_t menu_ctx_backend_lakka;
typedef struct menu_ctx_driver
{
void (*set_texture)(void*);
@ -197,8 +188,7 @@ typedef struct menu_ctx_driver
void (*list_set_selection)(void *);
void (*init_core_info)(void *);
void (*update_core_info)(void *);
const menu_ctx_driver_backend_t *backend;
int (*entry_iterate)(unsigned);
const char *ident;
} menu_ctx_driver_t;