2014-02-26 21:10:17 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2014 - Michael Lelli
|
2014-05-09 17:55:39 +02:00
|
|
|
* Copyright (C) 2014 - Jean-André Santoni
|
2014-02-26 21:10:17 +01: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>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2014-09-16 00:52:07 +02:00
|
|
|
#include "../menu_driver.h"
|
2014-02-26 21:10:17 +01:00
|
|
|
#include "../menu_common.h"
|
2014-09-16 00:52:07 +02:00
|
|
|
#include "menu_display.h"
|
|
|
|
#include "../backend/menu_common_backend.h"
|
2014-02-26 21:10:17 +01:00
|
|
|
#include "../../../general.h"
|
|
|
|
#include "../../../gfx/gfx_common.h"
|
|
|
|
#include "../../../gfx/gl_common.h"
|
|
|
|
#include "../../../gfx/shader_common.h"
|
|
|
|
#include "../../../config.def.h"
|
|
|
|
#include "../../../file.h"
|
|
|
|
#include "../../../dynamic.h"
|
|
|
|
#include "../../../compat/posix_string.h"
|
|
|
|
#include "../../../gfx/shader_parse.h"
|
|
|
|
#include "../../../performance.h"
|
|
|
|
#include "../../../input/input_common.h"
|
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
#include "../../../settings_data.h"
|
2014-02-26 21:10:17 +01:00
|
|
|
#include "../../../screenshot.h"
|
|
|
|
#include "../../../gfx/fonts/bitmap.h"
|
|
|
|
|
2014-05-08 01:12:51 +07:00
|
|
|
#include "lakka.h"
|
|
|
|
|
2014-05-10 06:21:03 +02:00
|
|
|
// Category variables
|
2014-05-27 02:02:39 +02:00
|
|
|
menu_category_t *categories;
|
2014-05-08 01:12:51 +07:00
|
|
|
int depth = 0;
|
|
|
|
int num_categories = 0;
|
|
|
|
int menu_active_category = 0;
|
|
|
|
float all_categories_x = 0;
|
2014-06-03 11:54:48 +02:00
|
|
|
float global_alpha = 0;
|
2014-08-08 11:52:14 +02:00
|
|
|
float arrow_alpha = 0;
|
2014-08-08 23:29:36 +02:00
|
|
|
float hspacing;
|
|
|
|
float vspacing;
|
|
|
|
float c_active_zoom;
|
|
|
|
float c_passive_zoom;
|
|
|
|
float i_active_zoom;
|
|
|
|
float i_passive_zoom;
|
|
|
|
float lakka_font_size;
|
|
|
|
float margin_left;
|
|
|
|
float margin_top;
|
|
|
|
float title_margin_left;
|
|
|
|
float title_margin_top;
|
|
|
|
float label_margin_left;
|
|
|
|
float label_margin_top;
|
|
|
|
int icon_size;
|
2014-08-08 21:03:35 -04:00
|
|
|
char icon_dir[4];
|
2014-08-08 23:29:36 +02:00
|
|
|
float above_subitem_offset;
|
|
|
|
float above_item_offset;
|
|
|
|
float active_item_factor;
|
|
|
|
float under_item_offset;
|
2014-05-08 01:12:51 +07:00
|
|
|
|
2014-05-10 06:21:03 +02:00
|
|
|
// Font variables
|
2014-09-12 15:34:53 -03:00
|
|
|
static void *font;
|
|
|
|
static const gl_font_renderer_t *font_driver;
|
|
|
|
static char font_path[PATH_MAX];
|
2014-06-06 06:22:16 +02:00
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
static const GLfloat vertex[] = {
|
2014-07-23 14:44:44 +02:00
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
0, 1,
|
2014-08-08 23:29:36 +02:00
|
|
|
1, 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GLfloat tex_coord[] = {
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
2014-07-23 14:44:44 +02:00
|
|
|
};
|
|
|
|
|
2014-06-06 06:22:16 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEXTURE_MAIN = 0,
|
|
|
|
TEXTURE_FONT,
|
2014-07-13 23:08:27 +02:00
|
|
|
TEXTURE_BG,
|
2014-06-06 06:22:16 +02:00
|
|
|
TEXTURE_SETTINGS,
|
|
|
|
TEXTURE_SETTING,
|
|
|
|
TEXTURE_SUBSETTING,
|
|
|
|
TEXTURE_ARROW,
|
|
|
|
TEXTURE_RUN,
|
|
|
|
TEXTURE_RESUME,
|
|
|
|
TEXTURE_SAVESTATE,
|
|
|
|
TEXTURE_LOADSTATE,
|
|
|
|
TEXTURE_SCREENSHOT,
|
|
|
|
TEXTURE_RELOAD,
|
|
|
|
TEXTURE_LAST
|
|
|
|
};
|
|
|
|
|
2014-06-06 07:26:14 +02:00
|
|
|
struct lakka_texture_item
|
|
|
|
{
|
|
|
|
GLuint id;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lakka_texture_item textures[TEXTURE_LAST];
|
2014-05-10 06:21:03 +02:00
|
|
|
|
2014-05-27 01:31:27 +02:00
|
|
|
static tween_t* tweens = NULL;
|
2014-09-12 15:34:53 -03:00
|
|
|
static int numtweens = 0;
|
2014-05-26 18:32:32 +02:00
|
|
|
|
2014-08-01 15:11:23 +02:00
|
|
|
static void lakka_responsive(void)
|
|
|
|
{
|
2014-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
2014-08-01 15:11:23 +02:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
c_active_zoom = 1.0;
|
|
|
|
c_passive_zoom = 0.5;
|
|
|
|
i_active_zoom = 1.0;
|
|
|
|
i_passive_zoom = 0.5;
|
2014-08-07 18:40:43 +02:00
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
above_subitem_offset = 1.5;
|
|
|
|
above_item_offset = -1.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
active_item_factor = 2.75;
|
|
|
|
under_item_offset = 4.0;
|
2014-08-07 18:40:43 +02:00
|
|
|
|
2014-08-25 19:11:10 +02:00
|
|
|
if (gl->win_width >= 3840)
|
2014-08-01 15:11:23 +02:00
|
|
|
{
|
2014-08-08 23:29:36 +02:00
|
|
|
icon_size = 256;
|
|
|
|
hspacing = 400;
|
|
|
|
vspacing = 128;
|
|
|
|
lakka_font_size = 42.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
margin_left = 672.0;
|
|
|
|
margin_top = 512;
|
2014-08-08 23:29:36 +02:00
|
|
|
title_margin_left = 20.0;
|
|
|
|
title_margin_top = 50.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
label_margin_left = 192;
|
2014-08-08 23:29:36 +02:00
|
|
|
label_margin_top = 15;
|
|
|
|
strcpy(icon_dir, "256");
|
2014-08-01 15:11:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 19:11:10 +02:00
|
|
|
if (gl->win_width >= 2560)
|
2014-08-01 15:11:23 +02:00
|
|
|
{
|
2014-08-08 23:29:36 +02:00
|
|
|
icon_size = 192;
|
|
|
|
hspacing = 300;
|
|
|
|
vspacing = 96;
|
|
|
|
lakka_font_size = 32.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
margin_left = 448.0;
|
|
|
|
margin_top = 384;
|
2014-08-08 23:29:36 +02:00
|
|
|
title_margin_left = 15.0;
|
|
|
|
title_margin_top = 40.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
label_margin_left = 144;
|
2014-08-08 23:29:36 +02:00
|
|
|
label_margin_top = 11.0;
|
|
|
|
strcpy(icon_dir, "192");
|
2014-08-01 15:11:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 19:11:10 +02:00
|
|
|
if (gl->win_width >= 1920)
|
|
|
|
{
|
|
|
|
icon_size = 128;
|
|
|
|
hspacing = 200.0;
|
|
|
|
vspacing = 64.0;
|
|
|
|
lakka_font_size = 24;
|
|
|
|
margin_left = 336.0;
|
|
|
|
margin_top = 256;
|
|
|
|
title_margin_left = 15.0;
|
|
|
|
title_margin_top = 35.0;
|
|
|
|
label_margin_left = 85;
|
|
|
|
label_margin_top = 8.0;
|
|
|
|
strcpy(icon_dir, "128");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-26 00:21:55 +02:00
|
|
|
if (gl->win_width <= 640)
|
2014-08-01 15:11:23 +02:00
|
|
|
{
|
2014-08-08 23:29:36 +02:00
|
|
|
icon_size = 64;
|
|
|
|
hspacing = 100.0;
|
|
|
|
vspacing = 32.0;
|
|
|
|
lakka_font_size = 16;
|
|
|
|
margin_left = 60.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
margin_top = 128.0;
|
2014-08-08 23:29:36 +02:00
|
|
|
title_margin_left = 10.0;
|
|
|
|
title_margin_top = 24.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
label_margin_left = 48;
|
2014-08-08 23:29:36 +02:00
|
|
|
label_margin_top = 6.0;
|
|
|
|
strcpy(icon_dir, "64");
|
2014-08-01 15:11:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 19:11:10 +02:00
|
|
|
icon_size = 96;
|
|
|
|
hspacing = 150.0;
|
|
|
|
vspacing = 48.0;
|
|
|
|
lakka_font_size = 18;
|
|
|
|
margin_left = 224;
|
|
|
|
margin_top = 192;
|
2014-08-08 23:29:36 +02:00
|
|
|
title_margin_left = 15.0;
|
2014-08-25 19:11:10 +02:00
|
|
|
title_margin_top = 30.0;
|
|
|
|
label_margin_left = 64;
|
|
|
|
label_margin_top = 6.0;
|
|
|
|
strcpy(icon_dir, "96");
|
2014-08-01 15:11:23 +02:00
|
|
|
}
|
|
|
|
|
2014-06-01 01:08:39 +02:00
|
|
|
static char *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)
|
|
|
|
return strdup (string);
|
|
|
|
|
|
|
|
newstr = strdup (string);
|
|
|
|
head = newstr;
|
|
|
|
while ( (tok = strstr ( head, substr )))
|
|
|
|
{
|
|
|
|
oldstr = newstr;
|
|
|
|
newstr = (char*)malloc(strlen(oldstr) - strlen(substr) + strlen(replacement) + 1);
|
|
|
|
|
|
|
|
if (!newstr)
|
|
|
|
{
|
|
|
|
/*failed to alloc mem, free old string and return NULL */
|
|
|
|
free (oldstr);
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-09-02 16:03:17 +02: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 );
|
2014-06-01 01:08:39 +02:00
|
|
|
/* move back head right after the last replacement */
|
|
|
|
head = newstr + (tok - oldstr) + strlen( replacement );
|
|
|
|
free (oldstr);
|
|
|
|
}
|
|
|
|
return newstr;
|
|
|
|
}
|
|
|
|
|
2014-06-03 11:54:48 +02:00
|
|
|
float inOutQuad(float t, float b, float c, float d)
|
2014-05-26 18:32:32 +02:00
|
|
|
{
|
|
|
|
t = t / d * 2;
|
|
|
|
if (t < 1)
|
|
|
|
return c / 2 * pow(t, 2) + b;
|
|
|
|
return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
void add_tween(float duration, float target_value, float* subject,
|
|
|
|
easingFunc easing, tweenCallback callback)
|
2014-05-26 18:32:32 +02:00
|
|
|
{
|
2014-05-27 06:32:33 +02:00
|
|
|
tween_t *tween;
|
2014-09-03 20:36:50 -04:00
|
|
|
tween_t *tweens_tmp;
|
2014-05-27 06:32:33 +02:00
|
|
|
|
2014-05-26 18:32:32 +02:00
|
|
|
numtweens++;
|
2014-05-27 01:31:27 +02:00
|
|
|
|
2014-09-03 20:36:50 -04:00
|
|
|
tweens_tmp = (tween_t*)realloc(tweens, numtweens * sizeof(tween_t));
|
|
|
|
if (tweens_tmp != NULL)
|
|
|
|
{
|
|
|
|
tweens = tweens_tmp;
|
|
|
|
}
|
|
|
|
else // realloc failed
|
|
|
|
{
|
|
|
|
if (tweens != NULL)
|
|
|
|
{
|
|
|
|
free(tweens);
|
|
|
|
tweens = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-27 06:32:33 +02:00
|
|
|
tween = (tween_t*)&tweens[numtweens-1];
|
2014-05-27 01:31:27 +02:00
|
|
|
|
|
|
|
if (!tween)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tween->alive = 1;
|
|
|
|
tween->duration = duration;
|
|
|
|
tween->running_since = 0;
|
|
|
|
tween->initial_value = *subject;
|
|
|
|
tween->target_value = target_value;
|
|
|
|
tween->subject = subject;
|
|
|
|
tween->easing = easing;
|
2014-06-03 11:54:48 +02:00
|
|
|
tween->callback = callback;
|
2014-05-26 18:32:32 +02:00
|
|
|
}
|
|
|
|
|
2014-05-27 01:31:27 +02:00
|
|
|
static void update_tween(void *data, float dt)
|
2014-05-26 18:32:32 +02:00
|
|
|
{
|
2014-05-27 01:31:27 +02:00
|
|
|
tween_t *tween = (tween_t*)data;
|
|
|
|
|
2014-05-27 03:06:58 +02:00
|
|
|
if (!tween)
|
|
|
|
return;
|
|
|
|
|
2014-05-27 03:48:08 +02:00
|
|
|
#if 0
|
|
|
|
RARCH_LOG("delta: %f\n", dt);
|
|
|
|
RARCH_LOG("tween running since: %f\n", tween->running_since);
|
|
|
|
RARCH_LOG("tween duration: %f\n", tween->duration);
|
|
|
|
#endif
|
|
|
|
|
2014-05-27 01:31:27 +02:00
|
|
|
if (tween->running_since < tween->duration)
|
2014-05-26 18:32:32 +02:00
|
|
|
{
|
2014-05-27 01:31:27 +02:00
|
|
|
tween->running_since += dt;
|
2014-06-05 20:09:40 +02:00
|
|
|
|
|
|
|
if (tween->easing)
|
|
|
|
*tween->subject = tween->easing(
|
|
|
|
tween->running_since,
|
|
|
|
tween->initial_value,
|
|
|
|
tween->target_value - tween->initial_value,
|
|
|
|
tween->duration);
|
|
|
|
|
|
|
|
if (tween->running_since >= tween->duration)
|
|
|
|
{
|
2014-05-27 01:31:27 +02:00
|
|
|
*tween->subject = tween->target_value;
|
2014-06-05 20:09:40 +02:00
|
|
|
|
2014-06-03 11:54:48 +02:00
|
|
|
if (tween->callback)
|
|
|
|
tween->callback();
|
|
|
|
}
|
2014-05-26 18:32:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_tweens(float dt)
|
|
|
|
{
|
|
|
|
int i, active_tweens;
|
|
|
|
|
|
|
|
active_tweens = 0;
|
2014-06-05 20:09:40 +02:00
|
|
|
|
2014-05-26 18:32:32 +02:00
|
|
|
for(i = 0; i < numtweens; i++)
|
|
|
|
{
|
2014-05-27 01:31:27 +02:00
|
|
|
update_tween(&tweens[i], dt);
|
2014-09-02 16:03:17 +02:00
|
|
|
active_tweens += tweens[i].running_since <
|
|
|
|
tweens[i].duration ? 1 : 0;
|
2014-05-26 18:32:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numtweens && !active_tweens)
|
|
|
|
numtweens = 0;
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
static void lakka_draw_text(const char *str, float x,
|
|
|
|
float y, float scale, float alpha)
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-08-08 11:52:14 +02:00
|
|
|
if (alpha > global_alpha)
|
|
|
|
alpha = global_alpha;
|
|
|
|
if (alpha == 0)
|
|
|
|
return;
|
|
|
|
|
2014-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
2014-06-09 12:44:48 +02:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
if (x < -icon_size || x > gl->win_width + icon_size
|
|
|
|
|| y < -icon_size || y > gl->win_height + icon_size)
|
2014-08-08 11:52:14 +02:00
|
|
|
return;
|
|
|
|
|
2014-06-09 12:44:48 +02:00
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
2014-05-10 06:21:03 +02:00
|
|
|
|
2014-06-09 12:24:23 +02:00
|
|
|
struct font_params params = {0};
|
2014-06-14 14:24:54 +02:00
|
|
|
params.x = x / gl->win_width;
|
|
|
|
params.y = 1.0f - y / gl->win_height;
|
2014-06-09 12:24:23 +02:00
|
|
|
|
|
|
|
params.scale = scale;
|
2014-06-09 12:44:48 +02:00
|
|
|
params.color = FONT_COLOR_RGBA(255, 255, 255, (uint8_t)(255 * alpha));
|
2014-06-14 14:24:54 +02:00
|
|
|
params.full_screen = true;
|
2014-05-08 01:12:51 +07:00
|
|
|
|
2014-06-09 12:24:23 +02:00
|
|
|
if (font_driver)
|
|
|
|
font_driver->render_msg(font, str, ¶ms);
|
2014-05-08 01:12:51 +07:00
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-06-05 20:09:40 +02:00
|
|
|
void lakka_draw_background(void)
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-07-13 23:08:27 +02:00
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, global_alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, global_alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, global_alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, global_alpha,
|
2014-06-03 11:54:48 +02:00
|
|
|
};
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-16 00:18:14 +02:00
|
|
|
float alpha = 0.9f;
|
|
|
|
if (alpha > global_alpha)
|
|
|
|
alpha = global_alpha;
|
|
|
|
|
|
|
|
GLfloat black_color[] = {
|
|
|
|
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-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
2014-06-06 03:59:35 +02:00
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2014-07-23 14:44:44 +02:00
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
|
|
|
|
2014-02-26 21:10:17 +01:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
gl->coords.vertex = vertex;
|
|
|
|
gl->coords.tex_coord = tex_coord;
|
2014-09-16 00:18:14 +02:00
|
|
|
gl->coords.color = textures[TEXTURE_BG].id ? color : black_color;
|
2014-07-13 23:08:27 +02:00
|
|
|
glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_BG].id);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-03 20:23:25 -04:00
|
|
|
if (gl->shader && gl->shader->use)
|
2014-05-08 01:12:51 +07:00
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
2014-06-09 12:44:48 +02:00
|
|
|
|
|
|
|
gl->coords.vertices = 4;
|
2014-02-26 21:10:17 +01:00
|
|
|
gl_shader_set_coords(gl, &gl->coords, &gl->mvp_no_rot);
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
gl->coords.color = gl->white_color_ptr;
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
void lakka_draw_icon(GLuint texture, float x, float y,
|
|
|
|
float alpha, float rotation, float scale)
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-07-24 14:00:56 +02:00
|
|
|
if (alpha > global_alpha)
|
|
|
|
alpha = global_alpha;
|
|
|
|
|
2014-08-08 11:52:14 +02:00
|
|
|
if (alpha == 0)
|
|
|
|
return;
|
|
|
|
|
2014-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
2014-08-08 11:52:14 +02:00
|
|
|
|
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
if (x < -icon_size || x > gl->win_width + icon_size
|
|
|
|
|| y < -icon_size || y > gl->win_height + icon_size)
|
2014-08-08 11:52:14 +02:00
|
|
|
return;
|
|
|
|
|
2014-02-26 21:10:17 +01:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
glViewport(x, gl->win_height - y, icon_size, icon_size);
|
2014-05-09 16:46:35 +02:00
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
gl->coords.vertex = vertex;
|
|
|
|
gl->coords.tex_coord = tex_coord;
|
2014-02-26 21:10:17 +01:00
|
|
|
gl->coords.color = color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
|
2014-09-03 20:23:25 -04:00
|
|
|
if (gl->shader && gl->shader->use)
|
2014-05-08 01:12:51 +07:00
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
|
|
|
math_matrix mymat;
|
|
|
|
|
|
|
|
math_matrix mrot;
|
|
|
|
matrix_rotate_z(&mrot, rotation);
|
|
|
|
matrix_multiply(&mymat, &mrot, &gl->mvp_no_rot);
|
|
|
|
|
|
|
|
math_matrix mscal;
|
|
|
|
matrix_scale(&mscal, scale, scale, 1);
|
|
|
|
matrix_multiply(&mymat, &mscal, &mymat);
|
|
|
|
|
2014-06-09 12:44:48 +02:00
|
|
|
gl->coords.vertices = 4;
|
2014-02-26 21:10:17 +01:00
|
|
|
gl_shader_set_coords(gl, &gl->coords, &mymat);
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
gl->coords.vertex = gl->vertex_ptr;
|
|
|
|
gl->coords.tex_coord = gl->tex_coords;
|
|
|
|
gl->coords.color = gl->white_color_ptr;
|
|
|
|
}
|
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
static void lakka_draw_subitems(int i, int j)
|
2014-05-08 01:12:51 +07:00
|
|
|
{
|
2014-06-02 23:57:19 +02:00
|
|
|
int k;
|
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
|
|
|
menu_item_t *item = (menu_item_t*)&category->items[j];
|
2014-09-02 16:03:17 +02:00
|
|
|
menu_category_t *active_category = (menu_category_t*)
|
|
|
|
&categories[menu_active_category];
|
|
|
|
menu_item_t *active_item = (menu_item_t*)
|
|
|
|
&active_category->items[active_category->active_item];
|
2014-05-09 17:29:41 +02:00
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
for(k = 0; k < item->num_subitems; k++)
|
|
|
|
{
|
|
|
|
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-06-05 20:09:40 +02:00
|
|
|
if (!subitem)
|
|
|
|
continue;
|
|
|
|
|
2014-09-10 10:58:02 +02:00
|
|
|
if (i && k == 0 && g_extern.main_is_init
|
2014-06-02 23:57:19 +02:00
|
|
|
&& !g_extern.libretro_dummy
|
2014-09-06 21:56:47 -03:00
|
|
|
&& strcmp(g_extern.fullpath, active_item->rom) == 0)
|
2014-06-02 23:57:19 +02:00
|
|
|
{
|
2014-06-06 07:26:14 +02:00
|
|
|
lakka_draw_icon(textures[TEXTURE_RESUME].id,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing*(i+2.25) +
|
|
|
|
all_categories_x - icon_size/2.0,
|
|
|
|
margin_top + subitem->y + icon_size/2.0,
|
|
|
|
subitem->alpha,
|
2014-06-02 23:57:19 +02:00
|
|
|
0,
|
|
|
|
subitem->zoom);
|
2014-09-02 16:03:17 +02:00
|
|
|
lakka_draw_text("Resume",
|
|
|
|
margin_left + hspacing*(i+2.25) +
|
|
|
|
all_categories_x + label_margin_left,
|
|
|
|
margin_top + subitem->y + label_margin_top,
|
2014-06-02 23:57:19 +02:00
|
|
|
1,
|
|
|
|
subitem->alpha);
|
|
|
|
}
|
2014-09-11 00:09:53 +02:00
|
|
|
else if (k == 0 ||
|
2014-06-02 23:57:19 +02:00
|
|
|
menu_active_category == 0 ||
|
|
|
|
(g_extern.main_is_init &&
|
|
|
|
!g_extern.libretro_dummy &&
|
2014-09-06 21:56:47 -03:00
|
|
|
strcmp(g_extern.fullpath, active_item->rom) == 0))
|
2014-06-06 03:59:35 +02:00
|
|
|
{
|
2014-06-02 23:57:19 +02:00
|
|
|
lakka_draw_icon(subitem->icon,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing*(i+2.25) +
|
|
|
|
all_categories_x - icon_size/2.0,
|
2014-08-08 23:29:36 +02:00
|
|
|
margin_top + subitem->y + icon_size/2.0,
|
2014-06-02 23:57:19 +02:00
|
|
|
subitem->alpha,
|
|
|
|
0,
|
|
|
|
subitem->zoom);
|
2014-06-09 12:24:23 +02:00
|
|
|
lakka_draw_text(subitem->name,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing * (i+2.25) +
|
|
|
|
all_categories_x + label_margin_left,
|
2014-08-08 23:29:36 +02:00
|
|
|
margin_top + subitem->y + label_margin_top,
|
2014-06-02 23:57:19 +02:00
|
|
|
1,
|
|
|
|
subitem->alpha);
|
2014-09-11 00:09:53 +02:00
|
|
|
|
|
|
|
if (i && (k == 1 || k == 2))
|
|
|
|
{
|
|
|
|
char slot[256];
|
|
|
|
if (g_settings.state_slot == -1)
|
|
|
|
snprintf(slot, sizeof(slot), "%d (auto)", g_settings.state_slot);
|
|
|
|
else
|
|
|
|
snprintf(slot, sizeof(slot), "%d", g_settings.state_slot);
|
|
|
|
lakka_draw_text(slot,
|
|
|
|
margin_left + hspacing * (i+2.25) +
|
|
|
|
all_categories_x + label_margin_left + 400,
|
|
|
|
margin_top + subitem->y + label_margin_top,
|
|
|
|
1,
|
|
|
|
subitem->alpha);
|
|
|
|
}
|
2014-06-02 23:57:19 +02:00
|
|
|
}
|
2014-06-06 05:35:05 +02:00
|
|
|
|
2014-09-11 22:07:41 +02:00
|
|
|
if (subitem->setting)
|
2014-09-09 22:59:27 +02:00
|
|
|
{
|
2014-09-11 22:07:41 +02:00
|
|
|
char val[256];
|
|
|
|
setting_data_get_string_representation(subitem->setting, val,
|
|
|
|
sizeof(val));
|
|
|
|
lakka_draw_text(val,
|
2014-09-09 22:59:27 +02:00
|
|
|
margin_left + hspacing * (i+2.25) +
|
|
|
|
all_categories_x + label_margin_left + 400,
|
|
|
|
margin_top + subitem->y + label_margin_top,
|
|
|
|
1,
|
|
|
|
subitem->alpha);
|
|
|
|
}
|
2014-06-02 23:57:19 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
static void lakka_draw_items(int i)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
2014-09-02 16:03:17 +02:00
|
|
|
menu_category_t *active_category = (menu_category_t*)
|
|
|
|
&categories[menu_active_category];
|
|
|
|
menu_item_t *active_item = (menu_item_t*)
|
|
|
|
&active_category->items[active_category->active_item];
|
2014-09-10 04:53:07 +02:00
|
|
|
|
|
|
|
(void)active_item;
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
for(j = 0; j < category->num_items; j++)
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-06-02 23:57:19 +02:00
|
|
|
menu_item_t *item = (menu_item_t*)&category->items[j];
|
2014-05-27 02:02:39 +02:00
|
|
|
|
2014-06-05 20:09:40 +02:00
|
|
|
if (!item)
|
|
|
|
continue;
|
|
|
|
|
2014-08-08 11:52:14 +02:00
|
|
|
if (i >= menu_active_category - 1 &&
|
2014-09-06 22:59:27 -03:00
|
|
|
i <= menu_active_category + 1) /* performance improvement */
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-06-09 12:24:23 +02:00
|
|
|
lakka_draw_icon(category->item_icon,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing*(i+1) +
|
|
|
|
all_categories_x - icon_size/2.0,
|
2014-08-08 23:29:36 +02:00
|
|
|
margin_top + item->y + icon_size/2.0,
|
2014-05-27 03:06:58 +02:00
|
|
|
item->alpha,
|
2014-05-08 01:12:51 +07:00
|
|
|
0,
|
2014-05-27 03:06:58 +02:00
|
|
|
item->zoom);
|
2014-05-08 01:12:51 +07:00
|
|
|
|
2014-05-09 16:46:35 +02:00
|
|
|
if (depth == 0)
|
2014-06-09 12:24:23 +02:00
|
|
|
lakka_draw_text(item->name,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing * (i+1) +
|
|
|
|
all_categories_x + label_margin_left,
|
2014-08-08 23:29:36 +02:00
|
|
|
margin_top + item->y + label_margin_top,
|
2014-06-02 23:57:19 +02:00
|
|
|
1,
|
|
|
|
item->alpha);
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
2014-05-08 01:12:51 +07:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
/* performance improvement */
|
|
|
|
if (i == menu_active_category
|
|
|
|
&& j == category->active_item && depth == 1)
|
2014-06-02 23:57:19 +02:00
|
|
|
lakka_draw_subitems(i, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 20:09:40 +02:00
|
|
|
static void lakka_draw_categories(void)
|
2014-06-02 23:57:19 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < num_categories; i++)
|
|
|
|
{
|
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
|
|
|
|
2014-06-05 20:09:40 +02:00
|
|
|
if (!category)
|
|
|
|
continue;
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
/* draw items */
|
2014-06-02 23:57:19 +02:00
|
|
|
lakka_draw_items(i);
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
/* draw category icon */
|
2014-06-02 23:57:19 +02:00
|
|
|
lakka_draw_icon(category->icon,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + (hspacing*(i+1)) +
|
|
|
|
all_categories_x - icon_size/2.0,
|
2014-08-08 23:29:36 +02:00
|
|
|
margin_top + icon_size/2.0,
|
2014-05-27 02:02:39 +02:00
|
|
|
category->alpha,
|
2014-05-09 16:46:35 +02:00
|
|
|
0,
|
2014-05-27 02:02:39 +02:00
|
|
|
category->zoom);
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
2014-06-02 23:57:19 +02:00
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
static void lakka_frame(void)
|
|
|
|
{
|
2014-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
2014-09-02 16:03:17 +02:00
|
|
|
menu_category_t *active_category = (menu_category_t*)
|
|
|
|
&categories[menu_active_category];
|
2014-06-03 16:32:00 +02:00
|
|
|
menu_item_t *active_item;
|
2014-06-02 23:57:19 +02:00
|
|
|
|
2014-06-03 16:32:00 +02:00
|
|
|
if (!driver.menu || !gl || !active_category)
|
2014-06-02 23:57:19 +02:00
|
|
|
return;
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
active_item = (menu_item_t*)
|
|
|
|
&active_category->items[active_category->active_item];
|
2014-06-03 16:32:00 +02:00
|
|
|
|
2014-06-02 23:57:19 +02:00
|
|
|
update_tweens(0.002);
|
|
|
|
|
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
|
|
|
|
|
|
|
lakka_draw_background();
|
|
|
|
|
|
|
|
lakka_draw_categories();
|
|
|
|
|
2014-09-03 20:23:25 -04:00
|
|
|
if (depth == 0)
|
2014-09-02 16:03:17 +02:00
|
|
|
lakka_draw_text(active_category->name,
|
|
|
|
title_margin_left, title_margin_top, 1, 1.0);
|
2014-08-08 11:52:14 +02:00
|
|
|
else if (active_item)
|
2014-09-02 16:03:17 +02:00
|
|
|
lakka_draw_text(active_item->name,
|
|
|
|
title_margin_left, title_margin_top, 1, 1.0);
|
2014-06-06 03:59:35 +02:00
|
|
|
|
2014-08-08 11:52:14 +02:00
|
|
|
lakka_draw_icon(textures[TEXTURE_ARROW].id,
|
2014-09-02 16:03:17 +02:00
|
|
|
margin_left + hspacing*(menu_active_category+1) +
|
|
|
|
all_categories_x + icon_size/2.0,
|
|
|
|
margin_top + vspacing*active_item_factor +
|
|
|
|
icon_size/2.0, arrow_alpha, 0, i_active_zoom);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-05-08 01:12:51 +07:00
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-14 15:17:03 +02:00
|
|
|
static GLuint lakka_png_texture_load(const char * file_name)
|
2014-05-26 18:40:27 +02:00
|
|
|
{
|
2014-09-16 00:18:14 +02:00
|
|
|
if (! path_file_exists(file_name))
|
|
|
|
return 0;
|
|
|
|
|
2014-09-06 14:09:07 -03:00
|
|
|
struct texture_image ti = {0};
|
2014-08-08 23:29:36 +02:00
|
|
|
texture_image_load(&ti, file_name);
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
/* Generate the OpenGL texture object */
|
2014-09-12 17:26:15 -03:00
|
|
|
GLuint texture = 0;
|
2014-08-08 23:29:36 +02:00
|
|
|
glGenTextures(1, &texture);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
2014-09-02 16:03:17 +02:00
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ti.width, ti.height, 0,
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, ti.pixels);
|
2014-08-08 23:29:36 +02:00
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
2014-09-06 14:28:53 -03:00
|
|
|
free(ti.pixels);
|
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
return texture;
|
2014-05-26 18:40:27 +02:00
|
|
|
}
|
|
|
|
|
2014-05-31 23:22:20 +02:00
|
|
|
static void lakka_context_destroy(void *data)
|
2014-05-31 23:19:59 +02:00
|
|
|
{
|
2014-09-06 22:50:04 -03:00
|
|
|
int i, j, k;
|
2014-09-12 17:18:44 -03:00
|
|
|
(void)data;
|
2014-09-10 04:53:07 +02:00
|
|
|
|
2014-06-06 06:22:16 +02:00
|
|
|
for (i = 0; i < TEXTURE_LAST; i++)
|
2014-06-06 07:26:14 +02:00
|
|
|
glDeleteTextures(1, &textures[i].id);
|
2014-05-31 23:19:59 +02:00
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
for (i = 1; i < num_categories; i++)
|
|
|
|
{
|
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
2014-06-05 21:24:58 +02:00
|
|
|
|
|
|
|
if (!category)
|
|
|
|
continue;
|
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
glDeleteTextures(1, &category->icon);
|
2014-06-03 02:20:14 +02:00
|
|
|
glDeleteTextures(1, &category->item_icon);
|
2014-06-01 17:07:03 +02:00
|
|
|
|
2014-06-05 21:24:58 +02:00
|
|
|
for (j = 0; j < category->num_items; j++)
|
2014-06-01 17:07:03 +02:00
|
|
|
{
|
2014-06-05 21:24:58 +02:00
|
|
|
menu_item_t *item;
|
|
|
|
menu_subitem_t *subitem;
|
|
|
|
|
|
|
|
item = (menu_item_t*)&category->items[j];
|
|
|
|
|
2014-09-06 22:50:04 -03:00
|
|
|
if (!item)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (k = 0; k < item->num_subitems; k++ )
|
2014-06-05 21:24:58 +02:00
|
|
|
{
|
2014-09-06 22:50:04 -03:00
|
|
|
subitem = (menu_subitem_t*)&item->subitems[k];
|
2014-06-05 21:24:58 +02:00
|
|
|
|
|
|
|
if (subitem)
|
|
|
|
glDeleteTextures(1, &subitem->icon);
|
|
|
|
}
|
|
|
|
}
|
2014-06-01 17:07:03 +02:00
|
|
|
}
|
|
|
|
|
2014-06-09 12:24:23 +02:00
|
|
|
if (font_driver)
|
|
|
|
{
|
|
|
|
font_driver->free(font);
|
|
|
|
font_driver = NULL;
|
|
|
|
}
|
|
|
|
|
2014-06-03 11:54:48 +02:00
|
|
|
//if (numtweens)
|
|
|
|
// free(tweens);
|
2014-05-31 23:19:59 +02:00
|
|
|
}
|
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
void lakka_init_settings(void)
|
|
|
|
{
|
2014-09-09 00:08:25 +02:00
|
|
|
rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list();
|
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
menu_category_t *category = (menu_category_t*)&categories[0];
|
|
|
|
|
|
|
|
strlcpy(category->name, "Settings", sizeof(category->name));
|
|
|
|
category->alpha = 1.0;
|
2014-08-08 23:29:36 +02:00
|
|
|
category->zoom = c_active_zoom;
|
2014-06-01 17:07:03 +02:00
|
|
|
category->active_item = 0;
|
|
|
|
category->num_items = 0;
|
2014-09-02 16:03:17 +02:00
|
|
|
category->items = (menu_item_t*)
|
|
|
|
calloc(category->num_items, sizeof(menu_item_t));
|
2014-06-01 17:07:03 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
int j, k, jj, kk;
|
2014-09-09 22:29:12 -04:00
|
|
|
jj = 0;
|
2014-09-09 00:08:25 +02:00
|
|
|
for (j = 0; j <= 512; j++)
|
|
|
|
{
|
2014-09-16 01:36:28 +02:00
|
|
|
rarch_setting_t *group = (rarch_setting_t*)&setting_data[j];
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-16 01:36:28 +02:00
|
|
|
if (group && group->type == ST_GROUP)
|
2014-09-09 00:08:25 +02:00
|
|
|
{
|
|
|
|
category->num_items++;
|
|
|
|
category->items = (menu_item_t*)
|
|
|
|
realloc(category->items, category->num_items * sizeof(menu_item_t));
|
|
|
|
|
|
|
|
menu_item_t *item = (menu_item_t*)&category->items[jj];
|
|
|
|
|
2014-09-16 01:36:28 +02:00
|
|
|
strlcpy(item->name, group->name, sizeof(item->name));
|
2014-09-09 00:08:25 +02:00
|
|
|
item->alpha = jj ? 0.5 : 1.0;
|
|
|
|
item->zoom = jj ? i_passive_zoom : i_active_zoom;
|
|
|
|
item->y = jj ?
|
|
|
|
vspacing*(under_item_offset+jj) : vspacing * active_item_factor;
|
|
|
|
item->active_subitem = 0;
|
|
|
|
item->num_subitems = 0;
|
2014-09-10 23:13:19 +02:00
|
|
|
item->subitems = NULL;
|
2014-09-09 00:08:25 +02:00
|
|
|
|
|
|
|
kk = 0;
|
|
|
|
for (k = 0; k <= 512; k++)
|
|
|
|
{
|
2014-09-16 01:36:28 +02:00
|
|
|
rarch_setting_t *setting = (rarch_setting_t*)&setting_data[k];
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-16 01:36:28 +02:00
|
|
|
if (setting
|
|
|
|
&& setting->type != ST_SUB_GROUP
|
|
|
|
&& setting->group == group->name)
|
2014-09-09 00:08:25 +02:00
|
|
|
{
|
|
|
|
item->num_subitems++;
|
2014-09-09 22:59:27 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
item->subitems = (menu_subitem_t*)
|
2014-09-10 14:38:41 +02:00
|
|
|
realloc(item->subitems,
|
|
|
|
item->num_subitems * sizeof(menu_subitem_t));
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[kk];
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-16 01:36:28 +02:00
|
|
|
strlcpy(subitem->name, setting->short_description,
|
2014-09-10 14:38:41 +02:00
|
|
|
sizeof(subitem->name));
|
2014-09-09 00:08:25 +02:00
|
|
|
subitem->alpha = kk ? 1.0 : 0.5;
|
|
|
|
subitem->zoom = kk ? i_active_zoom : i_passive_zoom;
|
|
|
|
subitem->y = kk ? vspacing * (kk + under_item_offset)
|
|
|
|
: vspacing * active_item_factor;
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-16 01:36:28 +02:00
|
|
|
subitem->setting = (rarch_setting_t*)&setting_data[k];
|
2014-09-09 22:59:27 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
kk++;
|
|
|
|
}
|
|
|
|
}
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
jj++;
|
|
|
|
}
|
|
|
|
}
|
2014-06-02 16:34:17 +02:00
|
|
|
|
|
|
|
category->num_items++;
|
2014-09-02 16:03:17 +02:00
|
|
|
category->items = (menu_item_t*)
|
|
|
|
realloc(category->items, category->num_items * sizeof(menu_item_t));
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
menu_item_t *itemq = (menu_item_t*)&category->items[jj];
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
strlcpy(itemq->name, "Quit RetroArch", sizeof(itemq->name));
|
|
|
|
itemq->alpha = jj ? 0.5 : 1.0;
|
|
|
|
itemq->zoom = jj ? i_passive_zoom : i_active_zoom;
|
|
|
|
itemq->y = jj ? vspacing*(under_item_offset+jj) :
|
2014-09-02 16:03:17 +02:00
|
|
|
vspacing * active_item_factor;
|
2014-09-09 00:08:25 +02:00
|
|
|
itemq->active_subitem = 0;
|
|
|
|
itemq->num_subitems = 0;
|
2014-06-02 16:34:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void lakka_settings_context_reset(void)
|
|
|
|
{
|
2014-06-06 05:35:05 +02:00
|
|
|
menu_item_t *item;
|
2014-09-09 00:08:25 +02:00
|
|
|
int j, k;
|
2014-06-02 16:34:17 +02:00
|
|
|
menu_category_t *category = (menu_category_t*)&categories[0];
|
2014-06-05 21:31:29 +02:00
|
|
|
|
|
|
|
if (!category)
|
|
|
|
return;
|
|
|
|
|
2014-06-06 07:26:14 +02:00
|
|
|
category->icon = textures[TEXTURE_SETTINGS].id;
|
|
|
|
category->item_icon = textures[TEXTURE_SETTING].id;
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
for (j = 0; j < category->num_items; j++)
|
2014-06-06 05:35:05 +02:00
|
|
|
{
|
2014-09-09 00:08:25 +02:00
|
|
|
item = (menu_item_t*)&category->items[j];
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-09-09 00:08:25 +02:00
|
|
|
for (k = 0; k < item->num_subitems; k++)
|
|
|
|
{
|
|
|
|
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
|
|
|
|
subitem->icon = textures[TEXTURE_SUBSETTING].id;
|
|
|
|
}
|
|
|
|
}
|
2014-06-01 17:07:03 +02:00
|
|
|
}
|
|
|
|
|
2014-06-02 16:34:17 +02:00
|
|
|
|
2014-05-31 23:22:20 +02:00
|
|
|
static void lakka_context_reset(void *data)
|
2014-05-08 01:12:51 +07:00
|
|
|
{
|
2014-06-01 17:07:03 +02:00
|
|
|
int i, j, k;
|
2014-09-03 20:20:04 -04:00
|
|
|
char mediapath[256], themepath[256], iconpath[256];
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-09-12 17:18:44 -03:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-08-11 14:52:41 +02:00
|
|
|
driver.gfx_use_rgba = true;
|
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
if (!menu)
|
2014-05-08 01:12:51 +07:00
|
|
|
return;
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
fill_pathname_join(mediapath, g_settings.assets_directory,
|
|
|
|
"lakka", sizeof(mediapath));
|
2014-07-20 19:56:41 +02:00
|
|
|
fill_pathname_join(themepath, mediapath, THEME, sizeof(themepath));
|
2014-08-08 23:29:36 +02:00
|
|
|
fill_pathname_join(iconpath, themepath, icon_dir, sizeof(iconpath));
|
2014-08-01 15:11:23 +02:00
|
|
|
fill_pathname_slash(iconpath, sizeof(iconpath));
|
2014-07-18 06:57:24 +02:00
|
|
|
|
2014-07-20 19:56:41 +02:00
|
|
|
fill_pathname_join(font_path, themepath, "font.ttf", sizeof(font_path));
|
2014-07-18 06:57:24 +02:00
|
|
|
|
2014-08-08 23:29:36 +02:00
|
|
|
gl_font_init_first(&font_driver, &font, gl, font_path, lakka_font_size);
|
2014-05-10 05:25:50 +02:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
fill_pathname_join(textures[TEXTURE_BG].path, iconpath,
|
|
|
|
"bg.png", sizeof(textures[TEXTURE_BG].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_SETTINGS].path, iconpath,
|
|
|
|
"settings.png", sizeof(textures[TEXTURE_SETTINGS].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_SETTING].path, iconpath,
|
|
|
|
"setting.png", sizeof(textures[TEXTURE_SETTING].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_SUBSETTING].path, iconpath,
|
|
|
|
"subsetting.png", sizeof(textures[TEXTURE_SUBSETTING].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_ARROW].path, iconpath,
|
|
|
|
"arrow.png", sizeof(textures[TEXTURE_ARROW].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_RUN].path, iconpath,
|
|
|
|
"run.png", sizeof(textures[TEXTURE_RUN].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_RESUME].path, iconpath,
|
|
|
|
"resume.png", sizeof(textures[TEXTURE_RESUME].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_SAVESTATE].path, iconpath,
|
|
|
|
"savestate.png", sizeof(textures[TEXTURE_SAVESTATE].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_LOADSTATE].path, iconpath,
|
|
|
|
"loadstate.png", sizeof(textures[TEXTURE_LOADSTATE].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_SCREENSHOT].path, iconpath,
|
|
|
|
"screenshot.png", sizeof(textures[TEXTURE_SCREENSHOT].path));
|
|
|
|
fill_pathname_join(textures[TEXTURE_RELOAD].path, iconpath,
|
|
|
|
"reload.png", sizeof(textures[TEXTURE_RELOAD].path));
|
2014-06-06 07:26:14 +02:00
|
|
|
|
|
|
|
for (k = 0; k < TEXTURE_LAST; k++)
|
2014-09-14 15:17:03 +02:00
|
|
|
textures[k].id = lakka_png_texture_load(textures[k].path);
|
2014-05-08 01:12:51 +07:00
|
|
|
|
2014-06-02 16:34:17 +02:00
|
|
|
lakka_settings_context_reset();
|
2014-06-01 17:07:03 +02:00
|
|
|
for (i = 1; i < num_categories; i++)
|
2014-06-01 01:08:39 +02:00
|
|
|
{
|
2014-06-01 17:07:03 +02:00
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
char core_id[256], texturepath[256], content_texturepath[256],
|
|
|
|
mediapath[256], themepath[256];
|
2014-06-01 17:07:03 +02:00
|
|
|
core_info_t *info;
|
|
|
|
core_info_list_t *info_list;
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
fill_pathname_join(mediapath, g_settings.assets_directory,
|
|
|
|
"lakka", sizeof(mediapath));
|
2014-07-20 19:56:41 +02:00
|
|
|
fill_pathname_join(themepath, mediapath, THEME, sizeof(themepath));
|
2014-08-08 23:29:36 +02:00
|
|
|
fill_pathname_join(iconpath, themepath, icon_dir, sizeof(iconpath));
|
2014-08-01 15:11:23 +02:00
|
|
|
fill_pathname_slash(iconpath, sizeof(iconpath));
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-09-03 14:57:29 +02:00
|
|
|
info_list = (core_info_list_t*)g_extern.core_info;
|
2014-06-01 17:07:03 +02:00
|
|
|
info = NULL;
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
if (info_list)
|
|
|
|
info = (core_info_t*)&info_list->list[i-1];
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-09-06 22:59:27 -03:00
|
|
|
if (info != NULL && info->systemname)
|
|
|
|
{
|
2014-09-06 14:28:53 -03:00
|
|
|
char *tmp = str_replace(info->systemname, "/", " ");
|
|
|
|
strlcpy(core_id, tmp, sizeof(core_id));
|
|
|
|
free(tmp);
|
2014-09-06 22:59:27 -03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-21 22:40:21 +02:00
|
|
|
strlcpy(core_id, "default", sizeof(core_id));
|
|
|
|
}
|
2014-06-01 17:07:03 +02:00
|
|
|
|
2014-08-01 15:11:23 +02:00
|
|
|
strlcpy(texturepath, iconpath, sizeof(texturepath));
|
2014-06-01 17:07:03 +02:00
|
|
|
strlcat(texturepath, core_id, sizeof(texturepath));
|
|
|
|
strlcat(texturepath, ".png", sizeof(texturepath));
|
|
|
|
|
2014-08-01 15:11:23 +02:00
|
|
|
strlcpy(content_texturepath, iconpath, sizeof(content_texturepath));
|
2014-06-03 02:20:14 +02:00
|
|
|
strlcat(content_texturepath, core_id, sizeof(content_texturepath));
|
|
|
|
strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-09-14 15:17:03 +02:00
|
|
|
category->icon = lakka_png_texture_load(texturepath);
|
|
|
|
category->item_icon = lakka_png_texture_load(content_texturepath);
|
2014-06-01 17:07:03 +02:00
|
|
|
|
|
|
|
for (j = 0; j < category->num_items; j++)
|
|
|
|
{
|
|
|
|
menu_item_t *item = (menu_item_t*)&category->items[j];
|
2014-06-01 01:08:39 +02:00
|
|
|
|
2014-06-01 17:07:03 +02:00
|
|
|
for (k = 0; k < item->num_subitems; k++)
|
2014-06-01 01:08:39 +02:00
|
|
|
{
|
2014-06-01 17:07:03 +02:00
|
|
|
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
|
|
|
|
|
|
|
|
switch (k)
|
|
|
|
{
|
2014-06-05 21:31:29 +02:00
|
|
|
case 0:
|
2014-06-06 07:26:14 +02:00
|
|
|
subitem->icon = textures[TEXTURE_RUN].id;
|
2014-06-05 21:31:29 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2014-06-06 07:26:14 +02:00
|
|
|
subitem->icon = textures[TEXTURE_SAVESTATE].id;
|
2014-06-05 21:31:29 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2014-06-06 07:26:14 +02:00
|
|
|
subitem->icon = textures[TEXTURE_LOADSTATE].id;
|
2014-06-05 21:31:29 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2014-06-06 07:26:14 +02:00
|
|
|
subitem->icon = textures[TEXTURE_SCREENSHOT].id;
|
2014-06-05 21:31:29 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2014-06-06 07:26:14 +02:00
|
|
|
subitem->icon = textures[TEXTURE_RELOAD].id;
|
2014-06-05 21:31:29 +02:00
|
|
|
break;
|
2014-06-01 17:07:03 +02:00
|
|
|
}
|
2014-06-01 01:08:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-08 01:12:51 +07:00
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-10 01:49:51 +02:00
|
|
|
static void lakka_init_subitems(menu_item_t *item)
|
|
|
|
{
|
|
|
|
int k;
|
|
|
|
for (k = 0; k < item->num_subitems; k++)
|
|
|
|
{
|
|
|
|
menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];
|
|
|
|
|
|
|
|
if (!subitem)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (k)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
strlcpy(subitem->name, "Run", sizeof(subitem->name));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
strlcpy(subitem->name, "Save State", sizeof(subitem->name));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
strlcpy(subitem->name, "Load State", sizeof(subitem->name));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
strlcpy(subitem->name, "Take Screenshot", sizeof(subitem->name));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
strlcpy(subitem->name, "Reset", sizeof(subitem->name));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
subitem->alpha = 0;
|
|
|
|
subitem->zoom = k ? i_passive_zoom : i_active_zoom;
|
|
|
|
subitem->y = k ? vspacing * (k+under_item_offset) :
|
|
|
|
vspacing * active_item_factor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lakka_init_item(int i, int j, menu_category_t *category,
|
|
|
|
core_info_t *info, struct string_list *list, const char * name)
|
|
|
|
{
|
|
|
|
menu_item_t *item;
|
|
|
|
|
|
|
|
int n = category->num_items;
|
|
|
|
|
|
|
|
category->num_items++;
|
|
|
|
category->items = (menu_item_t*)realloc(category->items,
|
|
|
|
category->num_items * sizeof(menu_item_t));
|
|
|
|
item = (menu_item_t*)&category->items[n];
|
|
|
|
|
|
|
|
strlcpy(item->name, name, sizeof(item->name));
|
|
|
|
if (list != NULL)
|
|
|
|
strlcpy(item->rom, list->elems[j].data, sizeof(item->rom));
|
|
|
|
item->alpha = i != menu_active_category ? 0 : n ? 0.5 : 1;
|
|
|
|
item->zoom = n ? i_passive_zoom : i_active_zoom;
|
|
|
|
item->y = n ? vspacing*(under_item_offset+n) :
|
|
|
|
vspacing*active_item_factor;
|
|
|
|
item->active_subitem = 0;
|
|
|
|
item->num_subitems = 5;
|
|
|
|
item->subitems = (menu_subitem_t*)
|
|
|
|
calloc(item->num_subitems, sizeof(menu_subitem_t));
|
|
|
|
|
|
|
|
lakka_init_subitems(item);
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
static void lakka_init_items(int i, menu_category_t *category,
|
|
|
|
core_info_t *info, const char* path)
|
2014-05-08 01:12:51 +07:00
|
|
|
{
|
2014-09-10 01:49:51 +02:00
|
|
|
int num_items, j;
|
2014-09-03 20:21:39 -04:00
|
|
|
struct string_list *list;
|
|
|
|
|
|
|
|
if (category == NULL || info == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list = (struct string_list*)dir_list_new(path, info->supported_extensions, true);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-05-08 01:12:51 +07:00
|
|
|
dir_list_sort(list, true);
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-05-09 16:46:35 +02:00
|
|
|
num_items = list ? list->size : 0;
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-05-09 16:46:35 +02:00
|
|
|
for (j = 0; j < num_items; j++)
|
|
|
|
{
|
2014-09-04 21:46:14 +02:00
|
|
|
if (list->elems[j].attr.i == RARCH_DIRECTORY) // is a directory
|
2014-06-01 17:07:03 +02:00
|
|
|
lakka_init_items(i, category, info, list->elems[j].data);
|
2014-05-08 01:12:51 +07:00
|
|
|
else
|
|
|
|
{
|
2014-09-10 01:49:51 +02:00
|
|
|
lakka_init_item(i, j, category, info, list,
|
|
|
|
path_basename(list->elems[j].data));
|
2014-05-08 01:12:51 +07:00
|
|
|
}
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
2014-09-06 22:56:30 -03:00
|
|
|
|
|
|
|
string_list_free(list);
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
|
|
|
|
2014-05-09 21:04:59 +02:00
|
|
|
static void lakka_free(void *data)
|
|
|
|
{
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-05-10 06:21:03 +02:00
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
if (menu->alloc_font)
|
|
|
|
free((uint8_t*)menu->font);
|
2014-09-06 14:28:53 -03:00
|
|
|
|
|
|
|
if (g_extern.core_info)
|
|
|
|
core_info_list_free(g_extern.core_info);
|
|
|
|
g_extern.core_info = NULL;
|
2014-05-09 21:04:59 +02:00
|
|
|
}
|
|
|
|
|
2014-05-30 20:53:10 +02:00
|
|
|
static int lakka_input_postprocess(uint64_t old_state)
|
2014-05-09 21:04:59 +02:00
|
|
|
{
|
2014-09-02 16:03:17 +02:00
|
|
|
if ((driver.menu && driver.menu->trigger_state
|
|
|
|
& (1ULL << RARCH_MENU_TOGGLE)) &&
|
2014-05-09 21:04:59 +02:00
|
|
|
g_extern.main_is_init &&
|
|
|
|
!g_extern.libretro_dummy)
|
2014-06-03 11:54:48 +02:00
|
|
|
global_alpha = 0;
|
2014-05-09 21:04:59 +02:00
|
|
|
|
2014-06-03 11:54:48 +02:00
|
|
|
if (! global_alpha)
|
2014-09-10 04:53:07 +02:00
|
|
|
add_tween(LAKKA_DELAY, 1.0, &global_alpha, &inOutQuad, NULL);
|
2014-06-03 11:54:48 +02:00
|
|
|
|
|
|
|
return 0;
|
2014-05-09 21:04:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void lakka_init_core_info(void *data)
|
|
|
|
{
|
2014-09-03 14:57:29 +02:00
|
|
|
(void)data;
|
2014-05-09 21:04:59 +02:00
|
|
|
|
2014-09-06 15:05:50 +02:00
|
|
|
core_info_list_free(g_extern.core_info);
|
|
|
|
g_extern.core_info = NULL;
|
2014-09-06 22:59:27 -03:00
|
|
|
if (*g_settings.libretro_directory)
|
|
|
|
{
|
2014-09-06 15:05:50 +02:00
|
|
|
g_extern.core_info = core_info_list_new(g_settings.libretro_directory);
|
|
|
|
}
|
|
|
|
|
2014-09-06 22:59:27 -03:00
|
|
|
if (g_extern.core_info)
|
|
|
|
{
|
2014-09-03 14:57:29 +02:00
|
|
|
num_categories = g_extern.core_info->count + 1;
|
2014-09-06 22:59:27 -03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-06 15:05:50 +02:00
|
|
|
num_categories = 1;
|
|
|
|
}
|
2014-05-09 21:04:59 +02:00
|
|
|
}
|
|
|
|
|
2014-05-08 01:12:51 +07:00
|
|
|
static void *lakka_init(void)
|
2014-02-26 21:10:17 +01:00
|
|
|
{
|
2014-09-03 20:20:04 -04:00
|
|
|
int i;
|
2014-09-12 14:40:05 -03:00
|
|
|
menu_handle_t *menu;
|
2014-09-12 17:18:44 -03:00
|
|
|
const video_driver_t *video_driver = NULL;
|
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(&video_driver);
|
2014-09-12 14:40:05 -03:00
|
|
|
|
2014-09-12 17:18:44 -03:00
|
|
|
if (video_driver != &video_gl || !gl)
|
2014-09-12 14:40:05 -03:00
|
|
|
{
|
|
|
|
RARCH_ERR("Cannot initialize Lakka menu driver: gl video driver is not active.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
2014-09-06 22:59:27 -03:00
|
|
|
|
2014-09-12 17:18:44 -03:00
|
|
|
if (!menu)
|
2014-05-09 18:13:28 +02:00
|
|
|
return NULL;
|
|
|
|
|
2014-08-01 15:11:23 +02:00
|
|
|
lakka_responsive();
|
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
lakka_init_core_info(menu);
|
2014-09-02 16:03:17 +02:00
|
|
|
categories = (menu_category_t*)
|
|
|
|
calloc(num_categories, sizeof(menu_category_t));
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-15 11:20:05 -04:00
|
|
|
if (!categories)
|
|
|
|
{
|
|
|
|
free(menu);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-06-02 16:34:17 +02:00
|
|
|
lakka_init_settings();
|
|
|
|
|
2014-05-31 13:25:33 +02:00
|
|
|
for (i = 1; i < num_categories; i++)
|
2014-05-09 16:46:35 +02:00
|
|
|
{
|
2014-05-27 06:27:31 +02:00
|
|
|
core_info_t *info;
|
2014-05-31 21:17:08 +02:00
|
|
|
core_info_list_t *info_list;
|
2014-05-31 13:25:33 +02:00
|
|
|
menu_category_t *category = (menu_category_t*)&categories[i];
|
2014-05-10 05:25:50 +02:00
|
|
|
|
2014-09-03 14:57:29 +02:00
|
|
|
info_list = (core_info_list_t*)g_extern.core_info;
|
2014-05-31 21:17:08 +02:00
|
|
|
info = NULL;
|
|
|
|
|
|
|
|
if (info_list)
|
|
|
|
info = (core_info_t*)&info_list->list[i-1];
|
2014-02-26 21:10:17 +01:00
|
|
|
|
2014-09-03 20:21:39 -04:00
|
|
|
if (info == NULL)
|
2014-09-15 11:20:05 -04:00
|
|
|
{
|
|
|
|
free(menu);
|
2014-09-15 17:32:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-09-03 20:21:39 -04:00
|
|
|
|
2014-05-27 06:27:31 +02:00
|
|
|
strlcpy(category->name, info->display_name, sizeof(category->name));
|
|
|
|
strlcpy(category->libretro, info->path, sizeof(category->libretro));
|
2014-05-27 02:02:39 +02:00
|
|
|
category->alpha = 0.5;
|
2014-08-08 23:29:36 +02:00
|
|
|
category->zoom = c_passive_zoom;
|
2014-05-27 02:02:39 +02:00
|
|
|
category->active_item = 0;
|
|
|
|
category->num_items = 0;
|
2014-09-02 16:03:17 +02:00
|
|
|
category->items = (menu_item_t*)
|
2014-09-06 22:37:33 -03:00
|
|
|
calloc(category->num_items + 1, sizeof(menu_item_t));
|
2014-05-09 16:46:35 +02:00
|
|
|
|
2014-09-10 01:49:51 +02:00
|
|
|
if (! info->supports_no_game)
|
|
|
|
lakka_init_items(i, category, info, g_settings.content_directory);
|
|
|
|
else
|
|
|
|
lakka_init_item(i, 0, category, info, NULL,
|
|
|
|
info->display_name);
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
return menu;
|
2014-02-26 21:10:17 +01:00
|
|
|
}
|
|
|
|
|
2014-09-11 07:06:20 +02:00
|
|
|
menu_ctx_driver_t menu_ctx_lakka = {
|
2014-05-10 06:21:03 +02:00
|
|
|
NULL,
|
2014-05-08 01:12:51 +07:00
|
|
|
NULL,
|
2014-04-01 04:45:00 +02:00
|
|
|
NULL,
|
2014-05-11 20:47:44 +02:00
|
|
|
lakka_frame,
|
2014-02-26 21:10:17 +01:00
|
|
|
lakka_init,
|
|
|
|
lakka_free,
|
2014-05-31 23:22:20 +02:00
|
|
|
lakka_context_reset,
|
|
|
|
lakka_context_destroy,
|
2014-02-26 21:10:17 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-02-28 01:44:03 +01:00
|
|
|
lakka_input_postprocess,
|
2014-04-13 23:41:47 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-04-14 00:09:52 +02:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-05-09 21:00:50 +02:00
|
|
|
lakka_init_core_info,
|
2014-05-08 01:12:51 +07:00
|
|
|
&menu_ctx_backend_lakka,
|
2014-02-26 21:10:17 +01:00
|
|
|
"lakka",
|
|
|
|
};
|