2014-09-11 02:07:07 +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-09-11 02:07:07 +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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-26 09:54:13 +00:00
|
|
|
#include <stdint.h>
|
2014-09-11 02:07:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "../menu.h"
|
2015-02-11 02:40:29 +00:00
|
|
|
|
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"
|
2015-03-25 14:04:53 +00:00
|
|
|
#include "../../gfx/font_gl_driver.h"
|
2015-03-20 01:19:19 +00:00
|
|
|
#include "../../gfx/video_texture.h"
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
#include "shared.h"
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
typedef struct glui_handle
|
|
|
|
{
|
|
|
|
unsigned line_height;
|
|
|
|
unsigned glyph_width;
|
2014-10-11 01:15:02 +00:00
|
|
|
unsigned margin;
|
|
|
|
unsigned term_width;
|
|
|
|
unsigned term_height;
|
2015-01-07 19:42:36 +00:00
|
|
|
char box_message[PATH_MAX_LENGTH];
|
2015-02-12 23:20:39 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GLuint id;
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
} bg;
|
|
|
|
} textures;
|
2015-03-25 14:04:53 +00:00
|
|
|
|
|
|
|
gl_font_raster_block_t raster_block;
|
2014-10-10 14:23:12 +00:00
|
|
|
} glui_handle_t;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static int glui_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;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(
|
2015-02-13 23:47:42 +00:00
|
|
|
menu->menu_list->selection_buf, 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;
|
|
|
|
}
|
|
|
|
|
2015-03-14 22:44:27 +00:00
|
|
|
static void glui_blit_line(gl_t *gl, float x, float y, const char *message, uint32_t color)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2015-01-10 22:45:14 +00:00
|
|
|
struct font_params params = {0};
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-03-24 19:43:53 +00:00
|
|
|
/* gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); */
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-01-19 05:44:46 +00:00
|
|
|
params.x = x / gl->win_width;
|
|
|
|
params.y = 1.0f - y / gl->win_height;
|
|
|
|
params.scale = 1.0;
|
2015-03-14 22:44:27 +00:00
|
|
|
params.color = color;
|
2014-09-11 02:07:07 +00:00
|
|
|
params.full_screen = true;
|
2015-01-19 05:44:46 +00:00
|
|
|
|
2015-03-22 17:48:24 +00:00
|
|
|
video_driver_set_osd_msg(message, ¶ms, NULL);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
static void glui_render_background(settings_t *settings,
|
|
|
|
gl_t *gl, glui_handle_t *glui,
|
2015-02-11 04:50:37 +00:00
|
|
|
bool force_transparency)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
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,
|
|
|
|
};
|
|
|
|
struct gl_coords coords;
|
2014-10-12 16:22:51 +00:00
|
|
|
float alpha = 0.75f;
|
2014-10-12 01:24:12 +00: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-09-14 08:32:35 +00:00
|
|
|
GLfloat black_color[] = {
|
2014-10-12 01:24:12 +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-09-11 02:07:07 +00:00
|
|
|
};
|
2015-03-21 04:42:49 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = vertex;
|
|
|
|
coords.tex_coord = tex_coord;
|
2014-10-12 01:24:12 +00:00
|
|
|
coords.lut_tex_coord = tex_coord;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if ((settings->menu.pause_libretro
|
2015-03-21 04:42:49 +00:00
|
|
|
|| !global->main_is_init || global->libretro_dummy)
|
2014-10-12 16:22:51 +00:00
|
|
|
&& !force_transparency
|
2015-02-12 23:20:39 +00:00
|
|
|
&& glui->textures.bg.id)
|
2014-10-12 01:24:12 +00:00
|
|
|
{
|
|
|
|
coords.color = color;
|
2015-02-12 23:20:39 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, glui->textures.bg.id);
|
2014-10-12 01:24:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
coords.color = black_color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-19 20:24:29 +00:00
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
2014-10-12 01:24:12 +00:00
|
|
|
gl->shader->set_coords(&coords);
|
2014-10-02 13:17:21 +00:00
|
|
|
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
glEnable(GL_BLEND);
|
2014-09-11 02:07:07 +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-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 22:35:48 +00:00
|
|
|
static void glui_draw_cursor(gl_t *gl, float x, float y)
|
2014-10-26 23:55:14 +00:00
|
|
|
{
|
2015-02-11 04:55:36 +00:00
|
|
|
struct gl_coords coords;
|
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,
|
|
|
|
};
|
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
1.0f, 1.0f, 1.0f, 1.0f,
|
|
|
|
};
|
2014-10-26 23:55:14 +00:00
|
|
|
|
2015-03-08 22:35:48 +00:00
|
|
|
glViewport(x - 5, gl->win_height - y + 5, 11, 11);
|
2014-10-26 23:55:14 +00:00
|
|
|
|
2015-01-10 22:45:14 +00:00
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = vertex;
|
|
|
|
coords.tex_coord = tex_coord;
|
2014-10-26 23:55:14 +00:00
|
|
|
coords.lut_tex_coord = tex_coord;
|
|
|
|
|
|
|
|
coords.color = color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
|
|
|
gl->shader->set_coords(&coords);
|
|
|
|
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
gl->coords.color = gl->white_color_ptr;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_get_message(const char *message)
|
2014-09-15 10:36:52 +00:00
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2014-09-15 10:36:52 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!message || !*message)
|
2014-09-15 10:36:52 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2015-02-02 17:51:48 +00:00
|
|
|
if (glui)
|
|
|
|
strlcpy(glui->box_message, message, sizeof(glui->box_message));
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_render_messagebox(const char *message)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
unsigned i;
|
2015-03-16 15:57:27 +00:00
|
|
|
uint32_t normal_color;
|
2014-10-10 14:23:12 +00:00
|
|
|
int x, y;
|
|
|
|
struct string_list *list = NULL;
|
|
|
|
glui_handle_t *glui = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
gl_t *gl = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 21:22:06 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2014-09-15 10:36:52 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-03-21 22:46:49 +00:00
|
|
|
gl = (gl_t*)video_driver_get_ptr(NULL);
|
2015-02-13 18:00:34 +00:00
|
|
|
|
|
|
|
if (!gl)
|
2014-09-15 10:36:52 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list = (struct string_list*)string_split(message, "\n");
|
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
if (list->elems == 0)
|
2015-02-02 17:51:48 +00:00
|
|
|
goto end;
|
2014-09-15 10:36:52 +00:00
|
|
|
|
2015-01-19 05:44:46 +00:00
|
|
|
x = gl->win_width / 2 - strlen(list->elems[0].data) * glui->glyph_width / 2;
|
2014-10-10 14:23:12 +00:00
|
|
|
y = gl->win_height / 2 - list->size * glui->line_height / 2;
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
2015-03-15 15:51:55 +00:00
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
|
|
|
const char *msg = list->elems[i].data;
|
2015-02-02 17:51:48 +00:00
|
|
|
if (msg)
|
2015-03-15 15:51:55 +00:00
|
|
|
glui_blit_line(gl, x, y + i * glui->line_height, msg, normal_color);
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 17:51:48 +00:00
|
|
|
end:
|
2014-09-15 10:36:52 +00:00
|
|
|
string_list_free(list);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-08 18:50:12 +00:00
|
|
|
static void glui_render(void)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-08 18:50:12 +00:00
|
|
|
gl_t *gl = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 21:22:06 +00:00
|
|
|
runloop_t *runloop = rarch_main_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
2015-03-21 22:46:49 +00:00
|
|
|
gl = (gl_t*)video_driver_get_ptr(NULL);
|
2015-03-08 18:50:12 +00:00
|
|
|
|
|
|
|
if (!gl)
|
2014-10-04 01:17:32 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
glui->line_height = settings->video.font_size * 4 / 3;
|
2014-10-10 14:23:12 +00:00
|
|
|
glui->glyph_width = glui->line_height / 2;
|
2015-01-10 22:45:14 +00:00
|
|
|
glui->margin = gl->win_width / 20 ;
|
|
|
|
glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width;
|
2014-10-11 01:15:02 +00:00
|
|
|
glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2;
|
2014-09-13 20:45:38 +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-03-18 05:47:22 +00:00
|
|
|
runloop->frames.video.current.menu.animation.is_active = false;
|
|
|
|
runloop->frames.video.current.menu.label.is_updated = false;
|
|
|
|
runloop->frames.video.current.menu.framebuf.dirty = false;
|
2015-03-08 18:50:12 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu->mouse.ptr = (menu->mouse.y - glui->margin) /
|
|
|
|
glui->line_height - 2 + menu->begin;
|
2014-10-26 23:55:14 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu->mouse.wheeldown && menu->begin
|
|
|
|
< menu_list_get_size(menu->menu_list) - glui->term_height)
|
|
|
|
menu->begin++;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu->mouse.wheelup && menu->begin > 0)
|
|
|
|
menu->begin--;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
/* Do not scroll if all items are visible. */
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu_list_get_size(menu->menu_list) <= glui->term_height)
|
|
|
|
menu->begin = 0;
|
2015-03-08 18:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void glui_frame(void)
|
|
|
|
{
|
|
|
|
unsigned x, y;
|
|
|
|
size_t i;
|
|
|
|
char title[PATH_MAX_LENGTH], title_buf[PATH_MAX_LENGTH],
|
|
|
|
title_msg[PATH_MAX_LENGTH];
|
|
|
|
char timedate[PATH_MAX_LENGTH];
|
|
|
|
const char *dir = NULL;
|
|
|
|
const char *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
size_t end;
|
|
|
|
gl_t *gl = NULL;
|
|
|
|
glui_handle_t *glui = NULL;
|
|
|
|
const char *core_name = NULL;
|
|
|
|
const char *core_version = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 21:22:06 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
const uint32_t normal_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_normal_color);
|
|
|
|
const uint32_t hover_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.entry_hover_color);
|
2015-03-24 20:28:53 +00:00
|
|
|
const uint32_t title_color = FONT_COLOR_ARGB_TO_RGBA(settings->menu.title_color);
|
2015-03-18 05:47:22 +00:00
|
|
|
runloop_t *runloop = rarch_main_get_ptr();
|
2015-03-21 04:42:49 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-08 18:50:12 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-03-21 22:46:49 +00:00
|
|
|
gl = (gl_t*)video_driver_get_ptr(NULL);
|
2015-03-08 18:50:12 +00:00
|
|
|
|
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (menu->need_refresh
|
2015-03-18 05:47:22 +00:00
|
|
|
&& runloop->is_menu
|
2015-03-08 18:50:12 +00:00
|
|
|
&& !menu->msg_force)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
end = (menu->begin + glui->term_height <=
|
|
|
|
menu_list_get_size(menu->menu_list)) ?
|
|
|
|
menu->begin + glui->term_height :
|
|
|
|
menu_list_get_size(menu->menu_list);
|
2014-09-13 02:21:48 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
glui_render_background(settings, gl, glui, false);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-16 02:21:31 +00:00
|
|
|
get_title(label, dir, menu_type, title, sizeof(title));
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 17:52:59 +00:00
|
|
|
menu_animation_ticker_line(title_buf, glui->term_width - 3,
|
2015-03-18 05:47:22 +00:00
|
|
|
runloop->frames.video.count / glui->margin, title, true);
|
2015-02-11 04:50:37 +00:00
|
|
|
glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height,
|
2015-03-24 20:28:53 +00:00
|
|
|
title_buf, title_color);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-03-21 04:42:49 +00:00
|
|
|
core_name = global->menu.info.library_name;
|
2014-09-11 02:07:07 +00:00
|
|
|
if (!core_name)
|
2015-03-21 04:42:49 +00:00
|
|
|
core_name = global->system.info.library_name;
|
2014-09-11 02:07:07 +00:00
|
|
|
if (!core_name)
|
|
|
|
core_name = "No Core";
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (settings->menu.core_enable)
|
2015-02-12 18:35:24 +00:00
|
|
|
{
|
2015-03-21 04:42:49 +00:00
|
|
|
core_version = global->menu.info.library_version;
|
2015-02-12 18:35:24 +00:00
|
|
|
if (!core_version)
|
2015-03-21 04:42:49 +00:00
|
|
|
core_version = global->system.info.library_version;
|
2015-02-12 18:35:24 +00:00
|
|
|
if (!core_version)
|
|
|
|
core_version = "";
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-12 18:35:24 +00:00
|
|
|
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
|
|
|
|
core_name, core_version);
|
2015-01-17 03:50:46 +00:00
|
|
|
|
2015-02-12 18:35:24 +00:00
|
|
|
glui_blit_line(gl,
|
|
|
|
glui->margin * 2,
|
2015-03-24 19:43:53 +00:00
|
|
|
glui->margin + glui->term_height * glui->line_height
|
2015-03-24 20:28:53 +00:00
|
|
|
+ glui->line_height * 2, title_msg, title_color);
|
2015-02-12 18:35:24 +00:00
|
|
|
}
|
2015-01-17 03:50:46 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (settings->menu.timedate_enable)
|
2015-02-12 18:35:24 +00:00
|
|
|
{
|
|
|
|
disp_timedate_set_label(timedate, sizeof(timedate), 0);
|
2015-02-11 04:50:37 +00:00
|
|
|
glui_blit_line(gl,
|
2015-01-17 03:50:46 +00:00
|
|
|
glui->margin * 14,
|
2015-03-24 19:43:53 +00:00
|
|
|
glui->margin + glui->term_height * glui->line_height
|
2015-03-15 15:51:55 +00:00
|
|
|
+ glui->line_height * 2, timedate, hover_color);
|
2015-02-12 18:35:24 +00:00
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
x = glui->margin;
|
|
|
|
y = glui->margin + glui->line_height * 2;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
for (i = menu->begin; i < end; i++, y += glui->line_height)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH],
|
|
|
|
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH],
|
|
|
|
path_buf[PATH_MAX_LENGTH];
|
2014-09-11 02:22:30 +00:00
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
2014-09-11 02:07:07 +00:00
|
|
|
bool selected = false;
|
2015-01-31 16:46:14 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
|
2014-09-11 02:07:07 +00:00
|
|
|
&entry_label, &type);
|
2015-01-31 16:19:12 +00:00
|
|
|
|
2015-01-31 16:46:14 +00:00
|
|
|
cbs = (menu_file_list_cbs_t*)
|
2015-02-11 19:28:54 +00:00
|
|
|
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
2015-01-31 16:46:14 +00:00
|
|
|
i);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-01-31 16:46:14 +00:00
|
|
|
if (cbs && cbs->action_get_representation)
|
2015-02-11 19:28:54 +00:00
|
|
|
cbs->action_get_representation(menu->menu_list->selection_buf,
|
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-09-11 02:07:07 +00:00
|
|
|
|
2015-02-13 23:47:42 +00:00
|
|
|
selected = (i == menu->navigation.selection_ptr);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-02-11 17:52:59 +00:00
|
|
|
menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
|
2015-03-18 05:47:22 +00:00
|
|
|
runloop->frames.video.count / glui->margin, path_buf, selected);
|
2015-02-11 17:52:59 +00:00
|
|
|
menu_animation_ticker_line(type_str_buf, w,
|
2015-03-18 05:47:22 +00:00
|
|
|
runloop->frames.video.count / glui->margin, type_str, selected);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
strlcpy(message, entry_title_buf, sizeof(message));
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-03-15 15:51:55 +00:00
|
|
|
glui_blit_line(gl, x, y, message, selected ? hover_color : normal_color);
|
2014-09-13 01:34:59 +00:00
|
|
|
|
2015-03-24 19:43:53 +00:00
|
|
|
glui_blit_line(gl, gl->win_width - glui->glyph_width * w - glui->margin ,
|
2015-03-15 15:51:55 +00:00
|
|
|
y, type_str_buf, selected ? hover_color : normal_color);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu->keyboard.display)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
char msg[PATH_MAX_LENGTH];
|
2015-02-11 19:28:54 +00:00
|
|
|
const char *str = *menu->keyboard.buffer;
|
2014-09-11 02:07:07 +00:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
2015-03-20 21:22:06 +00:00
|
|
|
glui_render_background(settings, gl, glui, true);
|
2015-02-11 19:28:54 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str);
|
2015-02-13 18:00:34 +00:00
|
|
|
glui_render_messagebox(msg);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
if (glui->box_message[0] != '\0')
|
2014-09-15 10:36:52 +00:00
|
|
|
{
|
2015-03-20 21:22:06 +00:00
|
|
|
glui_render_background(settings, gl, glui, true);
|
2015-02-13 18:00:34 +00:00
|
|
|
glui_render_messagebox(glui->box_message);
|
2014-10-10 14:23:12 +00:00
|
|
|
glui->box_message[0] = '\0';
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (settings->menu.mouse.enable)
|
2015-03-08 22:35:48 +00:00
|
|
|
glui_draw_cursor(gl, menu->mouse.x, menu->mouse.y);
|
2014-10-26 23:55:14 +00:00
|
|
|
|
2015-03-25 14:04:53 +00:00
|
|
|
if (gl->font_driver->flush)
|
|
|
|
gl->font_driver->flush(gl->font_handle);
|
2015-03-24 20:28:53 +00:00
|
|
|
|
2015-03-01 16:50:40 +00:00
|
|
|
gl_set_viewport(gl, gl->win_width, gl->win_height, false, true);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *glui_init(void)
|
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-12 20:18:44 +00:00
|
|
|
const video_driver_t *video_driver = NULL;
|
2015-02-13 18:00:34 +00:00
|
|
|
menu_handle_t *menu = NULL;
|
2015-03-21 22:46:49 +00:00
|
|
|
gl_t *gl = (gl_t*)video_driver_get_ptr(&video_driver);
|
2014-09-12 20:18:44 +00:00
|
|
|
|
|
|
|
if (video_driver != &video_gl || !gl)
|
|
|
|
{
|
|
|
|
RARCH_ERR("Cannot initialize GLUI menu driver: gl video driver is not active.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-12 20:18:44 +00:00
|
|
|
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
|
|
|
|
|
|
|
if (!menu)
|
2015-02-02 17:51:48 +00:00
|
|
|
goto error;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
menu->userdata = (glui_handle_t*)calloc(1, sizeof(glui_handle_t));
|
|
|
|
|
|
|
|
if (!menu->userdata)
|
2015-02-02 17:51:48 +00:00
|
|
|
goto error;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2015-02-02 17:51:48 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
2015-02-12 23:20:39 +00:00
|
|
|
glui->textures.bg.id = 0;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2015-03-25 14:04:53 +00:00
|
|
|
if (gl->font_driver->bind_block)
|
|
|
|
gl->font_driver->bind_block(gl->font_handle, &glui->raster_block);
|
2015-03-24 20:28:53 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
return menu;
|
2015-02-02 17:51:48 +00:00
|
|
|
error:
|
|
|
|
if (menu)
|
|
|
|
free(menu);
|
|
|
|
return NULL;
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void glui_free(void *data)
|
|
|
|
{
|
2015-03-24 20:28:53 +00:00
|
|
|
gl_t *gl = (gl_t*)video_driver_get_ptr(NULL);
|
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2015-03-25 14:04:53 +00:00
|
|
|
glui_handle_t *glui = (glui_handle_t*)menu->userdata;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2015-03-25 14:04:53 +00:00
|
|
|
gl_coord_array_release(&glui->raster_block.carr);
|
2015-03-24 20:28:53 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
if (menu->alloc_font)
|
|
|
|
free((uint8_t*)menu->font);
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
if (menu->userdata)
|
|
|
|
free(menu->userdata);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2015-02-12 23:20:39 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_context_destroy(void)
|
2015-02-12 23:20:39 +00:00
|
|
|
{
|
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-12 23:20:39 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (glui->textures.bg.id)
|
|
|
|
glDeleteTextures(1, &glui->textures.bg.id);
|
|
|
|
}
|
|
|
|
|
2015-02-23 22:32:59 +00:00
|
|
|
static bool glui_load_wallpaper(void *data)
|
2015-02-12 23:20:39 +00:00
|
|
|
{
|
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-12 23:20:39 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (glui->textures.bg.id)
|
|
|
|
glDeleteTextures(1, &glui->textures.bg.id);
|
|
|
|
|
2015-03-20 01:19:19 +00:00
|
|
|
glui->textures.bg.id = video_texture_load(data,
|
2015-02-12 23:20:39 +00:00
|
|
|
TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_context_reset(void)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2015-02-23 22:32:59 +00:00
|
|
|
const char *path = NULL;
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-20 21:22:06 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2014-09-14 23:34:58 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
fill_pathname_join(glui->textures.bg.path, settings->assets_directory,
|
2015-02-12 23:20:39 +00:00
|
|
|
"glui", sizeof(glui->textures.bg.path));
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
if (*settings->menu.wallpaper)
|
2015-02-12 23:20:39 +00:00
|
|
|
strlcpy(glui->textures.bg.path,
|
2015-03-20 21:22:06 +00:00
|
|
|
settings->menu.wallpaper, sizeof(glui->textures.bg.path));
|
2015-01-17 17:45:32 +00:00
|
|
|
else
|
2015-02-12 23:20:39 +00:00
|
|
|
fill_pathname_join(glui->textures.bg.path,
|
|
|
|
glui->textures.bg.path, "bg.png",
|
|
|
|
sizeof(glui->textures.bg.path));
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2015-02-23 22:32:59 +00:00
|
|
|
path = glui->textures.bg.path;
|
|
|
|
|
|
|
|
if (path_file_exists(path))
|
|
|
|
{
|
|
|
|
struct texture_image ti = {0};
|
|
|
|
texture_image_load(&ti, path);
|
|
|
|
|
|
|
|
strlcpy(glui->textures.bg.path, path, sizeof(glui->textures.bg.path));
|
|
|
|
|
|
|
|
glui_load_wallpaper(&ti);
|
|
|
|
|
|
|
|
texture_image_free(&ti);
|
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_navigation_clear(bool pending_push)
|
2014-10-26 23:55:14 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-11 13:32:09 +00:00
|
|
|
if (menu)
|
|
|
|
menu->begin = 0;
|
2014-10-26 23:55:14 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_navigation_set(bool scroll)
|
2014-10-26 23:55:14 +00:00
|
|
|
{
|
|
|
|
glui_handle_t *glui = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2014-10-26 23:55:14 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2015-02-11 13:32:09 +00:00
|
|
|
|
2014-10-26 23:55:14 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
if (!scroll)
|
|
|
|
return;
|
|
|
|
|
2015-02-13 23:47:42 +00:00
|
|
|
if (menu->navigation.selection_ptr < glui->term_height/2)
|
2015-02-11 05:34:30 +00:00
|
|
|
menu->begin = 0;
|
2015-02-13 23:47:42 +00:00
|
|
|
else if (menu->navigation.selection_ptr >= glui->term_height/2
|
|
|
|
&& menu->navigation.selection_ptr <
|
2015-02-11 05:34:30 +00:00
|
|
|
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
2015-02-13 23:47:42 +00:00
|
|
|
menu->begin = menu->navigation.selection_ptr - glui->term_height/2;
|
|
|
|
else if (menu->navigation.selection_ptr >=
|
2015-02-11 05:34:30 +00:00
|
|
|
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
|
|
|
menu->begin = menu_list_get_size(menu->menu_list)
|
2014-10-26 23:55:14 +00:00
|
|
|
- glui->term_height;
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_navigation_set_last(void)
|
2014-12-15 18:03:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
glui_navigation_set(true);
|
2014-12-15 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_navigation_descend_alphabet(size_t *unused)
|
2014-12-15 18:03:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
glui_navigation_set(true);
|
2014-12-15 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void glui_navigation_ascend_alphabet(size_t *unused)
|
2014-12-15 18:03:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
if (menu)
|
|
|
|
glui_navigation_set(true);
|
2014-12-15 18:03:47 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_glui = {
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
2014-09-15 10:36:52 +00:00
|
|
|
glui_get_message,
|
2015-03-08 18:50:12 +00:00
|
|
|
glui_render,
|
2014-09-11 02:07:07 +00:00
|
|
|
glui_frame,
|
|
|
|
glui_init,
|
|
|
|
glui_free,
|
|
|
|
glui_context_reset,
|
2015-02-12 23:20:39 +00:00
|
|
|
glui_context_destroy,
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-10-26 23:55:14 +00:00
|
|
|
glui_navigation_clear,
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-10-26 23:55:14 +00:00
|
|
|
glui_navigation_set,
|
2014-12-15 18:03:47 +00:00
|
|
|
glui_navigation_set_last,
|
|
|
|
glui_navigation_descend_alphabet,
|
|
|
|
glui_navigation_ascend_alphabet,
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-11-27 15:28:45 +00:00
|
|
|
NULL,
|
2015-01-26 09:54:13 +00:00
|
|
|
glui_entry_iterate,
|
2015-02-12 23:20:39 +00:00
|
|
|
glui_load_wallpaper,
|
2014-09-11 02:07:07 +00:00
|
|
|
"glui",
|
|
|
|
};
|