4469 lines
128 KiB
C
Raw Normal View History

2014-10-09 01:21:22 +02:00
/* RetroArch - A frontend for libretro.
2017-01-22 13:40:32 +01:00
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
* Copyright (C) 2016-2017 - Brad Parker
2014-10-09 01:21:22 +02: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 07:27:42 +02:00
#include <stdint.h>
2014-10-09 01:21:22 +02:00
#include <string.h>
#include <limits.h>
2015-06-05 18:22:15 +02:00
#include <file/file_path.h>
#include <compat/posix_string.h>
#include <compat/strl.h>
#include <formats/image.h>
2015-06-05 18:22:15 +02:00
#include <string/stdstring.h>
#include <lists/string_list.h>
#include <gfx/math/matrix_4x4.h>
#include <encodings/utf.h>
#include <features/features_cpu.h>
2015-06-04 22:46:23 +02:00
2016-09-08 06:00:45 +02:00
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
2016-09-15 16:07:20 +02:00
#ifndef HAVE_DYNAMIC
#include "../../frontend/frontend_driver.h"
#endif
2015-10-03 03:15:47 +02:00
#include "menu_generic.h"
#include "../menu_driver.h"
#include "../menu_animation.h"
2017-08-16 01:10:27 +02:00
#include "../../core_info.h"
#include "../../core.h"
2016-09-15 16:07:20 +02:00
#include "../widgets/menu_entry.h"
2016-09-15 00:10:37 +02:00
#include "../widgets/menu_list.h"
2016-09-15 19:26:04 +02:00
#include "../widgets/menu_input_dialog.h"
#include "../widgets/menu_osk.h"
#include "../widgets/menu_filebrowser.h"
2016-09-15 00:10:37 +02:00
#include "../menu_event.h"
2015-06-04 22:46:23 +02:00
2015-11-23 12:03:38 +01:00
#include "../../verbosity.h"
#include "../../configuration.h"
#include "../../playlist.h"
2017-05-11 09:11:46 +02:00
#include "../../retroarch.h"
2014-10-09 01:21:22 +02:00
#include "../../tasks/tasks_internal.h"
2015-04-13 18:59:39 +02:00
#define XMB_RIBBON_ROWS 64
#define XMB_RIBBON_COLS 64
#define XMB_RIBBON_VERTICES 2*XMB_RIBBON_COLS*XMB_RIBBON_ROWS-2*XMB_RIBBON_COLS
2016-04-16 21:09:54 +02:00
2014-10-09 02:41:08 +02:00
#ifndef XMB_DELAY
2015-03-06 16:00:46 +01:00
#define XMB_DELAY 10
2014-10-09 02:41:08 +02:00
#endif
#define BATTERY_LEVEL_CHECK_INTERVAL (30 * 1000000)
2016-12-12 03:28:55 +01:00
#if 0
2016-12-12 03:20:00 +01:00
#define XMB_DEBUG
#endif
/* NOTE: If you change this you HAVE to update
* xmb_alloc_node() and xmb_copy_node() */
2014-10-09 02:41:08 +02:00
typedef struct
{
float alpha;
2014-10-20 20:00:39 +02:00
float label_alpha;
2014-10-09 02:41:08 +02:00
float zoom;
2014-10-20 20:00:39 +02:00
float x;
2014-10-09 02:41:08 +02:00
float y;
uintptr_t icon;
uintptr_t content_icon;
char *fullpath;
2014-10-09 02:41:08 +02:00
} xmb_node_t;
enum
{
2015-10-20 19:11:43 +07:00
XMB_TEXTURE_MAIN_MENU = 0,
XMB_TEXTURE_SETTINGS,
2015-10-23 01:05:51 +07:00
XMB_TEXTURE_HISTORY,
XMB_TEXTURE_FAVORITES,
2016-07-30 19:29:10 +02:00
XMB_TEXTURE_MUSICS,
#ifdef HAVE_FFMPEG
XMB_TEXTURE_MOVIES,
2016-07-30 19:29:10 +02:00
#endif
#ifdef HAVE_NETWORKING
XMB_TEXTURE_NETPLAY,
XMB_TEXTURE_ROOM,
2017-07-24 20:52:27 -05:00
/* stub these out until we have the icons
XMB_TEXTURE_ROOM_LAN,
2017-07-24 20:52:27 -05:00
XMB_TEXTURE_ROOM_MITM,*/
#endif
2016-07-30 19:29:10 +02:00
#ifdef HAVE_IMAGEVIEWER
XMB_TEXTURE_IMAGES,
#endif
2014-10-09 22:59:05 +02:00
XMB_TEXTURE_SETTING,
XMB_TEXTURE_SUBSETTING,
XMB_TEXTURE_ARROW,
XMB_TEXTURE_RUN,
XMB_TEXTURE_CLOSE,
2014-10-09 22:59:05 +02:00
XMB_TEXTURE_RESUME,
XMB_TEXTURE_SAVESTATE,
XMB_TEXTURE_LOADSTATE,
2016-09-13 22:58:52 +02:00
XMB_TEXTURE_UNDO,
XMB_TEXTURE_CORE_INFO,
2016-09-22 12:36:36 +02:00
XMB_TEXTURE_WIFI,
XMB_TEXTURE_CORE_OPTIONS,
XMB_TEXTURE_INPUT_REMAPPING_OPTIONS,
XMB_TEXTURE_CHEAT_OPTIONS,
XMB_TEXTURE_DISK_OPTIONS,
2015-06-25 11:47:20 +07:00
XMB_TEXTURE_SHADER_OPTIONS,
2015-11-19 15:14:19 +07:00
XMB_TEXTURE_ACHIEVEMENT_LIST,
2014-10-09 22:59:05 +02:00
XMB_TEXTURE_SCREENSHOT,
XMB_TEXTURE_RELOAD,
2017-08-18 18:30:31 +07:00
XMB_TEXTURE_RENAME,
2014-10-14 23:05:53 +02:00
XMB_TEXTURE_FILE,
XMB_TEXTURE_FOLDER,
XMB_TEXTURE_ZIP,
XMB_TEXTURE_FAVORITE,
XMB_TEXTURE_ADD_FAVORITE,
2015-06-30 23:07:22 +07:00
XMB_TEXTURE_MUSIC,
2015-07-01 19:53:34 +07:00
XMB_TEXTURE_IMAGE,
2015-07-04 07:14:26 +07:00
XMB_TEXTURE_MOVIE,
2014-10-18 16:26:02 +02:00
XMB_TEXTURE_CORE,
2015-02-03 00:27:18 +01:00
XMB_TEXTURE_RDB,
XMB_TEXTURE_CURSOR,
XMB_TEXTURE_SWITCH_ON,
XMB_TEXTURE_SWITCH_OFF,
2015-02-04 22:44:33 +01:00
XMB_TEXTURE_CLOCK,
XMB_TEXTURE_BATTERY_FULL,
XMB_TEXTURE_BATTERY_CHARGING,
2015-03-09 00:14:55 +01:00
XMB_TEXTURE_POINTER,
XMB_TEXTURE_ADD,
2016-11-03 08:55:24 +01:00
XMB_TEXTURE_KEY,
XMB_TEXTURE_KEY_HOVER,
2017-02-27 20:34:17 +01:00
XMB_TEXTURE_DIALOG_SLICE,
2014-10-09 22:59:05 +02:00
XMB_TEXTURE_LAST
};
2014-10-09 01:21:22 +02:00
enum
{
XMB_SYSTEM_TAB_MAIN = 0,
XMB_SYSTEM_TAB_SETTINGS,
2016-08-21 00:09:29 -05:00
XMB_SYSTEM_TAB_HISTORY,
XMB_SYSTEM_TAB_FAVORITES,
2016-08-21 00:09:29 -05:00
XMB_SYSTEM_TAB_MUSIC,
#ifdef HAVE_FFMPEG
2016-12-12 03:54:53 -06:00
XMB_SYSTEM_TAB_VIDEO,
2016-08-21 00:09:29 -05:00
#endif
#ifdef HAVE_IMAGEVIEWER
XMB_SYSTEM_TAB_IMAGES,
#endif
#ifdef HAVE_NETWORKING
XMB_SYSTEM_TAB_NETPLAY,
#endif
XMB_SYSTEM_TAB_ADD
};
typedef struct xmb_handle
{
2017-09-28 08:42:12 +02:00
bool mouse_show;
uint8_t system_tab_end;
uint8_t tabs[8];
int depth;
int old_depth;
2017-09-28 08:42:12 +02:00
int icon_size;
int cursor_size;
size_t categories_selection_ptr;
size_t categories_selection_ptr_old;
size_t selection_ptr_old;
unsigned categories_active_idx;
unsigned categories_active_idx_old;
2016-04-08 01:42:53 +07:00
uintptr_t thumbnail;
2016-12-01 02:43:53 +01:00
uintptr_t savestate_thumbnail;
2017-09-28 08:42:12 +02:00
float x;
float alpha;
2016-04-08 01:42:53 +07:00
float thumbnail_width;
float thumbnail_height;
2016-12-01 02:43:53 +01:00
float savestate_thumbnail_width;
float savestate_thumbnail_height;
float above_subitem_offset;
float above_item_offset;
float active_item_factor;
float under_item_offset;
2016-05-09 03:57:02 +07:00
float shadow_offset;
2017-09-28 08:42:12 +02:00
float font_size;
float font2_size;
float margins_screen_left;
float margins_screen_top;
float margins_setting_left;
float margins_title_left;
float margins_title_top;
float margins_title_bottom;
float margins_label_left;
float margins_label_top;
float icon_spacing_horizontal;
float icon_spacing_vertical;
float items_active_alpha;
float items_active_zoom;
float items_passive_alpha;
float items_passive_zoom;
float margins_dialog;
float margins_slice;
float textures_arrow_alpha;
float categories_x_pos;
float categories_passive_alpha;
float categories_passive_zoom;
float categories_active_zoom;
float categories_active_alpha;
uint64_t frame_count;
2016-05-09 03:57:02 +07:00
char title_name[255];
2017-09-29 19:55:06 +02:00
char *box_message;
char *thumbnail_system;
2017-09-29 18:37:04 +02:00
char *thumbnail_content;
2017-09-29 19:55:06 +02:00
char *savestate_thumbnail_file_path;
char background_file_path[PATH_MAX_LENGTH];
2017-09-28 08:42:12 +02:00
char thumbnail_file_path[PATH_MAX_LENGTH];
file_list_t *selection_buf_old;
file_list_t *horizontal_list;
2015-02-12 18:34:36 +01:00
2016-03-09 16:17:18 -05:00
struct
{
2016-03-05 08:40:28 +01:00
menu_texture_item bg;
menu_texture_item list[XMB_TEXTURE_LAST];
} textures;
2015-10-20 19:11:43 +07:00
xmb_node_t main_menu_node;
2016-07-30 19:29:10 +02:00
#ifdef HAVE_IMAGEVIEWER
xmb_node_t images_tab_node;
#endif
xmb_node_t music_tab_node;
2016-07-30 19:29:10 +02:00
#ifdef HAVE_FFMPEG
xmb_node_t video_tab_node;
#endif
2015-10-20 19:11:43 +07:00
xmb_node_t settings_tab_node;
2015-10-23 01:05:51 +07:00
xmb_node_t history_tab_node;
xmb_node_t favorites_tab_node;
xmb_node_t add_tab_node;
xmb_node_t netplay_tab_node;
font_data_t *font;
2016-10-20 09:52:17 +02:00
font_data_t *font2;
2016-05-10 02:42:02 +02:00
video_font_raster_block_t raster_block;
2016-10-20 09:52:17 +02:00
video_font_raster_block_t raster_block2;
} xmb_handle_t;
static float coord_shadow[] = {
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0, 0
};
static float coord_black[] = {
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0,
0, 0, 0, 0
};
static float coord_white[] = {
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1, 1
};
static float item_color[] = {
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1,
1, 1, 1, 1
};
2016-04-22 15:20:08 +07:00
float gradient_dark_purple[16] = {
20/255.0, 13/255.0, 20/255.0, 1.0,
20/255.0, 13/255.0, 20/255.0, 1.0,
92/255.0, 44/255.0, 92/255.0, 1.0,
148/255.0, 90/255.0, 148/255.0, 1.0,
2016-04-22 13:47:14 +07:00
};
float gradient_midnight_blue[16] = {
44/255.0, 62/255.0, 80/255.0, 1.0,
44/255.0, 62/255.0, 80/255.0, 1.0,
44/255.0, 62/255.0, 80/255.0, 1.0,
44/255.0, 62/255.0, 80/255.0, 1.0,
};
2016-04-22 15:20:08 +07:00
float gradient_golden[16] = {
174/255.0, 123/255.0, 44/255.0, 1.0,
205/255.0, 174/255.0, 84/255.0, 1.0,
58/255.0, 43/255.0, 24/255.0, 1.0,
58/255.0, 43/255.0, 24/255.0, 1.0,
2016-04-22 13:47:14 +07:00
};
2016-04-22 15:20:08 +07:00
float gradient_legacy_red[16] = {
171/255.0, 70/255.0, 59/255.0, 1.0,
171/255.0, 70/255.0, 59/255.0, 1.0,
190/255.0, 80/255.0, 69/255.0, 1.0,
190/255.0, 80/255.0, 69/255.0, 1.0,
};
float gradient_electric_blue[16] = {
1/255.0, 2/255.0, 67/255.0, 1.0,
1/255.0, 73/255.0, 183/255.0, 1.0,
1/255.0, 93/255.0, 194/255.0, 1.0,
3/255.0, 162/255.0, 254/255.0, 1.0,
};
float gradient_apple_green[16] = {
102/255.0, 134/255.0, 58/255.0, 1.0,
122/255.0, 131/255.0, 52/255.0, 1.0,
82/255.0, 101/255.0, 35/255.0, 1.0,
63/255.0, 95/255.0, 30/255.0, 1.0,
};
float gradient_undersea[16] = {
23/255.0, 18/255.0, 41/255.0, 1.0,
30/255.0, 72/255.0, 114/255.0, 1.0,
52/255.0, 88/255.0, 110/255.0, 1.0,
69/255.0, 125/255.0, 140/255.0, 1.0,
2016-04-22 13:47:14 +07:00
};
2016-04-22 18:16:31 +07:00
float gradient_volcanic_red[16] = {
1.0, 0.0, 0.1, 1.00,
1.0, 0.1, 0.0, 1.00,
0.1, 0.0, 0.1, 1.00,
0.1, 0.0, 0.1, 1.00,
};
float gradient_dark[16] = {
0.1, 0.1, 0.1, 1.00,
0.1, 0.1, 0.1, 1.00,
0.0, 0.0, 0.0, 1.00,
0.0, 0.0, 0.0, 1.00,
};
static void xmb_calculate_visible_range(const xmb_handle_t *xmb,
unsigned height, size_t list_size, unsigned current,
unsigned *first, unsigned *last);
2017-01-14 04:06:56 -05:00
const char* xmb_theme_ident(void)
2016-03-22 02:54:16 +07:00
{
settings_t *settings = config_get_ptr();
2017-04-28 21:03:04 +02:00
switch (settings->uints.menu_xmb_theme)
2016-03-22 02:54:16 +07:00
{
case XMB_ICON_THEME_FLATUI:
2016-03-22 02:54:16 +07:00
return "flatui";
case XMB_ICON_THEME_RETROACTIVE:
return "retroactive";
case XMB_ICON_THEME_PIXEL:
return "pixel";
2016-10-31 21:15:33 +01:00
case XMB_ICON_THEME_NEOACTIVE:
return "neoactive";
2016-12-08 23:39:39 -06:00
case XMB_ICON_THEME_SYSTEMATIC:
return "systematic";
2017-01-30 21:13:44 -05:00
case XMB_ICON_THEME_DOTART:
return "dot-art";
case XMB_ICON_THEME_CUSTOM:
2016-03-22 02:54:16 +07:00
return "custom";
case XMB_ICON_THEME_MONOCHROME:
2016-03-22 02:54:16 +07:00
default:
2016-03-21 21:18:25 +01:00
break;
2016-03-22 02:54:16 +07:00
}
2016-03-21 21:18:25 +01:00
return "monochrome";
2016-03-22 02:54:16 +07:00
}
/* NOTE: This exists because calloc()ing xmb_node_t is expensive
* when you can have big lists like MAME and fba playlists */
static xmb_node_t *xmb_alloc_node(void)
{
xmb_node_t *node = (xmb_node_t*)malloc(sizeof(*node));
node->alpha = node->label_alpha = 0;
node->zoom = node->x = node->y = 0;
node->icon = node->content_icon = 0;
node->fullpath = NULL;
return node;
}
static void xmb_free_node(xmb_node_t *node)
{
if (!node)
return;
if (node->fullpath)
free(node->fullpath);
node->fullpath = NULL;
free(node);
}
/**
* @brief frees all xmb_node_t in a file_list_t
*
* file_list_t asumes userdata holds a simple structure and
* free()'s it. Can't change this at the time because other
* code depends on this behavior.
*
* @param list
* @param actiondata whether to free actiondata too
*/
static void xmb_free_list_nodes(file_list_t *list, bool actiondata)
{
unsigned i, size = file_list_get_size(list);
for (i = 0; i < size; ++i)
{
xmb_free_node((xmb_node_t*)file_list_get_userdata_at_offset(list, i));
/* file_list_set_userdata() doesn't accept NULL */
list->list[i].userdata = NULL;
if (actiondata)
file_list_free_actiondata(list, i);
}
}
static xmb_node_t *xmb_copy_node(const xmb_node_t *old_node)
{
xmb_node_t *new_node = (xmb_node_t*)malloc(sizeof(*new_node));
*new_node = *old_node;
new_node->fullpath = old_node->fullpath ? strdup(old_node->fullpath) : NULL;
return new_node;
}
2016-04-08 01:42:53 +07:00
static const char *xmb_thumbnails_ident(void)
{
settings_t *settings = config_get_ptr();
2016-04-16 05:07:08 +02:00
2017-04-28 21:03:04 +02:00
switch (settings->uints.menu_thumbnails)
2016-04-08 01:42:53 +07:00
{
case 1:
return "Named_Snaps";
case 2:
return "Named_Titles";
case 3:
return "Named_Boxarts";
2016-04-16 05:07:08 +02:00
case 0:
2016-04-08 01:42:53 +07:00
default:
break;
}
2016-12-15 11:23:08 +01:00
return msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
2016-04-08 01:42:53 +07:00
}
static float *xmb_gradient_ident(video_frame_info_t *video_info)
2016-04-22 13:47:14 +07:00
{
switch (video_info->xmb_color_theme)
2016-04-22 13:47:14 +07:00
{
2016-07-14 18:19:59 +02:00
case XMB_THEME_DARK_PURPLE:
2016-04-22 15:20:08 +07:00
return &gradient_dark_purple[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_MIDNIGHT_BLUE:
2016-04-22 13:47:14 +07:00
return &gradient_midnight_blue[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_GOLDEN:
2016-04-22 15:20:08 +07:00
return &gradient_golden[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_ELECTRIC_BLUE:
2016-04-22 15:20:08 +07:00
return &gradient_electric_blue[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_APPLE_GREEN:
2016-04-22 15:20:08 +07:00
return &gradient_apple_green[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_UNDERSEA:
2016-04-22 15:20:08 +07:00
return &gradient_undersea[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_VOLCANIC_RED:
2016-04-22 18:16:31 +07:00
return &gradient_volcanic_red[0];
2016-07-14 18:19:59 +02:00
case XMB_THEME_DARK:
return &gradient_dark[0];
2016-07-14 18:20:36 +02:00
case XMB_THEME_LEGACY_RED:
2016-04-22 13:47:14 +07:00
default:
break;
}
2016-04-22 15:20:08 +07:00
return &gradient_legacy_red[0];
2016-04-22 13:47:14 +07:00
}
2015-06-15 19:00:52 +02:00
static size_t xmb_list_get_selection(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-06-15 19:00:52 +02:00
2015-07-08 17:26:23 +02:00
if (!xmb)
return 0;
2017-09-28 08:42:12 +02:00
return xmb->categories_selection_ptr;
2015-06-15 19:00:52 +02:00
}
static size_t xmb_list_get_size(void *data, enum menu_list_type type)
2015-06-07 14:29:43 +02:00
{
2015-12-10 15:23:43 +01:00
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-07-08 17:26:23 +02:00
switch (type)
{
case MENU_LIST_PLAIN:
2016-03-03 06:59:54 +01:00
return menu_entries_get_stack_size(0);
2015-07-08 17:26:23 +02:00
case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list)
2016-03-03 06:59:54 +01:00
return file_list_get_size(xmb->horizontal_list);
2015-07-08 17:26:23 +02:00
break;
case MENU_LIST_TABS:
2016-08-18 16:42:39 +02:00
return xmb->system_tab_end;
2015-07-08 17:26:23 +02:00
}
2016-03-03 06:59:54 +01:00
return 0;
2015-06-07 14:29:43 +02:00
}
static void *xmb_list_get_entry(void *data, enum menu_list_type type, unsigned i)
{
2015-10-17 18:17:59 +02:00
size_t list_size = 0;
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-07-08 17:26:23 +02:00
switch (type)
{
case MENU_LIST_PLAIN:
2016-04-21 04:17:45 +02:00
{
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
list_size = menu_entries_get_stack_size(0);
if (i < list_size)
return (void*)&menu_stack->list[i];
}
2015-07-08 17:26:23 +02:00
break;
case MENU_LIST_HORIZONTAL:
if (xmb && xmb->horizontal_list)
list_size = file_list_get_size(xmb->horizontal_list);
if (i < list_size)
2016-04-21 04:17:45 +02:00
return (void*)&xmb->horizontal_list->list[i];
2015-07-08 17:26:23 +02:00
break;
default:
break;
2015-07-08 17:26:23 +02:00
}
2016-04-21 04:17:45 +02:00
return NULL;
}
static INLINE float xmb_item_y(const xmb_handle_t *xmb, int i, size_t current)
{
2017-09-28 08:42:12 +02:00
float iy = xmb->icon_spacing_vertical;
2015-03-16 17:40:05 +01:00
if (i < (int)current)
if (xmb->depth > 1)
iy *= (i - (int)current + xmb->above_subitem_offset);
else
iy *= (i - (int)current + xmb->above_item_offset);
else
iy *= (i - (int)current + xmb->under_item_offset);
2015-03-16 17:40:05 +01:00
if (i == (int)current)
2017-09-28 08:42:12 +02:00
iy = xmb->icon_spacing_vertical * xmb->active_item_factor;
return iy;
}
2016-04-21 09:14:25 +02:00
static void xmb_draw_icon(
menu_display_frame_info_t menu_disp_info,
2016-04-21 09:18:03 +02:00
int icon_size,
math_matrix_4x4 *mymat,
uintptr_t texture,
2016-04-21 09:14:25 +02:00
float x,
float y,
unsigned width,
unsigned height,
float alpha,
float rotation,
float scale_factor,
2016-05-09 03:57:02 +07:00
float *color,
float shadow_offset)
2014-10-09 01:21:22 +02:00
{
menu_display_ctx_draw_t draw;
2016-05-10 02:32:49 +02:00
struct video_coords coords;
2015-02-01 15:25:37 +01:00
if (
2016-12-14 16:47:10 +01:00
(x < (-icon_size / 2.0f)) ||
(x > width) ||
(y < (icon_size / 2.0f)) ||
(y > height + icon_size)
)
2014-10-09 01:21:22 +02:00
return;
2015-02-02 20:48:26 +01:00
coords.vertices = 4;
coords.vertex = NULL;
2015-11-02 22:46:23 +01:00
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2014-10-09 01:21:22 +02:00
2016-04-21 09:18:03 +02:00
draw.width = icon_size;
draw.height = icon_size;
2017-05-22 07:34:30 +01:00
#if defined(VITA) || defined(WIIU)
2016-12-14 16:47:10 +01:00
draw.width *= scale_factor;
draw.height *= scale_factor;
2016-08-23 02:49:53 +02:00
#endif
2016-04-21 09:14:25 +02:00
draw.coords = &coords;
draw.matrix_data = mymat;
draw.texture = texture;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
2016-05-08 11:11:28 +02:00
draw.pipeline.id = 0;
if (menu_disp_info.shadows_enable)
2016-04-08 00:24:55 +07:00
{
menu_display_set_alpha(coord_shadow, color[3] * 0.35f);
2016-04-08 00:24:55 +07:00
coords.color = coord_shadow;
2016-05-09 03:57:02 +07:00
draw.x = x + shadow_offset;
draw.y = height - y - shadow_offset;
2016-12-14 16:47:10 +01:00
2017-05-22 07:34:30 +01:00
#if defined(VITA) || defined(WIIU)
2016-12-14 16:47:10 +01:00
if(scale_factor < 1)
{
draw.x = draw.x + (icon_size-draw.width)/2;
draw.y = draw.y + (icon_size-draw.width)/2;
2016-08-23 02:49:53 +02:00
}
#endif
menu_display_draw(&draw);
2016-04-08 00:24:55 +07:00
}
2016-04-21 09:14:25 +02:00
coords.color = (const float*)color;
draw.x = x;
draw.y = height - y;
2016-12-14 16:47:10 +01:00
2017-05-22 07:34:30 +01:00
#if defined(VITA) || defined(WIIU)
2016-12-14 16:47:10 +01:00
if(scale_factor < 1)
{
2016-08-23 02:49:53 +02:00
draw.x = draw.x + (icon_size-draw.width)/2;
draw.y = draw.y + (icon_size-draw.width)/2;
}
#endif
menu_display_draw(&draw);
2014-10-09 01:21:22 +02:00
}
static void xmb_draw_thumbnail(
menu_display_frame_info_t menu_disp_info,
xmb_handle_t *xmb, float *color,
unsigned width, unsigned height,
2017-05-29 20:58:15 +02:00
float x, float y,
float w, float h, uintptr_t texture)
{
2016-02-09 04:43:15 +01:00
menu_display_ctx_rotate_draw_t rotate_draw;
menu_display_ctx_draw_t draw;
2016-05-10 02:32:49 +02:00
struct video_coords coords;
math_matrix_4x4 mymat;
2016-02-09 04:43:15 +01:00
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;
rotate_draw.scale_x = 1;
rotate_draw.scale_y = 1;
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw);
2016-12-14 16:47:10 +01:00
coords.vertices = 4;
coords.vertex = NULL;
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
2016-12-14 16:47:10 +01:00
draw.width = w;
draw.height = h;
draw.coords = &coords;
draw.matrix_data = &mymat;
draw.texture = texture;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
draw.pipeline.id = 0;
if (menu_disp_info.shadows_enable)
{
menu_display_set_alpha(coord_shadow, color[3] * 0.35f);
coords.color = coord_shadow;
2016-12-14 16:47:10 +01:00
draw.x = x + xmb->shadow_offset;
draw.y = height - y - xmb->shadow_offset;
menu_display_draw(&draw);
}
2016-12-14 16:47:10 +01:00
coords.color = (const float*)color;
draw.x = x;
draw.y = height - y;
2017-05-27 16:52:52 +02:00
menu_display_set_alpha(color, 1.0f);
menu_display_draw(&draw);
}
static void xmb_draw_text(
menu_display_frame_info_t menu_disp_info,
xmb_handle_t *xmb,
2015-04-21 16:45:27 +02:00
const char *str, float x,
float y, float scale_factor, float alpha,
enum text_alignment text_align,
2016-10-20 09:52:17 +02:00
unsigned width, unsigned height, font_data_t* font)
2014-10-09 01:21:22 +02:00
{
uint32_t color;
2017-01-09 23:11:05 +01:00
uint8_t a8;
if (alpha > xmb->alpha)
2017-01-09 23:11:05 +01:00
alpha = xmb->alpha;
a8 = 255 * alpha;
2015-02-01 15:25:37 +01:00
/* Avoid drawing 100% transparent text */
2014-10-09 01:21:22 +02:00
if (a8 == 0)
return;
color = FONT_COLOR_RGBA(255, 255, 255, a8);
2016-04-08 00:24:55 +07:00
menu_display_draw_text(font, str, x, y,
width, height, color, text_align, scale_factor,
menu_disp_info.shadows_enable,
xmb->shadow_offset);
2014-10-09 01:21:22 +02:00
}
2015-12-10 14:40:56 +01:00
static void xmb_messagebox(void *data, const char *message)
2014-10-09 01:21:22 +02:00
{
2015-12-10 14:40:56 +01:00
xmb_handle_t *xmb = (xmb_handle_t*)data;
2014-10-09 01:21:22 +02:00
2016-12-14 16:47:10 +01:00
if (!xmb || string_is_empty(message))
2014-10-09 01:21:22 +02:00
return;
2017-09-29 19:55:06 +02:00
xmb->box_message = strdup(message);
2014-10-09 01:21:22 +02:00
}
static void xmb_render_keyboard(xmb_handle_t *xmb,
video_frame_info_t *video_info,
const char *grid[], unsigned id)
{
unsigned i;
2016-11-04 14:29:02 +01:00
int ptr_width, ptr_height;
2017-01-19 21:37:13 +01:00
unsigned width = video_info->width;
unsigned height = video_info->height;
float dark[16] = {
2016-11-03 08:55:24 +01:00
0.00, 0.00, 0.00, 0.85,
0.00, 0.00, 0.00, 0.85,
0.00, 0.00, 0.00, 0.85,
0.00, 0.00, 0.00, 0.85,
};
2016-11-03 08:55:24 +01:00
float white[16]= {
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
1.00, 1.00, 1.00, 1.00,
};
2016-10-25 08:11:37 +02:00
menu_display_draw_quad(0, height/2.0, width, height/2.0,
width, height,
&dark[0]);
2016-11-04 14:29:02 +01:00
ptr_width = width / 11;
ptr_height = height / 10;
if (ptr_width >= ptr_height)
ptr_width = ptr_height;
2016-11-03 08:55:24 +01:00
for (i = 0; i < 44; i++)
{
int line_y = (i / 11) * height / 10.0;
2016-12-14 16:47:10 +01:00
if (i == id)
{
uintptr_t texture = xmb->textures.list[XMB_TEXTURE_KEY_HOVER];
2016-11-03 08:55:24 +01:00
menu_display_blend_begin();
2016-11-03 08:55:24 +01:00
menu_display_draw_texture(
width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width,
height/2.0 + ptr_height*1.5 + line_y,
ptr_width, ptr_height,
width, height,
&white[0],
texture);
2016-11-03 08:55:24 +01:00
menu_display_blend_end();
}
menu_display_draw_text(xmb->font, grid[i],
2016-11-03 08:55:24 +01:00
width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width + ptr_width/2.0,
height/2.0 + ptr_height + line_y + xmb->font->size / 3,
width, height, 0xffffffff, TEXT_ALIGN_CENTER, 1.0f,
false, 0);
}
}
2016-10-30 11:48:35 +01:00
/* Returns the OSK key at a given position */
static int xmb_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height)
2016-10-30 11:48:35 +01:00
{
unsigned i;
2016-11-04 14:29:02 +01:00
int ptr_width, ptr_height;
2016-10-30 11:48:35 +01:00
xmb_handle_t *xmb = (xmb_handle_t*)data;
2016-10-30 11:48:35 +01:00
if (!xmb)
return -1;
ptr_width = width / 11;
2016-11-04 14:29:02 +01:00
ptr_height = height / 10;
if (ptr_width >= ptr_height)
ptr_width = ptr_height;
2016-11-03 08:55:24 +01:00
for (i = 0; i < 44; i++)
2016-10-30 11:48:35 +01:00
{
2016-10-31 19:36:33 +01:00
int line_y = (i / 11)*height/10.0;
2016-11-03 08:55:24 +01:00
int ptr_x = width/2.0 - (11*ptr_width)/2.0 + (i % 11) * ptr_width;
int ptr_y = height/2.0 + ptr_height*1.5 + line_y - ptr_height;
2016-10-30 11:48:35 +01:00
if (x > ptr_x && x < ptr_x + ptr_width
&& y > ptr_y && y < ptr_y + ptr_height)
2016-10-30 11:48:35 +01:00
return i;
}
return -1;
}
2016-02-04 21:40:29 +01:00
static void xmb_render_messagebox_internal(
menu_display_frame_info_t menu_disp_info,
video_frame_info_t *video_info,
2017-02-27 20:34:17 +01:00
xmb_handle_t *xmb, const char *message, float* coord_white)
2014-10-09 01:21:22 +02:00
{
unsigned i, y_position;
int x, y, longest = 0, longest_width = 0;
2017-02-27 20:34:17 +01:00
float line_height = 0;
unsigned width = video_info->width;
unsigned height = video_info->height;
struct string_list *list = string_split(message, "\n");
2014-10-09 01:21:22 +02:00
if (!list)
return;
2014-10-09 01:21:22 +02:00
if (list->elems == 0)
2015-02-11 06:27:28 +01:00
goto end;
2014-10-09 01:21:22 +02:00
2017-02-27 20:34:17 +01:00
line_height = xmb->font->size * 1.2;
y_position = height / 2;
if (menu_input_dialog_get_display_kb())
y_position = height / 4;
2016-08-10 22:30:17 +02:00
x = width / 2;
2017-02-27 20:34:17 +01:00
y = y_position - (list->size-1) * line_height / 2;
2016-08-10 22:30:17 +02:00
/* find the longest line width */
for (i = 0; i < list->size; i++)
{
const char *msg = list->elems[i].data;
int len = (int)utf8len(msg);
2016-08-10 22:30:17 +02:00
if (len > longest)
{
longest = len;
longest_width = font_driver_get_message_width(xmb->font, msg, strlen(msg), 1);
2016-08-10 22:30:17 +02:00
}
}
2017-02-27 20:34:17 +01:00
menu_display_blend_begin();
menu_display_draw_texture_slice(
2017-09-28 08:42:12 +02:00
x - longest_width/2 - xmb->margins_dialog,
y + xmb->margins_slice - xmb->margins_dialog,
2017-02-27 20:34:17 +01:00
256, 256,
2017-09-28 08:42:12 +02:00
longest_width + xmb->margins_dialog * 2,
line_height * list->size + xmb->margins_dialog * 2,
2017-02-27 20:34:17 +01:00
width, height,
&coord_white[0],
2017-09-28 08:42:12 +02:00
xmb->margins_slice, 1.0, xmb->textures.list[XMB_TEXTURE_DIALOG_SLICE]);
2017-02-27 20:34:17 +01:00
2014-10-09 01:21:22 +02:00
for (i = 0; i < list->size; i++)
{
const char *msg = list->elems[i].data;
2014-10-09 22:45:29 +02:00
if (msg)
2017-02-27 20:34:17 +01:00
menu_display_draw_text(xmb->font, msg,
2016-08-10 22:30:17 +02:00
x - longest_width/2.0,
2017-02-27 20:34:17 +01:00
y + (i+0.75) * line_height,
width, height, 0x444444ff, TEXT_ALIGN_LEFT, 1.0f, false, 0);
2014-10-09 01:21:22 +02:00
}
if (menu_input_dialog_get_display_kb())
2016-12-14 16:47:10 +01:00
xmb_render_keyboard(xmb,
video_info,
2016-12-14 16:47:10 +01:00
menu_event_get_osk_grid(),
menu_event_get_osk_ptr());
2015-02-11 06:27:28 +01:00
end:
2014-10-09 01:21:22 +02:00
string_list_free(list);
}
static void xmb_update_thumbnail_path(void *data, unsigned i)
2015-06-18 09:32:56 +07:00
{
2017-09-29 18:37:04 +02:00
menu_entry_t entry;
2017-09-28 07:15:29 +02:00
unsigned entry_type = 0;
2016-11-20 14:48:00 +01:00
char *scrub_char_pointer = NULL;
settings_t *settings = config_get_ptr();
xmb_handle_t *xmb = (xmb_handle_t*)data;
playlist_t *playlist = NULL;
const char *core_name = NULL;
2017-09-11 04:40:35 +02:00
char *tmp = NULL;
char *tmp_new = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
if (!xmb)
2017-09-11 04:40:35 +02:00
goto end;
2017-09-29 18:37:04 +02:00
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, NULL, true);
2015-06-18 09:32:56 +07:00
2017-09-29 18:37:04 +02:00
entry_type = menu_entry_get_type_new(&entry);
2017-09-28 07:15:29 +02:00
if (entry_type == FILE_TYPE_IMAGEVIEWER || entry_type == FILE_TYPE_IMAGE)
{
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
xmb_node_t *node = (xmb_node_t*)
menu_entries_get_userdata_at_offset(selection_buf, i);
if (node && node->fullpath)
{
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry.path))
2017-09-29 18:37:04 +02:00
fill_pathname_join(
xmb->thumbnail_file_path,
node->fullpath,
entry.path,
sizeof(xmb->thumbnail_file_path));
2017-09-11 04:40:35 +02:00
goto end;
}
}
else if (filebrowser_get_type() != FILEBROWSER_NONE)
{
xmb->thumbnail_file_path[0] = '\0';
xmb->thumbnail = 0;
2017-09-11 04:40:35 +02:00
goto end;
}
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
if (playlist)
{
playlist_get_index(playlist, i,
NULL, NULL, NULL, &core_name, NULL, NULL);
2017-05-28 17:53:45 +02:00
if (string_is_equal(core_name, "imageviewer"))
{
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry.label))
2017-09-29 18:37:04 +02:00
strlcpy(xmb->thumbnail_file_path, entry.label,
sizeof(xmb->thumbnail_file_path));
2017-09-11 04:40:35 +02:00
goto end;
}
}
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_system))
fill_pathname_join(
xmb->thumbnail_file_path,
settings->paths.directory_thumbnails,
xmb->thumbnail_system,
sizeof(xmb->thumbnail_file_path));
2016-04-08 01:42:53 +07:00
fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path,
xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path));
2017-01-30 21:13:44 -05:00
/* Scrub characters that are not cross-platform and/or violate the
2016-12-14 16:47:10 +01:00
* No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
2016-12-14 16:47:10 +01:00
* Replace these characters in the entry name with underscores.
*/
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_content))
2017-09-29 18:37:04 +02:00
tmp = strdup(xmb->thumbnail_content);
2016-12-08 23:39:39 -06:00
2017-09-30 06:11:18 +02:00
if (!string_is_empty(tmp))
2017-09-29 18:37:04 +02:00
{
while((scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\\|")))
*scrub_char_pointer = '_';
}
/* Look for thumbnail file with this scrubbed filename */
2016-12-06 07:12:28 +01:00
tmp_new[0] = '\0';
2016-10-16 01:45:50 +02:00
2017-09-30 06:11:18 +02:00
if (!string_is_empty(tmp))
2017-09-29 18:37:04 +02:00
{
fill_pathname_join(tmp_new,
xmb->thumbnail_file_path,
tmp, PATH_MAX_LENGTH * sizeof(char));
strlcpy(xmb->thumbnail_file_path,
tmp_new, sizeof(xmb->thumbnail_file_path));
free(tmp);
}
2016-07-01 17:04:11 +02:00
strlcat(xmb->thumbnail_file_path,
file_path_str(FILE_PATH_PNG_EXTENSION),
sizeof(xmb->thumbnail_file_path));
2017-09-11 04:40:35 +02:00
end:
2017-09-29 18:37:04 +02:00
menu_entry_free(&entry);
2017-09-11 04:40:35 +02:00
free(tmp_new);
}
2015-06-18 09:32:56 +07:00
2016-12-01 02:43:53 +01:00
static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
{
2017-09-29 18:37:04 +02:00
menu_entry_t entry;
2016-12-01 02:43:53 +01:00
settings_t *settings = config_get_ptr();
xmb_handle_t *xmb = (xmb_handle_t*)data;
playlist_t *playlist = NULL;
if (!xmb)
return;
2017-09-29 18:37:04 +02:00
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, NULL, true);
2016-12-01 02:43:53 +01:00
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->savestate_thumbnail_file_path))
2017-09-29 19:55:06 +02:00
free(xmb->savestate_thumbnail_file_path);
2017-09-30 07:10:58 +02:00
xmb->savestate_thumbnail_file_path = NULL;
2016-12-14 16:47:10 +01:00
2017-09-30 06:40:54 +02:00
if (!string_is_empty(entry.label))
2016-12-01 02:43:53 +01:00
{
2017-09-30 06:40:54 +02:00
if ( (settings->bools.savestate_thumbnail_enable)
&& ((string_is_equal_fast(entry.label, "state_slot", 10))
|| (string_is_equal_fast(entry.label, "loadstate", 9))
|| (string_is_equal_fast(entry.label, "savestate", 9))))
{
size_t path_size = 8024 * sizeof(char);
char *path = (char*)malloc(8204 * sizeof(char));
global_t *global = global_get_ptr();
2016-12-14 16:47:10 +01:00
2017-09-30 06:40:54 +02:00
path[0] = '\0';
2016-12-14 16:47:10 +01:00
2017-09-30 06:40:54 +02:00
if (global)
{
if (settings->ints.state_slot > 0)
snprintf(path, path_size, "%s%d",
global->name.savestate, settings->ints.state_slot);
else if (settings->ints.state_slot < 0)
fill_pathname_join_delim(path,
global->name.savestate, "auto", '.', path_size);
else
strlcpy(path, global->name.savestate, path_size);
}
2016-12-01 02:43:53 +01:00
2017-09-30 06:40:54 +02:00
strlcat(path, file_path_str(FILE_PATH_PNG_EXTENSION), path_size);
2016-12-01 02:43:53 +01:00
2017-09-30 06:40:54 +02:00
if (path_file_exists(path))
2017-09-30 07:10:58 +02:00
{
if (!string_is_empty(xmb->savestate_thumbnail_file_path))
free(xmb->savestate_thumbnail_file_path);
2017-09-30 06:40:54 +02:00
xmb->savestate_thumbnail_file_path = strdup(path);
2017-09-30 07:10:58 +02:00
}
2017-09-11 02:37:53 +02:00
2017-09-30 06:40:54 +02:00
free(path);
}
2016-12-01 02:43:53 +01:00
}
2017-09-28 06:02:14 +02:00
2017-09-29 18:37:04 +02:00
menu_entry_free(&entry);
2016-12-01 02:43:53 +01:00
}
static void xmb_update_thumbnail_image(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2016-04-08 01:42:53 +07:00
if (path_file_exists(xmb->thumbnail_file_path))
task_push_image_load(xmb->thumbnail_file_path,
menu_display_handle_thumbnail_upload, NULL);
else
xmb->thumbnail = 0;
2015-06-18 09:32:56 +07:00
}
static void xmb_set_thumbnail_system(void *data, char*s, size_t len)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_system))
2017-09-29 19:55:06 +02:00
free(xmb->thumbnail_system);
xmb->thumbnail_system = strdup(s);
}
static void xmb_reset_thumbnail_content(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_content))
2017-09-29 18:37:04 +02:00
free(xmb->thumbnail_content);
xmb->thumbnail_content = NULL;
}
static void xmb_set_thumbnail_content(void *data, char *s, size_t len)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_content))
2017-09-29 20:56:54 +02:00
free(xmb->thumbnail_content);
2017-09-29 18:37:04 +02:00
xmb->thumbnail_content = strdup(s);
}
2016-12-01 02:43:53 +01:00
static void xmb_update_savestate_thumbnail_image(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->savestate_thumbnail_file_path)
2017-09-29 19:55:06 +02:00
&& path_file_exists(xmb->savestate_thumbnail_file_path))
task_push_image_load(xmb->savestate_thumbnail_file_path,
2016-12-01 02:43:53 +01:00
menu_display_handle_savestate_thumbnail_upload, NULL);
else
xmb->savestate_thumbnail = 0;
}
2016-02-04 21:40:29 +01:00
static void xmb_selection_pointer_changed(
xmb_handle_t *xmb, bool allow_animations)
2014-10-09 02:41:08 +02:00
{
2017-01-16 23:38:46 +01:00
unsigned i, end, height;
menu_animation_ctx_tag tag;
2017-09-29 18:37:04 +02:00
menu_entry_t entry;
size_t num = 0;
int threshold = 0;
2015-12-11 22:05:54 +01:00
menu_list_t *menu_list = NULL;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
2017-05-29 01:46:57 +02:00
const char *thumb_ident = xmb_thumbnails_ident();
2015-12-11 22:05:54 +01:00
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
2014-10-10 15:52:12 +02:00
if (!xmb)
2017-09-29 16:47:30 +02:00
goto end;
2014-10-09 02:41:08 +02:00
2017-09-29 18:37:04 +02:00
menu_entry_init(&entry);
menu_entry_get(&entry, 0, selection, NULL, true);
end = (unsigned)menu_entries_get_end();
2017-09-28 08:42:12 +02:00
threshold = xmb->icon_size * 10;
2014-10-09 22:45:29 +02:00
video_driver_get_size(NULL, &height);
tag = (uintptr_t)selection_buf;
2016-02-25 13:23:39 +01:00
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num);
for (i = 0; i < end; i++)
2014-10-09 02:41:08 +02:00
{
float iy, real_iy;
2017-09-28 08:42:12 +02:00
float ia = xmb->items_passive_alpha;
float iz = xmb->items_passive_zoom;
2016-02-04 21:40:29 +01:00
xmb_node_t *node = (xmb_node_t*)
menu_entries_get_userdata_at_offset(selection_buf, i);
2014-10-09 02:41:08 +02:00
if (!node)
continue;
2015-09-25 14:57:37 +02:00
iy = xmb_item_y(xmb, i, selection);
2017-09-28 08:42:12 +02:00
real_iy = iy + xmb->margins_screen_top;
2014-10-09 02:41:08 +02:00
2015-09-25 14:57:37 +02:00
if (i == selection)
2014-10-09 02:41:08 +02:00
{
2017-09-28 07:15:29 +02:00
unsigned depth = (unsigned)xmb_list_get_size(xmb, MENU_LIST_PLAIN);
size_t xmb_list = xmb_list_get_selection(xmb);
2017-09-29 18:37:04 +02:00
unsigned entry_type = menu_entry_get_type_new(&entry);
2017-01-16 23:38:46 +01:00
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
iz = xmb->items_active_zoom;
2016-12-01 02:43:53 +01:00
2017-05-29 01:46:57 +02:00
if (!string_is_equal(thumb_ident,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
{
if ((xmb_list > XMB_SYSTEM_TAB_SETTINGS && depth == 1) ||
(xmb_list < XMB_SYSTEM_TAB_SETTINGS && depth == 4))
{
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry.path))
2017-09-29 18:37:04 +02:00
xmb_set_thumbnail_content(xmb, entry.path, 0 /* will be ignored */);
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
2017-09-28 07:15:29 +02:00
else if (((entry_type == FILE_TYPE_IMAGE || entry_type == FILE_TYPE_IMAGEVIEWER ||
entry_type == FILE_TYPE_RDB || entry_type == FILE_TYPE_RDB_ENTRY)
2017-05-15 19:00:24 +02:00
&& xmb_list <= XMB_SYSTEM_TAB_SETTINGS))
{
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry.path))
2017-09-29 18:37:04 +02:00
xmb_set_thumbnail_content(xmb, entry.path, 0 /* will be ignored */);
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
else if (filebrowser_get_type() != FILEBROWSER_NONE)
{
xmb_reset_thumbnail_content(xmb);
xmb_update_thumbnail_path(xmb, i);
xmb_update_thumbnail_image(xmb);
}
}
2016-12-01 02:43:53 +01:00
xmb_update_savestate_thumbnail_path(xmb, i);
xmb_update_savestate_thumbnail_image(xmb);
2014-10-09 02:41:08 +02:00
}
2016-02-04 21:40:29 +01:00
if ( (!allow_animations)
2016-03-09 16:17:18 -05:00
|| (real_iy < -threshold
2016-02-04 21:40:29 +01:00
|| real_iy > height+threshold))
{
node->alpha = node->label_alpha = ia;
node->y = iy;
node->zoom = iz;
}
else
{
2017-09-29 16:47:30 +02:00
menu_animation_ctx_entry_t anim_entry;
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
anim_entry.duration = XMB_DELAY;
anim_entry.target_value = ia;
anim_entry.subject = &node->alpha;
anim_entry.easing_enum = EASING_OUT_QUAD;
anim_entry.tag = tag;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
anim_entry.subject = &node->label_alpha;
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
anim_entry.target_value = iz;
anim_entry.subject = &node->zoom;
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
anim_entry.target_value = iy;
anim_entry.subject = &node->y;
2016-02-25 15:44:30 +01:00
2017-09-29 16:47:30 +02:00
menu_animation_push(&anim_entry);
}
2014-10-09 02:41:08 +02:00
}
2017-09-28 06:02:14 +02:00
2017-09-29 16:47:30 +02:00
end:
2017-09-29 18:37:04 +02:00
menu_entry_free(&entry);
2014-10-09 02:41:08 +02:00
}
2015-04-21 16:45:27 +02:00
static void xmb_list_open_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-10-09 02:41:08 +02:00
{
unsigned i, height = 0;
2017-09-28 08:42:12 +02:00
int threshold = xmb->icon_size * 10;
2015-06-15 17:34:12 +02:00
size_t end = 0;
2015-06-07 15:07:38 +02:00
end = file_list_get_size(list);
video_driver_get_size(NULL, &height);
2015-06-07 15:07:38 +02:00
for (i = 0; i < end; i++)
2014-10-20 20:00:39 +02:00
{
float ia = 0;
float real_y;
2016-02-04 21:40:29 +01:00
xmb_node_t *node = (xmb_node_t*)
menu_entries_get_userdata_at_offset(list, i);
if (!node)
continue;
if (i == current)
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
if (dir == -1)
ia = 0;
2015-02-02 20:48:26 +01:00
2017-09-28 08:42:12 +02:00
real_y = node->y + xmb->margins_screen_top;
if (real_y < -threshold || real_y > height+threshold)
{
node->alpha = ia;
node->label_alpha = 0;
2017-09-28 08:42:12 +02:00
node->x = xmb->icon_size * dir * -2;
}
else
{
2017-09-28 06:02:14 +02:00
menu_animation_ctx_entry_t anim_entry;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.duration = XMB_DELAY;
anim_entry.target_value = ia;
anim_entry.subject = &node->alpha;
anim_entry.easing_enum = EASING_OUT_QUAD;
anim_entry.tag = (uintptr_t)list;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.target_value = 0;
anim_entry.subject = &node->label_alpha;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-28 08:42:12 +02:00
anim_entry.target_value = xmb->icon_size * dir * -2;
2017-09-28 06:02:14 +02:00
anim_entry.subject = &node->x;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
}
2014-10-20 20:00:39 +02:00
}
}
2015-04-21 16:45:27 +02:00
static void xmb_list_open_new(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-10-20 20:00:39 +02:00
{
unsigned i, height;
size_t skip = 0;
2017-09-28 08:42:12 +02:00
int threshold = xmb->icon_size * 10;
2015-06-15 19:12:31 +02:00
size_t end = file_list_get_size(list);
2015-06-07 15:07:38 +02:00
video_driver_get_size(NULL, &height);
2015-06-07 15:07:38 +02:00
for (i = 0; i < end; i++)
2014-10-18 01:24:14 +02:00
{
2015-06-07 15:08:32 +02:00
float ia;
float real_y;
2015-04-21 16:45:27 +02:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 16:32:51 +02:00
menu_entries_get_userdata_at_offset(list, i);
2015-02-02 20:48:26 +01:00
2015-02-11 06:22:00 +01:00
if (!node)
2015-02-02 20:48:26 +01:00
continue;
2015-01-26 19:30:44 +01:00
2014-10-20 20:00:39 +02:00
if (dir == 1 || (dir == -1 && i != current))
node->alpha = 0;
2015-01-26 19:30:44 +01:00
if (dir == 1 || dir == -1)
node->label_alpha = 0;
2017-09-28 08:42:12 +02:00
node->x = xmb->icon_size * dir * 2;
2015-02-11 05:33:53 +01:00
node->y = xmb_item_y(xmb, i, current);
2017-09-28 08:42:12 +02:00
node->zoom = xmb->categories_passive_zoom;
2014-10-18 01:24:14 +02:00
2017-09-28 08:42:12 +02:00
real_y = node->y + xmb->margins_screen_top;
2014-10-18 01:24:14 +02:00
if (i == current)
2017-09-28 08:42:12 +02:00
node->zoom = xmb->categories_active_zoom;
2014-11-27 17:07:52 +07:00
2017-09-28 08:42:12 +02:00
ia = xmb->items_passive_alpha;
2015-01-26 06:51:46 +01:00
if (i == current)
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
2015-01-26 06:51:46 +01:00
if (real_y < -threshold || real_y > height+threshold)
{
node->alpha = node->label_alpha = ia;
node->x = 0;
}
else
{
2017-09-28 06:02:14 +02:00
menu_animation_ctx_entry_t anim_entry;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.duration = XMB_DELAY;
anim_entry.target_value = ia;
anim_entry.subject = &node->alpha;
anim_entry.easing_enum = EASING_OUT_QUAD;
anim_entry.tag = (uintptr_t)list;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.subject = &node->label_alpha;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.target_value = 0;
anim_entry.subject = &node->x;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
menu_animation_push(&anim_entry);
}
2014-10-18 01:24:14 +02:00
}
xmb->old_depth = xmb->depth;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &skip);
if (xmb_list_get_selection(xmb) <= XMB_SYSTEM_TAB_SETTINGS)
{
if (xmb->depth < 4)
xmb_reset_thumbnail_content(xmb);
xmb_update_thumbnail_path(xmb, 0);
xmb_update_thumbnail_image(xmb);
}
2014-10-09 02:41:08 +02:00
}
static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i)
2015-06-07 16:39:40 +02:00
{
xmb_node_t *node = xmb_alloc_node();
xmb_node_t *tmp;
2015-01-26 06:51:46 +01:00
2015-06-07 16:41:20 +02:00
if (!node)
{
2015-01-26 06:51:46 +01:00
RARCH_ERR("XMB node could not be allocated.\n");
return NULL;
}
2017-09-28 08:42:12 +02:00
node->alpha = xmb->categories_passive_alpha;
node->zoom = xmb->categories_passive_zoom;
2017-09-28 08:42:12 +02:00
if ((i + xmb->system_tab_end) == xmb->categories_active_idx)
2015-01-26 06:51:46 +01:00
{
2017-09-28 08:42:12 +02:00
node->alpha = xmb->categories_active_alpha;
node->zoom = xmb->categories_active_zoom;
}
2017-09-02 20:21:02 -03:00
tmp = (xmb_node_t*)file_list_get_userdata_at_offset(xmb->horizontal_list, i);
xmb_free_node(tmp);
2017-09-02 20:21:02 -03:00
file_list_set_userdata(xmb->horizontal_list, i, node);
2015-06-07 16:41:20 +02:00
2014-11-13 21:05:16 +01:00
return node;
}
2015-06-07 16:52:07 +02:00
static xmb_node_t* xmb_get_userdata_from_horizontal_list(
xmb_handle_t *xmb, unsigned i)
{
2016-02-04 21:40:29 +01:00
return (xmb_node_t*)
2017-09-02 20:21:02 -03:00
menu_entries_get_userdata_at_offset(xmb->horizontal_list, i);
}
static void xmb_push_animations(xmb_node_t *node, uintptr_t tag, float ia, float ix)
{
2017-09-29 18:37:04 +02:00
menu_animation_ctx_entry_t anim_entry;
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
anim_entry.duration = XMB_DELAY;
anim_entry.target_value = ia;
anim_entry.subject = &node->alpha;
anim_entry.easing_enum = EASING_OUT_QUAD;
anim_entry.tag = tag;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
anim_entry.subject = &node->label_alpha;
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
menu_animation_push(&anim_entry);
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
anim_entry.target_value = ix;
anim_entry.subject = &node->x;
2016-02-25 15:44:30 +01:00
2017-09-29 18:37:04 +02:00
menu_animation_push(&anim_entry);
}
2015-04-21 16:45:27 +02:00
static void xmb_list_switch_old(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-11-14 21:56:21 +01:00
{
unsigned i, first, last, height;
2015-06-15 19:12:31 +02:00
size_t end = file_list_get_size(list);
2017-09-28 08:42:12 +02:00
float ix = -xmb->icon_spacing_horizontal * dir;
float ia = 0;
first = 0;
last = end > 0 ? end - 1 : 0;
video_driver_get_size(NULL, &height);
xmb_calculate_visible_range(xmb, height, end, current, &first, &last);
2014-11-14 21:56:21 +01:00
for (i = 0; i < end; i++)
2014-11-14 21:56:21 +01:00
{
2015-02-01 15:25:37 +01:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 16:32:51 +02:00
menu_entries_get_userdata_at_offset(list, i);
2014-11-14 21:56:21 +01:00
2015-02-11 06:11:25 +01:00
if (!node)
2015-06-06 14:07:20 +02:00
continue;
2014-11-14 21:56:21 +01:00
if (i >= first && i <= last)
xmb_push_animations(node, (uintptr_t)list, ia, ix);
else
{
node->alpha = node->label_alpha = ia;
node->x = ix;
}
2014-11-14 21:56:21 +01:00
}
}
2015-04-21 16:45:27 +02:00
static void xmb_list_switch_new(xmb_handle_t *xmb,
file_list_t *list, int dir, size_t current)
2014-11-14 21:56:21 +01:00
{
unsigned i, first, last, height;
size_t end = 0;
2015-06-04 17:17:23 +07:00
settings_t *settings = config_get_ptr();
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_dynamic_wallpaper_enable)
2015-06-04 17:17:23 +07:00
{
2017-09-11 02:37:53 +02:00
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *tmp = string_replace_substring(xmb->title_name, "/", " ");
2015-06-04 17:17:23 +07:00
2017-09-11 02:37:53 +02:00
path[0] = '\0';
2015-06-04 17:17:23 +07:00
if (tmp)
{
2016-06-28 13:05:46 +02:00
fill_pathname_join_noext(
2016-04-28 19:26:02 +02:00
path,
2017-04-29 00:39:29 +02:00
settings->paths.directory_dynamic_wallpapers,
2016-04-28 19:26:02 +02:00
tmp,
2017-09-11 02:37:53 +02:00
path_size);
2015-06-04 17:17:23 +07:00
free(tmp);
}
2016-07-01 17:04:11 +02:00
strlcat(path,
file_path_str(FILE_PATH_PNG_EXTENSION),
2017-09-11 02:37:53 +02:00
path_size);
2016-03-09 16:17:18 -05:00
if (!path_file_exists(path))
2017-09-11 02:37:53 +02:00
fill_pathname_application_special(path, path_size,
2016-06-11 20:11:36 +02:00
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG);
2016-03-09 16:17:18 -05:00
2016-01-20 04:54:17 +01:00
if(!string_is_equal(path, xmb->background_file_path))
{
if(path_file_exists(path))
{
task_push_image_load(path,
menu_display_handle_wallpaper_upload, NULL);
2016-02-04 21:40:29 +01:00
strlcpy(xmb->background_file_path,
path, sizeof(xmb->background_file_path));
}
}
2017-09-11 02:37:53 +02:00
free(path);
2015-06-04 17:17:23 +07:00
}
end = file_list_get_size(list);
2014-11-14 21:56:21 +01:00
first = 0;
last = end > 0 ? end - 1 : 0;
video_driver_get_size(NULL, &height);
xmb_calculate_visible_range(xmb, height, end, current, &first, &last);
for (i = 0; i < end; i++)
2014-11-14 21:56:21 +01:00
{
2015-02-01 15:25:37 +01:00
xmb_node_t *node = (xmb_node_t*)
2015-10-19 16:32:51 +02:00
menu_entries_get_userdata_at_offset(list, i);
2017-09-28 08:42:12 +02:00
float ia = xmb->items_passive_alpha;
2014-11-14 21:56:21 +01:00
2015-02-11 06:15:15 +01:00
if (!node)
2015-06-06 14:07:20 +02:00
continue;
2014-11-14 21:56:21 +01:00
2017-09-28 08:42:12 +02:00
node->x = xmb->icon_spacing_horizontal * dir;
2015-02-02 20:48:26 +01:00
node->alpha = 0;
2014-11-14 23:39:24 +01:00
node->label_alpha = 0;
2014-11-14 21:56:21 +01:00
if (i == current)
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
2015-06-06 14:07:20 +02:00
if (i >= first && i <= last)
xmb_push_animations(node, (uintptr_t)list, ia, 0);
else
{
node->x = 0;
node->alpha = node->label_alpha = ia;
}
2014-11-14 21:56:21 +01:00
}
}
static void xmb_set_title(xmb_handle_t *xmb)
2014-11-15 00:35:45 +01:00
{
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr <= xmb->system_tab_end)
2014-11-15 00:35:45 +01: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,
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr - (xmb->system_tab_end + 1),
&path, NULL, NULL, NULL, NULL);
2014-11-15 00:35:45 +01:00
if (!path)
return;
2014-11-15 00:35:45 +01:00
2016-06-30 05:14:12 +02:00
fill_pathname_base_noext(xmb->title_name, path, sizeof(xmb->title_name));
}
}
2016-08-18 16:42:39 +02:00
static unsigned xmb_get_system_tab(xmb_handle_t *xmb, unsigned i)
{
if (i <= xmb->system_tab_end)
{
return xmb->tabs[i];
}
return UINT_MAX;
}
static xmb_node_t* xmb_get_node(xmb_handle_t *xmb, unsigned i)
{
2016-08-18 16:42:39 +02:00
switch (xmb_get_system_tab(xmb, i))
{
case XMB_SYSTEM_TAB_SETTINGS:
return &xmb->settings_tab_node;
2016-07-30 19:29:10 +02:00
#ifdef HAVE_IMAGEVIEWER
case XMB_SYSTEM_TAB_IMAGES:
return &xmb->images_tab_node;
2016-07-30 19:29:10 +02:00
#endif
case XMB_SYSTEM_TAB_MUSIC:
return &xmb->music_tab_node;
#ifdef HAVE_FFMPEG
2016-12-12 03:54:53 -06:00
case XMB_SYSTEM_TAB_VIDEO:
return &xmb->video_tab_node;
2016-07-30 19:29:10 +02:00
#endif
case XMB_SYSTEM_TAB_HISTORY:
return &xmb->history_tab_node;
case XMB_SYSTEM_TAB_FAVORITES:
return &xmb->favorites_tab_node;
2017-01-22 17:57:49 -05:00
#ifdef HAVE_NETWORKING
case XMB_SYSTEM_TAB_NETPLAY:
return &xmb->netplay_tab_node;
2017-01-22 17:57:49 -05:00
#endif
case XMB_SYSTEM_TAB_ADD:
return &xmb->add_tab_node;
default:
2016-08-18 16:42:39 +02:00
if (i > xmb->system_tab_end)
return xmb_get_userdata_from_horizontal_list(
2016-08-18 16:42:39 +02:00
xmb, i - (xmb->system_tab_end + 1));
}
return &xmb->main_menu_node;
2014-11-15 00:35:45 +01:00
}
2015-12-10 15:28:05 +01:00
static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb)
2014-10-09 01:21:22 +02:00
{
2014-11-14 21:56:21 +01:00
unsigned j;
2016-03-09 16:17:18 -05:00
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
2016-08-18 16:42:39 +02:00
+ xmb->system_tab_end;
for (j = 0; j <= list_size; j++)
2014-11-14 21:56:21 +01:00
{
2016-02-25 15:44:30 +01:00
menu_animation_ctx_entry_t entry;
2017-09-28 08:42:12 +02: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 21:56:21 +01:00
if (!node)
continue;
2015-06-06 14:07:20 +02:00
2017-09-28 08:42:12 +02:00
if (j == xmb->categories_active_idx)
2015-02-02 20:40:29 +01:00
{
2017-09-28 08:42:12 +02:00
ia = xmb->categories_active_alpha;
iz = xmb->categories_active_zoom;
2015-02-02 20:40:29 +01:00
}
2014-11-14 21:56:21 +01:00
2016-02-25 15:44:30 +01:00
entry.duration = XMB_DELAY;
entry.target_value = ia;
entry.subject = &node->alpha;
entry.easing_enum = EASING_OUT_QUAD;
2017-09-06 00:21:20 +02:00
/* TODO/FIXME - integer conversion resulted in change of sign */
entry.tag = -1;
2016-02-25 15:44:30 +01:00
entry.cb = NULL;
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2016-02-25 15:44:30 +01:00
entry.target_value = iz;
entry.subject = &node->zoom;
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
}
2015-06-07 13:09:35 +02:00
}
static void xmb_list_switch(xmb_handle_t *xmb)
{
2017-09-28 06:02:14 +02:00
menu_animation_ctx_entry_t anim_entry;
int dir = -1;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
2017-07-14 15:11:27 -04:00
settings_t *settings = config_get_ptr();
2015-06-07 13:09:35 +02:00
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr > xmb->categories_selection_ptr_old)
2015-06-07 13:09:35 +02:00
dir = 1;
2017-09-28 08:42:12 +02:00
xmb->categories_active_idx += dir;
2015-06-07 13:09:35 +02:00
2015-12-10 15:28:05 +01:00
xmb_list_switch_horizontal_list(xmb);
2014-11-14 21:56:21 +01:00
2017-09-28 06:02:14 +02:00
anim_entry.duration = XMB_DELAY;
2017-09-28 08:42:12 +02:00
anim_entry.target_value = xmb->icon_spacing_horizontal * -(float)xmb->categories_selection_ptr;
anim_entry.subject = &xmb->categories_x_pos;
2017-09-28 06:02:14 +02:00
anim_entry.easing_enum = EASING_OUT_QUAD;
2017-09-06 00:21:20 +02:00
/* TODO/FIXME - integer conversion resulted in change of sign */
2017-09-28 06:02:14 +02:00
anim_entry.tag = -1;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-28 06:02:14 +02:00
if (anim_entry.subject)
menu_animation_push(&anim_entry);
2015-02-02 20:40:29 +01:00
dir = -1;
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr > xmb->categories_selection_ptr_old)
2015-02-02 20:40:29 +01:00
dir = 1;
2015-04-21 16:45:27 +02:00
xmb_list_switch_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
2017-07-14 15:11:27 -04:00
2017-08-06 17:12:57 +02:00
/* Check if we are to have horizontal animations. */
if (settings->bools.menu_horizontal_animation)
2017-07-14 15:11:27 -04:00
xmb_list_switch_new(xmb, selection_buf, dir, selection);
2017-09-28 08:42:12 +02:00
xmb->categories_active_idx_old = (unsigned)xmb->categories_selection_ptr;
2015-06-18 09:32:56 +07:00
2016-12-15 11:23:08 +01:00
if (!string_is_equal(xmb_thumbnails_ident(),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
{
2017-09-29 18:37:04 +02:00
menu_entry_t entry;
2017-09-29 18:37:04 +02:00
menu_entry_init(&entry);
menu_entry_get(&entry, 0, selection, NULL, true);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry.path))
2017-09-29 18:37:04 +02:00
xmb_set_thumbnail_content(xmb, entry.path, 0 /* will be ignored */);
2017-09-28 06:02:14 +02:00
2017-09-29 18:37:04 +02:00
menu_entry_free(&entry);
2016-04-08 01:42:53 +07:00
xmb_update_thumbnail_path(xmb, 0);
xmb_update_thumbnail_image(xmb);
}
}
2014-11-14 21:56:21 +01:00
2015-12-10 15:28:05 +01:00
static void xmb_list_open_horizontal_list(xmb_handle_t *xmb)
{
unsigned j;
2016-03-09 16:17:18 -05:00
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
2016-08-18 16:42:39 +02:00
+ xmb->system_tab_end;
2014-10-09 01:21:22 +02:00
for (j = 0; j <= list_size; j++)
{
2017-09-29 16:54:57 +02:00
menu_animation_ctx_entry_t anim_entry;
2015-03-22 08:09:00 +01:00
float ia = 0;
xmb_node_t *node = xmb_get_node(xmb, j);
if (!node)
continue;
2017-09-28 08:42:12 +02:00
if (j == xmb->categories_active_idx)
ia = xmb->categories_active_alpha;
2015-02-02 20:40:29 +01:00
else if (xmb->depth <= 1)
2017-09-28 08:42:12 +02:00
ia = xmb->categories_passive_alpha;
2015-02-02 20:40:29 +01:00
2017-09-29 16:54:57 +02:00
anim_entry.duration = XMB_DELAY;
anim_entry.target_value = ia;
anim_entry.subject = &node->alpha;
anim_entry.easing_enum = EASING_OUT_QUAD;
2017-09-06 00:21:20 +02:00
/* TODO/FIXME - integer conversion resulted in change of sign */
2017-09-29 16:54:57 +02:00
anim_entry.tag = -1;
anim_entry.cb = NULL;
2016-02-25 15:44:30 +01:00
2017-09-29 16:54:57 +02:00
if (anim_entry.subject)
menu_animation_push(&anim_entry);
}
2015-06-07 13:09:35 +02:00
}
2015-12-10 15:28:05 +01:00
static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb)
2015-11-02 22:56:05 +01:00
{
unsigned i;
2015-12-10 15:23:43 +01:00
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL);
2015-11-02 22:56:05 +01:00
for (i = 0; i < list_size; i++)
{
2016-01-08 22:26:13 +01:00
const char *path = NULL;
2015-11-02 22:56:05 +01:00
xmb_node_t *node = xmb_get_userdata_from_horizontal_list(xmb, i);
if (!node)
continue;
2016-01-08 22:26:13 +01:00
file_list_get_at_offset(xmb->horizontal_list, i,
&path, NULL, NULL, NULL);
2016-03-09 16:17:18 -05:00
2016-06-26 10:12:28 +02:00
if (!path || !strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION)))
2016-01-08 22:26:13 +01:00
continue;
2016-02-16 20:24:00 +01:00
video_driver_texture_unload(&node->icon);
video_driver_texture_unload(&node->content_icon);
2015-11-02 22:56:05 +01:00
}
}
2015-12-10 15:28:05 +01:00
static void xmb_init_horizontal_list(xmb_handle_t *xmb)
2015-11-02 22:56:05 +01:00
{
2016-12-19 18:40:00 +01:00
menu_displaylist_info_t info;
2015-11-02 22:56:05 +01:00
settings_t *settings = config_get_ptr();
2017-09-10 23:22:09 +02:00
menu_displaylist_info_init(&info);
2016-12-19 18:40:00 +01:00
info.list = xmb->horizontal_list;
2017-09-28 03:06:54 +02:00
info.path = strdup(
settings->paths.directory_playlist);
2017-09-28 02:45:03 +02:00
info.label = strdup(
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST));
info.exts = strdup(
file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT));
2016-12-19 18:40:00 +01:00
info.type_default = FILE_TYPE_PLAIN;
info.enum_idx = MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST;
2015-11-02 22:56:05 +01:00
if (!string_is_empty(info.path))
{
if (menu_displaylist_ctl(DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL, &info))
{
size_t i;
2017-09-10 23:22:09 +02:00
for (i = 0; i < xmb->horizontal_list->size; i++)
xmb_node_allocate_userdata(xmb, (unsigned)i);
2017-05-26 20:12:52 +02:00
menu_displaylist_process(&info);
}
}
2017-09-28 03:53:48 +02:00
menu_displaylist_info_free(&info);
2015-11-02 22:56:05 +01:00
}
2015-12-10 15:28:05 +01:00
static void xmb_toggle_horizontal_list(xmb_handle_t *xmb)
2015-11-02 22:56:05 +01:00
{
unsigned i;
2016-03-09 16:17:18 -05:00
size_t list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
2016-08-18 16:42:39 +02:00
+ xmb->system_tab_end;
2015-11-02 22:56:05 +01:00
for (i = 0; i <= list_size; i++)
2015-11-02 22:56:05 +01:00
{
xmb_node_t *node = xmb_get_node(xmb, i);
if (!node)
continue;
node->alpha = 0;
2017-09-28 08:42:12 +02:00
node->zoom = xmb->categories_passive_zoom;
2015-11-02 22:56:05 +01:00
2017-09-28 08:42:12 +02:00
if (i == xmb->categories_active_idx)
2015-11-02 22:56:05 +01:00
{
2017-09-28 08:42:12 +02:00
node->alpha = xmb->categories_active_alpha;
node->zoom = xmb->categories_active_zoom;
2015-11-02 22:56:05 +01:00
}
else if (xmb->depth <= 1)
2017-09-28 08:42:12 +02:00
node->alpha = xmb->categories_passive_alpha;
2015-11-02 22:56:05 +01:00
}
}
2016-02-04 21:40:29 +01:00
static void xmb_context_reset_horizontal_list(
2016-06-11 19:50:44 +02:00
xmb_handle_t *xmb)
2015-11-02 22:56:05 +01:00
{
unsigned i;
int depth; /* keep this integer */
2017-09-11 02:37:53 +02:00
size_t list_size =
xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL);
2015-11-02 22:56:05 +01:00
2017-09-28 08:42:12 +02:00
xmb->categories_x_pos = xmb->icon_spacing_horizontal *
-(float)xmb->categories_selection_ptr;
2015-11-02 22:56:05 +01:00
depth = (xmb->depth > 1) ? 2 : 1;
2017-09-28 08:42:12 +02:00
xmb->x = xmb->icon_size * -(depth*2-2);
2015-11-02 22:56:05 +01:00
for (i = 0; i < list_size; i++)
{
const char *path = NULL;
2016-03-09 16:17:18 -05:00
xmb_node_t *node =
2016-02-04 21:40:29 +01:00
xmb_get_userdata_from_horizontal_list(xmb, i);
2015-11-02 22:56:05 +01:00
if (!node)
{
node = xmb_node_allocate_userdata(xmb, i);
if (!node)
continue;
}
2015-11-02 22:56:05 +01:00
file_list_get_at_offset(xmb->horizontal_list, i,
&path, NULL, NULL, NULL);
if (!path)
continue;
2016-06-26 10:12:28 +02:00
if (!strstr(path, file_path_str(FILE_PATH_LPL_EXTENSION)))
continue;
2017-09-12 04:37:58 +02:00
{
struct texture_image ti;
char sysname[256];
char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *texturepath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *content_texturepath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2015-11-02 22:56:05 +01:00
2017-09-12 04:37:58 +02:00
iconpath[0] = sysname[0] =
texturepath[0] = content_texturepath[0] = '\0';
2015-11-02 22:56:05 +01:00
2017-09-12 04:37:58 +02:00
fill_pathname_base_noext(sysname, path, sizeof(sysname));
2015-11-02 22:56:05 +01:00
2017-09-12 04:37:58 +02:00
fill_pathname_application_special(iconpath,
PATH_MAX_LENGTH * sizeof(char),
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
2016-10-18 04:15:24 +02:00
2017-09-12 04:37:58 +02:00
fill_pathname_join_concat(texturepath, iconpath, sysname,
file_path_str(FILE_PATH_PNG_EXTENSION),
PATH_MAX_LENGTH * sizeof(char));
ti.width = 0;
ti.height = 0;
ti.pixels = NULL;
ti.supports_rgba = video_driver_supports_rgba();
if (image_texture_load(&ti, texturepath))
2016-07-17 15:58:14 +02:00
{
2017-09-12 04:37:58 +02:00
if(ti.pixels)
{
video_driver_texture_unload(&node->icon);
video_driver_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR, &node->icon);
}
2016-07-17 15:58:14 +02:00
2017-09-12 04:37:58 +02:00
image_texture_free(&ti);
}
2015-11-02 22:56:05 +01:00
2017-09-12 04:37:58 +02:00
strlcat(iconpath, sysname, PATH_MAX_LENGTH * sizeof(char));
fill_pathname_join_delim(content_texturepath, iconpath,
file_path_str(FILE_PATH_CONTENT_BASENAME), '-',
PATH_MAX_LENGTH * sizeof(char));
2016-07-17 15:59:38 +02:00
2017-09-12 04:37:58 +02:00
if (image_texture_load(&ti, content_texturepath))
2016-07-17 15:58:14 +02:00
{
2017-09-12 04:37:58 +02:00
if(ti.pixels)
{
video_driver_texture_unload(&node->content_icon);
video_driver_texture_load(&ti,
TEXTURE_FILTER_MIPMAP_LINEAR, &node->content_icon);
}
image_texture_free(&ti);
2016-07-17 15:58:14 +02:00
}
2017-09-12 04:37:58 +02:00
free(iconpath);
free(texturepath);
free(content_texturepath);
2016-07-16 20:32:00 -06:00
}
2015-11-02 22:56:05 +01:00
}
2015-12-10 15:28:05 +01:00
xmb_toggle_horizontal_list(xmb);
2015-11-02 22:56:05 +01:00
}
2015-12-10 15:28:05 +01:00
static void xmb_refresh_horizontal_list(xmb_handle_t *xmb)
2015-07-07 17:04:03 +07:00
{
2015-12-10 15:28:05 +01:00
xmb_context_destroy_horizontal_list(xmb);
2015-07-07 17:04:03 +07:00
if (xmb->horizontal_list)
{
xmb_free_list_nodes(xmb->horizontal_list, false);
file_list_free(xmb->horizontal_list);
}
2015-07-07 17:04:03 +07:00
xmb->horizontal_list = NULL;
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
2016-12-19 18:40:00 +01:00
xmb->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t));
if (xmb->horizontal_list)
xmb_init_horizontal_list(xmb);
2016-06-11 19:50:44 +02:00
xmb_context_reset_horizontal_list(xmb);
2015-07-07 17:04:03 +07:00
}
static int xmb_environ(enum menu_environ_cb type, void *data, void *userdata)
2015-07-08 00:37:44 +02:00
{
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
2015-07-08 00:37:44 +02:00
switch (type)
{
case MENU_ENVIRON_ENABLE_MOUSE_CURSOR:
if (!xmb)
return -1;
xmb->mouse_show = true;
break;
case MENU_ENVIRON_DISABLE_MOUSE_CURSOR:
if (!xmb)
return -1;
xmb->mouse_show = false;
break;
2015-07-08 00:37:44 +02:00
case MENU_ENVIRON_RESET_HORIZONTAL_LIST:
if (!xmb)
return -1;
2015-07-08 00:37:44 +02:00
xmb_refresh_horizontal_list(xmb);
2015-07-08 00:37:44 +02:00
break;
default:
return -1;
}
return 0;
}
2015-06-07 13:09:35 +02:00
static void xmb_list_open(xmb_handle_t *xmb)
{
2016-02-25 15:44:30 +01:00
menu_animation_ctx_entry_t entry;
2015-10-17 18:17:59 +02:00
int dir = 0;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
2015-06-07 13:09:35 +02:00
xmb->depth = (int)xmb_list_get_size(xmb, MENU_LIST_PLAIN);
2015-06-07 13:09:35 +02:00
if (xmb->depth > xmb->old_depth)
dir = 1;
else if (xmb->depth < xmb->old_depth)
dir = -1;
2015-12-10 15:28:05 +01:00
xmb_list_open_horizontal_list(xmb);
2015-04-21 16:45:27 +02:00
xmb_list_open_old(xmb, xmb->selection_buf_old,
dir, xmb->selection_ptr_old);
2015-10-17 18:17:59 +02:00
xmb_list_open_new(xmb, selection_buf,
dir, selection);
2014-10-09 01:21:22 +02:00
2016-02-25 15:44:30 +01:00
entry.duration = XMB_DELAY;
2017-09-28 08:42:12 +02:00
entry.target_value = xmb->icon_size * -(xmb->depth*2-2);
2016-02-25 15:44:30 +01:00
entry.subject = &xmb->x;
entry.easing_enum = EASING_OUT_QUAD;
2017-09-06 00:21:20 +02:00
/* TODO/FIXME - integer conversion resulted in change of sign */
2016-02-25 15:44:30 +01:00
entry.tag = -1;
entry.cb = NULL;
2015-02-01 15:25:37 +01:00
switch (xmb->depth)
{
case 1:
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2016-02-25 15:44:30 +01:00
entry.target_value = 0;
2017-09-28 08:42:12 +02:00
entry.subject = &xmb->textures_arrow_alpha;
2016-02-25 15:44:30 +01:00
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2015-02-01 15:25:37 +01:00
break;
case 2:
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2016-02-25 15:44:30 +01:00
entry.target_value = 1;
2017-09-28 08:42:12 +02:00
entry.subject = &xmb->textures_arrow_alpha;
2016-02-25 15:44:30 +01:00
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2015-02-01 15:25:37 +01:00
break;
}
2014-10-09 01:21:22 +02:00
2014-10-20 20:00:39 +02:00
xmb->old_depth = xmb->depth;
}
2014-10-09 01:21:22 +02:00
static void xmb_populate_entries(void *data,
const char *path,
const char *label, unsigned k)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
if (menu_driver_ctl(RARCH_MENU_CTL_IS_PREVENT_POPULATE, NULL))
{
2015-12-10 16:14:53 +01:00
xmb_selection_pointer_changed(xmb, false);
menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL);
2016-12-15 11:23:08 +01:00
if (!string_is_equal(xmb_thumbnails_ident(),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
2016-04-08 01:42:53 +07:00
xmb_update_thumbnail_image(xmb);
2016-12-01 02:43:53 +01:00
xmb_update_savestate_thumbnail_image(xmb);
return;
}
xmb_set_title(xmb);
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr != xmb->categories_active_idx_old)
xmb_list_switch(xmb);
2015-02-23 21:40:36 +01:00
else
xmb_list_open(xmb);
}
static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb,
2016-10-30 17:14:13 -05:00
xmb_node_t *core_node, xmb_node_t *node,
enum msg_hash_enums enum_idx, unsigned type, bool active)
{
2016-06-17 21:05:28 +02:00
switch (enum_idx)
2016-04-21 02:53:42 +07:00
{
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_CORE_OPTIONS:
2016-12-15 11:45:28 +01:00
case MENU_ENUM_LABEL_NAVIGATION_BROWSER_FILTER_SUPPORTED_EXTENSIONS_ENABLE:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS];
case MENU_ENUM_LABEL_ADD_TO_FAVORITES:
return xmb->textures.list[XMB_TEXTURE_ADD_FAVORITE];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_DISK_OPTIONS:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_SHADER_OPTIONS:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_ACHIEVEMENT_LIST:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_ACHIEVEMENT_LIST];
2016-11-05 16:55:57 -05:00
case MENU_ENUM_LABEL_ACHIEVEMENT_LIST_HARDCORE:
return xmb->textures.list[XMB_TEXTURE_ACHIEVEMENT_LIST];
2016-06-17 22:36:13 +02:00
case MENU_ENUM_LABEL_SAVE_STATE:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_SAVESTATE];
2016-06-17 22:36:13 +02:00
case MENU_ENUM_LABEL_LOAD_STATE:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_LOADSTATE];
2016-12-15 11:31:06 +01:00
case MENU_ENUM_LABEL_PARENT_DIRECTORY:
2016-09-13 22:58:52 +02:00
case MENU_ENUM_LABEL_UNDO_LOAD_STATE:
case MENU_ENUM_LABEL_UNDO_SAVE_STATE:
return xmb->textures.list[XMB_TEXTURE_UNDO];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_TAKE_SCREENSHOT:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_SCREENSHOT];
2016-08-29 00:54:51 +02:00
case MENU_ENUM_LABEL_DELETE_ENTRY:
return xmb->textures.list[XMB_TEXTURE_CLOSE];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_RESTART_CONTENT:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_RELOAD];
2017-08-18 18:30:31 +07:00
case MENU_ENUM_LABEL_PLAYLIST_ENTRY_RENAME:
return xmb->textures.list[XMB_TEXTURE_RENAME];
2016-06-17 21:05:28 +02:00
case MENU_ENUM_LABEL_RESUME_CONTENT:
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_RESUME];
2016-10-25 13:34:01 +02:00
case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE:
case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME:
return xmb->textures.list[XMB_TEXTURE_SAVESTATE];
2016-12-13 01:06:28 +01:00
case MENU_ENUM_LABEL_FAVORITES:
case MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST:
return xmb->textures.list[XMB_TEXTURE_FOLDER];
case MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR:
return xmb->textures.list[XMB_TEXTURE_RDB];
2016-06-17 21:05:28 +02:00
default:
break;
2016-04-21 02:53:42 +07:00
}
2016-04-20 17:34:15 +02:00
switch(type)
{
2016-06-20 15:50:37 +02:00
case FILE_TYPE_DIRECTORY:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_FOLDER];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_PLAIN:
2016-12-18 17:26:02 +01:00
case FILE_TYPE_IN_CARCHIVE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_FILE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_RPL_ENTRY:
if (core_node)
return core_node->content_icon;
2016-07-31 14:29:33 +02:00
2017-09-28 08:42:12 +02:00
switch (xmb_get_system_tab(xmb, (unsigned)xmb->categories_selection_ptr))
{
case XMB_SYSTEM_TAB_FAVORITES:
return xmb->textures.list[XMB_TEXTURE_FAVORITE];
case XMB_SYSTEM_TAB_MUSIC:
return xmb->textures.list[XMB_TEXTURE_MUSIC];
#ifdef HAVE_IMAGEVIEWER
case XMB_SYSTEM_TAB_IMAGES:
return xmb->textures.list[XMB_TEXTURE_IMAGE];
#endif
#ifdef HAVE_FFMPEG
case XMB_SYSTEM_TAB_VIDEO:
return xmb->textures.list[XMB_TEXTURE_MOVIE];
#endif
default:
break;
}
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_FILE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_CARCHIVE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_ZIP];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_MUSIC:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_MUSIC];
case FILE_TYPE_IMAGE:
2016-06-20 15:50:37 +02:00
case FILE_TYPE_IMAGEVIEWER:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_IMAGE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_MOVIE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_MOVIE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_CORE:
case FILE_TYPE_DIRECT_LOAD:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CORE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_RDB:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_RDB];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_CURSOR:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CURSOR];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_PLAYLIST_ENTRY:
case MENU_SETTING_ACTION_RUN:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_RUN];
case MENU_SETTING_ACTION_CLOSE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CLOSE];
case MENU_SETTING_ACTION_SAVESTATE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_SAVESTATE];
case MENU_SETTING_ACTION_LOADSTATE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_LOADSTATE];
2016-06-20 15:50:37 +02:00
case FILE_TYPE_RDB_ENTRY:
case MENU_SETTING_ACTION_CORE_INFORMATION:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CORE_INFO];
case MENU_SETTING_ACTION_CORE_OPTIONS:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS];
case MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS];
case MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS];
case MENU_SETTING_ACTION_CORE_DISK_OPTIONS:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS];
2015-06-25 11:47:20 +07:00
case MENU_SETTING_ACTION_CORE_SHADER_OPTIONS:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS];
case MENU_SETTING_ACTION_SCREENSHOT:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_SCREENSHOT];
2016-08-29 00:54:51 +02:00
case MENU_SETTING_ACTION_DELETE_ENTRY:
return xmb->textures.list[XMB_TEXTURE_CLOSE];
case MENU_SETTING_ACTION_RESET:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_RELOAD];
case MENU_SETTING_ACTION:
if (xmb->depth == 3)
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_SUBSETTING];
return xmb->textures.list[XMB_TEXTURE_SETTING];
case MENU_SETTING_GROUP:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_SETTING];
case MENU_INFO_MESSAGE:
2016-03-02 22:17:05 +01:00
return xmb->textures.list[XMB_TEXTURE_CORE_INFO];
2016-09-22 12:36:36 +02:00
case MENU_WIFI:
return xmb->textures.list[XMB_TEXTURE_WIFI];
2017-02-28 04:50:07 +01:00
#ifdef HAVE_NETWORKING
case MENU_ROOM:
return xmb->textures.list[XMB_TEXTURE_ROOM];
2017-07-24 20:52:27 -05:00
/* stub these out until we have the icons
case MENU_ROOM_LAN:
return xmb->textures.list[XMB_TEXTURE_ROOM_LAN];
case MENU_ROOM_MITM:
2017-07-24 20:52:27 -05:00
return xmb->textures.list[XMB_TEXTURE_ROOM_MITM]; */
2017-02-28 04:50:07 +01:00
#endif
}
2016-04-21 02:53:42 +07:00
return xmb->textures.list[XMB_TEXTURE_SUBSETTING];
}
static void xmb_calculate_visible_range(const xmb_handle_t *xmb,
unsigned height, size_t list_size, unsigned current,
unsigned *first, unsigned *last)
{
unsigned j;
2017-09-28 08:42:12 +02:00
float base_y = xmb->margins_screen_top;
*first = 0;
*last = list_size ? list_size - 1 : 0;
if (current)
{
for (j = current; j-- > 0; )
{
2017-09-28 08:42:12 +02:00
float bottom = xmb_item_y(xmb, j, current) + base_y + xmb->icon_size;
if (bottom < 0)
break;
*first = j;
}
}
for (j = current+1; j < list_size; j++)
{
float top = xmb_item_y(xmb, j, current) + base_y;
if (top > height)
break;
*last = j;
}
}
static int xmb_draw_item(
menu_display_frame_info_t menu_disp_info,
2017-09-29 18:12:17 +02:00
menu_entry_t *entry,
math_matrix_4x4 *mymat,
xmb_handle_t *xmb,
xmb_node_t *core_node,
file_list_t *list,
float *color,
const char *thumb_ident,
uint64_t frame_count,
size_t i,
size_t current,
unsigned width,
unsigned height
)
{
float icon_x, icon_y, label_offset;
menu_animation_ctx_ticker_t ticker;
char tmp[255];
2017-09-29 18:46:53 +02:00
char *ticker_str = NULL;
unsigned entry_type = 0;
const float half_size = xmb->icon_size / 2.0f;
uintptr_t texture_switch = 0;
bool do_draw_text = false;
unsigned ticker_limit = 35;
xmb_node_t * node = (xmb_node_t*)
menu_entries_get_userdata_at_offset(list, i);
if (!node)
2017-09-29 16:47:30 +02:00
goto iterate;
2017-09-29 18:46:53 +02:00
tmp[0] = '\0';
icon_y = xmb->margins_screen_top + node->y + half_size;
if (icon_y < half_size)
2017-09-29 16:47:30 +02:00
goto iterate;
if (icon_y > height + xmb->icon_size)
2017-09-29 16:47:30 +02:00
goto end;
icon_x = node->x + xmb->margins_screen_left +
xmb->icon_spacing_horizontal - half_size;
if (icon_x < -half_size || icon_x > width)
2017-09-29 16:47:30 +02:00
goto iterate;
2017-09-29 16:47:30 +02:00
entry_type = menu_entry_get_type_new(entry);
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
2017-09-29 16:47:30 +02:00
fill_short_pathname_representation(entry->path, entry->path,
sizeof(entry->path));
2017-09-29 16:47:30 +02:00
if (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_DISABLED)) ||
(string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))))
{
if (xmb->textures.list[XMB_TEXTURE_SWITCH_OFF])
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_OFF];
else
do_draw_text = true;
}
2017-09-29 16:47:30 +02:00
else if (string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_ENABLED)) ||
(string_is_equal(entry->value, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON))))
{
if (xmb->textures.list[XMB_TEXTURE_SWITCH_ON])
texture_switch = xmb->textures.list[XMB_TEXTURE_SWITCH_ON];
else
do_draw_text = true;
}
else
{
2017-09-29 21:19:07 +02:00
enum msg_file_type type = FILE_TYPE_NONE;
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry->value))
2017-09-29 21:19:07 +02:00
type = msg_hash_to_file_type(msg_hash_calculate(entry->value));
switch (type)
{
case FILE_TYPE_IN_CARCHIVE:
case FILE_TYPE_COMPRESSED:
case FILE_TYPE_MORE:
case FILE_TYPE_CORE:
case FILE_TYPE_DIRECT_LOAD:
case FILE_TYPE_RDB:
case FILE_TYPE_CURSOR:
case FILE_TYPE_PLAIN:
case FILE_TYPE_DIRECTORY:
case FILE_TYPE_MUSIC:
case FILE_TYPE_IMAGE:
case FILE_TYPE_MOVIE:
break;
default:
do_draw_text = true;
break;
}
}
2017-09-29 16:47:30 +02:00
if (string_is_empty(entry->value))
{
if (xmb->savestate_thumbnail ||
(!string_is_equal
(thumb_ident,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF))
&& xmb->thumbnail)
)
ticker_limit = 40;
else
ticker_limit = 70;
}
2017-09-29 18:46:53 +02:00
ticker_str = menu_entry_get_rich_label(entry);
ticker.s = tmp;
ticker.len = ticker_limit;
ticker.idx = frame_count / 20;
ticker.str = ticker_str;
ticker.selected = (i == current);
menu_animation_ticker(&ticker);
label_offset = xmb->margins_label_top;
if (i == current && width > 320 && height > 240
2017-09-29 16:47:30 +02:00
&& !string_is_empty(entry->sublabel))
{
char entry_sublabel[255];
entry_sublabel[0] = '\0';
label_offset = - xmb->margins_label_top;
2017-09-29 16:47:30 +02:00
word_wrap(entry_sublabel, entry->sublabel, 50, true);
xmb_draw_text(menu_disp_info, xmb, entry_sublabel,
node->x + xmb->margins_screen_left +
xmb->icon_spacing_horizontal + xmb->margins_label_left,
xmb->margins_screen_top + node->y + xmb->margins_label_top*3.5,
1, node->label_alpha, TEXT_ALIGN_LEFT,
width, height, xmb->font2);
}
xmb_draw_text(menu_disp_info, xmb, tmp,
node->x + xmb->margins_screen_left +
xmb->icon_spacing_horizontal + xmb->margins_label_left,
xmb->margins_screen_top + node->y + label_offset,
1, node->label_alpha, TEXT_ALIGN_LEFT,
width, height, xmb->font);
2017-09-29 16:47:30 +02:00
tmp[0] = '\0';
ticker.s = tmp;
ticker.len = 35;
ticker.idx = frame_count / 20;
ticker.selected = (i == current);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(entry->value))
2017-09-29 21:19:07 +02:00
{
ticker.str = entry->value;
menu_animation_ticker(&ticker);
}
if (do_draw_text)
xmb_draw_text(menu_disp_info, xmb, tmp,
node->x +
+ xmb->margins_screen_left
+ xmb->icon_spacing_horizontal
+ xmb->margins_label_left
+ xmb->margins_setting_left,
xmb->margins_screen_top + node->y + xmb->margins_label_top,
1,
node->label_alpha,
TEXT_ALIGN_LEFT,
width, height, xmb->font);
menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha));
if (color[3] != 0)
{
math_matrix_4x4 mymat_tmp;
menu_display_ctx_rotate_draw_t rotate_draw;
uintptr_t texture = xmb_icon_get_id(xmb, core_node, node,
2017-09-29 16:47:30 +02:00
entry->enum_idx, entry_type, (i == current));
float x = icon_x;
float y = icon_y;
float rotation = 0;
float scale_factor = node->zoom;
rotate_draw.matrix = &mymat_tmp;
rotate_draw.rotation = rotation;
rotate_draw.scale_x = scale_factor;
rotate_draw.scale_y = scale_factor;
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw);
xmb_draw_icon(
menu_disp_info,
xmb->icon_size,
&mymat_tmp,
texture,
x,
y,
width,
height,
1.0,
rotation,
scale_factor,
&color[0],
xmb->shadow_offset);
}
menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha));
if (texture_switch != 0 && color[3] != 0)
xmb_draw_icon(
menu_disp_info,
xmb->icon_size,
mymat,
texture_switch,
node->x + xmb->margins_screen_left
+ xmb->icon_spacing_horizontal
+ 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,
1,
&color[0],
xmb->shadow_offset);
2017-09-29 16:47:30 +02:00
iterate:
2017-09-30 06:11:18 +02:00
if (!string_is_empty(ticker_str))
2017-09-29 18:46:53 +02:00
free(ticker_str);
return 0;
2017-09-29 16:47:30 +02:00
end:
2017-09-30 06:11:18 +02:00
if (!string_is_empty(ticker_str))
2017-09-29 18:46:53 +02:00
free(ticker_str);
2017-09-29 16:47:30 +02:00
return -1;
}
static void xmb_draw_items(
video_frame_info_t *video_info,
menu_display_frame_info_t menu_disp_info,
xmb_handle_t *xmb,
2017-09-03 14:51:14 -03:00
file_list_t *list,
size_t current, size_t cat_selection_ptr, float *color,
2015-09-06 23:10:00 +02:00
unsigned width, unsigned height)
2014-10-20 20:00:39 +02:00
{
size_t i;
2017-09-12 04:37:58 +02:00
unsigned first, last;
math_matrix_4x4 mymat;
2016-06-16 16:33:39 +02:00
menu_display_ctx_rotate_draw_t rotate_draw;
xmb_node_t *core_node = NULL;
size_t end = 0;
2017-09-29 16:34:20 +02:00
uint64_t frame_count = xmb ? xmb->frame_count : 0;
2017-05-29 01:46:57 +02:00
const char *thumb_ident = xmb_thumbnails_ident();
2015-12-10 13:48:41 +01:00
if (!list || !list->size)
2014-10-20 20:00:39 +02:00
return;
2014-10-09 01:21:22 +02:00
2016-08-18 16:42:39 +02:00
if (cat_selection_ptr > xmb->system_tab_end)
2016-02-04 21:40:29 +01:00
core_node = xmb_get_userdata_from_horizontal_list(
2017-02-26 21:46:19 +01:00
xmb, (unsigned)(cat_selection_ptr - (xmb->system_tab_end + 1)));
2014-11-27 17:07:52 +07:00
2017-09-28 05:00:00 +02:00
end = file_list_get_size(list);
2015-02-12 17:08:57 +01:00
2016-02-09 04:43:15 +01:00
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;
rotate_draw.scale_x = 1;
rotate_draw.scale_y = 1;
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw);
2015-03-10 03:42:26 +01:00
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
if (list == xmb->selection_buf_old)
{
xmb_node_t *node = (xmb_node_t*)
menu_entries_get_userdata_at_offset(list, current);
if ((uint8_t)(255 * node->alpha) == 0)
return;
i = 0;
}
first = i;
last = end - 1;
xmb_calculate_visible_range(xmb, height, end, current, &first, &last);
menu_display_blend_begin();
for (i = first; i <= last; i++)
2014-10-09 01:21:22 +02:00
{
2017-09-29 21:00:56 +02:00
int ret;
2017-09-29 18:37:04 +02:00
menu_entry_t entry;
2017-09-29 21:00:56 +02:00
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, list, true);
ret = xmb_draw_item(menu_disp_info,
2017-09-29 18:37:04 +02:00
&entry,
&mymat,
xmb, core_node,
list, color, thumb_ident,
frame_count,
i, current,
width, height);
2017-09-29 18:37:04 +02:00
menu_entry_free(&entry);
if (ret == -1)
break;
2014-10-09 01:21:22 +02:00
}
menu_display_blend_end();
2014-10-20 20:00:39 +02:00
}
static void xmb_render(void *data, bool is_idle)
{
2016-04-20 17:37:31 +02:00
size_t i;
float delta_time;
menu_animation_ctx_delta_t delta;
2015-06-13 22:57:55 +02:00
settings_t *settings = config_get_ptr();
xmb_handle_t *xmb = (xmb_handle_t*)data;
unsigned end = (unsigned)menu_entries_get_size();
2017-04-28 13:43:47 +02:00
bool mouse_enable = settings->bools.menu_mouse_enable;
bool pointer_enable = settings->bools.menu_pointer_enable;
2015-03-08 23:36:12 +01:00
if (!xmb)
return;
2015-09-25 23:37:02 +02:00
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
delta.current = delta_time;
if (menu_animation_get_ideal_delta_time(&delta))
2017-01-09 16:39:09 +01:00
menu_animation_update(delta.ideal);
2017-04-28 13:43:47 +02:00
if (pointer_enable || mouse_enable)
2015-04-16 17:39:40 +02:00
{
size_t selection = menu_navigation_get_selection();
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS)
2017-09-28 08:42:12 +02:00
+ (xmb->cursor_size/2);
unsigned first = 0, last = end;
unsigned height;
2016-04-20 17:37:31 +02:00
video_driver_get_size(NULL, &height);
if (height)
xmb_calculate_visible_range(xmb, height, end, selection, &first, &last);
for (i = first; i <= last; i++)
{
2017-09-28 08:42:12 +02:00
float item_y1 = xmb->margins_screen_top
+ xmb_item_y(xmb, (int)i, selection);
2017-09-28 08:42:12 +02:00
float item_y2 = item_y1 + xmb->icon_size;
2017-04-28 13:43:47 +02:00
if (pointer_enable)
{
if (pointer_y > item_y1 && pointer_y < item_y2)
2015-09-26 02:52:05 +02:00
menu_input_ctl(MENU_INPUT_CTL_POINTER_PTR, &i);
}
2017-04-28 13:43:47 +02:00
if (mouse_enable)
{
2015-09-24 17:34:44 +02:00
if (mouse_y > item_y1 && mouse_y < item_y2)
2015-09-26 02:52:05 +02:00
menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i);
}
2015-04-16 17:39:40 +02:00
}
2015-03-08 23:36:12 +01:00
}
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
if (i >= end)
{
i = 0;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &i);
}
menu_animation_ctl(MENU_ANIMATION_CTL_CLEAR_ACTIVE, NULL);
}
static bool xmb_shader_pipeline_active(video_frame_info_t *video_info)
{
if (string_is_not_equal_fast(menu_driver_ident(), "xmb", 3))
return false;
if (video_info->menu_shader_pipeline == XMB_SHADER_PIPELINE_WALLPAPER)
return false;
return true;
}
2016-04-21 05:04:01 +02:00
static void xmb_draw_bg(
xmb_handle_t *xmb,
video_frame_info_t *video_info,
2016-04-21 05:04:01 +02:00
unsigned width,
unsigned height,
float alpha,
uintptr_t texture_id,
2016-04-22 17:11:56 +07:00
float *coord_black,
float *coord_white)
2016-04-16 17:57:51 +02:00
{
2016-04-21 05:04:01 +02:00
menu_display_ctx_draw_t draw;
bool running = video_info->libretro_running;
2016-04-21 04:54:07 +02:00
2016-04-22 17:43:23 +07:00
draw.x = 0;
draw.y = 0;
2016-04-21 05:04:01 +02:00
draw.texture = texture_id;
draw.width = width;
draw.height = height;
2016-04-22 17:11:56 +07:00
draw.color = &coord_black[0];
2016-04-21 05:04:01 +02:00
draw.vertex = NULL;
draw.tex_coord = NULL;
draw.vertex_count = 4;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
2016-05-08 11:11:28 +02:00
draw.pipeline.id = 0;
draw.pipeline.active = xmb_shader_pipeline_active(video_info);
2016-04-21 05:04:01 +02:00
menu_display_blend_begin();
menu_display_set_viewport(video_info->width, video_info->height);
2016-04-22 12:32:32 +07:00
2016-06-07 00:00:28 +02:00
#ifdef HAVE_SHADERPIPELINE
if (video_info->menu_shader_pipeline > XMB_SHADER_PIPELINE_WALLPAPER
2016-10-30 17:14:13 -05:00
&&
(video_info->xmb_color_theme != XMB_THEME_WALLPAPER))
2016-04-22 12:32:32 +07:00
{
draw.color = xmb_gradient_ident(video_info);
if (running)
menu_display_set_alpha(draw.color, coord_black[3]);
else
menu_display_set_alpha(draw.color, coord_white[3]);
menu_display_draw_gradient(&draw, video_info);
2016-05-08 11:11:28 +02:00
draw.pipeline.id = VIDEO_SHADER_MENU_2;
switch (video_info->menu_shader_pipeline)
{
case XMB_SHADER_PIPELINE_RIBBON:
draw.pipeline.id = VIDEO_SHADER_MENU;
break;
case XMB_SHADER_PIPELINE_SIMPLE_SNOW:
draw.pipeline.id = VIDEO_SHADER_MENU_3;
break;
case XMB_SHADER_PIPELINE_SNOW:
draw.pipeline.id = VIDEO_SHADER_MENU_4;
break;
2017-01-08 03:56:47 +01:00
case XMB_SHADER_PIPELINE_BOKEH:
draw.pipeline.id = VIDEO_SHADER_MENU_5;
break;
default:
break;
}
2016-04-24 22:56:28 +02:00
menu_display_draw_pipeline(&draw);
2016-04-22 12:32:32 +07:00
}
else
2016-06-07 00:00:28 +02:00
#endif
2016-04-22 12:32:32 +07:00
{
uintptr_t texture = draw.texture;
if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER)
draw.color = xmb_gradient_ident(video_info);
if (running)
menu_display_set_alpha(draw.color, coord_black[3]);
else
menu_display_set_alpha(draw.color, coord_white[3]);
if (video_info->xmb_color_theme != XMB_THEME_WALLPAPER)
menu_display_draw_gradient(&draw, video_info);
{
float override_opacity = video_info->menu_wallpaper_opacity;
bool add_opacity = false;
draw.texture = texture;
menu_display_set_alpha(draw.color, coord_white[3]);
if (draw.texture)
draw.color = &coord_white[0];
if (running || video_info->xmb_color_theme == XMB_THEME_WALLPAPER)
add_opacity = true;
menu_display_draw_bg(&draw, video_info, add_opacity, override_opacity);
}
2016-04-22 12:32:32 +07:00
}
menu_display_draw(&draw);
menu_display_blend_end();
2016-04-12 16:25:13 +02:00
}
static void xmb_draw_dark_layer(
xmb_handle_t *xmb,
unsigned width,
unsigned height)
{
menu_display_ctx_draw_t draw;
2016-05-10 02:32:49 +02:00
struct video_coords coords;
float black[16] = {
0, 0, 0, 1,
0, 0, 0, 1,
0, 0, 0, 1,
0, 0, 0, 1,
};
2016-04-22 17:43:23 +07:00
menu_display_set_alpha(black, MIN(xmb->alpha, 0.75));
coords.vertices = 4;
coords.vertex = NULL;
coords.tex_coord = NULL;
coords.lut_tex_coord = NULL;
coords.color = &black[0];
draw.x = 0;
draw.y = 0;
draw.width = width;
draw.height = height;
draw.coords = &coords;
draw.matrix_data = NULL;
draw.texture = menu_display_white_texture;
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
2016-05-08 11:11:28 +02:00
draw.pipeline.id = 0;
menu_display_blend_begin();
menu_display_draw(&draw);
menu_display_blend_end();
}
2017-01-18 21:23:18 +01:00
static void xmb_frame(void *data, video_frame_info_t *video_info)
2014-10-20 20:00:39 +02:00
{
size_t selection;
size_t percent_width = 0;
math_matrix_4x4 mymat;
unsigned i;
2016-02-09 04:43:15 +01:00
menu_display_ctx_rotate_draw_t rotate_draw;
2016-10-29 08:38:14 +02:00
char msg[1024];
char title_msg[255];
char title_truncated[255];
menu_display_frame_info_t menu_disp_info;
2017-04-23 13:46:21 +02:00
settings_t *settings = config_get_ptr();
unsigned width = video_info->width;
unsigned height = video_info->height;
2015-06-12 16:25:32 +02:00
bool render_background = false;
2016-04-21 07:02:30 +02:00
file_list_t *selection_buf = NULL;
xmb_handle_t *xmb = (xmb_handle_t*)data;
2014-10-20 20:00:39 +02:00
2015-12-10 15:44:26 +01:00
if (!xmb)
return;
xmb->frame_count++;
menu_disp_info.shadows_enable = video_info->xmb_shadows_enable;
2016-08-26 00:28:57 +02:00
msg[0] = '\0';
title_msg[0] = '\0';
title_truncated[0] = '\0';
2017-05-27 16:31:47 +02:00
font_driver_bind_block(xmb->font, &xmb->raster_block);
font_driver_bind_block(xmb->font2, &xmb->raster_block2);
2015-03-27 11:20:10 -03:00
xmb->raster_block.carr.coords.vertices = 0;
2016-10-20 09:52:17 +02:00
xmb->raster_block2.carr.coords.vertices = 0;
2015-03-25 13:42:25 -03:00
2016-04-22 17:43:23 +07:00
menu_display_set_alpha(coord_black, MIN(
(float)video_info->xmb_alpha_factor/100, xmb->alpha));
2016-04-22 17:11:56 +07:00
menu_display_set_alpha(coord_white, xmb->alpha);
2015-09-06 23:15:03 +02:00
2016-04-21 05:04:01 +02:00
xmb_draw_bg(
xmb,
video_info,
2016-04-21 05:04:01 +02:00
width,
height,
xmb->alpha,
xmb->textures.bg,
2016-04-22 17:11:56 +07:00
coord_black,
coord_white);
2014-10-20 20:00:39 +02:00
selection = menu_navigation_get_selection();
2016-08-26 00:28:57 +02:00
strlcpy(title_truncated, xmb->title_name, sizeof(title_truncated));
if (selection > 1)
title_truncated[25] = '\0';
2016-04-21 07:02:30 +02:00
/* Title text */
xmb_draw_text(menu_disp_info, xmb,
2017-09-28 08:42:12 +02:00
title_truncated, xmb->margins_title_left,
xmb->margins_title_top,
1, 1, TEXT_ALIGN_LEFT,
2016-10-20 09:52:17 +02:00
width, height, xmb->font);
2014-11-15 00:35:45 +01:00
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_core_enable &&
2017-04-23 13:46:21 +02:00
menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0)
2017-09-28 08:42:12 +02:00
xmb_draw_text(menu_disp_info, xmb, title_msg, xmb->margins_title_left,
height - xmb->margins_title_bottom, 1, 1, TEXT_ALIGN_LEFT,
width, height, xmb->font);
2014-10-20 20:00:39 +02:00
2016-02-09 04:43:15 +01:00
rotate_draw.matrix = &mymat;
rotate_draw.rotation = 0;
rotate_draw.scale_x = 1;
rotate_draw.scale_y = 1;
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw);
menu_display_blend_begin();
if (xmb->savestate_thumbnail)
xmb_draw_thumbnail(menu_disp_info,
xmb, &coord_white[0], width, height,
2017-09-28 08:42:12 +02:00
xmb->margins_screen_left
+ xmb->icon_spacing_horizontal +
xmb->icon_spacing_horizontal * 4 - xmb->icon_size / 4,
xmb->margins_screen_top + xmb->icon_size + xmb->savestate_thumbnail_height,
xmb->savestate_thumbnail_width, xmb->savestate_thumbnail_height,
xmb->savestate_thumbnail);
else if (xmb->thumbnail
&& !string_is_equal(xmb_thumbnails_ident(),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
{
#ifdef XMB_DEBUG
RARCH_LOG("[XMB thumbnail] width: %.2f, height: %.2f\n", xmb->thumbnail_width, xmb->thumbnail_height);
RARCH_LOG("[XMB thumbnail] w: %.2f, h: %.2f\n", width, height);
#endif
xmb_draw_thumbnail(menu_disp_info,
xmb, &coord_white[0], width, height,
2017-09-28 08:42:12 +02:00
xmb->margins_screen_left + xmb->icon_spacing_horizontal +
xmb->icon_spacing_horizontal*4 - xmb->icon_size / 4,
xmb->margins_screen_top + xmb->icon_size + xmb->thumbnail_height,
xmb->thumbnail_width, xmb->thumbnail_height,
xmb->thumbnail);
}
2016-04-21 07:02:30 +02:00
/* Clock image */
2016-04-22 17:43:23 +07:00
menu_display_set_alpha(coord_white, MIN(xmb->alpha, 1.00f));
if (video_info->battery_level_enable)
{
2016-12-24 01:44:30 +01:00
char msg[12];
static retro_time_t last_time = 0;
bool charging = false;
retro_time_t current_time = cpu_features_get_time_usec();
int percent = 0;
2016-12-20 09:18:07 -05:00
enum frontend_powerstate state = get_last_powerstate(&percent);
2016-12-24 01:44:30 +01:00
if (state == FRONTEND_POWERSTATE_CHARGING)
charging = true;
2016-12-24 01:44:30 +01:00
if (current_time - last_time >= BATTERY_LEVEL_CHECK_INTERVAL)
{
2016-12-20 09:18:07 -05:00
last_time = current_time;
task_push_get_powerstate();
}
*msg = '\0';
if (percent > 0)
{
2017-09-28 08:42:12 +02:00
size_t x_pos = xmb->icon_size / 6;
size_t x_pos_icon = xmb->margins_title_left;
2016-12-20 09:18:07 -05:00
if (coord_white[3] != 0)
xmb_draw_icon(
menu_disp_info,
2017-09-28 08:42:12 +02:00
xmb->icon_size,
2016-12-20 09:18:07 -05:00
&mymat,
2017-01-30 21:13:44 -05:00
xmb->textures.list[charging
2016-12-24 01:44:30 +01:00
? XMB_TEXTURE_BATTERY_CHARGING : XMB_TEXTURE_BATTERY_FULL],
2017-09-28 08:42:12 +02:00
width - (xmb->icon_size / 2) - x_pos_icon,
xmb->icon_size,
2016-12-20 09:18:07 -05:00
width,
height,
1,
0,
1,
&coord_white[0],
xmb->shadow_offset);
2016-12-20 09:18:07 -05:00
snprintf(msg, sizeof(msg), "%d%%", percent);
percent_width = (unsigned)font_driver_get_message_width(xmb->font, msg, (unsigned)strlen(msg), 1);
xmb_draw_text(menu_disp_info, xmb, msg,
2017-09-28 08:42:12 +02:00
width - xmb->margins_title_left - x_pos,
xmb->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT,
2016-12-20 09:18:07 -05:00
width, height, xmb->font);
}
}
if (video_info->timedate_enable)
{
menu_display_ctx_datetime_t datetime;
char timedate[255];
int x_pos = 0;
if (coord_white[3] != 0)
{
int x_pos = 0;
if (percent_width)
2017-09-28 08:42:12 +02:00
x_pos = percent_width + (xmb->icon_size / 2.5);
xmb_draw_icon(
menu_disp_info,
2017-09-28 08:42:12 +02:00
xmb->icon_size,
&mymat,
xmb->textures.list[XMB_TEXTURE_CLOCK],
2017-09-28 08:42:12 +02:00
width - xmb->icon_size - x_pos,
xmb->icon_size,
width,
height,
1,
0,
1,
&coord_white[0],
xmb->shadow_offset);
}
timedate[0] = '\0';
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = 4;
menu_display_timedate(&datetime);
if (percent_width)
2017-09-28 08:42:12 +02:00
x_pos = percent_width + (xmb->icon_size / 2.5);
xmb_draw_text(menu_disp_info, xmb, timedate,
2017-09-28 08:42:12 +02:00
width - xmb->margins_title_left - xmb->icon_size / 4 - x_pos,
xmb->margins_title_top, 1, 1, TEXT_ALIGN_RIGHT,
width, height, xmb->font);
}
2016-04-21 07:02:30 +02:00
/* Arrow image */
2017-09-28 08:42:12 +02:00
menu_display_set_alpha(coord_white, MIN(xmb->textures_arrow_alpha, xmb->alpha));
2016-04-22 17:43:23 +07:00
2016-04-22 17:11:56 +07:00
if (coord_white[3] != 0)
2016-04-21 09:14:25 +02:00
xmb_draw_icon(
menu_disp_info,
2017-09-28 08:42:12 +02:00
xmb->icon_size,
2015-09-06 23:24:51 +02:00
&mymat,
2016-03-02 22:17:05 +01:00
xmb->textures.list[XMB_TEXTURE_ARROW],
2017-09-28 08:42:12 +02:00
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->active_item_factor,
2015-09-06 23:24:51 +02:00
width,
height,
2017-09-28 08:42:12 +02:00
xmb->textures_arrow_alpha,
2015-09-06 23:24:51 +02:00
0,
2016-05-09 03:57:02 +07:00
1,
&coord_white[0],
xmb->shadow_offset);
2015-03-10 03:42:26 +01:00
menu_display_blend_begin();
2016-04-21 07:02:30 +02:00
/* Horizontal tab icons */
for (i = 0; i <= xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
2016-08-18 16:42:39 +02:00
+ xmb->system_tab_end; i++)
2016-04-21 04:12:04 +02:00
{
xmb_node_t *node = xmb_get_node(xmb, i);
if (!node)
continue;
2016-04-22 17:43:23 +07:00
menu_display_set_alpha(item_color, MIN(node->alpha, xmb->alpha));
2016-04-21 04:12:04 +02:00
if (item_color[3] != 0)
2016-04-21 09:14:25 +02:00
{
menu_display_ctx_rotate_draw_t rotate_draw;
math_matrix_4x4 mymat;
uintptr_t texture = node->icon;
2017-09-28 08:42:12 +02:00
float x = xmb->x + xmb->categories_x_pos +
xmb->margins_screen_left +
xmb->icon_spacing_horizontal * (i + 1) - xmb->icon_size / 2.0;
float y = xmb->margins_screen_top + xmb->icon_size / 2.0;
2016-04-21 09:14:25 +02:00
float rotation = 0;
float scale_factor = node->zoom;
rotate_draw.matrix = &mymat;
rotate_draw.rotation = rotation;
rotate_draw.scale_x = scale_factor;
rotate_draw.scale_y = scale_factor;
rotate_draw.scale_z = 1;
rotate_draw.scale_enable = true;
menu_display_rotate_z(&rotate_draw);
2016-04-21 09:14:25 +02:00
2016-04-21 09:18:03 +02:00
xmb_draw_icon(
menu_disp_info,
2017-09-28 08:42:12 +02:00
xmb->icon_size,
2016-04-21 09:18:03 +02:00
&mymat,
texture,
x,
y,
width,
height,
1.0,
rotation,
scale_factor,
2016-05-09 03:57:02 +07:00
&item_color[0],
xmb->shadow_offset);
2016-04-21 09:14:25 +02:00
}
2016-04-21 04:12:04 +02:00
}
2014-11-11 16:28:40 +01:00
menu_display_blend_end();
2016-04-21 07:02:30 +02:00
/* Vertical icons */
2017-09-28 05:00:00 +02:00
if (xmb)
xmb_draw_items(
video_info,
menu_disp_info,
xmb,
xmb->selection_buf_old,
xmb->selection_ptr_old,
(xmb_list_get_size(xmb, MENU_LIST_PLAIN) > 1)
2017-09-28 08:42:12 +02:00
? xmb->categories_selection_ptr : xmb->categories_selection_ptr_old,
2017-09-28 05:00:00 +02:00
&item_color[0],
width,
height);
2016-04-21 07:02:30 +02:00
selection_buf = menu_entries_get_selection_buf_ptr(0);
2017-09-28 05:00:00 +02:00
if (xmb)
xmb_draw_items(
video_info,
menu_disp_info,
xmb,
selection_buf,
selection,
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr,
2017-09-28 05:00:00 +02:00
&item_color[0],
width,
height);
2016-04-21 07:02:30 +02:00
2017-05-27 16:31:47 +02:00
font_driver_flush(video_info->width, video_info->height, xmb->font);
font_driver_bind_block(xmb->font, NULL);
font_driver_flush(video_info->width, video_info->height, xmb->font2);
font_driver_bind_block(xmb->font2, NULL);
2016-09-15 18:50:33 +02:00
if (menu_input_dialog_get_display_kb())
2014-10-09 01:21:22 +02:00
{
2016-09-15 18:56:51 +02:00
const char *str = menu_input_dialog_get_buffer();
2016-09-15 19:07:30 +02:00
const char *label = menu_input_dialog_get_label_buffer();
2016-09-15 18:56:51 +02:00
snprintf(msg, sizeof(msg), "%s\n%s", label, str);
2015-03-08 13:17:07 +01:00
render_background = true;
2014-10-09 01:21:22 +02:00
}
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->box_message))
2014-10-09 01:21:22 +02:00
{
2015-03-08 13:17:07 +01:00
strlcpy(msg, xmb->box_message,
sizeof(msg));
2017-09-29 19:55:06 +02:00
free(xmb->box_message);
xmb->box_message = NULL;
2015-03-08 13:17:07 +01:00
render_background = true;
}
if (render_background)
{
xmb_draw_dark_layer(xmb, width, height);
2017-02-27 20:34:17 +01:00
xmb_render_messagebox_internal(menu_disp_info, video_info, xmb, msg, &coord_white[0]);
2014-10-09 01:21:22 +02:00
}
2016-04-21 07:02:30 +02:00
/* Cursor image */
if (xmb->mouse_show)
{
menu_display_set_alpha(coord_white, MIN(xmb->alpha, 1.00f));
menu_display_draw_cursor(
&coord_white[0],
2017-09-28 08:42:12 +02:00
xmb->cursor_size,
xmb->textures.list[XMB_TEXTURE_POINTER],
menu_input_mouse_state(MENU_MOUSE_X_AXIS),
menu_input_mouse_state(MENU_MOUSE_Y_AXIS),
width,
height);
}
2016-12-12 03:57:56 +01:00
2017-01-19 00:01:55 +01:00
menu_display_unset_viewport(video_info->width, video_info->height);
2014-10-09 01:21:22 +02:00
}
static void xmb_layout_ps3(xmb_handle_t *xmb, int width)
{
unsigned new_font_size, new_header_height;
2016-12-12 03:24:31 +01:00
settings_t *settings = config_get_ptr();
2017-01-30 21:13:44 -05:00
float scale_factor =
2017-04-28 21:03:04 +02:00
(settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100);
2016-12-12 03:24:31 +01:00
xmb->above_subitem_offset = 1.5;
xmb->above_item_offset = -1.0;
xmb->active_item_factor = 3.0;
xmb->under_item_offset = 5.0;
2017-09-28 08:42:12 +02:00
xmb->categories_active_zoom = 1.0;
xmb->categories_passive_zoom = 0.5;
xmb->items_active_zoom = 1.0;
xmb->items_passive_zoom = 0.5;
2017-09-28 08:42:12 +02:00
xmb->categories_active_alpha = 1.0;
xmb->categories_passive_alpha = 0.85;
xmb->items_active_alpha = 1.0;
xmb->items_passive_alpha = 0.85;
xmb->shadow_offset = 2.0;
new_font_size = 32.0 * scale_factor;
2016-10-20 09:52:17 +02:00
xmb->font2_size = 24.0 * scale_factor;
new_header_height = 128.0 * scale_factor;
2016-12-12 03:18:48 +01:00
xmb->thumbnail_width = 460.0 * scale_factor;
2016-12-01 02:43:53 +01:00
xmb->savestate_thumbnail_width= 460.0 * scale_factor;
2017-09-28 08:42:12 +02:00
xmb->cursor_size = 64.0;
2015-09-26 23:37:25 +02:00
2017-09-28 08:42:12 +02:00
xmb->icon_spacing_horizontal = 200.0 * scale_factor;
xmb->icon_spacing_vertical = 64.0 * scale_factor;
2017-09-28 08:42:12 +02:00
xmb->margins_screen_top = (256+32) * scale_factor;
xmb->margins_screen_left = 336.0 * scale_factor;
2016-12-12 03:18:48 +01:00
2017-09-28 08:42:12 +02:00
xmb->margins_title_left = 60 * scale_factor;
xmb->margins_title_top = 60 * scale_factor + new_font_size / 3;
xmb->margins_title_bottom = 60 * scale_factor - new_font_size / 3;
2016-12-12 03:18:48 +01:00
2017-09-28 08:42:12 +02:00
xmb->margins_label_left = 85.0 * scale_factor;
xmb->margins_label_top = new_font_size / 3.0;
2016-12-12 03:18:48 +01:00
2017-09-28 08:42:12 +02:00
xmb->margins_setting_left = 600.0 * scale_factor;
xmb->margins_dialog = 48 * scale_factor;
2016-12-12 03:18:48 +01:00
2017-09-28 08:42:12 +02:00
xmb->margins_slice = 16;
2017-09-28 08:42:12 +02:00
xmb->icon_size = 128.0 * scale_factor;
xmb->font_size = new_font_size;
2016-12-12 03:20:00 +01:00
#ifdef XMB_DEBUG
2017-09-28 08:42:12 +02:00
RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left);
RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top);
RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left);
RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top);
RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom);
RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left);
RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top);
RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left);
RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal);
RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical);
RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size);
2016-12-12 03:18:48 +01:00
#endif
menu_display_set_header_height(new_header_height);
}
static void xmb_layout_psp(xmb_handle_t *xmb, int width)
{
unsigned new_font_size, new_header_height;
2016-12-12 03:24:31 +01:00
settings_t *settings = config_get_ptr();
2017-01-30 21:13:44 -05:00
float scale_factor =
2017-04-28 21:03:04 +02:00
((settings->uints.menu_xmb_scale_factor * width) / (1920.0 * 100)) * 1.5;
2016-10-10 22:18:42 +01:00
#ifdef _3DS
2017-04-28 21:03:04 +02:00
scale_factor = settings->uints.menu_xmb_scale_factor / 400.0;
2016-10-10 22:18:42 +01:00
#endif
xmb->above_subitem_offset = 1.5;
xmb->above_item_offset = -1.0;
xmb->active_item_factor = 2.0;
xmb->under_item_offset = 3.0;
2017-09-28 08:42:12 +02:00
xmb->categories_active_zoom = 1.0;
xmb->categories_passive_zoom = 1.0;
xmb->items_active_zoom = 1.0;
xmb->items_passive_zoom = 1.0;
2017-09-28 08:42:12 +02:00
xmb->categories_active_alpha = 1.0;
xmb->categories_passive_alpha = 0.85;
xmb->items_active_alpha = 1.0;
xmb->items_passive_alpha = 0.85;
xmb->shadow_offset = 1.0;
new_font_size = 32.0 * scale_factor;
2016-10-20 09:52:17 +02:00
xmb->font2_size = 24.0 * scale_factor;
new_header_height = 128.0 * scale_factor;
2017-09-28 08:42:12 +02:00
xmb->margins_screen_top = (256+32) * scale_factor;
xmb->thumbnail_width = 460.0 * scale_factor;
2016-12-01 02:43:53 +01:00
xmb->savestate_thumbnail_width= 460.0 * scale_factor;
2017-09-28 08:42:12 +02:00
xmb->cursor_size = 64.0;
xmb->icon_spacing_horizontal = 250.0 * scale_factor;
xmb->icon_spacing_vertical = 108.0 * scale_factor;
xmb->margins_screen_left = 136.0 * scale_factor;
xmb->margins_title_left = 60 * scale_factor;
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;
xmb->margins_label_top = new_font_size / 3.0;
xmb->margins_setting_left = 600.0 * scale_factor;
xmb->margins_dialog = 48 * scale_factor;
xmb->margins_slice = 16;
xmb->icon_size = 128.0 * scale_factor;
xmb->font_size = new_font_size;
2016-12-12 03:20:00 +01:00
#ifdef XMB_DEBUG
2017-09-28 08:42:12 +02:00
RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins_screen_left);
RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins_screen_top);
RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins_title_left);
RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins_title_top);
RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins_title_bottom);
RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins_label_left);
RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins_label_top);
RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins_setting_left);
RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon_spacing_horizontal);
RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon_spacing_vertical);
RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon_size);
2016-12-12 03:18:48 +01:00
#endif
menu_display_set_header_height(new_header_height);
}
static void xmb_layout(xmb_handle_t *xmb)
{
unsigned width, height, i, current, end;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
video_driver_get_size(&width, &height);
/* Mimic the layout of the PSP instead of the PS3 on tiny screens */
2016-10-10 22:18:42 +01:00
if (width > 320 && height > 240)
xmb_layout_ps3(xmb, width);
else
xmb_layout_psp(xmb, width);
current = (unsigned)selection;
end = (unsigned)menu_entries_get_end();
for (i = 0; i < end; i++)
{
2017-09-28 08:42:12 +02:00
float ia = xmb->items_passive_alpha;
float iz = xmb->items_passive_zoom;
2015-10-19 16:32:51 +02:00
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(
2015-10-17 18:17:59 +02:00
selection_buf, i);
if (!node)
continue;
if (i == current)
{
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
iz = xmb->items_active_alpha;
}
node->alpha = ia;
node->label_alpha = ia;
node->zoom = iz;
node->y = xmb_item_y(xmb, i, current);
}
if (xmb->depth <= 1)
return;
current = (unsigned)xmb->selection_ptr_old;
end = (unsigned)file_list_get_size(xmb->selection_buf_old);
for (i = 0; i < end; i++)
{
2017-09-28 08:42:12 +02:00
float ia = 0;
float iz = xmb->items_passive_zoom;
xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset(
xmb->selection_buf_old, i);
if (!node)
continue;
if (i == current)
{
2017-09-28 08:42:12 +02:00
ia = xmb->items_active_alpha;
iz = xmb->items_active_alpha;
}
node->alpha = ia;
node->label_alpha = 0;
node->zoom = iz;
node->y = xmb_item_y(xmb, i, current);
2017-09-28 08:42:12 +02:00
node->x = xmb->icon_size * 1 * -2;
}
}
2017-01-09 16:26:50 +01:00
static void xmb_ribbon_set_vertex(float *ribbon_verts,
unsigned idx, unsigned row, unsigned col)
{
ribbon_verts[idx++] = ((float)col) / (XMB_RIBBON_COLS-1) * 2.0f - 1.0f;
2017-01-08 04:16:13 +01:00
ribbon_verts[idx++] = ((float)row) / (XMB_RIBBON_ROWS-1) * 2.0f - 1.0f;
}
2016-04-17 02:50:17 +07:00
2016-04-17 23:23:37 +02:00
static void xmb_init_ribbon(xmb_handle_t * xmb)
2016-04-17 02:50:17 +07:00
{
2016-05-10 02:32:49 +02:00
video_coords_t coords;
unsigned r, c, col;
unsigned i = 0;
video_coord_array_t *ca = menu_display_get_coords_array();
2017-01-25 18:43:04 +01:00
unsigned vertices_total = XMB_RIBBON_VERTICES;
float *dummy = (float*)calloc(4 * vertices_total, sizeof(float));
float *ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float));
/* Set up vertices */
for (r = 0; r < XMB_RIBBON_ROWS - 1; r++)
{
for (c = 0; c < XMB_RIBBON_COLS; c++)
2016-04-17 02:50:17 +07:00
{
col = r % 2 ? XMB_RIBBON_COLS - c - 1 : c;
xmb_ribbon_set_vertex(ribbon_verts, i, r, col);
xmb_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col);
i += 4;
2016-04-17 02:50:17 +07:00
}
}
coords.color = dummy;
coords.vertex = ribbon_verts;
coords.tex_coord = dummy;
coords.lut_tex_coord = dummy;
coords.vertices = vertices_total;
2016-11-17 21:17:24 -05:00
video_coord_array_append(ca, &coords, coords.vertices);
free(dummy);
free(ribbon_verts);
2016-04-17 02:50:17 +07:00
}
static void *xmb_init(void **userdata, bool video_is_threaded)
2014-10-09 01:21:22 +02:00
{
unsigned width, height;
xmb_handle_t *xmb = NULL;
2016-08-18 16:42:39 +02:00
settings_t *settings = config_get_ptr();
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
2014-10-09 01:21:22 +02:00
if (!menu)
2015-02-02 18:44:56 +01:00
goto error;
2014-10-09 01:21:22 +02:00
if (!menu_display_init_first_driver(video_is_threaded))
goto error;
video_driver_get_size(&width, &height);
2015-12-11 14:55:04 +01:00
xmb = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t));
2015-12-11 14:55:04 +01:00
if (!xmb)
2015-02-02 18:44:56 +01:00
goto error;
*userdata = xmb;
2014-10-10 15:52:12 +02:00
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
2015-02-02 18:44:56 +01:00
if (!xmb->selection_buf_old)
goto error;
2017-09-28 08:42:12 +02:00
xmb->categories_active_idx = 0;
xmb->categories_active_idx_old = 0;
xmb->x = 0;
xmb->categories_x_pos = 0;
xmb->textures_arrow_alpha = 0;
xmb->depth = 1;
xmb->old_depth = 1;
xmb->alpha = 0;
2016-08-18 16:42:39 +02:00
xmb->system_tab_end = 0;
xmb->tabs[xmb->system_tab_end] = XMB_SYSTEM_TAB_MAIN;
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_settings)
2016-08-18 16:42:39 +02:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_SETTINGS;
2017-08-13 18:44:50 -04:00
if (settings->bools.menu_xmb_show_favorites)
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_FAVORITES;
2017-08-13 19:10:09 -04:00
if (settings->bools.menu_xmb_show_history)
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_HISTORY;
2016-08-18 16:42:39 +02:00
#ifdef HAVE_IMAGEVIEWER
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_images)
2016-08-18 16:42:39 +02:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_IMAGES;
#endif
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_music)
2016-08-21 00:09:29 -05:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_MUSIC;
#ifdef HAVE_FFMPEG
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_video)
2016-12-12 03:54:53 -06:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_VIDEO;
2016-08-18 16:42:39 +02:00
#endif
#ifdef HAVE_NETWORKING
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_netplay)
2017-02-27 23:32:24 +01:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_NETPLAY;
#endif
2016-08-18 16:42:39 +02:00
#ifdef HAVE_LIBRETRODB
2017-04-28 13:43:47 +02:00
if (settings->bools.menu_xmb_show_add)
2016-08-18 16:42:39 +02:00
xmb->tabs[++xmb->system_tab_end] = XMB_SYSTEM_TAB_ADD;
#endif
menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL);
/* TODO/FIXME - we don't use framebuffer at all
* for XMB, we should refactor this dependency
* away. */
menu_display_set_width(width);
menu_display_set_height(height);
menu_display_allocate_white_texture();
2016-12-19 18:40:00 +01:00
xmb->horizontal_list = (file_list_t*)calloc(1, sizeof(file_list_t));
if (xmb->horizontal_list)
xmb_init_horizontal_list(xmb);
2016-04-17 23:23:37 +02:00
xmb_init_ribbon(xmb);
2014-11-11 16:28:40 +01:00
2014-10-09 01:21:22 +02:00
return menu;
2015-02-02 18:44:56 +01:00
error:
if (menu)
free(menu);
2015-06-11 21:12:08 +02:00
if (xmb)
{
if (xmb->selection_buf_old)
free(xmb->selection_buf_old);
2015-06-11 21:12:08 +02:00
xmb->selection_buf_old = NULL;
if (xmb->horizontal_list)
{
xmb_free_list_nodes(xmb->horizontal_list, false);
file_list_free(xmb->horizontal_list);
}
2015-06-11 21:12:08 +02:00
xmb->horizontal_list = NULL;
}
2015-02-02 18:44:56 +01:00
return NULL;
2014-10-09 01:21:22 +02:00
}
static void xmb_free(void *data)
{
2016-02-04 21:40:29 +01:00
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-03-28 20:50:51 +01:00
if (xmb)
2015-03-28 17:54:09 -03:00
{
2015-06-11 21:12:08 +02:00
if (xmb->selection_buf_old)
{
xmb_free_list_nodes(xmb->selection_buf_old, false);
2015-06-12 20:27:15 -03:00
file_list_free(xmb->selection_buf_old);
}
2015-06-11 21:12:08 +02:00
if (xmb->horizontal_list)
{
xmb_free_list_nodes(xmb->horizontal_list, false);
2015-06-12 18:52:29 -03:00
file_list_free(xmb->horizontal_list);
}
xmb->selection_buf_old = NULL;
xmb->horizontal_list = NULL;
2016-05-10 02:32:49 +02:00
video_coord_array_free(&xmb->raster_block.carr);
2016-10-20 09:52:17 +02:00
video_coord_array_free(&xmb->raster_block2.carr);
2017-09-29 19:57:23 +02:00
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->box_message))
2017-09-29 19:57:23 +02:00
free(xmb->box_message);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_system))
2017-09-29 19:57:23 +02:00
free(xmb->thumbnail_system);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->thumbnail_content))
2017-09-29 19:57:23 +02:00
free(xmb->thumbnail_content);
2017-09-30 06:11:18 +02:00
if (!string_is_empty(xmb->savestate_thumbnail_file_path))
2017-09-29 19:57:23 +02:00
free(xmb->savestate_thumbnail_file_path);
2015-03-28 17:54:09 -03:00
}
2015-12-05 11:34:56 +01:00
font_driver_bind_block(NULL, NULL);
2014-10-09 01:21:22 +02:00
}
static void xmb_context_bg_destroy(xmb_handle_t *xmb)
{
if (!xmb)
return;
video_driver_texture_unload(&xmb->textures.bg);
video_driver_texture_unload(&menu_display_white_texture);
}
static bool xmb_load_image(void *userdata, void *data, enum menu_image_type type)
{
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
if (!xmb || !data)
return false;
switch (type)
{
case MENU_IMAGE_NONE:
break;
case MENU_IMAGE_WALLPAPER:
xmb_context_bg_destroy(xmb);
video_driver_texture_unload(&xmb->textures.bg);
video_driver_texture_load(data,
TEXTURE_FILTER_MIPMAP_LINEAR,
&xmb->textures.bg);
menu_display_allocate_white_texture();
break;
case MENU_IMAGE_THUMBNAIL:
{
struct texture_image *img = (struct texture_image*)data;
xmb->thumbnail_height = xmb->thumbnail_width
* (float)img->height / (float)img->width;
video_driver_texture_unload(&xmb->thumbnail);
video_driver_texture_load(data,
TEXTURE_FILTER_MIPMAP_LINEAR, &xmb->thumbnail);
}
break;
2016-12-01 02:43:53 +01:00
case MENU_IMAGE_SAVESTATE_THUMBNAIL:
{
struct texture_image *img = (struct texture_image*)data;
2016-12-01 02:43:53 +01:00
xmb->savestate_thumbnail_height = xmb->savestate_thumbnail_width
* (float)img->height / (float)img->width;
video_driver_texture_unload(&xmb->savestate_thumbnail);
video_driver_texture_load(data,
TEXTURE_FILTER_MIPMAP_LINEAR, &xmb->savestate_thumbnail);
}
break;
}
return true;
}
2016-04-18 02:20:54 +02:00
static const char *xmb_texture_path(unsigned id)
{
switch (id)
{
case XMB_TEXTURE_MAIN_MENU:
#if defined(HAVE_LAKKA)
return "lakka.png";
#else
return "retroarch.png";
#endif
case XMB_TEXTURE_SETTINGS:
return "settings.png";
case XMB_TEXTURE_HISTORY:
return "history.png";
case XMB_TEXTURE_FAVORITES:
return "favorites.png";
case XMB_TEXTURE_ADD_FAVORITE:
return "add-favorite.png";
2016-07-30 19:29:10 +02:00
case XMB_TEXTURE_MUSICS:
return "musics.png";
#ifdef HAVE_FFMPEG
case XMB_TEXTURE_MOVIES:
2016-07-30 19:29:10 +02:00
return "movies.png";
2016-07-30 19:30:29 +02:00
#endif
#ifdef HAVE_IMAGEVIEWER
2016-07-30 19:29:10 +02:00
case XMB_TEXTURE_IMAGES:
return "images.png";
#endif
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_SETTING:
return "setting.png";
case XMB_TEXTURE_SUBSETTING:
return "subsetting.png";
case XMB_TEXTURE_ARROW:
return "arrow.png";
case XMB_TEXTURE_RUN:
return "run.png";
case XMB_TEXTURE_CLOSE:
return "close.png";
case XMB_TEXTURE_RESUME:
return "resume.png";
case XMB_TEXTURE_CLOCK:
return "clock.png";
case XMB_TEXTURE_BATTERY_FULL:
return "battery-full.png";
case XMB_TEXTURE_BATTERY_CHARGING:
return "battery-charging.png";
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_POINTER:
return "pointer.png";
case XMB_TEXTURE_SAVESTATE:
return "savestate.png";
case XMB_TEXTURE_LOADSTATE:
return "loadstate.png";
2016-09-13 22:58:52 +02:00
case XMB_TEXTURE_UNDO:
return "undo.png";
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_CORE_INFO:
return "core-infos.png";
2016-09-22 12:36:36 +02:00
case XMB_TEXTURE_WIFI:
return "wifi.png";
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_CORE_OPTIONS:
return "core-options.png";
case XMB_TEXTURE_INPUT_REMAPPING_OPTIONS:
return "core-input-remapping-options.png";
case XMB_TEXTURE_CHEAT_OPTIONS:
return "core-cheat-options.png";
case XMB_TEXTURE_DISK_OPTIONS:
return "core-disk-options.png";
case XMB_TEXTURE_SHADER_OPTIONS:
return "core-shader-options.png";
case XMB_TEXTURE_ACHIEVEMENT_LIST:
return "achievement-list.png";
case XMB_TEXTURE_SCREENSHOT:
return "screenshot.png";
case XMB_TEXTURE_RELOAD:
return "reload.png";
2017-08-18 18:30:31 +07:00
case XMB_TEXTURE_RENAME:
return "rename.png";
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_FILE:
return "file.png";
case XMB_TEXTURE_FOLDER:
return "folder.png";
case XMB_TEXTURE_ZIP:
return "zip.png";
case XMB_TEXTURE_MUSIC:
return "music.png";
case XMB_TEXTURE_FAVORITE:
return "favorites-content.png";
2016-04-18 02:20:54 +02:00
case XMB_TEXTURE_IMAGE:
return "image.png";
case XMB_TEXTURE_MOVIE:
return "movie.png";
case XMB_TEXTURE_CORE:
return "core.png";
case XMB_TEXTURE_RDB:
return "database.png";
case XMB_TEXTURE_CURSOR:
return "cursor.png";
case XMB_TEXTURE_SWITCH_ON:
return "on.png";
case XMB_TEXTURE_SWITCH_OFF:
return "off.png";
case XMB_TEXTURE_ADD:
return "add.png";
2017-01-23 01:30:50 +01:00
#ifdef HAVE_NETWORKING
case XMB_TEXTURE_NETPLAY:
return "netplay.png";
case XMB_TEXTURE_ROOM:
return "room.png";
2017-07-24 20:52:27 -05:00
/* stub these out until we have the icons
case XMB_TEXTURE_ROOM_LAN:
return "room_lan.png";
case XMB_TEXTURE_ROOM_MITM:
return "room_mitm.png";
2017-07-24 20:52:27 -05:00
*/
2017-01-23 01:30:50 +01:00
#endif
2016-11-03 08:55:24 +01:00
case XMB_TEXTURE_KEY:
return "key.png";
case XMB_TEXTURE_KEY_HOVER:
return "key-hover.png";
2017-02-27 20:34:17 +01:00
case XMB_TEXTURE_DIALOG_SLICE:
return "dialog-slice.png";
2016-04-18 02:20:54 +02:00
}
return NULL;
}
2016-02-04 21:40:29 +01:00
static void xmb_context_reset_textures(
xmb_handle_t *xmb, const char *iconpath)
2014-10-09 01:21:22 +02:00
{
2015-06-06 13:56:31 +02:00
unsigned i;
2015-06-06 13:56:31 +02:00
for (i = 0; i < XMB_TEXTURE_LAST; i++)
menu_display_reset_textures_list(xmb_texture_path(i), iconpath, &xmb->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR);
2015-06-06 13:58:06 +02:00
menu_display_allocate_white_texture();
2016-04-18 02:20:54 +02:00
xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU];
2017-09-28 08:42:12 +02:00
xmb->main_menu_node.alpha = xmb->categories_active_alpha;
xmb->main_menu_node.zoom = xmb->categories_active_zoom;
2015-10-20 19:11:43 +07:00
2016-03-02 22:17:05 +01:00
xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS];
2017-09-28 08:42:12 +02:00
xmb->settings_tab_node.alpha = xmb->categories_active_alpha;
xmb->settings_tab_node.zoom = xmb->categories_active_zoom;
2015-10-23 01:05:51 +07:00
2016-04-18 02:20:54 +02:00
xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY];
2017-09-28 08:42:12 +02:00
xmb->history_tab_node.alpha = xmb->categories_active_alpha;
xmb->history_tab_node.zoom = xmb->categories_active_zoom;
xmb->favorites_tab_node.icon = xmb->textures.list[XMB_TEXTURE_FAVORITES];
2017-09-28 08:42:12 +02:00
xmb->favorites_tab_node.alpha = xmb->categories_active_alpha;
xmb->favorites_tab_node.zoom = xmb->categories_active_zoom;
2016-07-30 19:29:10 +02:00
xmb->music_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MUSICS];
2017-09-28 08:42:12 +02:00
xmb->music_tab_node.alpha = xmb->categories_active_alpha;
xmb->music_tab_node.zoom = xmb->categories_active_zoom;
2016-07-30 19:29:10 +02:00
#ifdef HAVE_FFMPEG
xmb->video_tab_node.icon = xmb->textures.list[XMB_TEXTURE_MOVIES];
2017-09-28 08:42:12 +02:00
xmb->video_tab_node.alpha = xmb->categories_active_alpha;
xmb->video_tab_node.zoom = xmb->categories_active_zoom;
2016-07-30 19:29:10 +02:00
#endif
#ifdef HAVE_IMAGEVIEWER
xmb->images_tab_node.icon = xmb->textures.list[XMB_TEXTURE_IMAGES];
2017-09-28 08:42:12 +02:00
xmb->images_tab_node.alpha = xmb->categories_active_alpha;
xmb->images_tab_node.zoom = xmb->categories_active_zoom;
2016-07-30 19:29:10 +02:00
#endif
2016-04-18 02:20:54 +02:00
xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD];
2017-09-28 08:42:12 +02:00
xmb->add_tab_node.alpha = xmb->categories_active_alpha;
xmb->add_tab_node.zoom = xmb->categories_active_zoom;
#ifdef HAVE_NETWORKING
2017-09-28 08:42:12 +02:00
xmb->netplay_tab_node.icon = xmb->textures.list[XMB_TEXTURE_NETPLAY];
xmb->netplay_tab_node.alpha = xmb->categories_active_alpha;
xmb->netplay_tab_node.zoom = xmb->categories_active_zoom;
#endif
2015-06-06 13:56:31 +02:00
}
static void xmb_context_reset_background(const char *iconpath)
{
2017-09-11 04:40:35 +02:00
char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
settings_t *settings = config_get_ptr();
2016-10-16 01:45:50 +02:00
path[0] = '\0';
2017-09-11 04:40:35 +02:00
fill_pathname_join(path, iconpath, "bg.png",
PATH_MAX_LENGTH * sizeof(char));
2017-04-29 00:39:29 +02:00
if (!string_is_empty(settings->paths.path_menu_wallpaper))
2017-09-11 04:40:35 +02:00
strlcpy(path, settings->paths.path_menu_wallpaper,
PATH_MAX_LENGTH * sizeof(char));
2016-07-21 05:43:09 +02:00
if (path_file_exists(path))
task_push_image_load(path,
menu_display_handle_wallpaper_upload, NULL);
2017-09-11 04:40:35 +02:00
free(path);
}
static void xmb_context_reset(void *data, bool is_threaded)
2015-06-06 13:56:31 +02:00
{
2017-09-12 04:47:37 +02:00
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-06-06 13:56:31 +02:00
2017-09-12 04:47:37 +02:00
if (xmb)
{
char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
iconpath[0] = '\0';
2015-11-25 01:34:26 +07:00
2017-09-12 04:47:37 +02:00
fill_pathname_application_special(xmb->background_file_path,
sizeof(xmb->background_file_path),
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG);
2017-09-11 04:40:35 +02:00
2017-09-12 04:47:37 +02:00
fill_pathname_application_special(iconpath,
PATH_MAX_LENGTH * sizeof(char),
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
xmb_layout(xmb);
xmb->font = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT,
xmb->font_size,
is_threaded);
xmb->font2 = menu_display_font(APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_FONT,
xmb->font2_size,
is_threaded);
xmb_context_reset_textures(xmb, iconpath);
xmb_context_reset_background(iconpath);
xmb_context_reset_horizontal_list(xmb);
if (!string_is_equal(xmb_thumbnails_ident(),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
xmb_update_thumbnail_image(xmb);
xmb_update_savestate_thumbnail_image(xmb);
free(iconpath);
}
2014-10-09 01:21:22 +02:00
}
static void xmb_navigation_clear(void *data, bool pending_push)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-03-12 18:06:28 +01:00
if (!pending_push)
2015-12-10 16:14:53 +01:00
xmb_selection_pointer_changed(xmb, true);
}
static void xmb_navigation_pointer_changed(void *data)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-12-10 16:14:53 +01:00
xmb_selection_pointer_changed(xmb, true);
}
static void xmb_navigation_set(void *data, bool scroll)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-12-10 16:14:53 +01:00
xmb_selection_pointer_changed(xmb, true);
}
static void xmb_navigation_alphabet(void *data, size_t *unused)
{
xmb_handle_t *xmb = (xmb_handle_t*)data;
2015-12-10 16:14:53 +01:00
xmb_selection_pointer_changed(xmb, true);
}
static void xmb_list_insert(void *userdata,
file_list_t *list,
const char *path,
const char *fullpath,
const char *unused,
size_t list_size,
unsigned entry_type)
{
2015-06-13 16:22:05 +02:00
int current = 0;
int i = (int)list_size;
2015-06-13 16:22:05 +02:00
xmb_node_t *node = NULL;
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
2015-02-11 21:00:34 +01:00
if (!xmb || !list)
2015-02-11 21:00:34 +01:00
return;
2015-06-06 14:07:20 +02:00
node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
2015-06-15 14:59:07 -03:00
if (!node)
node = xmb_alloc_node();
2015-06-11 20:14:59 +02:00
if (!node)
{
RARCH_ERR("XMB node could not be allocated.\n");
return;
}
current = (int)selection;
if (!string_is_empty(fullpath))
{
if (node->fullpath)
free(node->fullpath);
node->fullpath = strdup(fullpath);
}
2017-09-28 08:42:12 +02:00
node->alpha = xmb->items_passive_alpha;
node->zoom = xmb->items_passive_zoom;
2014-10-20 20:00:39 +02:00
node->label_alpha = node->alpha;
2015-02-11 05:33:53 +01:00
node->y = xmb_item_y(xmb, i, current);
2015-02-02 18:44:56 +01:00
node->x = 0;
if (i == current)
{
2017-09-28 08:42:12 +02:00
node->alpha = xmb->items_active_alpha;
node->label_alpha = xmb->items_active_alpha;
node->zoom = xmb->items_active_alpha;
2015-02-02 18:44:56 +01:00
}
2015-06-11 20:14:59 +02:00
file_list_set_userdata(list, i, node);
}
2015-06-15 14:59:07 -03:00
static void xmb_list_clear(file_list_t *list)
{
menu_animation_ctx_tag tag = (uintptr_t)list;
2017-08-13 18:44:50 -04:00
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
2015-06-15 14:59:07 -03:00
xmb_free_list_nodes(list, false);
2015-06-15 14:59:07 -03:00
}
static void xmb_list_free(file_list_t *list, size_t a, size_t b)
{
xmb_list_clear(list);
}
static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst,
size_t first, size_t last)
2015-06-15 14:36:16 -03:00
{
size_t i, j = 0;
menu_animation_ctx_tag tag = (uintptr_t)dst;
menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag);
2015-06-15 14:36:16 -03:00
/* use true here because file_list_copy() doesn't free actiondata */
xmb_free_list_nodes(dst, true);
2015-06-15 14:36:16 -03:00
file_list_clear(dst);
file_list_reserve(dst, (last + 1) - first);
2015-09-28 18:44:28 +02:00
for (i = first; i <= last; ++i)
2015-06-15 14:36:16 -03:00
{
struct item_file *d = &dst->list[j];
struct item_file *s = &src->list[i];
void *src_udata = s->userdata;
void *src_adata = s->actiondata;
*d = *s;
d->alt = string_is_empty(d->alt) ? NULL : strdup(d->alt);
d->path = string_is_empty(d->path) ? NULL : strdup(d->path);
d->label = string_is_empty(d->label) ? NULL : strdup(d->label);
2015-06-15 14:36:16 -03:00
if (src_udata)
2017-09-03 23:39:25 -04:00
file_list_set_userdata(dst, j, (void*)xmb_copy_node((const xmb_node_t*)src_udata));
2015-06-15 14:36:16 -03:00
if (src_adata)
{
void *data = malloc(sizeof(menu_file_list_cbs_t));
2015-06-15 14:36:16 -03:00
memcpy(data, src_adata, sizeof(menu_file_list_cbs_t));
file_list_set_actiondata(dst, j, data);
2015-06-15 14:36:16 -03:00
}
++j;
2015-06-15 14:36:16 -03:00
}
dst->size = j;
2015-06-15 14:36:16 -03:00
}
static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action)
{
size_t stack_size, list_size;
xmb_handle_t *xmb = (xmb_handle_t*)data;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
2017-07-14 15:11:27 -04:00
settings_t *settings = config_get_ptr();
if (!xmb)
return;
2017-08-31 14:46:29 -03:00
/* FIXME: this shouldn't be happening at all */
if (selection >= selection_buf->size)
selection = selection_buf->size ? selection_buf->size - 1 : 0;
2017-08-31 14:46:29 -03:00
xmb->selection_ptr_old = selection;
/* Check whether to enable the horizontal animation. */
if (settings->bools.menu_horizontal_animation)
{
unsigned first = 0, last = 0;
unsigned height = 0;
video_driver_get_size(NULL, &height);
xmb_calculate_visible_range(xmb, height, selection_buf->size,
xmb->selection_ptr_old, &first, &last);
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old, first, last);
xmb->selection_ptr_old -= first;
last -= first;
first = 0;
}
2016-03-09 16:17:18 -05:00
list_size = xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL)
2016-08-18 16:42:39 +02:00
+ xmb->system_tab_end;
switch (type)
2015-02-02 20:40:29 +01:00
{
case MENU_LIST_PLAIN:
2015-02-02 20:40:29 +01:00
break;
case MENU_LIST_HORIZONTAL:
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr_old = xmb->categories_selection_ptr;
switch (action)
{
case MENU_ACTION_LEFT:
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr == 0)
{
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr = list_size;
xmb->categories_active_idx = (unsigned)(list_size - 1);
}
else
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr--;
break;
default:
2017-09-28 08:42:12 +02:00
if (xmb->categories_selection_ptr == list_size)
{
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr = 0;
xmb->categories_active_idx = 1;
}
else
2017-09-28 08:42:12 +02:00
xmb->categories_selection_ptr++;
break;
}
2015-10-17 18:17:59 +02:00
stack_size = menu_stack->size;
2015-02-02 18:44:56 +01:00
2015-10-17 18:17:59 +02: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;
2017-09-28 08:42:12 +02:00
switch (xmb_get_system_tab(xmb, (unsigned)xmb->categories_selection_ptr))
{
case XMB_SYSTEM_TAB_MAIN:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU));
menu_stack->list[stack_size - 1].type =
MENU_SETTINGS;
break;
case XMB_SYSTEM_TAB_SETTINGS:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_SETTINGS_TAB));
menu_stack->list[stack_size - 1].type =
MENU_SETTINGS_TAB;
break;
2016-07-30 19:29:10 +02:00
#ifdef HAVE_IMAGEVIEWER
case XMB_SYSTEM_TAB_IMAGES:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_IMAGES_TAB));
menu_stack->list[stack_size - 1].type =
MENU_IMAGES_TAB;
break;
2016-07-30 19:29:10 +02:00
#endif
case XMB_SYSTEM_TAB_MUSIC:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_MUSIC_TAB));
menu_stack->list[stack_size - 1].type =
MENU_MUSIC_TAB;
break;
#ifdef HAVE_FFMPEG
2016-12-12 03:54:53 -06:00
case XMB_SYSTEM_TAB_VIDEO:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_TAB));
menu_stack->list[stack_size - 1].type =
MENU_VIDEO_TAB;
break;
2016-07-30 19:29:10 +02:00
#endif
case XMB_SYSTEM_TAB_HISTORY:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB));
menu_stack->list[stack_size - 1].type =
MENU_HISTORY_TAB;
break;
case XMB_SYSTEM_TAB_FAVORITES:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES_TAB));
menu_stack->list[stack_size - 1].type =
MENU_FAVORITES_TAB;
break;
2017-01-22 17:57:49 -05:00
#ifdef HAVE_NETWORKING
case XMB_SYSTEM_TAB_NETPLAY:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_TAB));
menu_stack->list[stack_size - 1].type =
MENU_NETPLAY_TAB;
break;
2017-01-22 17:57:49 -05:00
#endif
case XMB_SYSTEM_TAB_ADD:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_ADD_TAB));
menu_stack->list[stack_size - 1].type =
MENU_ADD_TAB;
break;
default:
menu_stack->list[stack_size - 1].label =
strdup(msg_hash_to_str(MENU_ENUM_LABEL_HORIZONTAL_MENU));
menu_stack->list[stack_size - 1].type =
MENU_SETTING_HORIZONTAL_MENU;
break;
}
break;
default:
break;
2015-03-12 14:53:14 +01:00
}
}
2014-10-09 22:59:05 +02:00
static void xmb_context_destroy(void *data)
{
2015-03-16 17:40:05 +01:00
unsigned i;
xmb_handle_t *xmb = (xmb_handle_t*)data;
if (!xmb)
return;
2015-06-07 13:09:35 +02:00
for (i = 0; i < XMB_TEXTURE_LAST; i++)
2016-03-02 22:17:05 +01:00
video_driver_texture_unload(&xmb->textures.list[i]);
2015-01-30 04:45:15 +01:00
video_driver_texture_unload(&xmb->thumbnail);
video_driver_texture_unload(&xmb->savestate_thumbnail);
2015-12-10 15:28:05 +01:00
xmb_context_destroy_horizontal_list(xmb);
2015-12-23 13:47:40 +01:00
xmb_context_bg_destroy(xmb);
2015-02-02 18:44:56 +01:00
menu_display_font_free(xmb->font);
2016-10-20 09:52:17 +02:00
menu_display_font_free(xmb->font2);
2016-10-29 14:36:16 -03:00
xmb->font = NULL;
xmb->font2 = NULL;
2015-06-07 13:09:35 +02:00
}
2015-12-10 16:54:46 +01:00
static void xmb_toggle(void *userdata, bool menu_on)
2015-06-07 13:09:35 +02:00
{
2016-02-25 15:44:30 +01:00
menu_animation_ctx_entry_t entry;
bool tmp = false;
2015-12-10 16:54:46 +01:00
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
2015-06-07 13:09:35 +02:00
if (!xmb)
return;
xmb->depth = (int)xmb_list_get_size(xmb, MENU_LIST_PLAIN);
2015-06-07 13:09:35 +02:00
if (!menu_on)
{
xmb->alpha = 0;
return;
}
entry.duration = XMB_DELAY * 2;
2016-02-25 15:44:30 +01:00
entry.target_value = 1.0f;
entry.subject = &xmb->alpha;
entry.easing_enum = EASING_OUT_QUAD;
2017-09-06 00:21:20 +02:00
/* TODO/FIXME - integer conversion resulted in change of sign */
2016-02-25 15:44:30 +01:00
entry.tag = -1;
entry.cb = NULL;
2017-08-11 01:20:57 +02:00
menu_animation_push(&entry);
2015-06-07 13:09:35 +02:00
2015-12-11 21:41:59 +01:00
tmp = !menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL);
if (tmp)
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
else
menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL);
2015-06-07 13:09:35 +02:00
2015-12-10 15:28:05 +01:00
xmb_toggle_horizontal_list(xmb);
2015-06-07 13:09:35 +02:00
}
static int deferred_push_content_actions(menu_displaylist_info_t *info)
{
2016-03-09 16:17:18 -05:00
if (!menu_displaylist_ctl(
2016-02-24 23:05:54 +01:00
DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS, info))
return -1;
2017-05-27 19:13:22 +02:00
menu_displaylist_process(info);
2017-09-10 22:57:26 +02:00
menu_displaylist_info_free(info);
return 0;
}
2016-07-01 20:59:51 +02:00
static int xmb_list_bind_init_compare_label(menu_file_list_cbs_t *cbs)
{
if (cbs && cbs->enum_idx != MSG_UNKNOWN)
{
2016-06-18 04:09:07 +02:00
switch (cbs->enum_idx)
{
case MENU_ENUM_LABEL_CONTENT_ACTIONS:
cbs->action_deferred_push = deferred_push_content_actions;
break;
default:
return -1;
}
}
return 0;
}
2015-06-08 16:01:57 +02:00
static int xmb_list_bind_init(menu_file_list_cbs_t *cbs,
2016-07-01 20:59:51 +02:00
const char *path, const char *label, unsigned type, size_t idx)
2015-06-08 16:01:57 +02:00
{
2016-07-01 20:59:51 +02:00
if (xmb_list_bind_init_compare_label(cbs) == 0)
return 0;
return -1;
2015-06-08 16:01:57 +02:00
}
2016-02-04 21:40:29 +01:00
static int xmb_list_push(void *data, void *userdata,
menu_displaylist_info_t *info, unsigned type)
{
2016-03-04 07:41:45 +01:00
menu_displaylist_ctx_parse_entry_t entry;
2015-10-22 04:46:05 +02:00
int ret = -1;
2017-08-16 01:10:27 +02:00
core_info_list_t *list = NULL;
menu_handle_t *menu = (menu_handle_t*)data;
2015-10-22 04:46:05 +02:00
switch (type)
{
2017-08-16 01:10:27 +02:00
case DISPLAYLIST_LOAD_CONTENT_LIST:
{
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES),
msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES),
MENU_ENUM_LABEL_FAVORITES,
MENU_SETTING_ACTION, 0, 0);
core_info_get_list(&list);
if (core_info_list_num_info_files(list))
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DOWNLOADED_FILE_DETECT_CORE_LIST),
msg_hash_to_str(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST),
MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST,
MENU_SETTING_ACTION, 0, 0);
}
#ifdef HAVE_LIBRETRODB
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_COLLECTION_LIST),
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST),
MENU_ENUM_LABEL_CONTENT_COLLECTION_LIST,
MENU_SETTING_ACTION, 0, 0);
#endif
if (frontend_driver_parse_drive_list(info->list, true) != 0)
menu_entries_append_enum(info->list, "/",
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR,
MENU_SETTING_ACTION, 0, 0);
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MENU_FILE_BROWSER_SETTINGS),
msg_hash_to_str(MENU_ENUM_LABEL_MENU_FILE_BROWSER_SETTINGS),
MENU_ENUM_LABEL_MENU_FILE_BROWSER_SETTINGS,
MENU_SETTING_ACTION, 0, 0);
info->need_push = true;
info->need_refresh = true;
ret = 0;
}
break;
2015-10-22 04:46:05 +02:00
case DISPLAYLIST_MAIN_MENU:
{
rarch_system_info_t *system = runloop_get_system_info();
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
entry.data = menu;
entry.info = info;
entry.parse_type = PARSE_ACTION;
entry.add_empty_entry = false;
2016-03-04 07:41:45 +01:00
if (!string_is_empty(system->info.library_name) &&
!string_is_equal(system->info.library_name,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE)))
{
entry.enum_idx = MENU_ENUM_LABEL_CONTENT_SETTINGS;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
}
if (system->load_no_content)
{
entry.enum_idx = MENU_ENUM_LABEL_START_CORE;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
}
#ifndef HAVE_DYNAMIC
if (frontend_driver_has_fork())
2015-10-22 04:46:05 +02:00
#endif
{
entry.enum_idx = MENU_ENUM_LABEL_CORE_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
}
2016-03-04 07:41:45 +01:00
entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
#if defined(HAVE_NETWORKING)
2017-06-20 01:42:28 +02:00
{
settings_t *settings = config_get_ptr();
if (settings->bools.menu_show_online_updater)
{
entry.enum_idx = MENU_ENUM_LABEL_ONLINE_UPDATER;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
}
}
2015-10-22 04:46:05 +02:00
#endif
settings_t *settings = config_get_ptr();
if (!settings->bools.menu_xmb_show_settings && !string_is_empty(settings->paths.menu_xmb_show_settings_password))
{
entry.enum_idx = MENU_ENUM_LABEL_XMB_MAIN_MENU_ENABLE_SETTINGS;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
}
entry.enum_idx = MENU_ENUM_LABEL_INFORMATION_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
2015-10-22 04:46:05 +02:00
#ifndef HAVE_DYNAMIC
entry.enum_idx = MENU_ENUM_LABEL_RESTART_RETROARCH;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
2015-10-22 04:46:05 +02:00
#endif
entry.enum_idx = MENU_ENUM_LABEL_CONFIGURATIONS_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
entry.enum_idx = MENU_ENUM_LABEL_HELP_LIST;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
2015-10-22 04:46:05 +02:00
#if !defined(IOS)
entry.enum_idx = MENU_ENUM_LABEL_QUIT_RETROARCH;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
2015-10-22 04:46:05 +02:00
#endif
entry.enum_idx = MENU_ENUM_LABEL_REBOOT;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
2016-03-04 07:41:45 +01:00
entry.enum_idx = MENU_ENUM_LABEL_SHUTDOWN;
menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry);
info->need_push = true;
ret = 0;
}
2015-10-22 04:46:05 +02:00
break;
}
return ret;
}
static bool xmb_menu_init_list(void *data)
{
2017-04-27 01:27:02 +02:00
menu_displaylist_info_t info;
2016-12-14 16:47:10 +01:00
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
2017-09-10 22:57:26 +02:00
menu_displaylist_info_init(&info);
2017-09-28 02:45:03 +02:00
info.label = strdup(
msg_hash_to_str(MENU_ENUM_LABEL_MAIN_MENU));
info.exts =
strdup(file_path_str(FILE_PATH_LPL_EXTENSION_NO_DOT));
2017-04-27 01:27:02 +02:00
info.type_default = FILE_TYPE_PLAIN;
info.enum_idx = MENU_ENUM_LABEL_MAIN_MENU;
menu_entries_append_enum(menu_stack, info.path,
info.label,
2016-06-16 13:13:43 +02:00
MENU_ENUM_LABEL_MAIN_MENU,
info.type, info.flags, 0);
2015-10-22 03:02:03 +02:00
info.list = selection_buf;
2016-03-09 16:17:18 -05:00
2016-02-24 23:19:53 +01:00
if (!menu_displaylist_ctl(DISPLAYLIST_MAIN_MENU, &info))
2017-09-10 22:57:26 +02:00
goto error;
2015-10-22 03:02:03 +02:00
info.need_push = true;
2017-05-26 20:12:52 +02:00
if (!menu_displaylist_process(&info))
2017-09-10 22:57:26 +02:00
goto error;
2017-09-10 22:57:26 +02:00
menu_displaylist_info_free(&info);
return true;
2017-09-10 22:57:26 +02:00
error:
menu_displaylist_info_free(&info);
return false;
}
2015-12-10 16:26:40 +01:00
static int xmb_pointer_tap(void *userdata,
unsigned x, unsigned y, unsigned ptr,
2015-11-01 20:44:04 +01:00
menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{
2016-06-22 06:48:35 +02:00
unsigned header_height = menu_display_get_header_height();
2015-11-01 20:44:04 +01:00
if (y < header_height)
{
size_t selection = menu_navigation_get_selection();
2017-02-26 21:46:19 +01:00
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
}
2015-11-01 20:44:04 +01:00
else if (ptr <= (menu_entries_get_size() - 1))
{
size_t selection = menu_navigation_get_selection();
2015-11-01 20:44:04 +01:00
if (ptr == selection && cbs && cbs->action_select)
2017-02-26 21:46:19 +01:00
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
menu_navigation_set_selection(ptr);
2017-05-15 07:56:22 +02:00
menu_driver_navigation_set(false);
}
return 0;
}
2014-10-09 01:21:22 +02:00
menu_ctx_driver_t menu_ctx_xmb = {
NULL,
2015-12-10 14:36:31 +01:00
xmb_messagebox,
generic_menu_iterate,
xmb_render,
2014-10-09 01:21:22 +02:00
xmb_frame,
xmb_init,
xmb_free,
xmb_context_reset,
2014-10-09 22:59:05 +02: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-07 00:41:53 +02:00
xmb_navigation_alphabet,
xmb_navigation_alphabet,
xmb_menu_init_list,
xmb_list_insert,
2015-12-10 15:48:04 +01:00
NULL,
xmb_list_free,
2015-06-15 14:59:07 -03:00
xmb_list_clear,
xmb_list_cache,
xmb_list_push,
2015-06-15 19:00:52 +02:00
xmb_list_get_selection,
2015-06-07 15:43:03 +02:00
xmb_list_get_size,
xmb_list_get_entry,
2015-02-11 21:00:34 +01:00
NULL,
2015-06-08 16:01:57 +02:00
xmb_list_bind_init,
xmb_load_image,
2014-10-09 01:21:22 +02:00
"xmb",
2015-07-08 00:37:44 +02:00
xmb_environ,
xmb_pointer_tap,
xmb_update_thumbnail_path,
xmb_update_thumbnail_image,
xmb_set_thumbnail_system,
xmb_set_thumbnail_content,
2016-10-30 11:48:35 +01:00
xmb_osk_ptr_at_pos,
2016-12-01 02:43:53 +01:00
xmb_update_savestate_thumbnail_path,
xmb_update_savestate_thumbnail_image
2014-10-09 01:21:22 +02:00
};