2014-10-08 23:21:22 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2014-2015 - Jean-André Santoni
|
2014-10-08 23:21:22 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
2014-10-16 05:27:42 +00:00
|
|
|
#include <stdint.h>
|
2014-10-08 23:21:22 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "../menu.h"
|
2015-02-11 02:52:35 +00:00
|
|
|
#include "../menu_animation.h"
|
|
|
|
#include "../menu_texture.h"
|
|
|
|
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../../gfx/gl_common.h"
|
|
|
|
#include "../../gfx/video_thread_wrapper.h"
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
#include "shared.h"
|
|
|
|
|
2014-10-09 00:41:08 +00:00
|
|
|
#ifndef XMB_THEME
|
|
|
|
#define XMB_THEME "monochrome"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef XMB_DELAY
|
2015-03-06 15:00:46 +00:00
|
|
|
#define XMB_DELAY 10
|
2014-10-09 00:41:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float alpha;
|
2014-10-20 18:00:39 +00:00
|
|
|
float label_alpha;
|
2014-10-09 00:41:08 +00:00
|
|
|
float zoom;
|
2014-10-20 18:00:39 +00:00
|
|
|
float x;
|
2014-10-09 00:41:08 +00:00
|
|
|
float y;
|
2014-11-11 15:28:40 +00:00
|
|
|
GLuint icon;
|
2014-11-21 09:40:47 +00:00
|
|
|
GLuint content_icon;
|
2014-10-09 00:41:08 +00:00
|
|
|
} xmb_node_t;
|
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
enum
|
|
|
|
{
|
2015-02-12 23:12:15 +00:00
|
|
|
XMB_TEXTURE_SETTINGS = 0,
|
2014-10-09 20:59:05 +00:00
|
|
|
XMB_TEXTURE_SETTING,
|
|
|
|
XMB_TEXTURE_SUBSETTING,
|
|
|
|
XMB_TEXTURE_ARROW,
|
|
|
|
XMB_TEXTURE_RUN,
|
|
|
|
XMB_TEXTURE_RESUME,
|
|
|
|
XMB_TEXTURE_SAVESTATE,
|
|
|
|
XMB_TEXTURE_LOADSTATE,
|
2015-02-17 22:43:34 +00:00
|
|
|
XMB_TEXTURE_CORE_INFO,
|
|
|
|
XMB_TEXTURE_CORE_OPTIONS,
|
|
|
|
XMB_TEXTURE_INPUT_REMAPPING_OPTIONS,
|
|
|
|
XMB_TEXTURE_CHEAT_OPTIONS,
|
|
|
|
XMB_TEXTURE_DISK_OPTIONS,
|
2014-10-09 20:59:05 +00:00
|
|
|
XMB_TEXTURE_SCREENSHOT,
|
|
|
|
XMB_TEXTURE_RELOAD,
|
2014-10-14 21:05:53 +00:00
|
|
|
XMB_TEXTURE_FILE,
|
|
|
|
XMB_TEXTURE_FOLDER,
|
|
|
|
XMB_TEXTURE_ZIP,
|
2014-10-18 14:26:02 +00:00
|
|
|
XMB_TEXTURE_CORE,
|
2015-02-02 23:27:18 +00:00
|
|
|
XMB_TEXTURE_RDB,
|
|
|
|
XMB_TEXTURE_CURSOR,
|
2014-10-22 00:41:28 +00:00
|
|
|
XMB_TEXTURE_SWITCH_ON,
|
|
|
|
XMB_TEXTURE_SWITCH_OFF,
|
2015-02-04 21:44:33 +00:00
|
|
|
XMB_TEXTURE_CLOCK,
|
2015-03-08 23:14:55 +00:00
|
|
|
XMB_TEXTURE_POINTER,
|
2014-10-09 20:59:05 +00:00
|
|
|
XMB_TEXTURE_LAST
|
2014-10-09 02:34:16 +00:00
|
|
|
};
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
struct xmb_texture_item
|
|
|
|
{
|
|
|
|
GLuint id;
|
2015-01-07 19:42:36 +00:00
|
|
|
char path[PATH_MAX_LENGTH];
|
2014-10-09 02:34:16 +00:00
|
|
|
};
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
typedef struct xmb_handle
|
|
|
|
{
|
2014-11-27 16:03:27 +00:00
|
|
|
file_list_t *menu_stack_old;
|
|
|
|
file_list_t *selection_buf_old;
|
|
|
|
size_t selection_ptr_old;
|
2014-10-10 20:42:56 +00:00
|
|
|
int depth;
|
2014-10-11 23:27:31 +00:00
|
|
|
int old_depth;
|
2015-01-07 19:42:36 +00:00
|
|
|
char box_message[PATH_MAX_LENGTH];
|
2014-10-11 23:27:31 +00:00
|
|
|
float x;
|
2014-10-10 20:42:56 +00:00
|
|
|
float alpha;
|
2015-02-12 19:23:14 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float left;
|
|
|
|
float top;
|
2015-02-12 19:26:04 +00:00
|
|
|
|
2015-02-12 19:23:14 +00:00
|
|
|
} screen;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float left;
|
|
|
|
} setting;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float left;
|
|
|
|
float top;
|
|
|
|
float bottom;
|
|
|
|
} title;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float left;
|
|
|
|
float top;
|
|
|
|
} label;
|
|
|
|
} margins;
|
|
|
|
|
|
|
|
char title_name[PATH_MAX_LENGTH];
|
2015-02-12 17:34:36 +00:00
|
|
|
|
2015-02-12 18:27:13 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float alpha;
|
|
|
|
} arrow;
|
|
|
|
|
2015-02-12 23:12:15 +00:00
|
|
|
struct xmb_texture_item bg;
|
2015-02-12 18:27:13 +00:00
|
|
|
struct xmb_texture_item list[XMB_TEXTURE_LAST];
|
|
|
|
} textures;
|
|
|
|
|
2015-02-12 17:34:36 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float item;
|
|
|
|
float subitem;
|
|
|
|
} above_offset;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float item;
|
|
|
|
} under_offset;
|
2015-02-12 17:23:47 +00:00
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
struct
|
|
|
|
{
|
2015-02-12 22:38:44 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float horizontal;
|
|
|
|
float vertical;
|
|
|
|
} spacing;
|
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
char dir[4];
|
|
|
|
int size;
|
|
|
|
} icon;
|
|
|
|
|
2015-03-08 23:14:55 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
} cursor;
|
2015-02-12 17:23:47 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float zoom;
|
|
|
|
float alpha;
|
2015-02-12 17:38:27 +00:00
|
|
|
int idx;
|
|
|
|
int idx_old;
|
2015-02-12 17:18:38 +00:00
|
|
|
} active;
|
2015-02-12 18:23:11 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float zoom;
|
|
|
|
float alpha;
|
|
|
|
} passive;
|
2015-02-12 18:23:11 +00:00
|
|
|
|
|
|
|
float x_pos;
|
|
|
|
size_t selection_ptr_old;
|
|
|
|
} categories;
|
2015-02-12 17:18:38 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float zoom;
|
|
|
|
float alpha;
|
|
|
|
float factor;
|
|
|
|
} active;
|
2015-02-12 18:27:13 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float zoom;
|
|
|
|
float alpha;
|
|
|
|
} passive;
|
|
|
|
} item;
|
|
|
|
|
2015-02-12 17:25:48 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
void *buf;
|
|
|
|
int size;
|
|
|
|
} font;
|
|
|
|
|
2014-11-13 20:32:45 +00:00
|
|
|
xmb_node_t settings_node;
|
2015-01-28 18:09:21 +00:00
|
|
|
bool prevent_populate;
|
2014-10-09 02:34:16 +00:00
|
|
|
} xmb_handle_t;
|
|
|
|
|
2014-10-09 02:51:42 +00:00
|
|
|
static const GLfloat rmb_vertex[] = {
|
2014-10-08 23:21:22 +00:00
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
};
|
|
|
|
|
2014-10-09 02:51:42 +00:00
|
|
|
static const GLfloat rmb_tex_coord[] = {
|
2014-10-08 23:21:22 +00:00
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
};
|
|
|
|
|
2015-02-11 04:33:53 +00:00
|
|
|
static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current)
|
2015-02-09 21:54:14 +00:00
|
|
|
{
|
2015-02-12 22:38:44 +00:00
|
|
|
float iy = xmb->icon.spacing.vertical;
|
2015-02-09 21:54:14 +00:00
|
|
|
|
|
|
|
if (i < current)
|
|
|
|
if (xmb->depth > 1)
|
2015-02-12 17:34:36 +00:00
|
|
|
iy *= (i - (int)current + xmb->above_offset.subitem);
|
2015-02-09 21:54:14 +00:00
|
|
|
else
|
2015-02-12 17:34:36 +00:00
|
|
|
iy *= (i - (int)current + xmb->above_offset.item);
|
2015-02-09 21:54:14 +00:00
|
|
|
else
|
2015-02-12 17:34:36 +00:00
|
|
|
iy *= (i - (int)current + xmb->under_offset.item);
|
2015-02-09 21:54:14 +00:00
|
|
|
|
|
|
|
if (i == current)
|
2015-02-12 22:38:44 +00:00
|
|
|
iy = xmb->icon.spacing.vertical * xmb->item.active.factor;
|
2015-02-09 21:54:14 +00:00
|
|
|
|
|
|
|
return iy;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static int xmb_entry_iterate(unsigned action)
|
2015-01-26 09:54:13 +00:00
|
|
|
{
|
|
|
|
const char *label = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
cbs = (menu_file_list_cbs_t*)
|
2015-02-11 18:28:06 +00:00
|
|
|
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
2015-02-13 23:47:42 +00:00
|
|
|
menu->navigation.selection_ptr);
|
2015-01-26 09:54:13 +00:00
|
|
|
|
2015-02-11 18:28:06 +00:00
|
|
|
menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL);
|
2015-01-26 09:54:13 +00:00
|
|
|
|
|
|
|
if (cbs && cbs->action_iterate)
|
|
|
|
return cbs->action_iterate(label, action);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-11-11 15:28:40 +00:00
|
|
|
static char *xmb_str_replace (const char *string,
|
|
|
|
const char *substr, const char *replacement)
|
|
|
|
{
|
|
|
|
char *tok, *newstr, *oldstr, *head;
|
|
|
|
|
|
|
|
/* if either substr or replacement is NULL,
|
|
|
|
* duplicate string a let caller handle it. */
|
|
|
|
if (!substr || !replacement)
|
2015-02-01 14:25:37 +00:00
|
|
|
return strdup(string);
|
2014-11-11 15:28:40 +00:00
|
|
|
|
2015-02-01 14:25:37 +00:00
|
|
|
newstr = strdup(string);
|
|
|
|
head = newstr;
|
2015-01-26 05:51:46 +00:00
|
|
|
|
2014-11-11 15:28:40 +00:00
|
|
|
while ( (tok = strstr ( head, substr )))
|
|
|
|
{
|
|
|
|
oldstr = newstr;
|
|
|
|
newstr = (char*)malloc(
|
|
|
|
strlen(oldstr) - strlen(substr) + strlen(replacement) + 1);
|
|
|
|
|
|
|
|
if (!newstr)
|
|
|
|
{
|
2015-02-01 14:25:37 +00:00
|
|
|
/* Failed to allocate memory,
|
|
|
|
* free old string and return NULL. */
|
2014-11-11 15:28:40 +00:00
|
|
|
free (oldstr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-02-01 14:25:37 +00:00
|
|
|
|
2014-11-11 15:28:40 +00:00
|
|
|
memcpy(newstr, oldstr, tok - oldstr );
|
|
|
|
memcpy(newstr + (tok - oldstr), replacement, strlen ( replacement ) );
|
|
|
|
memcpy(newstr + (tok - oldstr) + strlen( replacement ), tok +
|
|
|
|
strlen ( substr ), strlen ( oldstr ) -
|
|
|
|
strlen ( substr ) - ( tok - oldstr ) );
|
|
|
|
memset(newstr + strlen ( oldstr ) - strlen ( substr ) +
|
|
|
|
strlen ( replacement ) , 0, 1 );
|
2015-02-01 14:25:37 +00:00
|
|
|
|
|
|
|
/* Move back head right after the last replacement. */
|
2014-11-11 15:28:40 +00:00
|
|
|
head = newstr + (tok - oldstr) + strlen( replacement );
|
|
|
|
free (oldstr);
|
|
|
|
}
|
2015-01-26 05:51:46 +00:00
|
|
|
|
2014-11-11 15:28:40 +00:00
|
|
|
return newstr;
|
|
|
|
}
|
|
|
|
|
2015-03-08 12:24:16 +00:00
|
|
|
static void xmb_draw_icon_begin(gl_t *gl, xmb_handle_t *xmb)
|
|
|
|
{
|
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xmb_draw_icon_end(gl_t *gl, xmb_handle_t *xmb)
|
|
|
|
{
|
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2015-02-11 04:43:42 +00:00
|
|
|
static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb,
|
2015-02-11 04:33:53 +00:00
|
|
|
GLuint texture, float x, float y,
|
2014-10-14 20:37:01 +00:00
|
|
|
float alpha, float rotation, float scale_factor)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2014-10-09 02:34:16 +00:00
|
|
|
struct gl_coords coords;
|
2014-10-26 01:32:10 +00:00
|
|
|
math_matrix_4x4 mymat, mrot, mscal;
|
2014-10-09 02:34:16 +00:00
|
|
|
|
2014-10-10 20:42:56 +00:00
|
|
|
if (alpha > xmb->alpha)
|
|
|
|
alpha = xmb->alpha;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
if (alpha == 0)
|
|
|
|
return;
|
|
|
|
|
2015-02-01 14:25:37 +00:00
|
|
|
if (
|
2015-02-12 17:31:46 +00:00
|
|
|
x < -xmb->icon.size/2 ||
|
2015-02-01 14:25:37 +00:00
|
|
|
x > gl->win_width ||
|
2015-02-12 17:31:46 +00:00
|
|
|
y < xmb->icon.size/2 ||
|
|
|
|
y > gl->win_height + xmb->icon.size)
|
2014-10-08 23:21:22 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
};
|
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
glViewport(x, gl->win_height - y, xmb->icon.size, xmb->icon.size);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-02 19:48:26 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = rmb_vertex;
|
|
|
|
coords.tex_coord = rmb_tex_coord;
|
2014-10-09 02:51:42 +00:00
|
|
|
coords.lut_tex_coord = rmb_tex_coord;
|
2015-02-02 19:48:26 +00:00
|
|
|
coords.color = color;
|
2014-10-08 23:21:22 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
|
2014-10-26 01:32:10 +00:00
|
|
|
matrix_4x4_rotate_z(&mrot, rotation);
|
|
|
|
matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-26 01:32:10 +00:00
|
|
|
matrix_4x4_scale(&mscal, scale_factor, scale_factor, 1);
|
|
|
|
matrix_4x4_multiply(&mymat, &mscal, &mymat);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
gl->shader->set_coords(&coords);
|
|
|
|
gl->shader->set_mvp(gl, &mymat);
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
}
|
|
|
|
|
2015-03-10 02:42:26 +00:00
|
|
|
static void xmb_draw_icon_predone(gl_t *gl, xmb_handle_t *xmb,
|
|
|
|
math_matrix_4x4 *mymat,
|
|
|
|
GLuint texture, float x, float y,
|
|
|
|
float alpha, float rotation, float scale_factor)
|
|
|
|
{
|
|
|
|
struct gl_coords coords;
|
|
|
|
|
|
|
|
if (alpha > xmb->alpha)
|
|
|
|
alpha = xmb->alpha;
|
|
|
|
|
|
|
|
if (alpha == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (
|
|
|
|
x < -xmb->icon.size/2 ||
|
|
|
|
x > gl->win_width ||
|
|
|
|
y < xmb->icon.size/2 ||
|
|
|
|
y > gl->win_height + xmb->icon.size)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
};
|
|
|
|
|
|
|
|
glViewport(x, gl->win_height - y, xmb->icon.size, xmb->icon.size);
|
|
|
|
|
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = rmb_vertex;
|
|
|
|
coords.tex_coord = rmb_tex_coord;
|
|
|
|
coords.lut_tex_coord = rmb_tex_coord;
|
|
|
|
coords.color = color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
|
|
|
|
gl->shader->set_coords(&coords);
|
|
|
|
gl->shader->set_mvp(gl, mymat);
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
}
|
|
|
|
|
2015-02-11 04:43:42 +00:00
|
|
|
static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x,
|
2015-01-23 00:54:17 +00:00
|
|
|
float y, float scale_factor, float alpha, bool align_right)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2014-10-09 02:34:16 +00:00
|
|
|
uint8_t a8 = 0;
|
2014-10-09 19:57:05 +00:00
|
|
|
struct font_params params = {0};
|
2014-10-09 02:34:16 +00:00
|
|
|
|
2014-10-10 20:42:56 +00:00
|
|
|
if (alpha > xmb->alpha)
|
|
|
|
alpha = xmb->alpha;
|
2015-02-01 14:25:37 +00:00
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
a8 = 255 * alpha;
|
2015-02-01 14:25:37 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
if (a8 == 0)
|
|
|
|
return;
|
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
if (x < -xmb->icon.size || x > gl->win_width + xmb->icon.size
|
|
|
|
|| y < -xmb->icon.size || y > gl->win_height + xmb->icon.size)
|
2014-10-08 23:21:22 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
|
|
|
|
2015-02-02 19:48:26 +00:00
|
|
|
params.x = x / gl->win_width;
|
|
|
|
params.y = 1.0f - y / gl->win_height;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-02 19:48:26 +00:00
|
|
|
params.scale = scale_factor;
|
|
|
|
params.color = FONT_COLOR_RGBA(255, 255, 255, a8);
|
2014-10-08 23:21:22 +00:00
|
|
|
params.full_screen = true;
|
2015-01-23 00:54:17 +00:00
|
|
|
params.align_right = align_right;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
if (driver.video_data && driver.video_poke
|
|
|
|
&& driver.video_poke->set_osd_msg)
|
|
|
|
driver.video_poke->set_osd_msg(driver.video_data,
|
2015-02-12 17:25:48 +00:00
|
|
|
str, ¶ms, xmb->font.buf);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 22:34:01 +00:00
|
|
|
static void xmb_frame_background(gl_t *gl, xmb_handle_t *xmb,
|
2015-02-11 04:43:42 +00:00
|
|
|
bool force_transparency)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-01-26 05:51:46 +00:00
|
|
|
struct gl_coords coords;
|
|
|
|
float alpha = 0.75f;
|
2015-01-10 22:45:14 +00:00
|
|
|
static const GLfloat vertex[] = {
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GLfloat tex_coord[] = {
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
};
|
|
|
|
|
2014-10-12 00:35:50 +00:00
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (alpha > xmb->alpha)
|
|
|
|
alpha = xmb->alpha;
|
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
GLfloat black_color[] = {
|
2014-10-12 00:35:50 +00:00
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
2014-10-08 23:21:22 +00:00
|
|
|
};
|
|
|
|
|
2015-03-09 22:46:16 +00:00
|
|
|
/* force viewport to fullscreen */
|
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, true, false);
|
2014-10-12 00:35:50 +00:00
|
|
|
|
2015-02-02 19:48:26 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = vertex;
|
|
|
|
coords.tex_coord = tex_coord;
|
2014-10-12 00:35:50 +00:00
|
|
|
coords.lut_tex_coord = tex_coord;
|
2014-10-12 01:24:12 +00:00
|
|
|
|
|
|
|
if ((g_settings.menu.pause_libretro
|
|
|
|
|| !g_extern.main_is_init || g_extern.libretro_dummy)
|
2014-10-12 16:22:51 +00:00
|
|
|
&& !force_transparency
|
2015-02-12 23:12:15 +00:00
|
|
|
&& xmb->textures.bg.id)
|
2014-10-12 01:24:12 +00:00
|
|
|
{
|
|
|
|
coords.color = color;
|
2015-02-12 23:12:15 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, xmb->textures.bg.id);
|
2014-10-12 01:24:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
coords.color = black_color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
}
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-12 00:35:50 +00:00
|
|
|
gl->shader->set_coords(&coords);
|
2014-10-08 23:21:22 +00:00
|
|
|
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
|
|
|
|
|
2014-10-12 00:35:50 +00:00
|
|
|
glEnable(GL_BLEND);
|
2014-10-08 23:21:22 +00:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
glDisable(GL_BLEND);
|
2014-10-12 17:22:01 +00:00
|
|
|
|
|
|
|
gl->coords.color = gl->white_color_ptr;
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 12:17:07 +00:00
|
|
|
static void xmb_render_messagebox_internal(const char *message)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-02-11 19:28:54 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2015-02-11 19:28:54 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
if (!xmb || !message || !*message)
|
2014-10-08 23:21:22 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
strlcpy(xmb->box_message, message, sizeof(xmb->box_message));
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 22:34:01 +00:00
|
|
|
static void xmb_frame_messagebox(const char *message)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
int x, y;
|
2014-10-09 02:34:16 +00:00
|
|
|
unsigned i;
|
2015-01-10 22:45:14 +00:00
|
|
|
struct string_list *list = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
gl_t *gl = NULL;
|
2015-02-11 19:28:54 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2015-02-11 19:28:54 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2015-02-13 18:00:34 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gl = (gl_t*)video_driver_resolve(NULL);
|
|
|
|
|
|
|
|
if (!gl)
|
2014-10-08 23:21:22 +00:00
|
|
|
return;
|
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
list = string_split(message, "\n");
|
2014-10-08 23:21:22 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
2015-01-10 22:45:14 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
if (list->elems == 0)
|
2015-02-11 05:27:28 +00:00
|
|
|
goto end;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 17:25:48 +00:00
|
|
|
x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font.size / 4;
|
|
|
|
y = gl->win_height / 2 - list->size * xmb->font.size / 2;
|
2014-10-09 02:34:16 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
|
|
|
const char *msg = list->elems[i].data;
|
2014-10-09 20:45:29 +00:00
|
|
|
|
|
|
|
if (msg)
|
2015-02-12 17:25:48 +00:00
|
|
|
xmb_draw_text(gl, xmb, msg, x, y + i * xmb->font.size, 1, 1, 0);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:27:28 +00:00
|
|
|
end:
|
2014-10-08 23:21:22 +00:00
|
|
|
string_list_free(list);
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_selection_pointer_changed(void)
|
2014-10-09 00:41:08 +00:00
|
|
|
{
|
2015-02-24 21:26:08 +00:00
|
|
|
unsigned i, current, end;
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-09 00:41:08 +00:00
|
|
|
|
2014-10-10 13:52:12 +00:00
|
|
|
if (!xmb)
|
2014-10-09 02:34:16 +00:00
|
|
|
return;
|
2014-10-09 00:41:08 +00:00
|
|
|
|
2015-02-13 23:47:42 +00:00
|
|
|
current = menu->navigation.selection_ptr;
|
2015-02-11 05:34:30 +00:00
|
|
|
end = menu_list_get_size(menu->menu_list);
|
2014-10-09 20:45:29 +00:00
|
|
|
|
2014-10-09 20:33:23 +00:00
|
|
|
for (i = 0; i < end; i++)
|
2014-10-09 00:41:08 +00:00
|
|
|
{
|
|
|
|
float iy;
|
2015-02-12 17:18:38 +00:00
|
|
|
float ia = xmb->item.passive.alpha;
|
|
|
|
float iz = xmb->item.passive.zoom;
|
2014-10-10 20:08:11 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(
|
2015-02-11 05:34:30 +00:00
|
|
|
menu->menu_list->selection_buf, i);
|
2014-10-09 00:41:08 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
2015-02-11 04:33:53 +00:00
|
|
|
iy = xmb_item_y(xmb, i, current);
|
2014-10-09 00:41:08 +00:00
|
|
|
|
2014-10-09 20:30:17 +00:00
|
|
|
if (i == current)
|
2014-10-09 00:41:08 +00:00
|
|
|
{
|
2015-02-12 17:18:38 +00:00
|
|
|
ia = xmb->item.active.alpha;
|
|
|
|
iz = xmb->item.active.zoom;
|
2014-10-09 00:41:08 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:34:30 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, iy, &node->y, EASING_IN_OUT_QUAD, NULL);
|
2014-10-09 00:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
|
2014-10-09 00:41:08 +00:00
|
|
|
{
|
2014-10-28 01:00:56 +00:00
|
|
|
int i;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-10-11 23:27:31 +00:00
|
|
|
|
2014-10-20 18:00:39 +00:00
|
|
|
for (i = 0; i < file_list_get_size(list); i++)
|
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
float ia = 0;
|
|
|
|
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (i == current)
|
2015-02-12 17:18:38 +00:00
|
|
|
ia = xmb->item.active.alpha;
|
2015-01-10 22:45:14 +00:00
|
|
|
if (dir == -1)
|
|
|
|
ia = 0;
|
2015-02-02 19:48:26 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
|
2015-02-12 17:31:46 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * dir * -2, &node->x, EASING_IN_OUT_QUAD, NULL);
|
2014-10-20 18:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-11 23:27:31 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
|
2014-10-20 18:00:39 +00:00
|
|
|
{
|
2014-10-28 01:00:56 +00:00
|
|
|
int i;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-10-17 23:24:14 +00:00
|
|
|
|
2014-10-20 18:00:39 +00:00
|
|
|
for (i = 0; i < file_list_get_size(list); i++)
|
2014-10-17 23:24:14 +00:00
|
|
|
{
|
2014-10-20 21:07:24 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
|
2015-02-02 19:48:26 +00:00
|
|
|
|
2015-02-11 05:22:00 +00:00
|
|
|
if (!node)
|
2015-02-02 19:48:26 +00:00
|
|
|
continue;
|
2015-01-26 18:30:44 +00:00
|
|
|
|
2014-10-20 18:00:39 +00:00
|
|
|
if (dir == 1 || (dir == -1 && i != current))
|
|
|
|
node->alpha = 0;
|
2015-01-26 18:30:44 +00:00
|
|
|
|
|
|
|
if (dir == 1 || dir == -1)
|
|
|
|
node->label_alpha = 0;
|
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
node->x = xmb->icon.size * dir * 2;
|
2015-02-11 04:33:53 +00:00
|
|
|
node->y = xmb_item_y(xmb, i, current);
|
2014-10-17 23:24:14 +00:00
|
|
|
|
|
|
|
if (i == current)
|
2014-10-20 18:00:39 +00:00
|
|
|
node->zoom = 1;
|
|
|
|
}
|
|
|
|
for (i = 0; i < file_list_get_size(list); i++)
|
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
float ia;
|
2014-10-20 21:07:24 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
|
|
|
|
|
2015-02-11 05:15:15 +00:00
|
|
|
if (!node)
|
2014-10-20 21:07:24 +00:00
|
|
|
continue;
|
2014-11-27 10:07:52 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
ia = xmb->item.passive.alpha;
|
2015-01-26 05:51:46 +00:00
|
|
|
if (i == current)
|
2015-02-12 17:18:38 +00:00
|
|
|
ia = xmb->item.active.alpha;
|
2015-01-26 05:51:46 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL);
|
2014-10-17 23:24:14 +00:00
|
|
|
}
|
2014-10-19 23:51:00 +00:00
|
|
|
|
|
|
|
xmb->old_depth = xmb->depth;
|
2014-10-09 00:41:08 +00:00
|
|
|
}
|
|
|
|
|
2015-03-12 14:32:50 +00:00
|
|
|
static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, core_info_t *info, int i)
|
2014-11-13 20:05:16 +00:00
|
|
|
{
|
2015-02-01 14:25:37 +00:00
|
|
|
xmb_node_t *node = NULL;
|
2014-11-13 20:05:16 +00:00
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
2015-03-12 14:32:50 +00:00
|
|
|
|
2015-01-26 05:51:46 +00:00
|
|
|
info->userdata = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
|
|
|
|
|
|
|
|
if (!info->userdata)
|
2014-11-17 09:17:24 +00:00
|
|
|
{
|
2015-01-26 05:51:46 +00:00
|
|
|
RARCH_ERR("XMB node could not be allocated.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-11-17 09:17:24 +00:00
|
|
|
|
2015-01-26 05:51:46 +00:00
|
|
|
node = (xmb_node_t*)info->userdata;
|
2014-11-17 09:17:24 +00:00
|
|
|
|
2015-01-26 05:51:46 +00:00
|
|
|
if (!node)
|
|
|
|
return NULL;
|
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.passive.alpha;
|
|
|
|
node->zoom = xmb->categories.passive.zoom;
|
2014-11-17 09:17:24 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if ((i + 1) == xmb->categories.active.idx)
|
2015-01-26 05:51:46 +00:00
|
|
|
{
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.active.alpha;
|
|
|
|
node->zoom = xmb->categories.active.zoom;
|
2014-11-17 09:17:24 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 20:05:16 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2015-03-12 14:32:50 +00:00
|
|
|
static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i)
|
|
|
|
{
|
|
|
|
core_info_t *info = NULL;
|
|
|
|
xmb_node_t *node = NULL;
|
|
|
|
core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info;
|
|
|
|
|
|
|
|
if (!info_list)
|
|
|
|
return NULL;
|
|
|
|
if (!info_list->count)
|
|
|
|
return NULL;
|
2015-03-12 14:39:41 +00:00
|
|
|
if (i >= info_list->count)
|
|
|
|
return NULL;
|
2015-03-12 14:32:50 +00:00
|
|
|
|
|
|
|
info = (core_info_t*)&info_list->list[i];
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
node = (xmb_node_t*)info->userdata;
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return xmb_node_allocate_userdata(xmb, info, i);
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_push_animations(xmb_node_t *node, float ia, float ix)
|
2015-02-12 16:22:24 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-02-12 16:22:24 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ix, &node->x, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-02-13 18:00:34 +00:00
|
|
|
size_t end = 0;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
end = file_list_get_size(list);
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-12 16:22:24 +00:00
|
|
|
for (i = 0; i < end; i++)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
2015-02-01 14:25:37 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)
|
|
|
|
file_list_get_userdata_at_offset(list, i);
|
2015-02-12 16:22:24 +00:00
|
|
|
float ia = 0;
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-11 05:11:25 +00:00
|
|
|
if (!node)
|
2014-11-14 20:56:21 +00:00
|
|
|
continue;
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir);
|
2014-11-14 20:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
|
|
|
int i;
|
2015-02-13 18:00:34 +00:00
|
|
|
size_t end = 0;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
end = file_list_get_size(list);
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-12 16:22:24 +00:00
|
|
|
for (i = 0; i < end; i++)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
2015-02-01 14:25:37 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)
|
|
|
|
file_list_get_userdata_at_offset(list, i);
|
2015-02-12 16:22:24 +00:00
|
|
|
float ia = 0.5;
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-11 05:15:15 +00:00
|
|
|
if (!node)
|
2014-11-14 20:56:21 +00:00
|
|
|
continue;
|
|
|
|
|
2015-02-12 22:38:44 +00:00
|
|
|
node->x = xmb->icon.spacing.horizontal * dir;
|
2015-02-02 19:48:26 +00:00
|
|
|
node->alpha = 0;
|
2014-11-14 22:39:24 +00:00
|
|
|
node->label_alpha = 0;
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
if (i == current)
|
2015-02-23 21:08:09 +00:00
|
|
|
ia = xmb->item.active.alpha;
|
2015-02-01 14:25:37 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_push_animations(node, ia, 0);
|
2014-11-14 20:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_set_title(xmb_handle_t *xmb)
|
2014-11-14 23:35:45 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
if (menu->categories.selection_ptr == 0)
|
2014-11-14 23:35:45 +00:00
|
|
|
{
|
2015-02-02 19:48:26 +00:00
|
|
|
const char *dir = NULL;
|
2014-11-14 23:35:45 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
|
2015-02-11 20:15:39 +00:00
|
|
|
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
|
2015-02-12 19:23:14 +00:00
|
|
|
get_title(label, dir, menu_type, xmb->title_name, sizeof(xmb->title_name));
|
2014-11-14 23:35:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core_info_t *info = NULL;
|
|
|
|
core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info;
|
|
|
|
|
|
|
|
if (!info_list)
|
|
|
|
return;
|
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1];
|
2014-11-14 23:35:45 +00:00
|
|
|
|
2015-02-01 14:25:37 +00:00
|
|
|
if (info)
|
2015-02-12 19:23:14 +00:00
|
|
|
strlcpy(xmb->title_name, info->display_name, sizeof(xmb->title_name));
|
2014-11-14 23:35:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-23 20:40:36 +00:00
|
|
|
static void xmb_list_switch(xmb_handle_t *xmb)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2014-11-14 20:56:21 +00:00
|
|
|
unsigned j;
|
2015-02-02 19:40:29 +00:00
|
|
|
int dir = -1;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old)
|
2015-02-02 19:40:29 +00:00
|
|
|
dir = 1;
|
2014-11-14 23:35:45 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.active.idx += dir;
|
2015-01-26 20:59:55 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (j = 0; j < menu->categories.size; j++)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
2015-02-12 18:23:11 +00:00
|
|
|
float ia = xmb->categories.passive.alpha;
|
|
|
|
float iz = xmb->categories.passive.zoom;
|
2015-02-12 14:14:05 +00:00
|
|
|
xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node;
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-01-26 20:59:55 +00:00
|
|
|
if (!node)
|
|
|
|
continue;
|
2015-02-02 19:40:29 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (j == xmb->categories.active.idx)
|
2015-02-02 19:40:29 +00:00
|
|
|
{
|
2015-02-12 18:23:11 +00:00
|
|
|
ia = xmb->categories.active.alpha;
|
|
|
|
iz = xmb->categories.active.zoom;
|
2015-02-02 19:40:29 +00:00
|
|
|
}
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-11 20:15:39 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL);
|
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL);
|
2015-01-26 20:59:55 +00:00
|
|
|
}
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-11 20:15:39 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY,
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->icon.spacing.horizontal * -(float)menu->categories.selection_ptr,
|
2015-02-12 18:23:11 +00:00
|
|
|
&xmb->categories.x_pos, EASING_IN_OUT_QUAD, NULL);
|
2015-02-02 19:40:29 +00:00
|
|
|
|
|
|
|
dir = -1;
|
2015-02-12 18:23:11 +00:00
|
|
|
if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old)
|
2015-02-02 19:40:29 +00:00
|
|
|
dir = 1;
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
|
2015-02-13 23:47:42 +00:00
|
|
|
xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr);
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.active.idx_old = menu->categories.selection_ptr;
|
2015-01-26 20:59:55 +00:00
|
|
|
}
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-23 20:40:36 +00:00
|
|
|
static void xmb_list_open(xmb_handle_t *xmb)
|
2015-01-26 20:59:55 +00:00
|
|
|
{
|
|
|
|
unsigned j;
|
2015-02-02 19:40:29 +00:00
|
|
|
int dir = 0;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
xmb->depth = file_list_get_size(menu->menu_list->menu_stack);
|
2014-10-09 00:41:08 +00:00
|
|
|
|
2014-10-20 18:00:39 +00:00
|
|
|
if (xmb->depth > xmb->old_depth)
|
|
|
|
dir = 1;
|
|
|
|
else if (xmb->depth < xmb->old_depth)
|
|
|
|
dir = -1;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (j = 0; j < menu->categories.size; j++)
|
2014-11-11 17:15:00 +00:00
|
|
|
{
|
2015-02-02 19:40:29 +00:00
|
|
|
float ia = 0;
|
2015-02-12 14:14:05 +00:00
|
|
|
xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node;
|
2014-11-11 17:15:00 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (j == xmb->categories.active.idx)
|
|
|
|
ia = xmb->categories.active.alpha;
|
2015-02-02 19:40:29 +00:00
|
|
|
else if (xmb->depth <= 1)
|
2015-02-12 18:23:11 +00:00
|
|
|
ia = xmb->categories.passive.alpha;
|
2015-02-02 19:40:29 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, ia,
|
2015-02-11 00:15:16 +00:00
|
|
|
&node->alpha, EASING_IN_OUT_QUAD, NULL);
|
2014-11-11 17:15:00 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
|
2015-02-13 23:47:42 +00:00
|
|
|
xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-01 14:25:37 +00:00
|
|
|
switch (xmb->depth)
|
|
|
|
{
|
|
|
|
case 1:
|
2015-02-12 17:31:46 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2),
|
2015-02-11 00:15:16 +00:00
|
|
|
&xmb->x, EASING_IN_OUT_QUAD, NULL);
|
2015-02-12 18:27:13 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->textures.arrow.alpha,
|
2015-02-11 00:15:16 +00:00
|
|
|
EASING_IN_OUT_QUAD, NULL);
|
2015-02-01 14:25:37 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY,
|
2015-02-12 17:31:46 +00:00
|
|
|
xmb->icon.size * -(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL);
|
2015-02-12 18:27:13 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->textures.arrow.alpha,
|
2015-02-11 00:15:16 +00:00
|
|
|
EASING_IN_OUT_QUAD, NULL);
|
2015-02-01 14:25:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2014-10-20 18:00:39 +00:00
|
|
|
xmb->old_depth = xmb->depth;
|
|
|
|
}
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_populate_entries(const char *path,
|
2015-01-26 20:59:55 +00:00
|
|
|
const char *label, unsigned k)
|
|
|
|
{
|
2015-02-11 19:28:54 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2015-02-11 19:28:54 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2015-02-13 18:00:34 +00:00
|
|
|
|
2015-02-11 19:40:48 +00:00
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2015-01-26 20:59:55 +00:00
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
2015-01-28 18:09:21 +00:00
|
|
|
if (xmb->prevent_populate)
|
|
|
|
{
|
|
|
|
xmb->prevent_populate = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_set_title(xmb);
|
2015-01-26 20:59:55 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (menu->categories.selection_ptr != xmb->categories.active.idx_old)
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_list_switch(xmb);
|
2015-02-23 20:40:36 +00:00
|
|
|
else
|
|
|
|
xmb_list_open(xmb);
|
2015-01-26 20:59:55 +00:00
|
|
|
}
|
|
|
|
|
2015-03-09 23:39:18 +00:00
|
|
|
static GLuint xmb_icon_get_type(xmb_handle_t *xmb,
|
|
|
|
xmb_node_t *core_node, unsigned type)
|
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case MENU_FILE_DIRECTORY:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_FOLDER].id;
|
|
|
|
case MENU_FILE_PLAIN:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_FILE].id;
|
|
|
|
case MENU_FILE_PLAYLIST_ENTRY:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_FILE].id;
|
|
|
|
case MENU_FILE_CONTENTLIST_ENTRY:
|
|
|
|
if (core_node)
|
|
|
|
return core_node->content_icon;
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_FILE].id;
|
|
|
|
case MENU_FILE_CARCHIVE:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_ZIP].id;
|
|
|
|
case MENU_FILE_CORE:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_CORE].id;
|
|
|
|
case MENU_FILE_RDB:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_RDB].id;
|
|
|
|
case MENU_FILE_CURSOR:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_CURSOR].id;
|
|
|
|
case MENU_SETTING_ACTION_RUN:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_RUN].id;
|
|
|
|
case MENU_SETTING_ACTION_SAVESTATE:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SAVESTATE].id;
|
|
|
|
case MENU_SETTING_ACTION_LOADSTATE:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_LOADSTATE].id;
|
|
|
|
case MENU_SETTING_ACTION_CORE_INFORMATION:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_CORE_INFO].id;
|
|
|
|
case MENU_SETTING_ACTION_CORE_OPTIONS:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id;
|
|
|
|
case MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id;
|
|
|
|
case MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id;
|
|
|
|
case MENU_SETTING_ACTION_CORE_DISK_OPTIONS:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id;
|
|
|
|
case MENU_SETTING_ACTION_SCREENSHOT:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id;
|
|
|
|
case MENU_SETTING_ACTION_RESET:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_RELOAD].id;
|
|
|
|
case MENU_SETTING_ACTION:
|
|
|
|
if (xmb->depth == 3)
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SUBSETTING].id;
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SETTING].id;
|
|
|
|
case MENU_SETTING_GROUP:
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SETTING].id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xmb->textures.list[XMB_TEXTURE_SUBSETTING].id;
|
|
|
|
}
|
|
|
|
|
2015-02-11 05:05:27 +00:00
|
|
|
static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
|
2015-02-11 04:33:53 +00:00
|
|
|
file_list_t *list, file_list_t *stack,
|
2014-11-27 10:07:52 +00:00
|
|
|
size_t current, size_t cat_selection_ptr)
|
2014-10-20 18:00:39 +00:00
|
|
|
{
|
2015-03-10 02:42:26 +00:00
|
|
|
math_matrix_4x4 mymat, mrot, mscal;
|
2014-10-21 03:51:30 +00:00
|
|
|
unsigned i;
|
2015-02-02 19:48:26 +00:00
|
|
|
const char *label = NULL;
|
2015-01-10 22:45:14 +00:00
|
|
|
xmb_node_t *core_node = NULL;
|
2015-02-12 16:08:57 +00:00
|
|
|
size_t end = 0;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 16:08:57 +00:00
|
|
|
if (!list || !list->size)
|
2014-10-20 18:00:39 +00:00
|
|
|
return;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 16:08:57 +00:00
|
|
|
file_list_get_last(stack, NULL, &label, NULL);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (xmb->categories.active.idx)
|
2015-02-12 14:14:05 +00:00
|
|
|
core_node = xmb_get_userdata_from_core(xmb, cat_selection_ptr - 1);
|
2014-11-27 10:07:52 +00:00
|
|
|
|
2015-02-12 16:08:57 +00:00
|
|
|
end = file_list_get_size(list);
|
|
|
|
|
2015-03-10 02:42:26 +00:00
|
|
|
matrix_4x4_rotate_z(&mrot, 0 /* rotation */);
|
|
|
|
matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot);
|
|
|
|
|
|
|
|
matrix_4x4_scale(&mscal, 1 /* scale_factor */, 1 /* scale_factor */, 1);
|
|
|
|
matrix_4x4_multiply(&mymat, &mscal, &mymat);
|
|
|
|
|
2014-10-09 19:47:40 +00:00
|
|
|
for (i = 0; i < end; i++)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-02-02 19:40:29 +00:00
|
|
|
float icon_x, icon_y;
|
2015-01-31 16:46:14 +00:00
|
|
|
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
2015-02-12 16:05:56 +00:00
|
|
|
char name[PATH_MAX_LENGTH], value[PATH_MAX_LENGTH];
|
2014-10-09 17:22:42 +00:00
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
2015-01-31 16:46:14 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
2015-02-01 14:25:37 +00:00
|
|
|
GLuint icon = 0;
|
2015-02-12 16:05:56 +00:00
|
|
|
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 16:05:56 +00:00
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
2015-02-12 22:38:44 +00:00
|
|
|
icon_x = node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal - xmb->icon.size / 2.0;
|
2015-02-12 19:23:14 +00:00
|
|
|
icon_y = xmb->margins.screen.top + node->y + xmb->icon.size / 2.0;
|
2015-02-01 23:02:16 +00:00
|
|
|
|
|
|
|
if (
|
2015-02-12 17:31:46 +00:00
|
|
|
icon_x < -xmb->icon.size / 2 ||
|
2015-02-01 23:02:16 +00:00
|
|
|
icon_x > gl->win_width ||
|
2015-02-12 17:31:46 +00:00
|
|
|
icon_y < xmb->icon.size / 2 ||
|
|
|
|
icon_y > gl->win_height + xmb->icon.size)
|
2015-02-01 23:02:16 +00:00
|
|
|
continue;
|
|
|
|
|
2015-02-12 16:05:56 +00:00
|
|
|
menu_list_get_at_offset(list, i, &path, &entry_label, &type);
|
|
|
|
|
2015-02-03 03:24:34 +00:00
|
|
|
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(list, i);
|
2015-01-31 16:19:12 +00:00
|
|
|
|
2015-01-31 16:46:14 +00:00
|
|
|
if (cbs && cbs->action_get_representation)
|
2015-02-03 03:24:34 +00:00
|
|
|
cbs->action_get_representation(list,
|
2015-01-31 16:46:14 +00:00
|
|
|
&w, type, i, label,
|
|
|
|
type_str, sizeof(type_str),
|
|
|
|
entry_label, path,
|
|
|
|
path_buf, sizeof(path_buf));
|
2014-10-09 17:22:42 +00:00
|
|
|
|
2015-01-28 21:06:42 +00:00
|
|
|
if (type == MENU_FILE_CONTENTLIST_ENTRY)
|
2015-01-28 18:07:23 +00:00
|
|
|
strlcpy(path_buf, path_basename(path_buf), sizeof(path_buf));
|
2015-01-17 03:50:46 +00:00
|
|
|
|
2015-03-09 23:39:18 +00:00
|
|
|
icon = xmb_icon_get_type(xmb, core_node, type);
|
2014-10-14 21:05:53 +00:00
|
|
|
|
2015-02-18 09:31:01 +00:00
|
|
|
if (!strcmp(entry_label, "core_options"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].id;
|
|
|
|
else if (!strcmp(entry_label, "core_information"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_CORE_INFO].id;
|
|
|
|
else if (!strcmp(entry_label, "core_input_remapping_options"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].id;
|
|
|
|
else if (!strcmp(entry_label, "core_cheat_options"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].id;
|
|
|
|
else if (!strcmp(entry_label, "core_disk_options"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].id;
|
|
|
|
else if (!strcmp(entry_label, "savestate"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id;
|
|
|
|
else if (!strcmp(entry_label, "loadstate"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id;
|
|
|
|
else if (!strcmp(entry_label, "take_screenshot"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id;
|
|
|
|
else if (!strcmp(entry_label, "restart_content"))
|
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id;
|
|
|
|
else if (!strcmp(entry_label, "resume_content"))
|
2015-02-18 09:35:08 +00:00
|
|
|
icon = xmb->textures.list[XMB_TEXTURE_RESUME].id;
|
2015-02-18 09:31:01 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-03-07 12:14:04 +00:00
|
|
|
menu_animation_ticker_line(name, 35, g_runloop.frames.video.count / 20, path_buf,
|
2014-10-20 18:00:39 +00:00
|
|
|
(i == current));
|
2014-10-12 18:30:19 +00:00
|
|
|
|
2015-02-11 04:43:42 +00:00
|
|
|
xmb_draw_text(gl, xmb, name,
|
2015-02-12 22:38:44 +00:00
|
|
|
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->margins.label.left,
|
2015-02-12 19:23:14 +00:00
|
|
|
xmb->margins.screen.top + node->y + xmb->margins.label.top,
|
2015-02-02 19:48:26 +00:00
|
|
|
1, node->label_alpha, 0);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-03-07 12:14:04 +00:00
|
|
|
menu_animation_ticker_line(value, 35, g_runloop.frames.video.count / 20, type_str,
|
2014-10-12 18:30:19 +00:00
|
|
|
(i == current));
|
|
|
|
|
2015-01-31 16:46:14 +00:00
|
|
|
if(( strcmp(type_str, "...")
|
|
|
|
&& strcmp(type_str, "(CORE)")
|
2015-02-02 23:27:18 +00:00
|
|
|
&& strcmp(type_str, "(RDB)")
|
|
|
|
&& strcmp(type_str, "(CURSOR)")
|
2015-01-31 16:46:14 +00:00
|
|
|
&& strcmp(type_str, "(FILE)")
|
|
|
|
&& strcmp(type_str, "(DIR)")
|
|
|
|
&& strcmp(type_str, "(COMP)")
|
|
|
|
&& strcmp(type_str, "ON")
|
|
|
|
&& strcmp(type_str, "OFF"))
|
|
|
|
|| ((!strcmp(type_str, "ON")
|
2015-02-12 18:27:13 +00:00
|
|
|
&& !xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
|
2015-01-31 16:46:14 +00:00
|
|
|
|| (!strcmp(type_str, "OFF")
|
2015-02-12 18:27:13 +00:00
|
|
|
&& !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)))
|
2015-02-11 04:43:42 +00:00
|
|
|
xmb_draw_text(gl, xmb, value,
|
2015-02-12 22:38:44 +00:00
|
|
|
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal +
|
2015-02-12 19:23:14 +00:00
|
|
|
xmb->margins.label.left + xmb->margins.setting.left,
|
|
|
|
xmb->margins.screen.top + node->y + xmb->margins.label.top,
|
2014-10-21 23:37:55 +00:00
|
|
|
1,
|
2015-01-23 00:54:17 +00:00
|
|
|
node->label_alpha,
|
|
|
|
0);
|
2014-10-22 00:41:28 +00:00
|
|
|
|
2015-03-10 02:42:26 +00:00
|
|
|
|
2015-03-08 21:02:33 +00:00
|
|
|
xmb_draw_icon_begin(gl, xmb);
|
|
|
|
|
|
|
|
xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom);
|
|
|
|
|
2015-02-12 18:27:13 +00:00
|
|
|
if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id)
|
2015-03-08 12:24:16 +00:00
|
|
|
{
|
2015-03-10 02:42:26 +00:00
|
|
|
xmb_draw_icon_predone(gl, xmb, &mymat, xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id,
|
2015-02-12 22:38:44 +00:00
|
|
|
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal
|
2015-02-12 19:23:14 +00:00
|
|
|
+ xmb->icon.size / 2.0 + xmb->margins.setting.left,
|
|
|
|
xmb->margins.screen.top + node->y + xmb->icon.size / 2.0,
|
2014-10-22 00:41:28 +00:00
|
|
|
node->alpha,
|
|
|
|
0,
|
|
|
|
1);
|
2015-03-08 12:24:16 +00:00
|
|
|
}
|
2014-10-22 00:41:28 +00:00
|
|
|
|
2015-02-12 18:27:13 +00:00
|
|
|
if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id)
|
2015-03-08 12:24:16 +00:00
|
|
|
{
|
2015-03-10 02:42:26 +00:00
|
|
|
xmb_draw_icon_predone(gl, xmb, &mymat, xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id,
|
2015-02-12 22:38:44 +00:00
|
|
|
node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal
|
2015-02-12 19:23:14 +00:00
|
|
|
+ xmb->icon.size / 2.0 + xmb->margins.setting.left,
|
|
|
|
xmb->margins.screen.top + node->y + xmb->icon.size / 2.0,
|
2014-10-22 00:41:28 +00:00
|
|
|
node->alpha,
|
|
|
|
0,
|
|
|
|
1);
|
2015-03-08 12:24:16 +00:00
|
|
|
}
|
2015-03-08 21:02:33 +00:00
|
|
|
|
|
|
|
xmb_draw_icon_end(gl, xmb);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
2014-10-20 18:00:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 23:14:55 +00:00
|
|
|
static void xmb_draw_cursor(gl_t *gl, xmb_handle_t *xmb, float x, float y)
|
2015-03-08 22:36:12 +00:00
|
|
|
{
|
|
|
|
struct gl_coords coords;
|
2015-03-09 01:00:16 +00:00
|
|
|
math_matrix_4x4 mymat, mrot;
|
2015-03-08 22:36:12 +00:00
|
|
|
|
|
|
|
GLfloat color[] = {
|
2015-03-08 23:14:55 +00:00
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, xmb->alpha,
|
2015-03-08 22:36:12 +00:00
|
|
|
};
|
|
|
|
|
2015-03-08 23:14:55 +00:00
|
|
|
glViewport(x, gl->win_height - y, xmb->cursor.size, xmb->cursor.size);
|
2015-03-08 22:36:12 +00:00
|
|
|
|
|
|
|
coords.vertices = 4;
|
2015-03-08 23:14:55 +00:00
|
|
|
coords.vertex = rmb_vertex;
|
|
|
|
coords.tex_coord = rmb_tex_coord;
|
|
|
|
coords.lut_tex_coord = rmb_tex_coord;
|
|
|
|
coords.color = color;
|
2015-03-09 22:46:16 +00:00
|
|
|
|
2015-03-08 23:14:55 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, xmb->textures.list[XMB_TEXTURE_POINTER].id);
|
2015-03-08 22:36:12 +00:00
|
|
|
|
2015-03-10 17:44:55 +00:00
|
|
|
matrix_4x4_rotate_z(&mrot, 0);
|
2015-03-08 23:14:55 +00:00
|
|
|
matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot);
|
2015-03-08 22:36:12 +00:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
2015-03-08 23:14:55 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
gl->shader->set_coords(&coords);
|
|
|
|
gl->shader->set_mvp(gl, &mymat);
|
|
|
|
|
2015-03-08 22:36:12 +00:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
2015-03-08 23:14:55 +00:00
|
|
|
glDisable(GL_BLEND);
|
2015-03-08 22:36:12 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 18:15:24 +00:00
|
|
|
static void xmb_render(void)
|
|
|
|
{
|
2015-03-08 22:36:12 +00:00
|
|
|
unsigned i, current, end;
|
|
|
|
|
2015-03-08 18:15:24 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-03-08 22:36:12 +00:00
|
|
|
xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
2015-03-08 18:15:24 +00:00
|
|
|
menu_animation_update(menu->animation, menu->dt / IDEAL_DT);
|
2015-03-08 18:50:12 +00:00
|
|
|
|
2015-03-08 22:36:12 +00:00
|
|
|
current = menu->navigation.selection_ptr;
|
|
|
|
end = menu_list_get_size(menu->menu_list);
|
|
|
|
|
|
|
|
for (i = 0; i < end; i++)
|
|
|
|
{
|
|
|
|
float item_y = xmb->margins.screen.top + xmb_item_y(xmb, i, current);
|
|
|
|
|
|
|
|
if (menu->mouse.y > item_y && menu->mouse.y < item_y + xmb->icon.size)
|
|
|
|
menu->mouse.ptr = i;
|
|
|
|
}
|
|
|
|
|
2015-03-08 18:50:12 +00:00
|
|
|
g_runloop.frames.video.current.menu.animation.is_active = false;
|
|
|
|
g_runloop.frames.video.current.menu.label.is_updated = false;
|
|
|
|
g_runloop.frames.video.current.menu.framebuf.dirty = false;
|
2015-03-08 18:15:24 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_frame(void)
|
2014-10-20 18:00:39 +00:00
|
|
|
{
|
2015-03-10 02:42:26 +00:00
|
|
|
math_matrix_4x4 mymat, mrot, mscal;
|
2015-02-04 23:52:30 +00:00
|
|
|
int i, depth;
|
2015-03-08 12:17:07 +00:00
|
|
|
char msg[PATH_MAX_LENGTH];
|
2015-01-17 03:50:46 +00:00
|
|
|
char title_msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH];
|
2015-03-08 12:17:07 +00:00
|
|
|
bool render_background = false;
|
2015-01-10 22:45:14 +00:00
|
|
|
const char *core_name = NULL;
|
|
|
|
const char *core_version = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
|
|
|
gl_t *gl = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2014-10-20 18:00:39 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-20 18:00:39 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gl = (gl_t*)video_driver_resolve(NULL);
|
|
|
|
|
|
|
|
if (!gl)
|
2014-10-20 18:00:39 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-09 22:37:22 +00:00
|
|
|
if (gl->shader && gl->shader->use)
|
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
|
|
|
|
2015-03-09 22:34:01 +00:00
|
|
|
xmb_frame_background(gl, xmb, false);
|
2014-10-20 18:00:39 +00:00
|
|
|
|
2015-02-11 04:43:42 +00:00
|
|
|
xmb_draw_text(gl, xmb,
|
2015-02-12 19:23:14 +00:00
|
|
|
xmb->title_name, xmb->margins.title.left, xmb->margins.title.top, 1, 1, 0);
|
2014-11-14 23:35:45 +00:00
|
|
|
|
2015-01-17 03:50:46 +00:00
|
|
|
if (g_settings.menu.timedate_enable)
|
2015-02-04 21:44:33 +00:00
|
|
|
{
|
2015-02-12 18:35:24 +00:00
|
|
|
disp_timedate_set_label(timedate, sizeof(timedate), 0);
|
|
|
|
|
2015-02-11 04:43:42 +00:00
|
|
|
xmb_draw_text(gl, xmb,
|
2015-02-12 19:23:14 +00:00
|
|
|
timedate, gl->win_width - xmb->margins.title.left - xmb->icon.size / 4,
|
|
|
|
xmb->margins.title.top, 1, 1, 1);
|
2015-02-04 21:44:33 +00:00
|
|
|
}
|
|
|
|
|
2015-02-12 18:15:48 +00:00
|
|
|
if (g_settings.menu.core_enable)
|
|
|
|
{
|
2015-02-12 18:35:24 +00:00
|
|
|
core_name = g_extern.menu.info.library_name;
|
|
|
|
|
|
|
|
if (!core_name)
|
|
|
|
core_name = g_extern.system.info.library_name;
|
|
|
|
if (!core_name)
|
|
|
|
core_name = "No Core";
|
|
|
|
|
2015-02-12 18:15:48 +00:00
|
|
|
core_version = g_extern.menu.info.library_version;
|
2015-01-10 22:45:14 +00:00
|
|
|
|
2015-02-12 18:15:48 +00:00
|
|
|
if (!core_version)
|
|
|
|
core_version = g_extern.system.info.library_version;
|
|
|
|
if (!core_version)
|
|
|
|
core_version = "";
|
2014-10-20 18:00:39 +00:00
|
|
|
|
2015-02-12 18:15:48 +00:00
|
|
|
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
|
|
|
|
core_name, core_version);
|
2015-02-12 19:23:14 +00:00
|
|
|
xmb_draw_text(gl, xmb, title_msg, xmb->margins.title.left,
|
|
|
|
gl->win_height - xmb->margins.title.bottom, 1, 1, 0);
|
2015-02-12 18:15:48 +00:00
|
|
|
}
|
2014-10-20 18:00:39 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
depth = file_list_get_size(menu->menu_list->menu_stack);
|
2015-02-04 23:52:30 +00:00
|
|
|
|
2015-02-11 05:05:27 +00:00
|
|
|
xmb_draw_items(xmb, gl,
|
2014-11-27 16:03:27 +00:00
|
|
|
xmb->selection_buf_old,
|
|
|
|
xmb->menu_stack_old,
|
|
|
|
xmb->selection_ptr_old,
|
2015-02-11 20:43:16 +00:00
|
|
|
depth > 1 ? menu->categories.selection_ptr :
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.selection_ptr_old);
|
2015-02-11 04:33:53 +00:00
|
|
|
|
2015-02-11 05:05:27 +00:00
|
|
|
xmb_draw_items(xmb, gl,
|
2015-02-11 19:28:54 +00:00
|
|
|
menu->menu_list->selection_buf,
|
|
|
|
menu->menu_list->menu_stack,
|
2015-02-13 23:47:42 +00:00
|
|
|
menu->navigation.selection_ptr,
|
2015-02-11 20:43:16 +00:00
|
|
|
menu->categories.selection_ptr);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-03-10 02:42:26 +00:00
|
|
|
matrix_4x4_rotate_z(&mrot, 0 /* rotation */);
|
|
|
|
matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot);
|
|
|
|
|
|
|
|
matrix_4x4_scale(&mscal, 1 /* scale_factor */, 1 /* scale_factor */, 1);
|
|
|
|
matrix_4x4_multiply(&mymat, &mscal, &mymat);
|
|
|
|
|
2015-03-08 12:54:03 +00:00
|
|
|
xmb_draw_icon_begin(gl, xmb);
|
2015-03-08 20:55:02 +00:00
|
|
|
|
|
|
|
if (g_settings.menu.timedate_enable)
|
2015-03-10 02:42:26 +00:00
|
|
|
xmb_draw_icon_predone(gl, xmb, &mymat, xmb->textures.list[XMB_TEXTURE_CLOCK].id,
|
2015-03-08 20:55:02 +00:00
|
|
|
gl->win_width - xmb->icon.size, xmb->icon.size, 1, 0, 1);
|
|
|
|
|
2015-03-10 02:42:26 +00:00
|
|
|
xmb_draw_icon_predone(gl, xmb, &mymat, xmb->textures.list[XMB_TEXTURE_ARROW].id,
|
2015-03-08 20:55:02 +00: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->item.active.factor,
|
|
|
|
xmb->textures.arrow.alpha, 0, 1);
|
2015-03-10 02:42:26 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (i = 0; i < menu->categories.size; i++)
|
2014-11-11 15:28:40 +00:00
|
|
|
{
|
2015-02-12 14:14:05 +00:00
|
|
|
xmb_node_t *node = i ? xmb_get_userdata_from_core(xmb, i - 1) : &xmb->settings_node;
|
2014-11-11 15:28:40 +00:00
|
|
|
|
2015-02-11 04:33:53 +00:00
|
|
|
if (node)
|
2015-02-11 04:43:42 +00:00
|
|
|
xmb_draw_icon(gl, xmb, node->icon,
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0,
|
2015-02-12 19:23:14 +00:00
|
|
|
xmb->margins.screen.top + xmb->icon.size / 2.0,
|
2015-02-11 04:33:53 +00:00
|
|
|
node->alpha,
|
|
|
|
0,
|
|
|
|
node->zoom);
|
2014-11-11 15:28:40 +00:00
|
|
|
}
|
2015-03-08 12:54:03 +00:00
|
|
|
xmb_draw_icon_end(gl, xmb);
|
2014-11-11 15:28:40 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu->keyboard.display)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-02-11 19:28:54 +00:00
|
|
|
const char *str = *menu->keyboard.buffer;
|
2015-02-02 17:44:56 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
2014-10-09 02:34:16 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s",
|
2015-02-11 19:28:54 +00:00
|
|
|
menu->keyboard.label, str);
|
2015-03-08 12:17:07 +00:00
|
|
|
render_background = true;
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-10-09 02:34:16 +00:00
|
|
|
if (xmb->box_message[0] != '\0')
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2015-03-08 12:17:07 +00:00
|
|
|
strlcpy(msg, xmb->box_message,
|
|
|
|
sizeof(msg));
|
2014-10-09 02:34:16 +00:00
|
|
|
xmb->box_message[0] = '\0';
|
2015-03-08 12:17:07 +00:00
|
|
|
render_background = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (render_background)
|
|
|
|
{
|
2015-03-09 22:34:01 +00:00
|
|
|
xmb_frame_background(gl, xmb, true);
|
|
|
|
xmb_frame_messagebox(msg);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 22:36:12 +00:00
|
|
|
if (menu->mouse.enable)
|
2015-03-08 23:14:55 +00:00
|
|
|
xmb_draw_cursor(gl, xmb, menu->mouse.x, menu->mouse.y);
|
2015-03-08 22:36:12 +00:00
|
|
|
|
2015-03-01 16:46:08 +00:00
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *xmb_init(void)
|
|
|
|
{
|
2014-10-09 02:34:16 +00:00
|
|
|
menu_handle_t *menu = NULL;
|
2014-10-10 13:52:12 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2014-10-08 23:21:22 +00:00
|
|
|
const video_driver_t *video_driver = NULL;
|
2015-01-10 22:45:14 +00:00
|
|
|
float scale_factor = 1;
|
2015-01-19 03:22:49 +00:00
|
|
|
gl_t *gl = (gl_t*)video_driver_resolve(&video_driver);
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
if (video_driver != &video_gl || !gl)
|
|
|
|
{
|
2015-02-02 17:44:56 +00:00
|
|
|
RARCH_ERR("Cannot initialize XMB menu driver: GL video driver is not active.\n");
|
2014-10-08 23:21:22 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
|
|
|
|
|
|
|
if (!menu)
|
2015-02-02 17:44:56 +00:00
|
|
|
goto error;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t));
|
2014-10-09 02:34:16 +00:00
|
|
|
|
2014-10-10 13:52:12 +00:00
|
|
|
if (!menu->userdata)
|
2015-02-02 17:44:56 +00:00
|
|
|
goto error;
|
2014-10-09 02:34:16 +00:00
|
|
|
|
2014-10-10 13:52:12 +00:00
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
2015-02-02 17:44:56 +00:00
|
|
|
|
|
|
|
if (!xmb->menu_stack_old)
|
|
|
|
goto error;
|
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
2014-11-27 16:03:27 +00:00
|
|
|
|
2015-02-02 17:44:56 +00:00
|
|
|
if (!xmb->selection_buf_old)
|
|
|
|
goto error;
|
|
|
|
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->categories.active.idx = 0;
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.active.idx_old = 0;
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->x = 0;
|
|
|
|
xmb->categories.x_pos = 0;
|
|
|
|
xmb->textures.arrow.alpha = 0;
|
|
|
|
xmb->depth = 1;
|
|
|
|
xmb->old_depth = 1;
|
|
|
|
xmb->alpha = 0;
|
|
|
|
xmb->prevent_populate = false;
|
2015-02-12 17:18:38 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.active.zoom = 1.0;
|
|
|
|
xmb->categories.passive.zoom = 0.5;
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->item.active.zoom = 1.0;
|
|
|
|
xmb->item.passive.zoom = 0.5;
|
2015-02-12 17:18:38 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.active.alpha = 1.0;
|
|
|
|
xmb->categories.passive.alpha= 0.5;
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->item.active.alpha = 1.0;
|
|
|
|
xmb->item.passive.alpha = 0.5;
|
2015-02-12 17:18:38 +00:00
|
|
|
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->above_offset.subitem = 1.5;
|
|
|
|
xmb->above_offset.item = -1.0;
|
|
|
|
xmb->item.active.factor = 3.0;
|
|
|
|
xmb->under_offset.item = 5.0;
|
2014-10-12 00:52:33 +00:00
|
|
|
|
2015-02-27 06:27:58 +00:00
|
|
|
menu->frame_buf.width = gl->win_width;
|
|
|
|
menu->frame_buf.height = gl->win_height;
|
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
if (gl->win_width >= 3840)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 2.0;
|
2015-01-10 22:45:14 +00:00
|
|
|
else if (gl->win_width >= 2560)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 1.5;
|
2015-01-10 22:45:14 +00:00
|
|
|
else if (gl->win_width >= 1920)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 1.0;
|
2015-01-10 22:45:14 +00:00
|
|
|
else if (gl->win_width >= 1280)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 0.75;
|
2015-01-10 22:45:14 +00:00
|
|
|
else if (gl->win_width >= 640)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 0.5;
|
2015-01-10 22:45:14 +00:00
|
|
|
else if (gl->win_width >= 320)
|
2015-02-12 22:38:44 +00:00
|
|
|
scale_factor = 0.25;
|
2014-10-12 17:22:01 +00:00
|
|
|
|
2015-02-12 17:31:46 +00:00
|
|
|
strlcpy(xmb->icon.dir, "256", sizeof(xmb->icon.dir));
|
2014-10-08 23:21:22 +00:00
|
|
|
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->icon.size = 128.0 * scale_factor;
|
2015-03-08 23:14:55 +00:00
|
|
|
xmb->cursor.size = 48.0;
|
2015-02-12 22:38:44 +00:00
|
|
|
xmb->font.size = 32.0 * scale_factor;
|
|
|
|
xmb->icon.spacing.horizontal = 200.0 * scale_factor;
|
|
|
|
xmb->icon.spacing.vertical = 64.0 * scale_factor;
|
|
|
|
xmb->margins.screen.left = 336.0 * scale_factor;
|
|
|
|
xmb->margins.screen.top = (256+32) * scale_factor;
|
|
|
|
xmb->margins.title.left = 60 * scale_factor;
|
|
|
|
xmb->margins.title.top = 60 * scale_factor + xmb->font.size/3;
|
|
|
|
xmb->margins.title.bottom = 60 * scale_factor - xmb->font.size/3;
|
|
|
|
xmb->margins.label.left = 85.0 * scale_factor;
|
|
|
|
xmb->margins.label.top = xmb->font.size/3.0;
|
|
|
|
xmb->margins.setting.left = 600.0 * scale_factor;
|
2015-02-12 17:18:38 +00:00
|
|
|
|
|
|
|
menu->categories.size = 1;
|
|
|
|
|
2015-02-10 16:46:35 +00:00
|
|
|
if (g_extern.core_info)
|
2015-02-12 17:18:38 +00:00
|
|
|
menu->categories.size = g_extern.core_info->count + 1;
|
2014-11-11 15:28:40 +00:00
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
return menu;
|
2015-02-02 17:44:56 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (menu)
|
|
|
|
free(menu);
|
|
|
|
if (xmb && xmb->menu_stack_old)
|
|
|
|
free(xmb->menu_stack_old);
|
|
|
|
if (xmb && xmb->selection_buf_old)
|
|
|
|
free(xmb->selection_buf_old);
|
|
|
|
return NULL;
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void xmb_free(void *data)
|
|
|
|
{
|
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
|
|
|
|
2015-02-10 22:17:19 +00:00
|
|
|
if (menu && menu->userdata)
|
2014-10-10 13:52:12 +00:00
|
|
|
free(menu->userdata);
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 16:08:44 +00:00
|
|
|
static bool xmb_font_init_first(const gl_font_renderer_t **font_driver,
|
|
|
|
void **font_handle, void *video_data, const char *font_path,
|
2014-11-08 02:02:58 +00:00
|
|
|
float xmb_font_size)
|
2014-11-07 16:08:44 +00:00
|
|
|
{
|
|
|
|
if (g_settings.video.threaded
|
|
|
|
&& !g_extern.system.hw_render_callback.context_type)
|
|
|
|
{
|
|
|
|
thread_video_t *thr = (thread_video_t*)driver.video_data;
|
2015-02-10 22:14:01 +00:00
|
|
|
|
|
|
|
if (!thr)
|
|
|
|
return false;
|
|
|
|
|
2014-11-07 16:08:44 +00:00
|
|
|
thr->cmd_data.font_init.method = gl_font_init_first;
|
|
|
|
thr->cmd_data.font_init.font_driver = font_driver;
|
|
|
|
thr->cmd_data.font_init.font_handle = font_handle;
|
|
|
|
thr->cmd_data.font_init.video_data = video_data;
|
|
|
|
thr->cmd_data.font_init.font_path = font_path;
|
2014-11-08 02:02:58 +00:00
|
|
|
thr->cmd_data.font_init.font_size = xmb_font_size;
|
2014-11-07 16:08:44 +00:00
|
|
|
thr->send_cmd_func(thr, CMD_FONT_INIT);
|
|
|
|
thr->wait_reply_func(thr, CMD_FONT_INIT);
|
|
|
|
|
|
|
|
return thr->cmd_data.font_init.return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gl_font_init_first(font_driver, font_handle, video_data,
|
2014-11-08 13:42:08 +00:00
|
|
|
font_path, xmb_font_size);
|
2014-11-07 16:08:44 +00:00
|
|
|
}
|
|
|
|
|
2015-02-23 22:32:59 +00:00
|
|
|
static bool xmb_load_wallpaper(void *data)
|
2015-02-12 23:12:15 +00:00
|
|
|
{
|
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2015-02-12 23:12:15 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return false;
|
2015-02-23 22:32:59 +00:00
|
|
|
if (!data)
|
2015-02-12 23:12:15 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (xmb->textures.bg.id)
|
|
|
|
glDeleteTextures(1, &xmb->textures.bg.id);
|
|
|
|
|
2015-02-23 22:32:59 +00:00
|
|
|
xmb->textures.bg.id = menu_texture_load(data,
|
2015-02-12 23:12:15 +00:00
|
|
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
|
|
|
|
2015-02-23 21:54:39 +00:00
|
|
|
|
2015-02-12 23:12:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_context_reset(void)
|
2014-10-08 23:21:22 +00:00
|
|
|
{
|
2014-11-24 14:59:11 +00:00
|
|
|
int i, k;
|
2015-01-07 19:42:36 +00:00
|
|
|
char bgpath[PATH_MAX_LENGTH];
|
|
|
|
char mediapath[PATH_MAX_LENGTH], themepath[PATH_MAX_LENGTH], iconpath[PATH_MAX_LENGTH],
|
|
|
|
fontpath[PATH_MAX_LENGTH], core_id[PATH_MAX_LENGTH], texturepath[PATH_MAX_LENGTH],
|
|
|
|
content_texturepath[PATH_MAX_LENGTH];
|
2014-11-24 14:59:11 +00:00
|
|
|
|
2015-02-23 21:54:39 +00:00
|
|
|
struct texture_image ti = {0};
|
2015-01-10 22:45:14 +00:00
|
|
|
core_info_t* info = NULL;
|
|
|
|
core_info_list_t* info_list = NULL;
|
2014-10-10 13:52:12 +00:00
|
|
|
gl_t *gl = NULL;
|
|
|
|
xmb_handle_t *xmb = NULL;
|
2014-11-24 14:59:11 +00:00
|
|
|
xmb_node_t *node = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2014-10-10 13:52:12 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-01-19 03:22:49 +00:00
|
|
|
gl = (gl_t*)video_driver_resolve(NULL);
|
2014-10-10 13:52:12 +00:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
2014-10-08 23:21:22 +00:00
|
|
|
|
|
|
|
fill_pathname_join(bgpath, g_settings.assets_directory,
|
|
|
|
"xmb", sizeof(bgpath));
|
|
|
|
|
|
|
|
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
|
|
|
|
|
|
|
fill_pathname_join(mediapath, g_settings.assets_directory,
|
|
|
|
"lakka", sizeof(mediapath));
|
2014-10-09 00:41:08 +00:00
|
|
|
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
|
2015-02-12 17:31:46 +00:00
|
|
|
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
|
2014-10-08 23:21:22 +00:00
|
|
|
fill_pathname_slash(iconpath, sizeof(iconpath));
|
|
|
|
|
2014-11-07 16:08:44 +00:00
|
|
|
fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath));
|
|
|
|
|
2015-02-12 17:25:48 +00:00
|
|
|
xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size);
|
2014-11-07 16:08:44 +00:00
|
|
|
|
2015-02-12 18:27:13 +00:00
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath,
|
|
|
|
"settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTING].path, iconpath,
|
|
|
|
"setting.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTING].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SUBSETTING].path, iconpath,
|
|
|
|
"subsetting.png", sizeof(xmb->textures.list[XMB_TEXTURE_SUBSETTING].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_ARROW].path, iconpath,
|
|
|
|
"arrow.png", sizeof(xmb->textures.list[XMB_TEXTURE_ARROW].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RUN].path, iconpath,
|
|
|
|
"run.png", sizeof(xmb->textures.list[XMB_TEXTURE_RUN].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RESUME].path, iconpath,
|
|
|
|
"resume.png", sizeof(xmb->textures.list[XMB_TEXTURE_RESUME].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SAVESTATE].path, iconpath,
|
|
|
|
"savestate.png", sizeof(xmb->textures.list[XMB_TEXTURE_SAVESTATE].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_LOADSTATE].path, iconpath,
|
|
|
|
"loadstate.png", sizeof(xmb->textures.list[XMB_TEXTURE_LOADSTATE].path));
|
2015-02-17 22:43:34 +00:00
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CORE_INFO].path, iconpath,
|
|
|
|
"core-infos.png", sizeof(xmb->textures.list[XMB_TEXTURE_CORE_INFO].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].path, iconpath,
|
|
|
|
"core-options.png", sizeof(xmb->textures.list[XMB_TEXTURE_CORE_OPTIONS].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].path, iconpath,
|
|
|
|
"core-input-remapping-options.png", sizeof(xmb->textures.list[XMB_TEXTURE_INPUT_REMAPPING_OPTIONS].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CHEAT_OPTIONS].path, iconpath,
|
|
|
|
"core-cheat-options.png", sizeof(xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].path, iconpath,
|
|
|
|
"core-disk-options.png", sizeof(xmb->textures.list[XMB_TEXTURE_DISK_OPTIONS].path));
|
2015-02-12 18:27:13 +00:00
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SCREENSHOT].path, iconpath,
|
|
|
|
"screenshot.png", sizeof(xmb->textures.list[XMB_TEXTURE_SCREENSHOT].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RELOAD].path, iconpath,
|
|
|
|
"reload.png", sizeof(xmb->textures.list[XMB_TEXTURE_RELOAD].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_FILE].path, iconpath,
|
|
|
|
"file.png", sizeof(xmb->textures.list[XMB_TEXTURE_FILE].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_FOLDER].path, iconpath,
|
|
|
|
"folder.png", sizeof(xmb->textures.list[XMB_TEXTURE_FOLDER].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_ZIP].path, iconpath,
|
|
|
|
"zip.png", sizeof(xmb->textures.list[XMB_TEXTURE_ZIP].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CORE].path, iconpath,
|
|
|
|
"core.png", sizeof(xmb->textures.list[XMB_TEXTURE_CORE].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RDB].path, iconpath,
|
|
|
|
"database.png", sizeof(xmb->textures.list[XMB_TEXTURE_RDB].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CURSOR].path, iconpath,
|
|
|
|
"cursor.png", sizeof(xmb->textures.list[XMB_TEXTURE_CURSOR].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SWITCH_ON].path, iconpath,
|
|
|
|
"on.png", sizeof(xmb->textures.list[XMB_TEXTURE_SWITCH_ON].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].path, iconpath,
|
|
|
|
"off.png", sizeof(xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].path));
|
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CLOCK].path, iconpath,
|
|
|
|
"clock.png", sizeof(xmb->textures.list[XMB_TEXTURE_CLOCK].path));
|
2015-03-08 23:14:55 +00:00
|
|
|
fill_pathname_join(xmb->textures.list[XMB_TEXTURE_POINTER].path, iconpath,
|
|
|
|
"pointer.png", sizeof(xmb->textures.list[XMB_TEXTURE_POINTER].path));
|
2014-10-09 20:59:05 +00:00
|
|
|
|
|
|
|
for (k = 0; k < XMB_TEXTURE_LAST; k++)
|
2015-02-23 21:54:39 +00:00
|
|
|
{
|
|
|
|
const char *path = xmb->textures.list[k].path;
|
|
|
|
if (! path_file_exists(path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
texture_image_load(&ti, path);
|
|
|
|
|
|
|
|
xmb->textures.list[k].id = menu_texture_load(&ti,
|
2015-02-11 14:19:21 +00:00
|
|
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
2014-11-11 15:28:40 +00:00
|
|
|
|
2015-02-23 21:54:39 +00:00
|
|
|
texture_image_free(&ti);
|
|
|
|
}
|
|
|
|
|
2015-02-23 22:32:59 +00:00
|
|
|
{
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
struct texture_image ti = {0};
|
|
|
|
|
|
|
|
fill_pathname_join(path, iconpath,
|
|
|
|
"bg.png", sizeof(path));
|
|
|
|
|
|
|
|
if (*g_settings.menu.wallpaper)
|
|
|
|
strlcpy(path, g_settings.menu.wallpaper,
|
|
|
|
sizeof(path));
|
|
|
|
|
|
|
|
if ( path_file_exists(path))
|
|
|
|
{
|
|
|
|
texture_image_load(&ti, path);
|
|
|
|
|
|
|
|
xmb_load_wallpaper(&ti);
|
|
|
|
|
|
|
|
texture_image_free(&ti);
|
|
|
|
}
|
|
|
|
}
|
2015-02-12 23:12:15 +00:00
|
|
|
|
2015-02-12 18:27:13 +00:00
|
|
|
xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id;
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->settings_node.alpha = xmb->categories.active.alpha;
|
|
|
|
xmb->settings_node.zoom = xmb->categories.active.zoom;
|
2014-11-24 14:59:11 +00:00
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
info_list = (core_info_list_t*)g_extern.core_info;
|
2014-11-24 14:59:11 +00:00
|
|
|
|
|
|
|
if (!info_list)
|
|
|
|
return;
|
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (i = 1; i < menu->categories.size; i++)
|
2014-11-24 14:59:11 +00:00
|
|
|
{
|
2015-02-23 21:54:39 +00:00
|
|
|
struct texture_image ti = {0};
|
2015-02-12 14:14:05 +00:00
|
|
|
node = xmb_get_userdata_from_core(xmb, i - 1);
|
2014-11-24 14:59:11 +00:00
|
|
|
|
|
|
|
fill_pathname_join(mediapath, g_settings.assets_directory,
|
|
|
|
"lakka", sizeof(mediapath));
|
|
|
|
fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath));
|
2015-02-12 17:31:46 +00:00
|
|
|
fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath));
|
2014-11-24 14:59:11 +00:00
|
|
|
fill_pathname_slash(iconpath, sizeof(iconpath));
|
|
|
|
|
|
|
|
info = (core_info_t*)&info_list->list[i-1];
|
|
|
|
|
|
|
|
if (!info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (info->systemname)
|
|
|
|
{
|
|
|
|
char *tmp = xmb_str_replace(info->systemname, "/", " ");
|
|
|
|
strlcpy(core_id, tmp, sizeof(core_id));
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strlcpy(core_id, "default", sizeof(core_id));
|
|
|
|
|
|
|
|
strlcpy(texturepath, iconpath, sizeof(texturepath));
|
|
|
|
strlcat(texturepath, core_id, sizeof(texturepath));
|
|
|
|
strlcat(texturepath, ".png", sizeof(texturepath));
|
|
|
|
|
|
|
|
strlcpy(content_texturepath, iconpath, sizeof(content_texturepath));
|
|
|
|
strlcat(content_texturepath, core_id, sizeof(content_texturepath));
|
|
|
|
strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));
|
|
|
|
|
2015-02-02 19:28:17 +00:00
|
|
|
node->alpha = 0;
|
2015-02-12 18:23:11 +00:00
|
|
|
node->zoom = xmb->categories.passive.zoom;
|
2015-02-23 21:54:39 +00:00
|
|
|
|
|
|
|
texture_image_load(&ti, texturepath);
|
|
|
|
|
|
|
|
node->icon = menu_texture_load(&ti,
|
2015-02-11 14:19:21 +00:00
|
|
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
2015-02-23 21:54:39 +00:00
|
|
|
|
|
|
|
texture_image_free(&ti);
|
|
|
|
|
|
|
|
texture_image_load(&ti, content_texturepath);
|
|
|
|
|
|
|
|
node->content_icon = menu_texture_load(&ti,
|
2015-02-11 14:19:21 +00:00
|
|
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
2015-02-11 02:52:35 +00:00
|
|
|
|
2015-02-23 21:54:39 +00:00
|
|
|
texture_image_free(&ti);
|
2015-02-02 19:28:17 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (i == xmb->categories.active.idx)
|
2015-02-02 19:28:17 +00:00
|
|
|
{
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.active.alpha;
|
|
|
|
node->zoom = xmb->categories.active.zoom;
|
2015-02-02 19:28:17 +00:00
|
|
|
}
|
|
|
|
else if (xmb->depth <= 1)
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.passive.alpha;
|
2014-11-24 14:59:11 +00:00
|
|
|
}
|
2014-10-08 23:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_clear(bool pending_push)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_decrement(void)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_increment(void)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_set(bool scroll)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_set_last(void)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_descend_alphabet(size_t *unused)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_navigation_ascend_alphabet(size_t *unused)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_selection_pointer_changed();
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_insert(file_list_t *list,
|
2014-10-09 20:25:13 +00:00
|
|
|
const char *path, const char *unused, size_t list_size)
|
|
|
|
{
|
2014-10-10 20:08:11 +00:00
|
|
|
int current = 0, i = list_size;
|
2015-01-10 22:45:14 +00:00
|
|
|
xmb_node_t *node = NULL;
|
2015-02-11 20:00:34 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2015-02-11 20:00:34 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-10 20:08:11 +00:00
|
|
|
|
|
|
|
if (!list || !xmb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list->list[i].userdata = (xmb_node_t*)calloc(1, sizeof(xmb_node_t));
|
|
|
|
|
|
|
|
if (!list->list[i].userdata)
|
2014-10-11 22:33:17 +00:00
|
|
|
{
|
2014-10-10 20:08:11 +00:00
|
|
|
RARCH_ERR("XMB node could not be allocated.\n");
|
2014-10-11 22:33:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-10-10 20:08:11 +00:00
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
node = (xmb_node_t*)list->list[i].userdata;
|
2014-10-10 20:08:11 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return;
|
|
|
|
|
2015-02-13 23:47:42 +00:00
|
|
|
current = menu->navigation.selection_ptr;
|
2014-10-10 20:08:11 +00:00
|
|
|
|
2015-02-12 17:18:38 +00:00
|
|
|
node->alpha = xmb->item.passive.alpha;
|
|
|
|
node->zoom = xmb->item.passive.zoom;
|
2014-10-20 18:00:39 +00:00
|
|
|
node->label_alpha = node->alpha;
|
2015-02-11 04:33:53 +00:00
|
|
|
node->y = xmb_item_y(xmb, i, current);
|
2015-02-02 17:44:56 +00:00
|
|
|
node->x = 0;
|
|
|
|
|
|
|
|
if (i == current)
|
|
|
|
{
|
2015-02-12 17:18:38 +00:00
|
|
|
node->alpha = xmb->item.active.alpha;
|
|
|
|
node->label_alpha = xmb->item.active.alpha;
|
|
|
|
node->zoom = xmb->item.active.zoom;
|
2015-02-02 17:44:56 +00:00
|
|
|
}
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_delete(file_list_t *list,
|
|
|
|
size_t idx, size_t list_size)
|
2014-10-09 20:25:13 +00:00
|
|
|
{
|
2014-10-10 20:08:11 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
2014-10-20 17:18:18 +00:00
|
|
|
if (list->list[idx].userdata)
|
|
|
|
free(list->list[idx].userdata);
|
|
|
|
list->list[idx].userdata = NULL;
|
2014-10-09 20:25:13 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_list_cache(bool horizontal, unsigned action)
|
2014-11-27 15:28:45 +00:00
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
size_t stack_size;
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-11-27 16:03:27 +00:00
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
2015-02-11 20:00:34 +00:00
|
|
|
file_list_copy(menu->menu_list->selection_buf, xmb->selection_buf_old);
|
|
|
|
file_list_copy(menu->menu_list->menu_stack, xmb->menu_stack_old);
|
2015-02-13 23:47:42 +00:00
|
|
|
xmb->selection_ptr_old = menu->navigation.selection_ptr;
|
2014-11-27 15:28:45 +00:00
|
|
|
|
|
|
|
if(!horizontal)
|
|
|
|
return;
|
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
xmb->categories.selection_ptr_old = menu->categories.selection_ptr;
|
2015-02-02 19:40:29 +00:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_LEFT:
|
2015-02-11 20:43:16 +00:00
|
|
|
menu->categories.selection_ptr--;
|
2015-02-02 19:40:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-02-11 20:43:16 +00:00
|
|
|
menu->categories.selection_ptr++;
|
2015-02-02 19:40:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-11-27 15:28:45 +00:00
|
|
|
|
2015-02-11 20:00:34 +00:00
|
|
|
stack_size = menu->menu_list->menu_stack->size;
|
2015-01-10 22:45:14 +00:00
|
|
|
|
2015-03-12 13:53:14 +00:00
|
|
|
if (menu->menu_list->menu_stack->list[stack_size - 1].label)
|
|
|
|
free(menu->menu_list->menu_stack->list[stack_size - 1].label);
|
|
|
|
menu->menu_list->menu_stack->list[stack_size - 1].label = NULL;
|
2015-02-02 17:44:56 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
if (menu->categories.selection_ptr == 0)
|
2015-03-12 13:53:14 +00:00
|
|
|
{
|
|
|
|
menu->menu_list->menu_stack->list[stack_size - 1].label = strdup("Main Menu");
|
|
|
|
menu->menu_list->menu_stack->list[stack_size - 1].type =
|
|
|
|
MENU_SETTINGS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu->menu_list->menu_stack->list[stack_size - 1].label = strdup("Horizontal Menu");
|
|
|
|
menu->menu_list->menu_stack->list[stack_size - 1].type =
|
2015-02-02 19:40:29 +00:00
|
|
|
MENU_SETTING_HORIZONTAL_MENU;
|
2015-03-12 13:53:14 +00:00
|
|
|
}
|
2014-11-27 15:28:45 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_context_destroy(void)
|
2014-10-09 20:59:05 +00:00
|
|
|
{
|
2014-10-21 03:51:30 +00:00
|
|
|
unsigned i;
|
2014-10-10 13:52:12 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
2014-10-10 13:52:12 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-10-09 20:59:05 +00:00
|
|
|
|
2014-10-10 13:52:12 +00:00
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2014-10-09 20:59:05 +00:00
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < XMB_TEXTURE_LAST; i++)
|
2015-02-12 18:27:13 +00:00
|
|
|
glDeleteTextures(1, &xmb->textures.list[i].id);
|
2014-11-14 20:56:21 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (i = 1; i < menu->categories.size; i++)
|
2014-11-14 20:56:21 +00:00
|
|
|
{
|
2015-02-12 14:14:05 +00:00
|
|
|
xmb_node_t *node = xmb_get_userdata_from_core(xmb, i - 1);
|
2014-11-14 20:56:21 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
glDeleteTextures(1, &node->icon);
|
2014-11-21 09:40:47 +00:00
|
|
|
glDeleteTextures(1, &node->content_icon);
|
2014-11-14 20:56:21 +00:00
|
|
|
}
|
2014-10-09 20:59:05 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void xmb_toggle(bool menu_on)
|
2015-01-26 22:45:16 +00:00
|
|
|
{
|
2015-01-28 18:49:10 +00:00
|
|
|
int i;
|
2015-02-13 18:00:34 +00:00
|
|
|
xmb_handle_t *xmb = NULL;
|
|
|
|
menu_handle_t *menu = menu_driver_resolve();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmb = (xmb_handle_t*)menu->userdata;
|
2015-01-26 22:45:16 +00:00
|
|
|
|
|
|
|
if (!xmb)
|
|
|
|
return;
|
|
|
|
|
2015-02-11 20:15:39 +00:00
|
|
|
xmb->depth = file_list_get_size(menu->menu_list->menu_stack);
|
2015-01-30 03:45:15 +00:00
|
|
|
|
2015-02-02 17:44:56 +00:00
|
|
|
if (!menu_on)
|
2015-01-28 18:09:21 +00:00
|
|
|
{
|
2015-01-26 22:45:16 +00:00
|
|
|
xmb->alpha = 0;
|
2015-02-02 17:44:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-11 20:15:39 +00:00
|
|
|
menu_animation_push(menu->animation, XMB_DELAY, 1.0f,
|
2015-02-11 00:15:16 +00:00
|
|
|
&xmb->alpha, EASING_IN_OUT_QUAD, NULL);
|
2015-02-02 17:44:56 +00:00
|
|
|
|
2015-02-10 01:50:22 +00:00
|
|
|
xmb->prevent_populate = !menu->need_refresh;
|
2015-02-02 17:44:56 +00:00
|
|
|
|
2015-02-11 20:43:16 +00:00
|
|
|
for (i = 0; i < menu->categories.size; i++)
|
2015-02-02 17:44:56 +00:00
|
|
|
{
|
2015-02-12 14:14:05 +00:00
|
|
|
xmb_node_t *node = i ? xmb_get_userdata_from_core(xmb, i - 1) : &xmb->settings_node;
|
2015-02-02 17:44:56 +00:00
|
|
|
|
|
|
|
if (!node)
|
|
|
|
continue;
|
|
|
|
|
2015-02-02 19:40:29 +00:00
|
|
|
node->alpha = 0;
|
2015-02-12 18:23:11 +00:00
|
|
|
node->zoom = xmb->categories.passive.zoom;
|
2015-02-02 19:40:29 +00:00
|
|
|
|
2015-02-12 18:23:11 +00:00
|
|
|
if (i == xmb->categories.active.idx)
|
2015-02-02 19:40:29 +00:00
|
|
|
{
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.active.alpha;
|
|
|
|
node->zoom = xmb->categories.active.zoom;
|
2015-02-02 19:40:29 +00:00
|
|
|
}
|
|
|
|
else if (xmb->depth <= 1)
|
2015-02-12 18:23:11 +00:00
|
|
|
node->alpha = xmb->categories.passive.alpha;
|
2015-02-02 17:44:56 +00:00
|
|
|
}
|
2015-01-26 22:45:16 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:21:22 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_xmb = {
|
|
|
|
NULL,
|
2015-03-08 12:17:07 +00:00
|
|
|
xmb_render_messagebox_internal,
|
2015-03-08 18:15:24 +00:00
|
|
|
xmb_render,
|
2014-10-08 23:21:22 +00:00
|
|
|
xmb_frame,
|
|
|
|
xmb_init,
|
|
|
|
xmb_free,
|
|
|
|
xmb_context_reset,
|
2014-10-09 20:59:05 +00:00
|
|
|
xmb_context_destroy,
|
2014-10-09 17:06:07 +00:00
|
|
|
xmb_populate_entries,
|
2015-01-26 22:45:16 +00:00
|
|
|
xmb_toggle,
|
2014-10-09 20:25:13 +00:00
|
|
|
xmb_navigation_clear,
|
|
|
|
xmb_navigation_decrement,
|
|
|
|
xmb_navigation_increment,
|
|
|
|
xmb_navigation_set,
|
|
|
|
xmb_navigation_set_last,
|
|
|
|
xmb_navigation_descend_alphabet,
|
|
|
|
xmb_navigation_ascend_alphabet,
|
|
|
|
xmb_list_insert,
|
|
|
|
xmb_list_delete,
|
2015-02-11 20:00:34 +00:00
|
|
|
NULL,
|
2014-11-27 15:28:45 +00:00
|
|
|
xmb_list_cache,
|
2015-02-11 20:00:34 +00:00
|
|
|
NULL,
|
2015-01-26 09:54:13 +00:00
|
|
|
xmb_entry_iterate,
|
2015-02-12 23:20:39 +00:00
|
|
|
xmb_load_wallpaper,
|
2014-10-08 23:21:22 +00:00
|
|
|
"xmb",
|
|
|
|
};
|