RetroArch/menu/drivers/xmb.c

2724 lines
77 KiB
C
Raw Normal View History

2014-10-08 23:21:22 +00:00
/* RetroArch - A frontend for libretro.
2015-01-07 16:46:50 +00:00
* Copyright (C) 2011-2015 - Daniel De Matteis
* Copyright (C) 2014-2015 - Jean-André Santoni
2014-10-08 23:21:22 +00:00
*
* 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 <stdlib.h>
#include <stddef.h>
2014-10-16 05:27:42 +00:00
#include <stdint.h>
2014-10-08 23:21:22 +00:00
#include <string.h>
#include <limits.h>
2015-06-05 16:22:15 +00:00
#include <file/file_path.h>
#include <compat/posix_string.h>
#include <string/stdstring.h>
2015-06-17 17:48:55 +00:00
#include <string/string_list.h>
2015-06-04 20:46:23 +00:00
2015-10-03 01:15:47 +00:00
#include "menu_generic.h"
2015-01-10 03:53:37 +00:00
#include "../menu.h"
#include "../menu_driver.h"
#include "../menu_entry.h"
#include "../menu_animation.h"
2015-04-24 20:17:08 +00:00
#include "../menu_display.h"
2015-06-17 17:55:24 +00:00
#include "../menu_hash.h"
2015-10-18 05:15:54 +00:00
#include "../menu_display.h"
#include "../menu_cbs.h"
2015-06-04 20:46:23 +00:00
#include "../../file_ext.h"
2014-10-08 23:21:22 +00:00
2015-04-13 16:59:39 +00:00
#include "../../runloop_data.h"
2014-10-09 00:41:08 +00:00
#ifndef XMB_THEME
#define XMB_THEME "monochrome"
#endif
#ifndef XMB_DELAY
2015-03-06 15:00:46 +00:00
#define XMB_DELAY 10
2014-10-09 00:41:08 +00:00
#endif
#define XMB_ABOVE_OFFSET_SUBITEM 1.5
#define XMB_ABOVE_OFFSET_ITEM -1.0
#define XMB_ITEM_ACTIVE_FACTOR 3.0
#define XMB_UNDER_OFFSET_ITEM 5.0
#define XMB_CATEGORIES_ACTIVE_ZOOM 1.0
#define XMB_CATEGORIES_PASSIVE_ZOOM 0.5
#define XMB_ITEM_ACTIVE_ZOOM 1.0
#define XMB_ITEM_PASSIVE_ZOOM 0.5
#define XMB_CATEGORIES_ACTIVE_ALPHA 1.0
#define XMB_CATEGORIES_PASSIVE_ALPHA 0.5
#define XMB_ITEM_ACTIVE_ALPHA 1.0
#define XMB_ITEM_PASSIVE_ALPHA 0.5
2014-10-09 00:41:08 +00:00
typedef struct
{
float alpha;
2014-10-20 18:00:39 +00:00
float label_alpha;
2014-10-09 00:41:08 +00:00
float zoom;
2014-10-20 18:00:39 +00:00
float x;
2014-10-09 00:41:08 +00:00
float y;
GRuint icon;
GRuint content_icon;
2014-10-09 00:41:08 +00:00
} xmb_node_t;
enum
{
2015-10-20 12:11:43 +00:00
XMB_TEXTURE_MAIN_MENU = 0,
XMB_TEXTURE_SETTINGS,
2015-10-22 18:05:51 +00:00
XMB_TEXTURE_HISTORY,
2014-10-09 20:59:05 +00:00
XMB_TEXTURE_SETTING,
XMB_TEXTURE_SUBSETTING,
XMB_TEXTURE_ARROW,
XMB_TEXTURE_RUN,
XMB_TEXTURE_CLOSE,
2014-10-09 20:59:05 +00:00
XMB_TEXTURE_RESUME,
XMB_TEXTURE_SAVESTATE,
XMB_TEXTURE_LOADSTATE,
XMB_TEXTURE_CORE_INFO,
XMB_TEXTURE_CORE_OPTIONS,
XMB_TEXTURE_INPUT_REMAPPING_OPTIONS,
XMB_TEXTURE_CHEAT_OPTIONS,
XMB_TEXTURE_DISK_OPTIONS,
2015-06-25 04:47:20 +00:00
XMB_TEXTURE_SHADER_OPTIONS,
2014-10-09 20:59:05 +00:00
XMB_TEXTURE_SCREENSHOT,
XMB_TEXTURE_RELOAD,
2014-10-14 21:05:53 +00:00
XMB_TEXTURE_FILE,
XMB_TEXTURE_FOLDER,
XMB_TEXTURE_ZIP,
2015-06-30 16:07:22 +00:00
XMB_TEXTURE_MUSIC,
2015-07-01 12:53:34 +00:00
XMB_TEXTURE_IMAGE,
2015-07-04 00:14:26 +00:00
XMB_TEXTURE_MOVIE,
2014-10-18 14:26:02 +00:00
XMB_TEXTURE_CORE,
2015-02-02 23:27:18 +00:00
XMB_TEXTURE_RDB,
XMB_TEXTURE_CURSOR,
XMB_TEXTURE_SWITCH_ON,
XMB_TEXTURE_SWITCH_OFF,
2015-02-04 21:44:33 +00:00
XMB_TEXTURE_CLOCK,
2015-03-08 23:14:55 +00:00
XMB_TEXTURE_POINTER,
XMB_TEXTURE_ADD,
2014-10-09 20:59:05 +00:00
XMB_TEXTURE_LAST
};
2014-10-08 23:21:22 +00:00
2015-10-22 02:52:57 +00:00
enum
{
XMB_SYSTEM_TAB_MAIN = 0,
2015-10-22 18:05:51 +00:00
XMB_SYSTEM_TAB_SETTINGS,
XMB_SYSTEM_TAB_HISTORY,
XMB_SYSTEM_TAB_ADD
2015-10-22 02:52:57 +00:00
};
#define XMB_SYSTEM_TAB_END XMB_SYSTEM_TAB_ADD
2015-10-21 23:03:49 +00:00
struct xmb_texture_item
{
GRuint id;
};
2014-10-08 23:21:22 +00:00
typedef struct xmb_handle
{
file_list_t *menu_stack_old;
file_list_t *selection_buf_old;
file_list_t *horizontal_list;
size_t selection_ptr_old;
int depth;
int old_depth;
char box_message[PATH_MAX_LENGTH];
float x;
float alpha;
GRuint boxart;
float boxart_size;
char background_file_path[PATH_MAX_LENGTH];
2015-02-12 19:23:14 +00:00
struct
{
struct
{
float left;
float top;
2015-02-12 19:26:04 +00:00
2015-02-12 19:23:14 +00:00
} screen;
struct
{
float left;
} setting;
struct
{
float left;
float top;
float bottom;
} title;
struct
{
float left;
float top;
} label;
} margins;
char title_name[PATH_MAX_LENGTH];
2015-02-12 17:34:36 +00:00
struct
{
struct
{
float alpha;
} arrow;
struct xmb_texture_item bg;
struct xmb_texture_item list[XMB_TEXTURE_LAST];
} textures;
2015-02-12 17:31:46 +00:00
struct
{
2015-02-12 22:38:44 +00:00
struct
{
float horizontal;
float vertical;
} spacing;
2015-02-12 17:31:46 +00:00
char dir[4];
int size;
} icon;
2015-03-08 23:14:55 +00:00
struct
{
int size;
} cursor;
2015-02-12 17:23:47 +00:00
struct
{
struct
{
2015-03-16 16:40:05 +00:00
unsigned idx;
unsigned idx_old;
} active;
2015-02-12 18:23:11 +00:00
float x_pos;
size_t selection_ptr_old;
2015-06-15 17:00:52 +00:00
size_t selection_ptr;
2015-02-12 18:23:11 +00:00
} categories;
2015-10-20 12:11:43 +00:00
xmb_node_t main_menu_node;
xmb_node_t settings_tab_node;
2015-10-22 18:05:51 +00:00
xmb_node_t history_tab_node;
xmb_node_t add_tab_node;
bool prevent_populate;
gfx_font_raster_block_t raster_block;
} xmb_handle_t;
static void xmb_fill_default_background_path(xmb_handle_t *xmb, char *path, size_t size)
{
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0};
char iconpath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
strlcpy(xmb->icon.dir, "png", sizeof(xmb->icon.dir));
fill_pathname_join(mediapath, settings->assets_directory,
"xmb", sizeof(mediapath));
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
fill_pathname_join(path, iconpath, "bg.png", size);
if (*settings->menu.wallpaper)
strlcpy(path, settings->menu.wallpaper, size);
}
2015-06-15 17:00:52 +00:00
static size_t xmb_list_get_selection(void *data)
{
2015-07-08 15:26:23 +00:00
menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
2015-06-15 17:00:52 +00:00
2015-07-08 15:26:23 +00:00
if (!xmb)
return 0;
return xmb->categories.selection_ptr;
2015-06-15 17:00:52 +00:00
}
2015-06-07 12:29:43 +00:00
static size_t xmb_list_get_size(void *data, menu_list_type_t type)
{
2015-07-09 16:28:03 +00:00
size_t list_size = 0;
menu_handle_t *menu = (menu_handle_t*)data;
2015-07-08 15:26:23 +00:00
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
switch (type)
{
case MENU_LIST_PLAIN:
2015-10-27 09:29:50 +00:00
list_size = menu_entries_get_stack_size(0);
2015-07-08 15:26:23 +00:00
break;
case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list)
list_size = file_list_get_size(xmb->horizontal_list);
break;
case MENU_LIST_TABS:
list_size = XMB_SYSTEM_TAB_END;
2015-07-08 15:26:23 +00:00
}
return list_size;
2015-06-07 12:29:43 +00:00
}
static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i)
{
2015-10-17 16:17:59 +00:00
void *ptr = NULL;
size_t list_size = 0;
menu_handle_t *menu = (menu_handle_t*)data;
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
2015-07-08 15:26:23 +00:00
switch (type)
{
case MENU_LIST_PLAIN:
2015-10-27 09:29:50 +00:00
list_size = menu_entries_get_stack_size(0);
2015-07-08 15:26:23 +00:00
if (i < list_size)
2015-10-17 16:17:59 +00:00
ptr = (void*)&menu_stack->list[i];
2015-07-08 15:26:23 +00:00
break;
case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list)
list_size = file_list_get_size(xmb->horizontal_list);
if (i < list_size)
ptr = (void*)&xmb->horizontal_list->list[i];
break;
default:
break;
2015-07-08 15:26:23 +00:00
}
return ptr;
}
2015-02-11 04:33:53 +00:00
static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current)
{
2015-02-12 22:38:44 +00:00
float iy = xmb->icon.spacing.vertical;
2015-03-16 16:40:05 +00:00
if (i < (int)current)
if (xmb->depth > 1)
iy *= (i - (int)current + XMB_ABOVE_OFFSET_SUBITEM);
else
iy *= (i - (int)current + XMB_ABOVE_OFFSET_ITEM);
else
iy *= (i - (int)current + XMB_UNDER_OFFSET_ITEM);
2015-03-16 16:40:05 +00:00
if (i == (int)current)
iy = xmb->icon.spacing.vertical * XMB_ITEM_ACTIVE_FACTOR;
return iy;
}
static void xmb_draw_icon(xmb_handle_t *xmb,
GRuint texture,
float x, float y,
unsigned width, unsigned height,
2015-09-06 20:18:59 +00:00
float rotation, float scale_factor,
GRfloat *color)
2014-10-08 23:21:22 +00:00
{
2015-07-12 01:57:06 +00:00
struct gfx_coords coords;
math_matrix_4x4 mymat;
2015-02-01 14:25:37 +00:00
if (
2015-02-12 17:31:46 +00:00
x < -xmb->icon.size/2 ||
x > width ||
2015-02-12 17:31:46 +00:00
y < xmb->icon.size/2 ||
y > height + xmb->icon.size)
2014-10-08 23:21:22 +00:00
return;
menu_display_matrix_4x4_rotate_z(&mymat, rotation, scale_factor, scale_factor, 1, true);
2015-02-02 19:48:26 +00:00
coords.vertices = 4;
coords.vertex = NULL;
2015-11-02 21:46:23 +00:00
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2015-09-06 20:18:59 +00:00
coords.color = (const float*)color;
2014-10-08 23:21:22 +00:00
menu_display_draw_frame(
2015-09-06 16:16:24 +00:00
x,
height - y,
xmb->icon.size,
xmb->icon.size,
2015-11-02 17:55:05 +00:00
&coords, &mymat, texture,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
2014-10-08 23:21:22 +00:00
}
2015-11-02 18:04:20 +00:00
static void xmb_draw_icon_predone(xmb_handle_t *xmb,
2015-03-10 02:42:26 +00:00
math_matrix_4x4 *mymat,
GRuint texture,
float x, float y,
unsigned width, unsigned height,
2015-09-06 21:24:51 +00:00
float alpha, float rotation, float scale_factor,
GRfloat *color)
2015-03-10 02:42:26 +00:00
{
2015-07-12 01:57:06 +00:00
struct gfx_coords coords;
2015-03-10 02:42:26 +00:00
if (
x < -xmb->icon.size/2 ||
x > width ||
2015-03-10 02:42:26 +00:00
y < xmb->icon.size/2 ||
y > height + xmb->icon.size)
2015-03-10 02:42:26 +00:00
return;
coords.vertices = 4;
coords.vertex = NULL;
2015-11-02 21:46:23 +00:00
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2015-03-10 02:42:26 +00:00
coords.color = color;
menu_display_draw_frame(
2015-09-06 16:16:24 +00:00
x,
height - y,
xmb->icon.size,
xmb->icon.size,
2015-11-02 17:55:05 +00:00
&coords, mymat, texture,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
2015-03-10 02:42:26 +00:00
}
static void xmb_draw_boxart(xmb_handle_t *xmb, GRfloat *color, unsigned width, unsigned height)
{
2015-07-12 01:57:06 +00:00
struct gfx_coords coords;
math_matrix_4x4 mymat;
float y = xmb->margins.screen.top + xmb->icon.size + xmb->boxart_size;
float x = xmb->margins.screen.left + xmb->icon.spacing.horizontal +
2015-07-08 15:26:23 +00:00
xmb->icon.spacing.horizontal*4 - xmb->icon.size / 4;
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
coords.vertices = 4;
coords.vertex = NULL;
2015-11-02 21:46:23 +00:00
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2015-09-06 20:01:12 +00:00
coords.color = (const float*)color;
menu_display_draw_frame(
2015-09-06 16:16:24 +00:00
x,
height - y,
xmb->boxart_size,
xmb->boxart_size,
2015-11-02 17:55:05 +00:00
&coords, &mymat, xmb->boxart,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
}
2015-04-24 21:06:04 +00:00
static void xmb_draw_text(menu_handle_t *menu,
2015-04-26 04:14:59 +00:00
xmb_handle_t *xmb,
2015-04-21 14:45:27 +00:00
const char *str, float x,
float y, float scale_factor, float alpha,
enum text_alignment text_align,
unsigned width, unsigned height)
2014-10-08 23:21:22 +00:00
{
uint8_t a8 = 0;
struct font_params params = {0};
void *disp_buf = NULL;
if (alpha > xmb->alpha)
alpha = xmb->alpha;
2015-02-01 14:25:37 +00:00
a8 = 255 * alpha;
2015-02-01 14:25:37 +00:00
2014-10-08 23:21:22 +00:00
if (a8 == 0)
return;
if (x < -xmb->icon.size || x > width + xmb->icon.size
|| y < -xmb->icon.size || y > height + xmb->icon.size)
2014-10-08 23:21:22 +00:00
return;
params.x = x / width;
params.y = 1.0f - y / height;
2014-10-08 23:21:22 +00:00
2015-02-02 19:48:26 +00:00
params.scale = scale_factor;
params.color = FONT_COLOR_RGBA(255, 255, 255, a8);
2014-10-08 23:21:22 +00:00
params.full_screen = true;
params.text_align = text_align;
2014-10-08 23:21:22 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_FONT_BUF, &disp_buf);
video_driver_set_osd_msg(str, &params, disp_buf);
2014-10-08 23:21:22 +00:00
}
2015-03-08 12:17:07 +00:00
static void xmb_render_messagebox_internal(const char *message)
2014-10-08 23:21:22 +00:00
{
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
2015-06-06 12:07:20 +00:00
xmb = (xmb_handle_t*)menu->userdata;
2014-10-08 23:21:22 +00:00
if (!xmb || !message || !*message)
2014-10-08 23:21:22 +00:00
return;
strlcpy(xmb->box_message, message, sizeof(xmb->box_message));
2014-10-08 23:21:22 +00:00
}
2015-03-09 22:34:01 +00:00
static void xmb_frame_messagebox(const char *message)
2014-10-08 23:21:22 +00:00
{
2015-09-26 21:37:25 +00:00
int x, y, font_size;
unsigned i;
unsigned width, height;
struct string_list *list = NULL;
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
video_driver_get_size(&width, &height);
xmb = (xmb_handle_t*)menu->userdata;
2014-10-08 23:21:22 +00:00
if (!xmb)
return;
list = string_split(message, "\n");
2014-10-08 23:21:22 +00:00
if (!list)
return;
2014-10-08 23:21:22 +00:00
if (list->elems == 0)
2015-02-11 05:27:28 +00:00
goto end;
2014-10-08 23:21:22 +00:00
2015-09-26 21:37:25 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
x = width / 2 - strlen(list->elems[0].data) * font_size / 4;
y = height / 2 - list->size * font_size / 2;
2014-10-08 23:21:22 +00:00
for (i = 0; i < list->size; i++)
{
const char *msg = list->elems[i].data;
2014-10-09 20:45:29 +00:00
if (msg)
2015-06-14 13:34:05 +00:00
xmb_draw_text(menu,
xmb,
msg,
x,
2015-09-26 21:37:25 +00:00
y + i * font_size,
2015-06-14 13:34:05 +00:00
1,
1,
TEXT_ALIGN_LEFT,
width,
height);
2014-10-08 23:21:22 +00:00
}
2015-02-11 05:27:28 +00:00
end:
2014-10-08 23:21:22 +00:00
string_list_free(list);
}
2015-06-18 02:32:56 +00:00
static void xmb_update_boxart(xmb_handle_t *xmb, unsigned i)
{
2015-06-29 19:52:55 +00:00
menu_entry_t entry;
char path[PATH_MAX_LENGTH] = {0};
2015-10-17 16:17:59 +00:00
settings_t *settings = config_get_ptr();
2015-06-18 02:32:56 +00:00
menu_entry_get(&entry, 0, i, NULL, true);
2015-06-18 02:32:56 +00:00
fill_pathname_join(path, settings->boxarts_directory, entry.path, sizeof(path));
strlcat(path, ".png", sizeof(path));
if (path_file_exists(path))
rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, path,
"cb_menu_boxart", 0, 1, true);
else if (xmb->depth == 1)
2015-06-18 02:32:56 +00:00
xmb->boxart = 0;
}
static void xmb_selection_pointer_changed(bool allow_animations)
2014-10-09 00:41:08 +00:00
{
2015-09-25 12:57:37 +00:00
size_t selection;
unsigned i, end, tag, height, skip;
int threshold = 0;
2015-10-17 16:40:47 +00:00
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
2015-10-17 16:40:47 +00:00
settings_t *settings = config_get_ptr();
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
2014-10-09 00:41:08 +00:00
2014-10-10 13:52:12 +00:00
if (!xmb)
return;
2015-09-25 12:57:37 +00:00
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2014-10-09 00:41:08 +00:00
end = menu_entries_get_end();
tag = (uintptr_t)menu_list;
threshold = xmb->icon.size * 16;
2014-10-09 20:45:29 +00:00
video_driver_get_size(NULL, &height);
2015-09-25 20:24:07 +00:00
menu_animation_kill_by_tag(tag);
menu_entries_set_start(0);
skip = 0;
for (i = 0; i < end; i++)
2014-10-09 00:41:08 +00:00
{
float iy, real_iy;
float ia = XMB_ITEM_PASSIVE_ALPHA;
float iz = XMB_ITEM_PASSIVE_ZOOM;
2015-10-19 14:32:51 +00:00
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(selection_buf, i);
2014-10-09 00:41:08 +00:00
if (!node)
continue;
2015-09-25 12:57:37 +00:00
iy = xmb_item_y(xmb, i, selection);
real_iy = iy + xmb->margins.screen.top;
2014-10-09 00:41:08 +00:00
2015-09-25 12:57:37 +00:00
if (i == selection)
2014-10-09 00:41:08 +00:00
{
ia = XMB_ITEM_ACTIVE_ALPHA;
iz = XMB_ITEM_ACTIVE_ZOOM;
2015-06-18 02:32:56 +00:00
if (settings->menu.boxart_enable)
xmb_update_boxart(xmb, i);
2014-10-09 00:41:08 +00:00
}
if (real_iy < -threshold)
skip++;
if (!allow_animations || (real_iy < -threshold || real_iy > height+threshold))
{
node->alpha = node->label_alpha = ia;
node->y = iy;
node->zoom = iz;
}
else
{
2015-09-25 20:24:07 +00:00
menu_animation_push(XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, tag, NULL);
menu_animation_push(XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, tag, NULL);
menu_animation_push(XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, tag, NULL);
menu_animation_push(XMB_DELAY, iy, &node->y, EASING_IN_OUT_QUAD, tag, NULL);
}
2014-10-09 00:41:08 +00:00
}
menu_entries_set_start(skip);
2014-10-09 00:41:08 +00:00
}
2015-04-21 14:45:27 +00:00
static void xmb_list_open_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-10-09 00:41:08 +00:00
{
unsigned i, height = 0;
int threshold = xmb->icon.size * 16;
2015-06-15 15:34:12 +00:00
size_t end = 0;
2015-06-07 13:07:38 +00:00
end = file_list_get_size(list);
video_driver_get_size(NULL, &height);
2015-06-07 13:07:38 +00:00
for (i = 0; i < end; i++)
2014-10-20 18:00:39 +00:00
{
float ia = 0;
float real_y;
2015-10-19 14:32:51 +00:00
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
if (!node)
continue;
if (i == current)
ia = XMB_ITEM_ACTIVE_ALPHA;
if (dir == -1)
ia = 0;
2015-02-02 19:48:26 +00:00
2015-06-23 20:06:04 +00:00
real_y = node->y + xmb->margins.screen.top;
if (real_y < -threshold || real_y > height+threshold)
{
node->alpha = ia;
node->label_alpha = 0;
node->x = xmb->icon.size * dir * -2;
}
else
{
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, xmb->icon.size * dir * -2, &node->x,
EASING_IN_OUT_QUAD, -1, NULL);
}
2014-10-20 18:00:39 +00:00
}
}
2015-04-21 14:45:27 +00:00
static void xmb_list_open_new(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-10-20 18:00:39 +00:00
{
unsigned i, height;
2015-09-25 20:48:58 +00:00
int threshold = xmb->icon.size * 10;
2015-06-15 17:12:31 +00:00
size_t end = file_list_get_size(list);
2015-06-07 13:07:38 +00:00
video_driver_get_size(NULL, &height);
2015-06-07 13:07:38 +00:00
for (i = 0; i < end; i++)
2014-10-17 23:24:14 +00:00
{
2015-06-07 13:08:32 +00:00
float ia;
float real_y;
2015-04-21 14:45:27 +00:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 14:32:51 +00:00
menu_entries_get_userdata_at_offset(list, i);
2015-02-02 19:48:26 +00:00
2015-02-11 05:22:00 +00:00
if (!node)
2015-02-02 19:48:26 +00:00
continue;
2015-01-26 18:30:44 +00:00
2014-10-20 18:00:39 +00:00
if (dir == 1 || (dir == -1 && i != current))
node->alpha = 0;
2015-01-26 18:30:44 +00:00
if (dir == 1 || dir == -1)
node->label_alpha = 0;
2015-02-12 17:31:46 +00:00
node->x = xmb->icon.size * dir * 2;
2015-02-11 04:33:53 +00:00
node->y = xmb_item_y(xmb, i, current);
node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM;
2014-10-17 23:24:14 +00:00
2015-06-23 20:06:04 +00:00
real_y = node->y + xmb->margins.screen.top;
2014-10-17 23:24:14 +00:00
if (i == current)
node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
2014-11-27 10:07:52 +00:00
ia = XMB_ITEM_PASSIVE_ALPHA;
2015-01-26 05:51:46 +00:00
if (i == current)
ia = XMB_ITEM_ACTIVE_ALPHA;
2015-01-26 05:51:46 +00:00
if (real_y < -threshold || real_y > height+threshold)
{
node->alpha = node->label_alpha = ia;
node->x = 0;
}
else
{
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, -1, NULL);
}
2014-10-17 23:24:14 +00:00
}
xmb->old_depth = xmb->depth;
menu_entries_set_start(0);
2014-10-09 00:41:08 +00:00
}
static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i)
2015-06-07 14:39:40 +00:00
{
xmb_node_t *node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
2015-01-26 05:51:46 +00:00
2015-06-07 14:41:20 +00:00
if (!node)
{
2015-01-26 05:51:46 +00:00
RARCH_ERR("XMB node could not be allocated.\n");
return NULL;
}
node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA;
node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM;
if ((i + XMB_SYSTEM_TAB_END) == xmb->categories.active.idx)
2015-01-26 05:51:46 +00:00
{
node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
}
file_list_free_actiondata(xmb->horizontal_list, i);
file_list_set_actiondata(xmb->horizontal_list, i, node);
2015-06-07 14:41:20 +00:00
2014-11-13 20:05:16 +00:00
return node;
}
2015-06-07 14:52:07 +00:00
static xmb_node_t* xmb_get_userdata_from_horizontal_list(
xmb_handle_t *xmb, unsigned i)
{
2015-10-19 14:32:51 +00:00
return (xmb_node_t*)menu_entries_get_actiondata_at_offset(xmb->horizontal_list, i);
}
static void xmb_push_animations(xmb_node_t *node, float ia, float ix)
{
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ix, &node->x, EASING_IN_OUT_QUAD, -1, NULL);
}
2015-04-21 14:45:27 +00:00
static void xmb_list_switch_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-11-14 20:56:21 +00:00
{
2015-03-16 16:40:05 +00:00
unsigned i;
2015-06-15 17:12:31 +00:00
size_t end = file_list_get_size(list);
2014-11-14 20:56:21 +00:00
for (i = 0; i < end; i++)
2014-11-14 20:56:21 +00:00
{
2015-02-01 14:25:37 +00:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 14:32:51 +00:00
menu_entries_get_userdata_at_offset(list, i);
float ia = 0;
2014-11-14 20:56:21 +00:00
2015-02-11 05:11:25 +00:00
if (!node)
2015-06-06 12:07:20 +00:00
continue;
2014-11-14 20:56:21 +00:00
xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir);
2014-11-14 20:56:21 +00:00
}
}
2015-04-21 14:45:27 +00:00
static void xmb_list_switch_new(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-11-14 20:56:21 +00:00
{
2015-03-16 16:40:05 +00:00
unsigned i;
size_t end = 0;
2015-06-04 10:17:23 +00:00
settings_t *settings = config_get_ptr();
2015-06-04 10:17:23 +00:00
if (settings->menu.dynamic_wallpaper_enable)
{
2015-06-12 14:25:32 +00:00
char path[PATH_MAX_LENGTH] = {0};
2015-06-04 10:17:23 +00:00
char *tmp = string_replace_substring(xmb->title_name, "/", " ");
if (tmp)
{
2015-06-11 14:06:39 +00:00
fill_pathname_join(path, settings->dynamic_wallpapers_directory, tmp, sizeof(path));
path_remove_extension(path);
2015-06-04 10:17:23 +00:00
free(tmp);
}
strlcat(path, ".png", sizeof(path));
if (!path_file_exists(path))
xmb_fill_default_background_path(xmb, path, sizeof(path));
if(strcmp(path, xmb->background_file_path) != 0) {
if(path_file_exists(path)) {
rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, path,
"cb_menu_wallpaper", 0, 1, true);
strlcpy(xmb->background_file_path, path, sizeof(xmb->background_file_path));
}
}
2015-06-04 10:17:23 +00:00
}
end = file_list_get_size(list);
2014-11-14 20:56:21 +00:00
for (i = 0; i < end; i++)
2014-11-14 20:56:21 +00:00
{
2015-02-01 14:25:37 +00:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 14:32:51 +00:00
menu_entries_get_userdata_at_offset(list, i);
float ia = 0.5;
2014-11-14 20:56:21 +00:00
2015-02-11 05:15:15 +00:00
if (!node)
2015-06-06 12:07:20 +00:00
continue;
2014-11-14 20:56:21 +00:00
2015-02-12 22:38:44 +00:00
node->x = xmb->icon.spacing.horizontal * dir;
2015-02-02 19:48:26 +00:00
node->alpha = 0;
2014-11-14 22:39:24 +00:00
node->label_alpha = 0;
2014-11-14 20:56:21 +00:00
if (i == current)
ia = XMB_ITEM_ACTIVE_ALPHA;
2015-06-06 12:07:20 +00:00
xmb_push_animations(node, ia, 0);
2014-11-14 20:56:21 +00:00
}
}
static void xmb_set_title(xmb_handle_t *xmb)
2014-11-14 23:35:45 +00:00
{
if (xmb->categories.selection_ptr <= XMB_SYSTEM_TAB_END)
2014-11-14 23:35:45 +00:00
{
menu_entries_get_title(xmb->title_name, sizeof(xmb->title_name));
}
else
{
const char *path = NULL;
menu_entries_get_at_offset(
xmb->horizontal_list,
xmb->categories.selection_ptr - (XMB_SYSTEM_TAB_END + 1),
&path, NULL, NULL, NULL, NULL);
2014-11-14 23:35:45 +00:00
if (!path)
return;
2014-11-14 23:35:45 +00:00
strlcpy(xmb->title_name, path, sizeof(xmb->title_name));
path_remove_extension(xmb->title_name);
}
}
static xmb_node_t* xmb_get_node(xmb_handle_t *xmb, unsigned i)
{
xmb_node_t *node = NULL;
switch (i)
{
case XMB_SYSTEM_TAB_SETTINGS:
node = &xmb->settings_tab_node;
break;
case XMB_SYSTEM_TAB_HISTORY:
node = &xmb->history_tab_node;
break;
case XMB_SYSTEM_TAB_ADD:
node = &xmb->add_tab_node;
break;
default:
node = &xmb->main_menu_node;
if (i > XMB_SYSTEM_TAB_END)
node = xmb_get_userdata_from_horizontal_list(xmb, i - (XMB_SYSTEM_TAB_END + 1));
2015-10-22 18:05:51 +00:00
break;
2014-11-14 23:35:45 +00:00
}
return node;
2014-11-14 23:35:45 +00:00
}
2015-06-07 11:09:35 +00:00
static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
2014-10-08 23:21:22 +00:00
{
2014-11-14 20:56:21 +00:00
unsigned j;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
2015-06-11 14:54:28 +00:00
for (j = 0; j <= list_size; j++)
2014-11-14 20:56:21 +00:00
{
float ia = XMB_CATEGORIES_PASSIVE_ALPHA;
float iz = XMB_CATEGORIES_PASSIVE_ZOOM;
xmb_node_t *node = xmb_get_node(xmb, j);
2014-11-14 20:56:21 +00:00
if (!node)
continue;
2015-06-06 12:07:20 +00:00
2015-02-12 18:23:11 +00:00
if (j == xmb->categories.active.idx)
2015-02-02 19:40:29 +00:00
{
ia = XMB_CATEGORIES_ACTIVE_ALPHA;
iz = XMB_CATEGORIES_ACTIVE_ZOOM;
2015-02-02 19:40:29 +00:00
}
2014-11-14 20:56:21 +00:00
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, -1, NULL);
}
2015-06-07 11:09:35 +00:00
}
static void xmb_list_switch(xmb_handle_t *xmb)
{
2015-09-25 12:57:37 +00:00
size_t selection;
2015-06-07 11:09:35 +00:00
int dir = -1;
2015-10-17 16:17:59 +00:00
menu_handle_t *menu = menu_driver_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
2015-10-17 16:17:59 +00:00
settings_t *settings = config_get_ptr();
2015-09-25 12:57:37 +00:00
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-06-07 11:09:35 +00:00
if (!menu)
return;
2015-06-15 17:00:52 +00:00
if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old)
2015-06-07 11:09:35 +00:00
dir = 1;
xmb->categories.active.idx += dir;
xmb_list_switch_horizontal_list(xmb, menu);
2014-11-14 20:56:21 +00:00
2015-09-25 20:24:07 +00:00
menu_animation_push(XMB_DELAY,
2015-06-15 17:00:52 +00:00
xmb->icon.spacing.horizontal * -(float)xmb->categories.selection_ptr,
&xmb->categories.x_pos, EASING_IN_OUT_QUAD, -1, NULL);
2015-02-02 19:40:29 +00:00
dir = -1;
2015-06-15 17:00:52 +00:00
if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old)
2015-02-02 19:40:29 +00:00
dir = 1;
2015-04-21 14:45:27 +00:00
xmb_list_switch_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
2015-10-17 16:17:59 +00:00
xmb_list_switch_new(xmb, selection_buf, dir, selection);
2015-06-15 17:00:52 +00:00
xmb->categories.active.idx_old = xmb->categories.selection_ptr;
2015-06-18 02:32:56 +00:00
if (settings->menu.boxart_enable)
xmb_update_boxart(xmb, 0);
}
2014-11-14 20:56:21 +00:00
2015-06-07 11:09:35 +00:00
static void xmb_list_open_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
{
unsigned j;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
2014-10-08 23:21:22 +00:00
for (j = 0; j <= list_size; j++)
{
2015-03-22 07:09:00 +00:00
float ia = 0;
xmb_node_t *node = xmb_get_node(xmb, j);
if (!node)
continue;
2015-02-12 18:23:11 +00:00
if (j == xmb->categories.active.idx)
ia = XMB_CATEGORIES_ACTIVE_ALPHA;
2015-02-02 19:40:29 +00:00
else if (xmb->depth <= 1)
ia = XMB_CATEGORIES_PASSIVE_ALPHA;
2015-02-02 19:40:29 +00:00
2015-09-25 20:24:07 +00:00
menu_animation_push(XMB_DELAY, ia,
&node->alpha, EASING_IN_OUT_QUAD, -1, NULL);
}
2015-06-07 11:09:35 +00:00
}
2015-11-02 21:56:05 +00:00
static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL);
for (i = 0; i < list_size; i++)
{
xmb_node_t *node = xmb_get_userdata_from_horizontal_list(xmb, i);
if (!node)
continue;
menu_display_texture_unload((uintptr_t*)&node->icon);
menu_display_texture_unload((uintptr_t*)&node->content_icon);
}
}
static void xmb_init_horizontal_list(menu_handle_t *menu, xmb_handle_t *xmb)
{
menu_displaylist_info_t info = {0};
settings_t *settings = config_get_ptr();
xmb->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t));
if (!xmb->horizontal_list)
return;
info.list = xmb->horizontal_list;
info.menu_list = NULL;
info.type = 0;
info.type_default = MENU_FILE_PLAIN;
info.flags = SL_FLAG_ALLOW_EMPTY_LIST;
strlcpy(info.label,
menu_hash_to_str(MENU_LABEL_CONTENT_COLLECTION_LIST), sizeof(info.label));
strlcpy(info.path, settings->playlist_directory, sizeof(info.path));
strlcpy(info.exts, "lpl", sizeof(info.exts));
if (menu_displaylist_push_list(&info, DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL) == 0)
menu_displaylist_push_list_process(&info);
}
static void xmb_toggle_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
for (i = 0; i <= list_size; i++)
{
xmb_node_t *node = xmb_get_node(xmb, i);
if (!node)
continue;
node->alpha = 0;
node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM;
if (i == xmb->categories.active.idx)
{
node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
}
else if (xmb->depth <= 1)
node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA;
}
}
static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu, const char *themepath)
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL);
xmb->categories.x_pos = xmb->icon.spacing.horizontal *
-(float)xmb->categories.selection_ptr;
for (i = 0; i < list_size; i++)
{
char iconpath[PATH_MAX_LENGTH] = {0};
char sysname[PATH_MAX_LENGTH] = {0};
char texturepath[PATH_MAX_LENGTH] = {0};
char content_texturepath[PATH_MAX_LENGTH] = {0};
struct texture_image ti = {0};
const char *path = NULL;
xmb_node_t *node = xmb_get_userdata_from_horizontal_list(xmb, i);
if (!node)
{
node = xmb_node_allocate_userdata(xmb, i);
if (!node)
continue;
}
file_list_get_at_offset(xmb->horizontal_list, i,
&path, NULL, NULL, NULL);
if (!path)
continue;
strlcpy(sysname, path, sizeof(sysname));
path_remove_extension(sysname);
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
fill_pathname_join(texturepath, iconpath, sysname, sizeof(texturepath));
strlcat(texturepath, ".png", sizeof(texturepath));
fill_pathname_join(content_texturepath, iconpath, sysname, sizeof(content_texturepath));
strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));
texture_image_load(&ti, texturepath);
node->icon = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
texture_image_load(&ti, content_texturepath);
node->content_icon = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
texture_image_free(&ti);
}
xmb_toggle_horizontal_list(xmb, menu);
}
2015-07-07 10:04:03 +00:00
static void xmb_refresh_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu)
{
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
2015-07-07 10:04:03 +00:00
fill_pathname_join(mediapath, settings->assets_directory, "xmb", sizeof(mediapath));
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
xmb_context_destroy_horizontal_list(xmb, menu);
2015-07-07 10:04:03 +00:00
if (xmb->horizontal_list)
free(xmb->horizontal_list);
xmb->horizontal_list = NULL;
xmb->prevent_populate = true;
2015-07-07 10:04:03 +00:00
xmb_init_horizontal_list(menu, xmb);
xmb_context_reset_horizontal_list(xmb, menu, themepath);
}
static int xmb_environ(menu_environ_cb_t type, void *data)
2015-07-07 22:37:44 +00:00
{
switch (type)
{
case MENU_ENVIRON_RESET_HORIZONTAL_LIST:
{
menu_handle_t *menu = menu_driver_get_ptr();
xmb_handle_t *xmb = menu ?
(xmb_handle_t*)menu->userdata : NULL;
2015-07-07 22:37:44 +00:00
if (!xmb || !menu)
return -1;
2015-07-07 22:37:44 +00:00
xmb_refresh_horizontal_list(xmb, menu);
2015-07-07 22:37:44 +00:00
}
break;
default:
return -1;
}
return 0;
}
2015-06-07 11:09:35 +00:00
static void xmb_list_open(xmb_handle_t *xmb)
{
size_t selection;
2015-10-17 16:17:59 +00:00
int dir = 0;
menu_handle_t *menu = menu_driver_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
2015-06-07 11:09:35 +00:00
if (!menu)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-06-07 11:09:35 +00:00
2015-06-07 12:33:33 +00:00
xmb->depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
2015-06-07 11:09:35 +00:00
if (xmb->depth > xmb->old_depth)
dir = 1;
else if (xmb->depth < xmb->old_depth)
dir = -1;
xmb_list_open_horizontal_list(xmb, menu);
2015-04-21 14:45:27 +00:00
xmb_list_open_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
2015-10-17 16:17:59 +00:00
xmb_list_open_new(xmb, selection_buf,
dir, selection);
2014-10-08 23:21:22 +00:00
2015-02-01 14:25:37 +00:00
switch (xmb->depth)
{
case 1:
2015-09-25 20:24:07 +00:00
menu_animation_push(
2015-04-21 14:45:27 +00:00
XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2),
&xmb->x, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
2015-04-21 14:45:27 +00:00
XMB_DELAY, 0, &xmb->textures.arrow.alpha,
EASING_IN_OUT_QUAD, -1, NULL);
2015-02-01 14:25:37 +00:00
break;
case 2:
2015-09-25 20:24:07 +00:00
menu_animation_push(
2015-04-21 14:45:27 +00:00
XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2),
&xmb->x, EASING_IN_OUT_QUAD, -1, NULL);
2015-09-25 20:24:07 +00:00
menu_animation_push(
2015-04-21 14:45:27 +00:00
XMB_DELAY, 1, &xmb->textures.arrow.alpha,
EASING_IN_OUT_QUAD, -1, NULL);
2015-02-01 14:25:37 +00:00
break;
}
2014-10-08 23:21:22 +00:00
2014-10-20 18:00:39 +00:00
xmb->old_depth = xmb->depth;
}
2014-10-08 23:21:22 +00:00
static void xmb_populate_entries(const char *path,
const char *label, unsigned k)
{
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
2015-02-11 19:40:48 +00:00
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
if (xmb->prevent_populate)
{
xmb_selection_pointer_changed(false);
xmb->prevent_populate = false;
return;
}
xmb_set_title(xmb);
2015-06-15 17:00:52 +00:00
if (xmb->categories.selection_ptr != xmb->categories.active.idx_old)
xmb_list_switch(xmb);
2015-02-23 20:40:36 +00:00
else
xmb_list_open(xmb);
}
static GRuint xmb_icon_get_id(xmb_handle_t *xmb,
2015-06-18 02:32:56 +00:00
xmb_node_t *core_node, xmb_node_t *node, unsigned type, bool active)
{
switch(type)
{
case MENU_FILE_DIRECTORY:
return xmb->textures.list[XMB_TEXTURE_FOLDER].id;
case MENU_FILE_PLAIN:
return xmb->textures.list[XMB_TEXTURE_FILE].id;
case MENU_FILE_RPL_ENTRY:
if (core_node)
return core_node->content_icon;
return xmb->textures.list[XMB_TEXTURE_FILE].id;
case MENU_FILE_CARCHIVE:
return xmb->textures.list[XMB_TEXTURE_ZIP].id;
2015-06-30 16:07:22 +00:00
case MENU_FILE_MUSIC:
return xmb->textures.list[XMB_TEXTURE_MUSIC].id;
2015-07-01 12:53:34 +00:00
case MENU_FILE_IMAGEVIEWER:
return xmb->textures.list[XMB_TEXTURE_IMAGE].id;
2015-07-04 00:14:26 +00:00
case MENU_FILE_MOVIE:
return xmb->textures.list[XMB_TEXTURE_MOVIE].id;
case MENU_FILE_CORE:
return xmb->textures.list[XMB_TEXTURE_CORE].id;
case MENU_FILE_RDB:
return xmb->textures.list[XMB_TEXTURE_RDB].id;
case MENU_FILE_CURSOR:
return xmb->textures.list[XMB_TEXTURE_CURSOR].id;
case MENU_FILE_PLAYLIST_ENTRY:
case MENU_SETTING_ACTION_RUN:
return xmb->textures.list[XMB_TEXTURE_RUN].id;
case MENU_SETTING_ACTION_CLOSE:
return xmb->textures.list[XMB_TEXTURE_CLOSE].id;
case MENU_SETTING_ACTION_SAVESTATE:
return xmb->textures.list[XMB_TEXTURE_SAVESTATE].id;
case MENU_SETTING_ACTION_LOADSTATE:
return xmb->textures.list[XMB_TEXTURE_LOADSTATE].id;
case MENU_FILE_RDB_ENTRY:
case MENU_SETTING_ACTION_CORE_INFORMATION:
return xmb->textures.list[XMB_TEXTURE_CORE_INFO].id;
case MENU_SETTING_ACTION_CORE_OPTIONS:
return xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id;
case MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS:
return xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id;
case MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS:
return xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id;
case MENU_SETTING_ACTION_CORE_DISK_OPTIONS:
return xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id;
2015-06-25 04:47:20 +00:00
case MENU_SETTING_ACTION_CORE_SHADER_OPTIONS:
return xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS].id;
case MENU_SETTING_ACTION_SCREENSHOT:
return xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id;
case MENU_SETTING_ACTION_RESET:
return xmb->textures.list[XMB_TEXTURE_RELOAD].id;
case MENU_SETTING_ACTION:
if (xmb->depth == 3)
return xmb->textures.list[XMB_TEXTURE_SUBSETTING].id;
return xmb->textures.list[XMB_TEXTURE_SETTING].id;
case MENU_SETTING_GROUP:
return xmb->textures.list[XMB_TEXTURE_SETTING].id;
case MENU_INFO_MESSAGE:
return xmb->textures.list[XMB_TEXTURE_CORE_INFO].id;
}
return xmb->textures.list[XMB_TEXTURE_SUBSETTING].id;
}
static void xmb_draw_items(xmb_handle_t *xmb,
2015-02-11 04:33:53 +00:00
file_list_t *list, file_list_t *stack,
2015-09-06 21:10:00 +00:00
size_t current, size_t cat_selection_ptr, GRfloat *color,
unsigned width, unsigned height)
2014-10-20 18:00:39 +00:00
{
2015-09-06 21:10:00 +00:00
unsigned i, ticker_limit;
math_matrix_4x4 mymat;
xmb_node_t *core_node = NULL;
size_t end = 0;
2015-08-03 21:01:07 +00:00
uint64_t *frame_count = video_driver_get_frame_count();
menu_handle_t *menu = menu_driver_get_ptr();
2015-07-06 13:34:28 +00:00
settings_t *settings = config_get_ptr();
if (!list || !list->size || !menu)
2014-10-20 18:00:39 +00:00
return;
2014-10-08 23:21:22 +00:00
2015-10-21 23:03:49 +00:00
if (cat_selection_ptr > XMB_SYSTEM_TAB_END)
2015-10-23 06:13:12 +00:00
core_node = xmb_get_userdata_from_horizontal_list(xmb, cat_selection_ptr - (XMB_SYSTEM_TAB_END + 1));
2014-11-27 10:07:52 +00:00
2015-02-12 16:08:57 +00:00
end = file_list_get_size(list);
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
2015-03-10 02:42:26 +00:00
i = menu_entries_get_start();
if (list == xmb->selection_buf_old)
i = 0;
for (; i < end; i++)
2014-10-08 23:21:22 +00:00
{
char name[PATH_MAX_LENGTH];
char value[PATH_MAX_LENGTH];
2015-09-06 23:33:38 +00:00
float icon_x, icon_y;
2015-09-28 14:20:26 +00:00
const float half_size = xmb->icon.size / 2.0f;
menu_entry_t entry = {{0}};
GRuint texture_switch = 0;
GRuint icon = 0;
2015-10-19 14:32:51 +00:00
xmb_node_t * node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
2015-06-12 14:25:32 +00:00
uint32_t hash_label = 0;
uint32_t hash_value = 0;
bool do_draw_text = false;
2014-10-08 23:21:22 +00:00
2015-09-28 14:20:26 +00:00
*entry.path = *entry.label = *entry.value = 0;
entry.idx = entry.spacing = entry.type = 0;
2015-02-12 16:05:56 +00:00
if (!node)
continue;
2015-06-06 12:07:20 +00:00
icon_y = xmb->margins.screen.top + node->y + half_size;
if (icon_y < half_size)
continue;
if (icon_y > height + xmb->icon.size)
break;
icon_x = node->x + xmb->margins.screen.left +
xmb->icon.spacing.horizontal - half_size;
if (icon_x < -half_size || icon_x > width)
continue;
menu_entry_get(&entry, 0, i, list, true);
2014-10-09 17:22:42 +00:00
2015-06-17 17:55:24 +00:00
hash_label = menu_hash_calculate(entry.label);
hash_value = menu_hash_calculate(entry.value);
2015-06-04 20:46:23 +00:00
2015-06-02 06:06:20 +00:00
if (entry.type == MENU_FILE_CONTENTLIST_ENTRY)
2015-06-22 17:39:56 +00:00
fill_short_pathname_representation(entry.path, entry.path,
sizeof(entry.path));
2015-06-01 13:21:43 +00:00
2015-06-18 02:32:56 +00:00
icon = xmb_icon_get_id(xmb, core_node, node, entry.type, (i == current));
2015-01-17 03:50:46 +00:00
2015-06-05 08:05:09 +00:00
switch (hash_label)
{
case MENU_LABEL_CORE_OPTIONS:
icon = xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id;
break;
case MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS:
icon = xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id;
break;
case MENU_LABEL_CORE_CHEAT_OPTIONS:
icon = xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id;
break;
case MENU_LABEL_DISK_OPTIONS:
icon = xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id;
break;
2015-06-25 04:47:20 +00:00
case MENU_LABEL_SHADER_OPTIONS:
icon = xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS].id;
break;
2015-06-05 08:05:09 +00:00
case MENU_LABEL_SAVESTATE:
icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id;
break;
case MENU_LABEL_LOADSTATE:
icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id;
break;
case MENU_LABEL_TAKE_SCREENSHOT:
icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id;
break;
case MENU_LABEL_RESTART_CONTENT:
icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id;
break;
case MENU_LABEL_RESUME_CONTENT:
icon = xmb->textures.list[XMB_TEXTURE_RESUME].id;
break;
}
2015-02-18 09:31:01 +00:00
if (!strcmp(entry.value, "disabled") ||
!strcmp(entry.value, "off"))
2015-06-06 09:36:29 +00:00
{
if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id;
else
2015-06-06 09:36:29 +00:00
do_draw_text = true;
}
else if (!strcmp(entry.value, "enabled") ||
!strcmp(entry.value, "on"))
{
if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id;
else
do_draw_text = true;
}
else
{
switch (hash_value)
{
case MENU_VALUE_COMP:
break;
case MENU_VALUE_MORE:
break;
case MENU_VALUE_CORE:
break;
case MENU_VALUE_RDB:
break;
case MENU_VALUE_CURSOR:
break;
case MENU_VALUE_FILE:
break;
case MENU_VALUE_DIR:
break;
case MENU_VALUE_MUSIC:
break;
case MENU_VALUE_IMAGE:
break;
case MENU_VALUE_MOVIE:
break;
case MENU_VALUE_ON:
if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id;
else
do_draw_text = true;
break;
case MENU_VALUE_OFF:
if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id;
else
do_draw_text = true;
break;
default:
do_draw_text = true;
break;
}
2015-06-06 09:36:29 +00:00
}
2015-07-06 13:34:28 +00:00
ticker_limit = 35;
if (entry.value[0] == '\0')
{
if (settings->menu.boxart_enable && xmb->boxart)
ticker_limit = 40;
else
ticker_limit = 70;
}
menu_animation_ticker_str(name, ticker_limit,
2015-08-03 21:01:07 +00:00
*frame_count / 20, entry.path,
2015-06-06 09:38:10 +00:00
(i == current));
xmb_draw_text(menu, xmb, name,
node->x + xmb->margins.screen.left +
xmb->icon.spacing.horizontal + xmb->margins.label.left,
xmb->margins.screen.top + node->y + xmb->margins.label.top,
1, node->label_alpha, TEXT_ALIGN_LEFT,
width, height);
2015-06-06 09:38:10 +00:00
menu_animation_ticker_str(value, 35,
2015-08-03 21:01:07 +00:00
*frame_count / 20, entry.value,
2015-06-06 09:38:10 +00:00
(i == current));
2015-06-06 09:36:29 +00:00
if (do_draw_text)
2015-04-26 04:14:59 +00:00
xmb_draw_text(menu, xmb, value,
2015-02-12 22:38:44 +00:00
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal +
2015-02-12 19:23:14 +00:00
xmb->margins.label.left + xmb->margins.setting.left,
xmb->margins.screen.top + node->y + xmb->margins.label.top,
1,
2015-01-23 00:54:17 +00:00
node->label_alpha,
TEXT_ALIGN_LEFT,
width, height);
menu_display_blend_begin();
2015-09-06 21:24:51 +00:00
/* set alpha components of color */
color[3] = color[7] = color[11] = color[15] = (node->alpha > xmb->alpha) ? xmb->alpha : node->alpha;
2015-09-06 21:24:51 +00:00
if (color[3] != 0)
xmb_draw_icon(xmb, icon, icon_x, icon_y, width, height,
2015-09-06 20:18:59 +00:00
0, node->zoom, &color[0]);
2015-04-27 02:21:39 +00:00
2015-09-06 21:24:51 +00:00
/* set alpha components of color */
color[3] = color[7] = color[11] = color[15] = (node->alpha > xmb->alpha) ? xmb->alpha : node->alpha;
if (texture_switch != 0 && color[3] != 0)
2015-11-02 18:04:20 +00:00
xmb_draw_icon_predone(xmb, &mymat,
2015-04-27 02:21:39 +00:00
texture_switch,
2015-02-12 22:38:44 +00:00
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal
2015-02-12 19:23:14 +00:00
+ xmb->icon.size / 2.0 + xmb->margins.setting.left,
xmb->margins.screen.top + node->y + xmb->icon.size / 2.0,
width, height,
node->alpha,
0,
2015-09-06 21:24:51 +00:00
1, &color[0]);
menu_display_blend_end();
2014-10-08 23:21:22 +00:00
}
2014-10-20 18:00:39 +00:00
}
2015-11-02 18:41:10 +00:00
static void xmb_draw_cursor(xmb_handle_t *xmb,
2015-09-06 20:01:12 +00:00
GRfloat *color,
float x, float y, unsigned width, unsigned height)
2015-03-08 22:36:12 +00:00
{
2015-07-12 01:57:06 +00:00
struct gfx_coords coords;
2015-03-08 22:36:12 +00:00
coords.vertices = 4;
coords.vertex = NULL;
2015-11-02 21:46:23 +00:00
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2015-09-06 20:01:12 +00:00
coords.color = (const float*)color;
menu_display_blend_begin();
2015-04-27 03:00:07 +00:00
menu_display_draw_frame(
x - (xmb->cursor.size/2),
height - y - (xmb->cursor.size/2),
2015-09-06 16:16:24 +00:00
xmb->cursor.size,
xmb->cursor.size,
2015-11-02 18:38:53 +00:00
&coords, NULL, xmb->textures.list[XMB_TEXTURE_POINTER].id,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
menu_display_blend_end();
2015-03-08 22:36:12 +00:00
}
static void xmb_render(void)
{
2015-09-25 21:47:01 +00:00
float delta_time, dt;
2015-09-25 12:57:37 +00:00
size_t selection;
unsigned i, end, height = 0;
2015-06-13 20:57:55 +00:00
xmb_handle_t *xmb = NULL;
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
2015-04-16 15:39:40 +00:00
if (!menu)
return;
2015-06-06 12:48:58 +00:00
xmb = (xmb_handle_t*)menu->userdata;
2015-03-08 22:36:12 +00:00
if (!xmb)
return;
2015-09-25 21:37:02 +00:00
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
2015-09-25 21:47:01 +00:00
dt = delta_time / IDEAL_DT;
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &dt);
video_driver_get_size(NULL, &height);
2015-09-25 12:57:37 +00:00
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-10-17 17:21:18 +00:00
end = menu_entries_get_size();
2015-03-08 22:36:12 +00:00
if (settings->menu.pointer.enable || settings->menu.mouse.enable)
2015-04-16 15:39:40 +00:00
{
for (i = 0; i < end; i++)
{
2015-09-25 12:57:37 +00:00
float item_y1 = xmb->margins.screen.top + xmb_item_y(xmb, i, selection);
float item_y2 = item_y1 + xmb->icon.size;
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS) + (xmb->cursor.size/2);
if (settings->menu.pointer.enable)
{
if (pointer_y > item_y1 && pointer_y < item_y2)
2015-09-26 00:52:05 +00:00
menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &i);
}
if (settings->menu.mouse.enable)
{
2015-09-24 15:34:44 +00:00
if (mouse_y > item_y1 && mouse_y < item_y2)
2015-09-26 00:52:05 +00:00
menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i);
}
2015-04-16 15:39:40 +00:00
}
2015-03-08 22:36:12 +00:00
}
if (menu_entries_get_start() >= end)
menu_entries_set_start(0);
menu_animation_ctl(MENU_ANIMATION_CTL_CLEAR_ACTIVE, NULL);
}
2015-06-15 17:12:31 +00:00
static void xmb_frame_horizontal_list(xmb_handle_t *xmb,
menu_handle_t *menu, unsigned width, unsigned height,
2015-09-06 20:24:14 +00:00
GRfloat *color)
2015-06-07 11:09:35 +00:00
{
unsigned i;
size_t list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
2015-06-07 11:09:35 +00:00
2015-06-10 11:48:40 +00:00
for (i = 0; i <= list_size; i++)
2015-06-07 11:09:35 +00:00
{
xmb_node_t *node = xmb_get_node(xmb, i);
2015-06-07 11:09:35 +00:00
if (!node)
continue;
menu_display_blend_begin();
2015-06-07 11:09:35 +00:00
2015-09-06 21:24:51 +00:00
/* set alpha components of color */
color[3] = color[7] = color[11] = color[15] = (node->alpha > xmb->alpha) ? xmb->alpha : node->alpha;
2015-09-06 20:18:59 +00:00
2015-09-06 21:24:51 +00:00
if (color[3] != 0)
xmb_draw_icon(xmb, node->icon,
2015-09-06 20:18:59 +00:00
xmb->x + xmb->categories.x_pos +
xmb->margins.screen.left +
xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0,
xmb->margins.screen.top + xmb->icon.size / 2.0,
width, height,
0,
node->zoom,
&color[0]);
2015-06-07 11:09:35 +00:00
menu_display_blend_end();
2015-06-07 11:09:35 +00:00
}
}
static void xmb_frame(void)
2014-10-20 18:00:39 +00:00
{
size_t selection;
math_matrix_4x4 mymat;
2015-09-06 15:45:16 +00:00
unsigned depth, i, width, height;
char msg[PATH_MAX_LENGTH];
char title_msg[PATH_MAX_LENGTH];
char timedate[PATH_MAX_LENGTH];
2015-09-06 20:24:14 +00:00
GRfloat item_color[16];
2015-09-06 15:45:16 +00:00
GRfloat coord_color[16];
2015-09-06 18:59:35 +00:00
GRfloat coord_color2[16];
bool display_kb;
2015-06-12 14:25:32 +00:00
bool render_background = false;
xmb_handle_t *xmb = NULL;
const struct font_renderer *font_driver = NULL;
2015-06-12 14:25:32 +00:00
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
2014-10-20 18:00:39 +00:00
if (!menu)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-06-06 12:07:20 +00:00
xmb = (xmb_handle_t*)menu->userdata;
2014-10-20 18:00:39 +00:00
if (!xmb)
return;
msg[0] = '\0';
title_msg[0] = '\0';
timedate[0] = '\0';
video_driver_get_size(&width, &height);
menu_display_font_bind_block(menu, font_driver, &xmb->raster_block);
2015-03-27 14:20:10 +00:00
xmb->raster_block.carr.coords.vertices = 0;
2015-03-25 16:42:25 +00:00
2015-09-06 15:45:16 +00:00
for (i = 0; i < 16; i++)
{
2015-09-06 18:59:35 +00:00
coord_color[i] = 0;
coord_color2[i] = 1.0f;
2015-09-06 20:24:14 +00:00
item_color[i] = 1.0f;
2015-09-06 15:45:16 +00:00
}
2015-09-06 21:24:51 +00:00
/* set alpha components of colors */
2015-09-06 21:15:03 +00:00
coord_color[3] = coord_color[7] = coord_color[11] = coord_color[15] = (0.75f > xmb->alpha) ? xmb->alpha : 0.75f;
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] = xmb->alpha;
menu_display_frame_background(
width, height, xmb->textures.bg.id, xmb->alpha, false, &coord_color[0],
2015-11-02 21:46:23 +00:00
&coord_color2[0], NULL, NULL, 4,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
2014-10-20 18:00:39 +00:00
2015-04-26 04:14:59 +00:00
xmb_draw_text(menu, xmb,
2015-04-21 14:45:27 +00:00
xmb->title_name, xmb->margins.title.left,
xmb->margins.title.top, 1, 1, TEXT_ALIGN_LEFT,
width, height);
2014-11-14 23:35:45 +00:00
2015-03-20 21:22:06 +00:00
if (settings->menu.timedate_enable)
2015-02-04 21:44:33 +00:00
{
menu_display_timedate(timedate, sizeof(timedate), 4);
2015-04-26 04:14:59 +00:00
xmb_draw_text(menu, xmb, timedate,
width - xmb->margins.title.left - xmb->icon.size / 4,
xmb->margins.title.top, 1, 1, TEXT_ALIGN_RIGHT,
width, height);
2015-02-04 21:44:33 +00:00
}
2015-08-17 16:14:51 +00:00
if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0)
2015-04-26 04:14:59 +00:00
xmb_draw_text(menu, xmb, title_msg, xmb->margins.title.left,
height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT,
width, height);
2014-10-20 18:00:39 +00:00
2015-06-07 12:33:33 +00:00
depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
2015-02-04 23:52:30 +00:00
xmb_draw_items(xmb,
xmb->selection_buf_old,
xmb->menu_stack_old,
xmb->selection_ptr_old,
2015-06-15 17:00:52 +00:00
depth > 1 ? xmb->categories.selection_ptr :
2015-09-06 20:24:14 +00:00
xmb->categories.selection_ptr_old,
2015-09-06 21:10:00 +00:00
&item_color[0], width, height);
2015-02-11 04:33:53 +00:00
xmb_draw_items(xmb,
2015-10-17 16:17:59 +00:00
selection_buf,
menu_stack,
selection,
2015-09-06 20:24:14 +00:00
xmb->categories.selection_ptr,
2015-09-06 21:10:00 +00:00
&item_color[0], width, height);
2014-10-08 23:21:22 +00:00
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
2015-03-10 02:42:26 +00:00
menu_display_blend_begin();
if (settings->menu.boxart_enable && xmb->boxart)
xmb_draw_boxart(xmb, &coord_color2[0], width, height);
2015-09-06 21:24:51 +00:00
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] = (1.00f > xmb->alpha) ? xmb->alpha : 1.00f;
if (settings->menu.timedate_enable && coord_color2[3] != 0)
2015-11-02 18:04:20 +00:00
xmb_draw_icon_predone(xmb, &mymat, xmb->textures.list[XMB_TEXTURE_CLOCK].id,
2015-09-06 21:24:51 +00:00
width - xmb->icon.size, xmb->icon.size, width, height, 1, 0, 1, &coord_color2[0]);
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] = (xmb->textures.arrow.alpha > xmb->alpha)
? xmb->alpha : xmb->textures.arrow.alpha;
if (coord_color2[3] != 0)
2015-11-02 18:04:20 +00:00
xmb_draw_icon_predone(
2015-09-06 21:24:51 +00:00
xmb,
&mymat,
xmb->textures.list[XMB_TEXTURE_ARROW].id,
xmb->x + xmb->margins.screen.left +
xmb->icon.spacing.horizontal - xmb->icon.size / 2.0 + xmb->icon.size,
xmb->margins.screen.top +
xmb->icon.size / 2.0 + xmb->icon.spacing.vertical
* XMB_ITEM_ACTIVE_FACTOR,
2015-09-06 21:24:51 +00:00
width,
height,
xmb->textures.arrow.alpha,
0,
1, &coord_color2[0]);
2015-03-10 02:42:26 +00:00
xmb_frame_horizontal_list(xmb, menu, width, height, &item_color[0]);
2014-11-11 15:28:40 +00:00
2015-04-24 21:28:25 +00:00
menu_display_font_flush_block(menu, font_driver);
2015-04-02 23:12:18 +00:00
2015-09-26 00:52:05 +00:00
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb);
if (display_kb)
2014-10-08 23:21:22 +00:00
{
const char *str = NULL, *label = NULL;
2015-09-26 00:52:05 +00:00
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_BUFF_PTR, &str);
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL, &label);
2015-02-02 17:44:56 +00:00
2014-10-08 23:21:22 +00:00
if (!str)
str = "";
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
2015-03-08 12:17:07 +00:00
render_background = true;
2014-10-08 23:21:22 +00:00
}
if (xmb->box_message[0] != '\0')
2014-10-08 23:21:22 +00:00
{
2015-03-08 12:17:07 +00:00
strlcpy(msg, xmb->box_message,
sizeof(msg));
xmb->box_message[0] = '\0';
2015-03-08 12:17:07 +00:00
render_background = true;
}
if (render_background)
{
menu_display_frame_background(
2015-09-06 20:30:46 +00:00
width, height,
2015-09-06 18:59:35 +00:00
xmb->textures.bg.id, xmb->alpha, true,
&coord_color[0], &coord_color2[0],
2015-11-02 21:46:23 +00:00
NULL, NULL, 4,
2015-10-24 05:51:33 +00:00
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
2015-03-09 22:34:01 +00:00
xmb_frame_messagebox(msg);
2014-10-08 23:21:22 +00:00
}
2015-10-27 08:05:02 +00:00
/* set alpha components of colors */
coord_color2[3] = coord_color2[7] = coord_color2[11] = coord_color2[15] = (1.00f > xmb->alpha) ? xmb->alpha : 1.00f;
if (settings->menu.mouse.enable && (settings->video.fullscreen || !video_driver_has_windowed()))
2015-09-24 15:29:46 +00:00
{
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
2015-11-02 18:41:10 +00:00
xmb_draw_cursor(xmb, &coord_color2[0], mouse_x, mouse_y, width, height);
2015-09-24 15:29:46 +00:00
}
2015-03-08 22:36:12 +00:00
2015-09-25 11:27:15 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL);
2014-10-08 23:21:22 +00:00
}
static void xmb_font(menu_handle_t *menu)
{
2015-09-26 21:37:25 +00:00
int font_size;
char mediapath[PATH_MAX_LENGTH], themepath[PATH_MAX_LENGTH], fontpath[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
2015-09-26 21:37:25 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
fill_pathname_join(mediapath, settings->assets_directory, "xmb", sizeof(mediapath));
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
2015-09-26 21:37:25 +00:00
if (!menu_display_init_main_font(menu, fontpath, font_size))
RARCH_WARN("Failed to load font.");
}
static void xmb_layout(menu_handle_t *menu, xmb_handle_t *xmb)
{
2015-09-26 21:37:25 +00:00
int new_font_size;
size_t selection;
float scale_factor;
2015-09-26 21:37:25 +00:00
unsigned width, height, i, current, end, new_header_height;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
video_driver_get_size(&width, &height);
2015-09-26 21:37:25 +00:00
scale_factor = width / 1920.0;
new_font_size = 32.0 * scale_factor;
new_header_height = 128.0 * scale_factor;
xmb->boxart_size = 460.0 * scale_factor;
xmb->cursor.size = 64.0;
2015-09-26 21:37:25 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_SIZE, &new_font_size);
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, &new_header_height);
xmb->icon.spacing.horizontal = 200.0 * scale_factor;
xmb->icon.spacing.vertical = 64.0 * scale_factor;
xmb->margins.screen.left = 336.0 * scale_factor;
xmb->margins.screen.top = (256+32) * scale_factor;
xmb->margins.title.left = 60 * scale_factor;
2015-09-26 21:37:25 +00:00
xmb->margins.title.top = 60 * scale_factor + new_font_size / 3;
xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3;
xmb->margins.label.left = 85.0 * scale_factor;
2015-09-26 21:37:25 +00:00
xmb->margins.label.top = new_font_size / 3.0;
xmb->margins.setting.left = 600.0 * scale_factor;
if (width >= 3840)
scale_factor = 2.0;
else if (width >= 2560)
scale_factor = 1.5;
else if (width >= 1920)
scale_factor = 1.0;
else if (width >= 1440)
scale_factor = 0.75;
else if (width >= 960)
scale_factor = 0.5;
else if (width >= 640)
scale_factor = 0.375;
else if (width >= 480)
scale_factor = 0.25;
else if (width >= 320)
scale_factor = 0.1875;
else if (width >= 240)
scale_factor = 0.125;
xmb->icon.size = 128.0 * scale_factor;
current = selection;
end = menu_entries_get_end();
for (i = 0; i < end; i++)
{
float ia = XMB_ITEM_PASSIVE_ALPHA;
float iz = XMB_ITEM_PASSIVE_ZOOM;
2015-10-19 14:32:51 +00:00
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(
2015-10-17 16:17:59 +00:00
selection_buf, i);
if (!node)
continue;
if (i == current)
{
ia = XMB_ITEM_ACTIVE_ALPHA;
iz = XMB_ITEM_ACTIVE_ZOOM;
}
node->alpha = ia;
node->label_alpha = ia;
node->zoom = iz;
node->y = xmb_item_y(xmb, i, current);
}
}
2014-10-08 23:21:22 +00:00
static void *xmb_init(void)
{
unsigned width, height;
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
2014-10-08 23:21:22 +00:00
if (!menu)
2015-02-02 17:44:56 +00:00
goto error;
2014-10-08 23:21:22 +00:00
2015-11-02 21:12:43 +00:00
if (!menu_display_check_compatibility((enum menu_display_driver_type)menu_ctx_xmb.type))
goto error;
video_driver_get_size(&width, &height);
menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t));
2014-10-10 13:52:12 +00:00
if (!menu->userdata)
2015-02-02 17:44:56 +00:00
goto error;
2014-10-10 13:52:12 +00:00
xmb = (xmb_handle_t*)menu->userdata;
xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
2015-02-02 17:44:56 +00:00
if (!xmb->menu_stack_old)
goto error;
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
2015-02-02 17:44:56 +00:00
if (!xmb->selection_buf_old)
goto error;
2015-02-12 22:38:44 +00:00
xmb->categories.active.idx = 0;
2015-02-12 18:23:11 +00:00
xmb->categories.active.idx_old = 0;
2015-02-12 22:38:44 +00:00
xmb->x = 0;
xmb->categories.x_pos = 0;
xmb->textures.arrow.alpha = 0;
xmb->depth = 1;
xmb->old_depth = 1;
xmb->alpha = 0;
xmb->prevent_populate = false;
/* TODO/FIXME - we don't use framebuffer at all
* for XMB, we should refactor this dependency
* away. */
2015-09-25 19:32:16 +00:00
menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &width);
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height);
xmb_init_horizontal_list(menu, xmb);
xmb_font(menu);
2014-11-11 15:28:40 +00:00
2014-10-08 23:21:22 +00:00
return menu;
2015-02-02 17:44:56 +00:00
error:
if (menu)
free(menu);
2015-06-11 19:12:08 +00:00
if (xmb)
{
if (xmb->menu_stack_old)
free(xmb->menu_stack_old);
2015-06-11 19:12:08 +00:00
xmb->menu_stack_old = NULL;
if (xmb->selection_buf_old)
free(xmb->selection_buf_old);
2015-06-11 19:12:08 +00:00
xmb->selection_buf_old = NULL;
if (xmb->horizontal_list)
free(xmb->horizontal_list);
2015-06-11 19:12:08 +00:00
xmb->horizontal_list = NULL;
}
2015-02-02 17:44:56 +00:00
return NULL;
2014-10-08 23:21:22 +00:00
}
static void xmb_free(void *data)
{
2015-06-12 14:25:32 +00:00
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
driver_t *driver = driver_get_ptr();
const struct font_renderer *font_driver =
(const struct font_renderer*)driver->font_osd_driver;
2015-03-28 19:50:51 +00:00
2015-02-10 22:17:19 +00:00
if (menu && menu->userdata)
2015-03-28 20:54:09 +00:00
{
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
2015-06-11 19:12:08 +00:00
if (xmb->menu_stack_old)
2015-06-15 17:36:16 +00:00
file_list_free(xmb->menu_stack_old);
2015-06-11 19:12:08 +00:00
xmb->menu_stack_old = NULL;
2015-06-13 17:37:58 +00:00
2015-06-11 19:12:08 +00:00
if (xmb->selection_buf_old)
2015-06-12 23:27:15 +00:00
file_list_free(xmb->selection_buf_old);
2015-06-11 19:12:08 +00:00
xmb->selection_buf_old = NULL;
if (xmb->horizontal_list)
2015-06-12 21:52:29 +00:00
file_list_free(xmb->horizontal_list);
2015-06-11 19:12:08 +00:00
xmb->horizontal_list = NULL;
2015-07-12 03:30:04 +00:00
gfx_coord_array_free(&xmb->raster_block.carr);
2015-06-11 19:12:08 +00:00
if (menu->userdata)
free(menu->userdata);
2015-03-28 20:54:09 +00:00
menu->userdata = NULL;
}
2015-03-28 19:50:51 +00:00
if (font_driver->bind_block)
font_driver->bind_block(driver->font_osd_data, NULL);
2014-10-08 23:21:22 +00:00
}
2015-05-09 11:29:48 +00:00
static void xmb_context_bg_destroy(xmb_handle_t *xmb)
{
2015-10-25 01:35:52 +00:00
if (!xmb)
return;
menu_display_texture_unload((uintptr_t*)&xmb->textures.bg.id);
2015-05-09 11:29:48 +00:00
}
static bool xmb_load_image(void *data, menu_image_type_t type)
{
2015-06-12 14:25:32 +00:00
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return false;
2015-06-06 12:07:20 +00:00
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb || !data)
return false;
switch (type)
{
case MENU_IMAGE_NONE:
break;
case MENU_IMAGE_WALLPAPER:
xmb_context_bg_destroy(xmb);
xmb->textures.bg.id = menu_display_texture_load(data,
TEXTURE_FILTER_MIPMAP_LINEAR);
break;
case MENU_IMAGE_BOXART:
xmb->boxart = menu_display_texture_load(data,
TEXTURE_FILTER_MIPMAP_LINEAR);
break;
}
return true;
}
2015-06-06 11:56:31 +00:00
static void xmb_context_reset_textures(xmb_handle_t *xmb, const char *iconpath)
2014-10-08 23:21:22 +00:00
{
2015-06-06 11:56:31 +00:00
unsigned i;
2015-06-06 11:56:31 +00:00
for (i = 0; i < XMB_TEXTURE_LAST; i++)
{
2015-06-06 11:56:31 +00:00
struct texture_image ti = {0};
2015-06-12 14:25:32 +00:00
char path[PATH_MAX_LENGTH] = {0};
2015-06-06 11:41:47 +00:00
2015-06-06 11:56:31 +00:00
switch(i)
2015-06-06 11:41:47 +00:00
{
2015-10-20 12:11:43 +00:00
case XMB_TEXTURE_MAIN_MENU:
#if defined(HAVE_LAKKA)
fill_pathname_join(path, iconpath, "lakka.png", sizeof(path));
#else
fill_pathname_join(path, iconpath, "retroarch.png", sizeof(path));
#endif
2015-10-20 12:11:43 +00:00
break;
2015-06-06 11:41:47 +00:00
case XMB_TEXTURE_SETTINGS:
fill_pathname_join(path, iconpath, "settings.png", sizeof(path));
break;
2015-10-22 18:05:51 +00:00
case XMB_TEXTURE_HISTORY:
fill_pathname_join(path, iconpath, "history.png", sizeof(path));
break;
2015-06-06 11:41:47 +00:00
case XMB_TEXTURE_SETTING:
2015-06-06 12:07:20 +00:00
fill_pathname_join(path, iconpath, "setting.png", sizeof(path));
2015-06-06 11:41:47 +00:00
break;
case XMB_TEXTURE_SUBSETTING:
fill_pathname_join(path, iconpath, "subsetting.png", sizeof(path));
break;
case XMB_TEXTURE_ARROW:
fill_pathname_join(path, iconpath, "arrow.png", sizeof(path));
break;
case XMB_TEXTURE_RUN:
fill_pathname_join(path, iconpath, "run.png", sizeof(path));
break;
case XMB_TEXTURE_CLOSE:
fill_pathname_join(path, iconpath, "close.png", sizeof(path));
2015-06-06 11:41:47 +00:00
break;
case XMB_TEXTURE_RESUME:
fill_pathname_join(path, iconpath, "resume.png", sizeof(path));
break;
case XMB_TEXTURE_CLOCK:
fill_pathname_join(path, iconpath, "clock.png", sizeof(path));
break;
case XMB_TEXTURE_POINTER:
fill_pathname_join(path, iconpath, "pointer.png", sizeof(path));
break;
case XMB_TEXTURE_SAVESTATE:
fill_pathname_join(path, iconpath, "savestate.png", sizeof(path));
break;
case XMB_TEXTURE_LOADSTATE:
fill_pathname_join(path, iconpath, "loadstate.png", sizeof(path));
break;
case XMB_TEXTURE_CORE_INFO:
fill_pathname_join(path, iconpath, "core-infos.png", sizeof(path));
break;
case XMB_TEXTURE_CORE_OPTIONS:
fill_pathname_join(path, iconpath, "core-options.png", sizeof(path));
break;
case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS:
fill_pathname_join(path, iconpath, "core-input-remapping-options.png", sizeof(path));
break;
case XMB_TEXTURE_CHEAT_OPTIONS:
fill_pathname_join(path, iconpath, "core-cheat-options.png", sizeof(path));
break;
case XMB_TEXTURE_DISK_OPTIONS:
fill_pathname_join(path, iconpath, "core-disk-options.png", sizeof(path));
break;
2015-06-25 04:47:20 +00:00
case XMB_TEXTURE_SHADER_OPTIONS:
fill_pathname_join(path, iconpath, "core-shader-options.png", sizeof(path));
break;
2015-06-06 11:41:47 +00:00
case XMB_TEXTURE_SCREENSHOT:
fill_pathname_join(path, iconpath, "screenshot.png", sizeof(path));
break;
case XMB_TEXTURE_RELOAD:
fill_pathname_join(path, iconpath, "reload.png", sizeof(path));
break;
case XMB_TEXTURE_FILE:
fill_pathname_join(path, iconpath, "file.png", sizeof(path));
break;
case XMB_TEXTURE_FOLDER:
fill_pathname_join(path, iconpath, "folder.png", sizeof(path));
break;
case XMB_TEXTURE_ZIP:
fill_pathname_join(path, iconpath, "zip.png", sizeof(path));
break;
2015-06-30 16:07:22 +00:00
case XMB_TEXTURE_MUSIC:
fill_pathname_join(path, iconpath, "music.png", sizeof(path));
break;
2015-07-01 12:53:34 +00:00
case XMB_TEXTURE_IMAGE:
fill_pathname_join(path, iconpath, "image.png", sizeof(path));
break;
2015-07-04 00:14:26 +00:00
case XMB_TEXTURE_MOVIE:
fill_pathname_join(path, iconpath, "movie.png", sizeof(path));
break;
2015-06-06 11:41:47 +00:00
case XMB_TEXTURE_CORE:
fill_pathname_join(path, iconpath, "core.png", sizeof(path));
break;
case XMB_TEXTURE_RDB:
fill_pathname_join(path, iconpath, "database.png", sizeof(path));
break;
case XMB_TEXTURE_CURSOR:
fill_pathname_join(path, iconpath, "cursor.png", sizeof(path));
break;
case XMB_TEXTURE_SWITCH_ON:
fill_pathname_join(path, iconpath, "on.png", sizeof(path));
break;
case XMB_TEXTURE_SWITCH_OFF:
fill_pathname_join(path, iconpath, "off.png", sizeof(path));
break;
case XMB_TEXTURE_ADD:
fill_pathname_join(path, iconpath, "add.png", sizeof(path));
break;
2015-06-06 11:41:47 +00:00
}
if (path[0] == '\0' || !path_file_exists(path))
continue;
texture_image_load(&ti, path);
xmb->textures.list[i].id = menu_display_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR);
2014-11-11 15:28:40 +00:00
texture_image_free(&ti);
}
2015-06-06 11:58:06 +00:00
2015-10-20 12:11:43 +00:00
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU].id;
xmb->main_menu_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
xmb->main_menu_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
2015-10-20 12:11:43 +00:00
xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id;
xmb->settings_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
xmb->settings_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
2015-10-22 18:05:51 +00:00
xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY].id;
xmb->history_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
xmb->history_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD].id;
xmb->add_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA;
xmb->add_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM;
2015-06-06 11:56:31 +00:00
}
static void xmb_context_reset_background(const char *iconpath)
{
2015-06-12 14:25:32 +00:00
char path[PATH_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr();
fill_pathname_join(path, iconpath, "bg.png", sizeof(path));
if (*settings->menu.wallpaper)
strlcpy(path, settings->menu.wallpaper, sizeof(path));
if (path_file_exists(path))
rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, path,
2015-06-06 12:07:20 +00:00
"cb_menu_wallpaper", 0, 1, true);
}
2015-06-06 11:56:31 +00:00
static void xmb_context_reset(void)
{
2015-06-12 14:25:32 +00:00
char mediapath[PATH_MAX_LENGTH] = {0};
char themepath[PATH_MAX_LENGTH] = {0};
char iconpath[PATH_MAX_LENGTH] = {0};
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
2015-06-06 11:56:31 +00:00
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
strlcpy(xmb->icon.dir, "png", sizeof(xmb->icon.dir));
xmb_fill_default_background_path(xmb, xmb->background_file_path, sizeof(xmb->background_file_path));
2015-06-06 11:56:31 +00:00
fill_pathname_join(mediapath, settings->assets_directory,
2015-06-09 07:15:24 +00:00
"xmb", sizeof(mediapath));
2015-06-06 11:56:31 +00:00
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
xmb_layout(menu, xmb);
xmb_font(menu);
2015-06-06 11:56:31 +00:00
xmb_context_reset_textures(xmb, iconpath);
xmb_context_reset_background(iconpath);
2015-06-07 12:33:33 +00:00
xmb_context_reset_horizontal_list(xmb, menu, themepath);
2014-10-08 23:21:22 +00:00
}
static void xmb_navigation_clear(bool pending_push)
{
2015-03-12 17:06:28 +00:00
if (!pending_push)
xmb_selection_pointer_changed(true);
}
static void xmb_navigation_pointer_changed(void)
{
xmb_selection_pointer_changed(true);
}
static void xmb_navigation_set(bool scroll)
{
xmb_selection_pointer_changed(true);
}
2015-06-06 22:41:53 +00:00
static void xmb_navigation_alphabet(size_t *unused)
{
xmb_selection_pointer_changed(true);
}
static void xmb_list_insert(file_list_t *list,
const char *path, const char *unused, size_t list_size)
{
size_t selection;
2015-06-13 14:22:05 +00:00
int current = 0;
int i = list_size;
xmb_node_t *node = NULL;
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
2015-02-11 20:00:34 +00:00
if (!menu)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-06-06 12:07:20 +00:00
2015-02-11 20:00:34 +00:00
xmb = (xmb_handle_t*)menu->userdata;
if (!list || !xmb)
return;
node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
2015-06-15 17:59:07 +00:00
if (!node)
node = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
2015-06-11 18:14:59 +00:00
if (!node)
{
RARCH_ERR("XMB node could not be allocated.\n");
return;
}
current = selection;
node->alpha = XMB_ITEM_PASSIVE_ALPHA;
node->zoom = XMB_ITEM_PASSIVE_ZOOM;
2014-10-20 18:00:39 +00:00
node->label_alpha = node->alpha;
2015-02-11 04:33:53 +00:00
node->y = xmb_item_y(xmb, i, current);
2015-02-02 17:44:56 +00:00
node->x = 0;
if (i == current)
{
node->alpha = XMB_ITEM_ACTIVE_ALPHA;
node->label_alpha = XMB_ITEM_ACTIVE_ALPHA;
node->zoom = XMB_ITEM_ACTIVE_ZOOM;
2015-02-02 17:44:56 +00:00
}
2015-06-11 18:14:59 +00:00
file_list_set_userdata(list, i, node);
}
static void xmb_list_free(file_list_t *list,
size_t idx, size_t list_size)
{
}
2015-06-15 17:59:07 +00:00
static void xmb_list_clear(file_list_t *list)
{
2015-09-25 20:48:58 +00:00
size_t i;
size_t size = list->size;
2015-06-15 17:59:07 +00:00
for (i = 0; i < size; ++i)
{
float *subjects[5];
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
2015-06-15 17:59:07 +00:00
if (!node)
2015-06-15 18:48:01 +00:00
continue;
2015-06-15 17:59:07 +00:00
subjects[0] = &node->alpha;
subjects[1] = &node->label_alpha;
subjects[2] = &node->zoom;
subjects[3] = &node->x;
subjects[4] = &node->y;
2015-09-25 20:24:07 +00:00
menu_animation_kill_by_subject(5, subjects);
2015-06-15 17:59:07 +00:00
file_list_free_userdata(list, i);
}
}
2015-06-15 17:36:16 +00:00
static void xmb_list_deep_copy(menu_handle_t *menu, const file_list_t *src, file_list_t *dst)
{
2015-09-28 16:44:28 +00:00
size_t i;
size_t size = dst->size;
2015-06-15 17:36:16 +00:00
for (i = 0; i < size; ++i)
{
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(dst, i);
2015-06-15 18:48:01 +00:00
if (node)
{
2015-09-28 16:44:28 +00:00
float *subjects[5];
2015-06-15 18:48:01 +00:00
subjects[0] = &node->alpha;
subjects[1] = &node->label_alpha;
subjects[2] = &node->zoom;
subjects[3] = &node->x;
subjects[4] = &node->y;
2015-09-25 20:24:07 +00:00
menu_animation_kill_by_subject(5, subjects);
2015-06-15 18:48:01 +00:00
}
2015-06-15 17:36:16 +00:00
file_list_free_userdata(dst, i);
2015-06-15 17:59:07 +00:00
file_list_free_actiondata(dst, i); /* this one was allocated by us */
2015-06-15 17:36:16 +00:00
}
file_list_copy(src, dst);
size = dst->size;
2015-09-28 16:44:28 +00:00
2015-06-15 17:36:16 +00:00
for (i = 0; i < size; ++i)
{
void *src_udata = menu_entries_get_userdata_at_offset(src, i);
void *src_adata = (void*)menu_entries_get_actiondata_at_offset(src, i);
2015-06-15 17:36:16 +00:00
if (src_udata)
{
2015-09-28 16:49:32 +00:00
void *data = calloc(1, sizeof(xmb_node_t));
2015-06-15 17:36:16 +00:00
memcpy(data, src_udata, sizeof(xmb_node_t));
file_list_set_userdata(dst, i, data);
}
if (src_adata)
{
2015-09-28 16:49:32 +00:00
void *data = calloc(1, sizeof(menu_file_list_cbs_t));
2015-06-15 17:36:16 +00:00
memcpy(data, src_adata, sizeof(menu_file_list_cbs_t));
file_list_set_actiondata(dst, i, data);
}
}
}
static void xmb_list_cache(menu_list_type_t type, unsigned action)
{
size_t stack_size, list_size, selection;
2015-06-08 09:30:19 +00:00
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
2015-10-17 16:17:59 +00:00
xmb_list_deep_copy(menu, selection_buf, xmb->selection_buf_old);
xmb_list_deep_copy(menu, menu_stack, xmb->menu_stack_old);
xmb->selection_ptr_old = selection;
list_size = xmb_list_get_size(menu, MENU_LIST_HORIZONTAL) + XMB_SYSTEM_TAB_END;
switch (type)
2015-02-02 19:40:29 +00:00
{
case MENU_LIST_PLAIN:
2015-02-02 19:40:29 +00:00
break;
case MENU_LIST_HORIZONTAL:
2015-06-15 17:00:52 +00:00
xmb->categories.selection_ptr_old = xmb->categories.selection_ptr;
switch (action)
{
case MENU_ACTION_LEFT:
if (xmb->categories.selection_ptr == 0)
{
xmb->categories.selection_ptr = list_size;
xmb->categories.active.idx = list_size - 1;
}
else
xmb->categories.selection_ptr--;
break;
default:
if (xmb->categories.selection_ptr == list_size)
{
xmb->categories.selection_ptr = 0;
xmb->categories.active.idx = 1;
}
else
xmb->categories.selection_ptr++;
break;
}
2015-10-17 16:17:59 +00:00
stack_size = menu_stack->size;
2015-02-02 17:44:56 +00:00
2015-10-17 16:17:59 +00:00
if (menu_stack->list[stack_size - 1].label)
free(menu_stack->list[stack_size - 1].label);
menu_stack->list[stack_size - 1].label = NULL;
2015-10-19 15:35:47 +00:00
switch (xmb->categories.selection_ptr)
{
2015-10-22 02:52:57 +00:00
case XMB_SYSTEM_TAB_MAIN:
2015-10-19 15:35:47 +00:00
menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_MAIN_MENU));
menu_stack->list[stack_size - 1].type =
MENU_SETTINGS;
break;
2015-10-22 02:52:57 +00:00
case XMB_SYSTEM_TAB_SETTINGS:
2015-10-20 12:11:43 +00:00
menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_SETTINGS_TAB));
menu_stack->list[stack_size - 1].type =
MENU_SETTINGS_TAB;
break;
2015-10-22 18:05:51 +00:00
case XMB_SYSTEM_TAB_HISTORY:
menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_HISTORY_TAB));
menu_stack->list[stack_size - 1].type =
MENU_HISTORY_TAB;
break;
case XMB_SYSTEM_TAB_ADD:
menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_ADD_TAB));
menu_stack->list[stack_size - 1].type =
MENU_ADD_TAB;
break;
2015-10-19 15:35:47 +00:00
default:
menu_stack->list[stack_size - 1].label =
strdup(menu_hash_to_str(MENU_VALUE_HORIZONTAL_MENU));
menu_stack->list[stack_size - 1].type =
MENU_SETTING_HORIZONTAL_MENU;
break;
}
break;
default:
break;
2015-03-12 13:53:14 +00:00
}
}
2014-10-09 20:59:05 +00:00
2015-06-07 11:09:35 +00:00
static void xmb_context_destroy(void)
{
2015-03-16 16:40:05 +00:00
unsigned i;
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
2015-06-07 11:09:35 +00:00
for (i = 0; i < XMB_TEXTURE_LAST; i++)
menu_display_texture_unload((uintptr_t*)&xmb->textures.list[i].id);
2015-01-30 03:45:15 +00:00
2015-06-07 11:09:35 +00:00
xmb_context_destroy_horizontal_list(xmb, menu);
2015-02-02 17:44:56 +00:00
menu_display_free_main_font();
2015-06-07 11:09:35 +00:00
}
2015-06-07 11:09:35 +00:00
static void xmb_toggle(bool menu_on)
{
2015-06-15 15:34:12 +00:00
xmb_handle_t *xmb = NULL;
menu_handle_t *menu = menu_driver_get_ptr();
2015-06-07 11:09:35 +00:00
if (!menu)
return;
xmb = (xmb_handle_t*)menu->userdata;
if (!xmb)
return;
2015-06-07 12:33:33 +00:00
xmb->depth = xmb_list_get_size(menu, MENU_LIST_PLAIN);
2015-06-07 11:09:35 +00:00
if (!menu_on)
{
xmb->alpha = 0;
return;
}
2015-09-25 20:24:07 +00:00
menu_animation_push(XMB_DELAY, 1.0f,
&xmb->alpha, EASING_IN_OUT_QUAD, -1, NULL);
2015-06-07 11:09:35 +00:00
xmb->prevent_populate = !menu_entries_needs_refresh();
2015-06-07 11:09:35 +00:00
xmb_toggle_horizontal_list(xmb, menu);
}
static int deferred_push_content_actions(menu_displaylist_info_t *info)
{
int ret = menu_displaylist_push_list(info, DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS);
if (ret != 0)
return ret;
menu_displaylist_push_list_process(info);
return 0;
}
static int xmb_list_bind_init_compare_label(menu_file_list_cbs_t *cbs,
uint32_t label_hash)
{
switch (label_hash)
{
case MENU_LABEL_CONTENT_ACTIONS:
cbs->action_deferred_push = deferred_push_content_actions;
break;
default:
return -1;
}
return 0;
}
2015-06-08 14:01:57 +00:00
static int xmb_list_bind_init(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx,
const char *elem0, const char *elem1,
uint32_t label_hash, uint32_t menu_label_hash)
{
if (xmb_list_bind_init_compare_label(cbs, label_hash) == 0)
return 0;
return -1;
2015-06-08 14:01:57 +00:00
}
static int xmb_list_push(menu_displaylist_info_t *info, unsigned type)
{
2015-10-22 02:46:05 +00:00
int ret = -1;
menu_handle_t *menu = menu_driver_get_ptr();
global_t *global = global_get_ptr();
2015-10-22 02:46:05 +00:00
switch (type)
{
case DISPLAYLIST_MAIN_MENU:
menu_entries_clear(info->list);
if (global->inited.main && (global->inited.core.type != CORE_TYPE_DUMMY))
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_CONTENT_SETTINGS), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#if defined(HAVE_DYNAMIC) || defined(HAVE_LIBRETRO_MANAGEMENT)
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_CORE_LIST), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#endif
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_LOAD_CONTENT_LIST), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#if defined(HAVE_NETWORKING)
#if defined(HAVE_LIBRETRODB)
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_ADD_CONTENT_LIST), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#endif
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_ONLINE_UPDATER), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#endif
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_INFORMATION_LIST), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#ifndef HAVE_DYNAMIC
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_RESTART_RETROARCH), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#endif
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_CONFIGURATIONS), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_SAVE_NEW_CONFIG), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_HELP_LIST), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#if !defined(IOS)
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_QUIT_RETROARCH), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
#endif
menu_displaylist_parse_settings(menu, info,
menu_hash_to_str(MENU_LABEL_SHUTDOWN), PARSE_ACTION, false);
2015-10-22 02:46:05 +00:00
info->need_push = true;
ret = 0;
break;
}
return ret;
}
static bool xmb_menu_init_list(void *data)
{
int ret;
menu_displaylist_info_t info = {0};
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
strlcpy(info.label, menu_hash_to_str(MENU_VALUE_MAIN_MENU), sizeof(info.label));
menu_entries_push(menu_stack, info.path, info.label, info.type, info.flags, 0);
2015-10-22 01:02:03 +00:00
info.list = selection_buf;
menu_displaylist_push_list(&info, DISPLAYLIST_MAIN_MENU);
2015-10-22 01:02:03 +00:00
info.need_push = true;
(void)ret;
menu_displaylist_push_list_process(&info);
return true;
}
2015-11-01 19:44:04 +00:00
static int xmb_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{
size_t selection, idx;
unsigned header_height;
bool scroll = false;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
2015-11-01 19:44:04 +00:00
if (y < header_height)
{
menu_entries_pop_stack(&selection, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
}
2015-11-01 19:44:04 +00:00
else if (ptr <= (menu_entries_get_size() - 1))
{
2015-11-01 19:44:04 +00:00
if (ptr == selection && cbs && cbs->action_select)
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
2015-11-01 19:44:04 +00:00
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
}
return 0;
}
2014-10-08 23:21:22 +00:00
menu_ctx_driver_t menu_ctx_xmb = {
NULL,
2015-03-08 12:17:07 +00:00
xmb_render_messagebox_internal,
generic_menu_iterate,
xmb_render,
2014-10-08 23:21:22 +00:00
xmb_frame,
xmb_init,
xmb_free,
xmb_context_reset,
2014-10-09 20:59:05 +00:00
xmb_context_destroy,
xmb_populate_entries,
xmb_toggle,
xmb_navigation_clear,
xmb_navigation_pointer_changed,
xmb_navigation_pointer_changed,
xmb_navigation_set,
xmb_navigation_pointer_changed,
2015-06-06 22:41:53 +00:00
xmb_navigation_alphabet,
xmb_navigation_alphabet,
xmb_menu_init_list,
xmb_list_insert,
xmb_list_free,
2015-06-15 17:59:07 +00:00
xmb_list_clear,
xmb_list_cache,
xmb_list_push,
2015-06-15 17:00:52 +00:00
xmb_list_get_selection,
2015-06-07 13:43:03 +00:00
xmb_list_get_size,
xmb_list_get_entry,
2015-02-11 20:00:34 +00:00
NULL,
2015-06-08 14:01:57 +00:00
xmb_list_bind_init,
xmb_load_image,
2014-10-08 23:21:22 +00:00
"xmb",
2015-08-17 03:05:29 +00:00
MENU_VIDEO_DRIVER_OPENGL,
2015-07-07 22:37:44 +00:00
xmb_environ,
xmb_pointer_tap,
2014-10-08 23:21:22 +00:00
};