2012-05-06 02:04:33 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2014-04-13 10:12:12 +00:00
|
|
|
*
|
2012-05-06 02:04:33 +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>
|
2012-05-06 02:04:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2013-11-11 11:23:18 +00:00
|
|
|
#include "../menu_common.h"
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../../general.h"
|
2015-01-09 16:40:47 +00:00
|
|
|
#include "../../retroarch.h"
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2013-03-09 14:33:44 +00:00
|
|
|
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../../gfx/fonts/bitmap.h"
|
2013-01-09 16:49:43 +00:00
|
|
|
|
2014-09-02 23:51:29 +00:00
|
|
|
#include "shared.h"
|
|
|
|
|
2014-10-11 01:02:49 +00:00
|
|
|
typedef struct rgui_handle
|
|
|
|
{
|
2014-10-26 22:43:33 +00:00
|
|
|
unsigned term_height;
|
|
|
|
uint16_t *frame_buf;
|
|
|
|
size_t frame_buf_pitch;
|
2014-10-11 01:02:49 +00:00
|
|
|
} rgui_handle_t;
|
2013-04-07 14:45:05 +00:00
|
|
|
|
2014-09-06 01:21:57 +00:00
|
|
|
#define RGUI_TERM_START_X (driver.menu->width / 21)
|
|
|
|
#define RGUI_TERM_START_Y (driver.menu->height / 9)
|
2014-09-06 01:17:51 +00:00
|
|
|
#define RGUI_TERM_WIDTH (((driver.menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE)))
|
|
|
|
#define RGUI_TERM_HEIGHT (((driver.menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1)
|
2013-05-04 14:56:02 +00:00
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf)
|
|
|
|
{
|
|
|
|
int y, x;
|
|
|
|
for (y = 0; y < FONT_HEIGHT; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < FONT_WIDTH; x++)
|
|
|
|
{
|
|
|
|
uint32_t col =
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) |
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) |
|
|
|
|
((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16);
|
|
|
|
|
|
|
|
uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7);
|
|
|
|
unsigned offset = (x + y * FONT_WIDTH) >> 3;
|
|
|
|
|
|
|
|
if (col != 0xff)
|
|
|
|
glyph[offset] |= rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t gray_filler(unsigned x, unsigned y)
|
|
|
|
{
|
|
|
|
x >>= 1;
|
|
|
|
y >>= 1;
|
|
|
|
unsigned col = ((x + y) & 1) + 1;
|
2014-02-18 21:01:04 +00:00
|
|
|
#if defined(GEKKO) || defined(PSP)
|
2013-11-04 12:27:03 +00:00
|
|
|
return (6 << 12) | (col << 8) | (col << 4) | (col << 0);
|
|
|
|
#else
|
|
|
|
return (col << 13) | (col << 9) | (col << 5) | (12 << 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint16_t green_filler(unsigned x, unsigned y)
|
|
|
|
{
|
|
|
|
x >>= 1;
|
|
|
|
y >>= 1;
|
|
|
|
unsigned col = ((x + y) & 1) + 1;
|
2014-02-18 21:01:04 +00:00
|
|
|
#if defined(GEKKO) || defined(PSP)
|
2013-11-04 12:27:03 +00:00
|
|
|
return (6 << 12) | (col << 8) | (col << 5) | (col << 0);
|
|
|
|
#else
|
|
|
|
return (col << 13) | (col << 10) | (col << 5) | (12 << 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_rect(uint16_t *buf, unsigned pitch,
|
|
|
|
unsigned x, unsigned y,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
uint16_t (*col)(unsigned x, unsigned y))
|
|
|
|
{
|
|
|
|
unsigned j, i;
|
2015-01-01 17:47:39 +00:00
|
|
|
|
2015-01-01 17:53:04 +00:00
|
|
|
if (!buf || !col)
|
2015-01-01 17:47:39 +00:00
|
|
|
return;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
for (j = y; j < y + height; j++)
|
|
|
|
for (i = x; i < x + width; i++)
|
|
|
|
buf[j * (pitch >> 1) + i] = col(i, j);
|
|
|
|
}
|
2014-10-25 21:21:28 +00:00
|
|
|
static void color_rect(uint16_t *buf, unsigned pitch,
|
|
|
|
unsigned x, unsigned y,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
uint16_t color)
|
|
|
|
{
|
|
|
|
unsigned j, i;
|
|
|
|
for (j = y; j < y + height; j++)
|
|
|
|
for (i = x; i < x + width; i++)
|
2014-10-25 23:17:41 +00:00
|
|
|
if (i < driver.menu->width && j < driver.menu->height)
|
2014-10-25 21:21:28 +00:00
|
|
|
buf[j * (pitch >> 1) + i] = color;
|
|
|
|
}
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
static void blit_line(int x, int y, const char *message, bool green)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
int j, i;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
2014-05-30 19:51:12 +00:00
|
|
|
|
2014-05-31 20:20:27 +00:00
|
|
|
if (!driver.menu)
|
2014-05-30 19:51:12 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui = (rgui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
return;
|
|
|
|
|
2013-11-04 12:27:03 +00:00
|
|
|
while (*message)
|
|
|
|
{
|
|
|
|
for (j = 0; j < FONT_HEIGHT; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < FONT_WIDTH; i++)
|
|
|
|
{
|
|
|
|
uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7);
|
|
|
|
int offset = (i + j * FONT_WIDTH) >> 3;
|
2014-08-31 23:59:30 +00:00
|
|
|
bool col = (driver.menu->font[FONT_OFFSET
|
|
|
|
((unsigned char)*message) + offset] & rem);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
|
|
|
if (col)
|
|
|
|
{
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui->frame_buf[(y + j) *
|
|
|
|
(rgui->frame_buf_pitch >> 1) + (x + i)] = green ?
|
2014-02-18 21:01:04 +00:00
|
|
|
#if defined(GEKKO)|| defined(PSP)
|
2013-11-04 12:27:03 +00:00
|
|
|
(3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF;
|
|
|
|
#else
|
|
|
|
(15 << 0) | (7 << 4) | (15 << 8) | (7 << 12) : 0xFFFF;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x += FONT_WIDTH_STRIDE;
|
|
|
|
message++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-12 04:30:53 +00:00
|
|
|
static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
uint8_t *font = (uint8_t *) calloc(1, FONT_OFFSET(256));
|
2014-09-12 04:30:53 +00:00
|
|
|
|
|
|
|
if (!font)
|
|
|
|
{
|
2014-09-13 23:49:24 +00:00
|
|
|
RARCH_ERR("Font memory allocation failed.\n");
|
2014-09-12 04:30:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->alloc_font = true;
|
2013-11-04 12:27:03 +00:00
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
unsigned y = i / 16;
|
|
|
|
unsigned x = i % 16;
|
|
|
|
rgui_copy_glyph(&font[FONT_OFFSET(i)],
|
|
|
|
font_bmp_buf + 54 + 3 * (256 * (255 - 16 * y) + 16 * x));
|
|
|
|
}
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->font = font;
|
2014-09-12 04:30:53 +00:00
|
|
|
return true;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool rguidisp_init_font(void *data)
|
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
|
|
|
const uint8_t *font_bmp_buf = NULL;
|
|
|
|
const uint8_t *font_bin_buf = bitmap_bin;
|
|
|
|
|
|
|
|
if (font_bmp_buf)
|
2014-09-12 04:30:53 +00:00
|
|
|
return init_font(menu, font_bmp_buf);
|
2013-11-04 12:27:03 +00:00
|
|
|
else if (font_bin_buf)
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->font = font_bin_buf;
|
2013-11-04 12:27:03 +00:00
|
|
|
else
|
2014-08-27 02:02:32 +00:00
|
|
|
return false;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-08-27 02:02:32 +00:00
|
|
|
return true;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
static void rgui_render_background(void *data)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
2014-05-30 19:51:12 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-05-31 20:20:27 +00:00
|
|
|
0, 0, driver.menu->width, driver.menu->height, gray_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-05-31 20:20:27 +00:00
|
|
|
5, 5, driver.menu->width - 10, 5, green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-09-02 14:03:17 +00:00
|
|
|
5, driver.menu->height - 10, driver.menu->width - 10, 5,
|
|
|
|
green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-05-31 20:20:27 +00:00
|
|
|
5, 5, 5, driver.menu->height - 10, green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-09-02 14:03:17 +00:00
|
|
|
driver.menu->width - 10, 5, 5, driver.menu->height - 10,
|
|
|
|
green_filler);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
static void rgui_render_messagebox(const char *message)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2015-01-04 14:22:49 +00:00
|
|
|
int x, y;
|
|
|
|
unsigned width, glyphs_width, height;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
2015-01-04 14:22:49 +00:00
|
|
|
struct string_list *list = NULL;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-05-31 20:20:27 +00:00
|
|
|
if (!driver.menu || !message || !*message)
|
2013-11-04 12:27:03 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui = (rgui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
return;
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
list = string_split(message, "\n");
|
2013-11-04 12:27:03 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
if (list->elems == 0)
|
|
|
|
{
|
|
|
|
string_list_free(list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
width = 0;
|
|
|
|
glyphs_width = 0;
|
2013-11-04 12:27:03 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
2015-01-04 14:22:49 +00:00
|
|
|
unsigned line_width;
|
|
|
|
char *msg = list->elems[i].data;
|
2013-11-04 12:27:03 +00:00
|
|
|
unsigned msglen = strlen(msg);
|
2015-01-04 14:22:49 +00:00
|
|
|
|
2014-02-28 00:34:10 +00:00
|
|
|
if (msglen > RGUI_TERM_WIDTH)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2014-02-28 00:34:10 +00:00
|
|
|
msg[RGUI_TERM_WIDTH - 2] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH - 1] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH - 0] = '.';
|
|
|
|
msg[RGUI_TERM_WIDTH + 1] = '\0';
|
|
|
|
msglen = RGUI_TERM_WIDTH;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
line_width = msglen * FONT_WIDTH_STRIDE - 1 + 6 + 10;
|
2013-11-04 12:27:03 +00:00
|
|
|
width = max(width, line_width);
|
|
|
|
glyphs_width = max(glyphs_width, msglen);
|
|
|
|
}
|
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
height = FONT_HEIGHT_STRIDE * list->size + 6 + 10;
|
|
|
|
x = (driver.menu->width - width) / 2;
|
|
|
|
y = (driver.menu->height - height) / 2;
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
x + 5, y + 5, width - 10, height - 10, gray_filler);
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
x, y, width - 5, 5, green_filler);
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
x + width - 5, y, 5, height - 5, green_filler);
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
x + 5, y + height - 5, width - 5, 5, green_filler);
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2013-11-04 12:27:03 +00:00
|
|
|
x, y + 5, 5, height - 5, green_filler);
|
|
|
|
|
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
|
|
|
const char *msg = list->elems[i].data;
|
|
|
|
int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2;
|
|
|
|
int offset_y = FONT_HEIGHT_STRIDE * i;
|
2014-05-30 19:51:12 +00:00
|
|
|
blit_line(x + 8 + offset_x, y + 8 + offset_y, msg, false);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string_list_free(list);
|
|
|
|
}
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
static void rgui_blit_cursor(void* data)
|
2014-10-25 21:21:28 +00:00
|
|
|
{
|
2014-10-26 22:43:33 +00:00
|
|
|
int16_t x, y;
|
|
|
|
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
|
|
|
|
|
|
|
x = driver.menu->mouse.x;
|
|
|
|
y = driver.menu->mouse.y;
|
2014-10-25 21:21:28 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
color_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-10-25 21:21:28 +00:00
|
|
|
x, y-5, 1, 11, 0xFFFF);
|
2014-10-26 22:43:33 +00:00
|
|
|
color_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
2014-10-25 21:21:28 +00:00
|
|
|
x-5, y, 11, 1, 0xFFFF);
|
|
|
|
}
|
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
static void rgui_render(void)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
2015-01-04 14:22:49 +00:00
|
|
|
size_t i, end;
|
|
|
|
char title[256], title_buf[256], title_msg[64];
|
|
|
|
unsigned x, y, menu_type = 0;
|
|
|
|
const char *dir = NULL;
|
|
|
|
const char *label = NULL;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-09-25 04:33:28 +00:00
|
|
|
if (driver.menu->need_refresh
|
|
|
|
&& g_extern.is_menu
|
2014-05-31 20:20:27 +00:00
|
|
|
&& !driver.menu->msg_force)
|
2013-11-04 12:27:03 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui = (rgui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
return;
|
|
|
|
|
2014-10-26 23:55:14 +00:00
|
|
|
driver.menu->mouse.ptr = driver.menu->mouse.y / 11 - 2 + driver.menu->begin;
|
|
|
|
|
2014-10-26 21:31:53 +00:00
|
|
|
if (driver.menu->mouse.wheeldown && driver.menu->begin
|
|
|
|
< menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT)
|
|
|
|
driver.menu->begin++;
|
|
|
|
|
|
|
|
if (driver.menu->mouse.wheelup && driver.menu->begin > 0)
|
|
|
|
driver.menu->begin--;
|
2014-04-13 10:12:12 +00:00
|
|
|
|
2014-09-02 14:03:17 +00:00
|
|
|
/* Do not scroll if all items are visible. */
|
2014-10-18 00:32:59 +00:00
|
|
|
if (menu_list_get_size(driver.menu->menu_list) <= RGUI_TERM_HEIGHT)
|
2014-10-26 21:31:53 +00:00
|
|
|
driver.menu->begin = 0;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 21:31:53 +00:00
|
|
|
end = (driver.menu->begin + RGUI_TERM_HEIGHT <=
|
|
|
|
menu_list_get_size(driver.menu->menu_list)) ?
|
|
|
|
driver.menu->begin + RGUI_TERM_HEIGHT :
|
|
|
|
menu_list_get_size(driver.menu->menu_list);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_render_background(rgui);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-17 23:59:16 +00:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list,
|
2014-10-17 23:17:00 +00:00
|
|
|
&dir, &label, &menu_type);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-08-31 17:47:45 +00:00
|
|
|
#if 0
|
2014-09-02 23:51:29 +00:00
|
|
|
RARCH_LOG("Dir is: %s\n", label);
|
2014-08-31 17:47:45 +00:00
|
|
|
#endif
|
|
|
|
|
2014-09-16 02:21:31 +00:00
|
|
|
get_title(label, dir, menu_type, title, sizeof(title));
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-08-31 23:59:30 +00:00
|
|
|
menu_ticker_line(title_buf, RGUI_TERM_WIDTH - 3,
|
2014-09-06 01:17:51 +00:00
|
|
|
g_extern.frame_count / RGUI_TERM_START_X, title, true);
|
|
|
|
blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-09-07 05:12:10 +00:00
|
|
|
const char *core_name = g_extern.menu.info.library_name;
|
2013-11-04 12:27:03 +00:00
|
|
|
if (!core_name)
|
|
|
|
core_name = g_extern.system.info.library_name;
|
|
|
|
if (!core_name)
|
|
|
|
core_name = "No Core";
|
|
|
|
|
2014-09-07 05:12:10 +00:00
|
|
|
const char *core_version = g_extern.menu.info.library_version;
|
2013-11-04 12:27:03 +00:00
|
|
|
if (!core_version)
|
|
|
|
core_version = g_extern.system.info.library_version;
|
|
|
|
if (!core_version)
|
|
|
|
core_version = "";
|
|
|
|
|
2014-08-31 23:59:30 +00:00
|
|
|
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
|
|
|
|
core_name, core_version);
|
2014-09-09 02:04:12 +00:00
|
|
|
blit_line(
|
|
|
|
RGUI_TERM_START_X + RGUI_TERM_START_X,
|
|
|
|
(RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) +
|
2014-08-31 23:59:30 +00:00
|
|
|
RGUI_TERM_START_Y + 2, title_msg, true);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
|
|
|
|
2014-02-28 00:34:10 +00:00
|
|
|
x = RGUI_TERM_START_X;
|
|
|
|
y = RGUI_TERM_START_Y;
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-10-26 21:31:53 +00:00
|
|
|
for (i = driver.menu->begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
|
2013-11-04 12:27:03 +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-10 23:57:25 +00:00
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
2014-09-10 16:26:02 +00:00
|
|
|
bool selected = false;
|
|
|
|
|
2014-10-17 23:17:00 +00:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
2014-09-02 23:51:29 +00:00
|
|
|
&entry_label, &type);
|
2014-08-29 23:56:12 +00:00
|
|
|
rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
|
2014-10-08 22:50:35 +00:00
|
|
|
driver.menu->list_settings,
|
2014-10-17 23:17:00 +00:00
|
|
|
driver.menu->menu_list->selection_buf->list[i].label);
|
2014-09-04 16:40:12 +00:00
|
|
|
(void)setting;
|
|
|
|
|
2014-10-20 17:54:55 +00:00
|
|
|
disp_set_label(driver.menu->menu_list->selection_buf, &w, type, i, label,
|
2014-09-10 16:26:02 +00:00
|
|
|
type_str, sizeof(type_str),
|
2014-09-10 23:57:25 +00:00
|
|
|
entry_label, path,
|
|
|
|
path_buf, sizeof(path_buf));
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-09-10 16:26:02 +00:00
|
|
|
selected = (i == driver.menu->selection_ptr);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
2014-08-31 23:59:30 +00:00
|
|
|
menu_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
|
2014-09-10 23:57:25 +00:00
|
|
|
g_extern.frame_count / RGUI_TERM_START_X, path_buf, selected);
|
2014-09-06 01:17:51 +00:00
|
|
|
menu_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X,
|
2014-08-31 23:59:30 +00:00
|
|
|
type_str, selected);
|
2013-11-04 12:27:03 +00:00
|
|
|
|
|
|
|
snprintf(message, sizeof(message), "%c %-*.*s %-*s",
|
|
|
|
selected ? '>' : ' ',
|
2014-09-09 02:04:12 +00:00
|
|
|
RGUI_TERM_WIDTH - (w + 1 + 2),
|
|
|
|
RGUI_TERM_WIDTH - (w + 1 + 2),
|
2013-11-04 12:27:03 +00:00
|
|
|
entry_title_buf,
|
|
|
|
w,
|
|
|
|
type_str_buf);
|
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
blit_line(x, y, message, selected);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GEKKO
|
|
|
|
const char *message_queue;
|
|
|
|
|
2014-05-31 20:20:27 +00:00
|
|
|
if (driver.menu->msg_force)
|
2013-11-04 12:27:03 +00:00
|
|
|
{
|
|
|
|
message_queue = msg_queue_pull(g_extern.msg_queue);
|
2014-05-31 20:20:27 +00:00
|
|
|
driver.menu->msg_force = false;
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
message_queue = driver.current_msg;
|
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
rgui_render_messagebox(message_queue);
|
2013-11-04 12:27:03 +00:00
|
|
|
#endif
|
2013-12-09 15:18:58 +00:00
|
|
|
|
2014-05-31 20:20:27 +00:00
|
|
|
if (driver.menu->keyboard.display)
|
2013-12-09 15:18:58 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
char msg[PATH_MAX_LENGTH];
|
2014-05-31 20:20:27 +00:00
|
|
|
const char *str = *driver.menu->keyboard.buffer;
|
2013-12-10 18:39:09 +00:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
2014-05-31 20:20:27 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
2014-05-30 19:51:12 +00:00
|
|
|
rgui_render_messagebox(msg);
|
2013-12-09 15:18:58 +00:00
|
|
|
}
|
2014-10-25 21:21:28 +00:00
|
|
|
|
2014-10-26 17:06:57 +00:00
|
|
|
if (driver.menu->mouse.enable)
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_blit_cursor(rgui);
|
2013-11-04 12:27:03 +00:00
|
|
|
}
|
2013-09-28 02:45:44 +00:00
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
static void *rgui_init(void)
|
2012-05-06 02:04:33 +00:00
|
|
|
{
|
2015-01-04 14:22:49 +00:00
|
|
|
bool ret = false;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2014-05-30 18:41:31 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-10-11 01:02:49 +00:00
|
|
|
menu->userdata = (rgui_handle_t*)calloc(1, sizeof(rgui_handle_t));
|
|
|
|
|
|
|
|
if (!menu->userdata)
|
2014-10-13 20:55:15 +00:00
|
|
|
{
|
|
|
|
free(menu);
|
2014-10-11 01:02:49 +00:00
|
|
|
return NULL;
|
2014-10-13 20:55:15 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui = (rgui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
rgui->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t));
|
2014-10-11 01:02:49 +00:00
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
if (!rgui->frame_buf)
|
2014-10-13 20:55:15 +00:00
|
|
|
{
|
2014-10-14 04:31:55 +00:00
|
|
|
free(menu->userdata);
|
2014-10-13 20:55:15 +00:00
|
|
|
free(menu);
|
2014-10-11 01:02:49 +00:00
|
|
|
return NULL;
|
2014-10-13 20:55:15 +00:00
|
|
|
}
|
2014-10-11 01:02:49 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
menu->width = 320;
|
|
|
|
menu->height = 240;
|
2014-10-26 21:31:53 +00:00
|
|
|
menu->begin = 0;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui->frame_buf_pitch = menu->width * sizeof(uint16_t);
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2015-01-04 14:22:49 +00:00
|
|
|
ret = rguidisp_init_font(menu);
|
2013-09-28 02:45:44 +00:00
|
|
|
|
|
|
|
if (!ret)
|
2012-08-27 00:33:22 +00:00
|
|
|
{
|
2013-09-28 02:45:44 +00:00
|
|
|
RARCH_ERR("No font bitmap or binary, abort");
|
2014-09-09 02:04:12 +00:00
|
|
|
|
2014-09-01 01:08:27 +00:00
|
|
|
rarch_main_command(RARCH_CMD_QUIT_RETROARCH);
|
2014-10-13 20:55:15 +00:00
|
|
|
|
|
|
|
free(menu->userdata);
|
|
|
|
free(menu);
|
2013-04-18 20:22:25 +00:00
|
|
|
return NULL;
|
2012-08-27 00:33:22 +00:00
|
|
|
}
|
2012-05-06 02:04:33 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
return menu;
|
2012-05-06 02:04:33 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 13:01:17 +00:00
|
|
|
static void rgui_free(void *data)
|
2012-05-06 02:04:33 +00:00
|
|
|
{
|
2014-10-11 01:02:49 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-05-30 18:41:31 +00:00
|
|
|
|
2014-10-11 01:02:49 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rgui = (rgui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
return;
|
|
|
|
|
2014-10-26 22:43:33 +00:00
|
|
|
if (rgui->frame_buf)
|
|
|
|
free(rgui->frame_buf);
|
2014-10-11 01:02:49 +00:00
|
|
|
|
|
|
|
if (menu->userdata)
|
|
|
|
free(menu->userdata);
|
|
|
|
driver.menu->userdata = NULL;
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (menu->alloc_font)
|
|
|
|
free((uint8_t*)menu->font);
|
2012-05-06 02:04:33 +00:00
|
|
|
}
|
|
|
|
|
2014-10-14 16:54:40 +00:00
|
|
|
static void rgui_set_texture(void *data)
|
2013-11-04 15:23:37 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = (rgui_handle_t*)menu->userdata;
|
2013-11-04 15:23:37 +00:00
|
|
|
|
2014-08-31 23:59:30 +00:00
|
|
|
if (driver.video_data && driver.video_poke &&
|
|
|
|
driver.video_poke->set_texture_frame)
|
|
|
|
driver.video_poke->set_texture_frame(driver.video_data,
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui->frame_buf, false, menu->width, menu->height, 1.0f);
|
2013-11-04 15:23:37 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 21:31:53 +00:00
|
|
|
static void rgui_navigation_clear(void *data, bool pending_push)
|
|
|
|
{
|
|
|
|
driver.menu->begin = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgui_navigation_set(void *data, bool scroll)
|
|
|
|
{
|
2014-10-26 22:43:33 +00:00
|
|
|
rgui_handle_t *rgui = NULL;
|
|
|
|
|
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rgui = (rgui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!rgui)
|
|
|
|
return;
|
|
|
|
|
2014-10-26 21:31:53 +00:00
|
|
|
if (!scroll)
|
|
|
|
return;
|
|
|
|
|
2014-10-26 21:39:26 +00:00
|
|
|
if (driver.menu->selection_ptr < RGUI_TERM_HEIGHT/2)
|
|
|
|
driver.menu->begin = 0;
|
|
|
|
else if (driver.menu->selection_ptr >= RGUI_TERM_HEIGHT/2
|
|
|
|
&& driver.menu->selection_ptr <
|
|
|
|
menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT/2)
|
|
|
|
driver.menu->begin = driver.menu->selection_ptr - RGUI_TERM_HEIGHT/2;
|
|
|
|
else if (driver.menu->selection_ptr >=
|
|
|
|
menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT/2)
|
|
|
|
driver.menu->begin = menu_list_get_size(driver.menu->menu_list)
|
|
|
|
- RGUI_TERM_HEIGHT;
|
2014-10-26 21:31:53 +00:00
|
|
|
}
|
|
|
|
|
2014-12-15 17:56:49 +00:00
|
|
|
static void rgui_navigation_set_last(void *data)
|
|
|
|
{
|
|
|
|
rgui_navigation_set(data, true);
|
|
|
|
}
|
|
|
|
|
2014-12-15 18:03:47 +00:00
|
|
|
static void rgui_navigation_descend_alphabet(void *data, size_t *unused)
|
|
|
|
{
|
|
|
|
rgui_navigation_set(data, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rgui_navigation_ascend_alphabet(void *data, size_t *unused)
|
|
|
|
{
|
|
|
|
rgui_navigation_set(data, true);
|
|
|
|
}
|
|
|
|
|
2014-11-25 02:49:26 +00:00
|
|
|
static void rgui_update_core_info(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
menu_update_libretro_info(&g_extern.menu.info);
|
|
|
|
}
|
|
|
|
|
2015-01-04 14:52:46 +00:00
|
|
|
static void rgui_populate_entries(void *data, const char *path,
|
|
|
|
const char *label, unsigned k)
|
|
|
|
{
|
|
|
|
rgui_navigation_set(data, true);
|
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_rgui = {
|
2013-11-04 15:23:37 +00:00
|
|
|
rgui_set_texture,
|
|
|
|
rgui_render_messagebox,
|
|
|
|
rgui_render,
|
2014-04-01 02:45:00 +00:00
|
|
|
NULL,
|
2013-09-19 12:49:07 +00:00
|
|
|
rgui_init,
|
2014-10-08 23:31:11 +00:00
|
|
|
NULL,
|
2013-09-19 12:49:07 +00:00
|
|
|
rgui_free,
|
2013-11-08 14:13:14 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2015-01-04 14:52:46 +00:00
|
|
|
rgui_populate_entries,
|
2013-11-19 05:35:11 +00:00
|
|
|
NULL,
|
2014-09-29 12:55:35 +00:00
|
|
|
NULL,
|
2014-10-26 21:31:53 +00:00
|
|
|
rgui_navigation_clear,
|
2014-04-13 21:41:47 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-10-26 21:31:53 +00:00
|
|
|
rgui_navigation_set,
|
2014-12-15 17:56:49 +00:00
|
|
|
rgui_navigation_set_last,
|
2014-12-15 18:03:47 +00:00
|
|
|
rgui_navigation_descend_alphabet,
|
|
|
|
rgui_navigation_ascend_alphabet,
|
2014-04-13 22:09:52 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-09-03 12:57:29 +00:00
|
|
|
NULL,
|
2014-11-27 15:28:45 +00:00
|
|
|
NULL,
|
2014-11-25 02:49:26 +00:00
|
|
|
rgui_update_core_info,
|
2014-04-14 00:32:54 +00:00
|
|
|
&menu_ctx_backend_common,
|
2013-09-19 12:49:07 +00:00
|
|
|
"rgui",
|
|
|
|
};
|