2016-02-14 14:30:28 -05:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2014-2015 - Jean-André Santoni
|
2016-02-24 16:08:36 -05:00
|
|
|
* Copyright (C) 2016 - Andrés Suárez
|
2016-02-14 14:30:28 -05: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 <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
2016-02-25 21:29:38 +01:00
|
|
|
#include <math.h>
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-02-25 21:29:38 +01:00
|
|
|
#include <retro_assert.h>
|
2016-02-14 14:30:28 -05:00
|
|
|
#include <compat/posix_string.h>
|
|
|
|
#include <file/file_path.h>
|
|
|
|
#include <formats/image.h>
|
|
|
|
#include <gfx/math/matrix_4x4.h>
|
|
|
|
#include <string/stdstring.h>
|
2016-03-20 14:53:54 +01:00
|
|
|
#include <lists/string_list.h>
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
#include "menu_generic.h"
|
2016-03-09 15:33:27 -05:00
|
|
|
#include "zr_menu.h"
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
#include "../menu_driver.h"
|
|
|
|
#include "../menu_animation.h"
|
|
|
|
#include "../menu_navigation.h"
|
|
|
|
#include "../menu_hash.h"
|
|
|
|
#include "../menu_display.h"
|
|
|
|
|
|
|
|
#include "../../core_info.h"
|
|
|
|
#include "../../configuration.h"
|
|
|
|
#include "../../frontend/frontend_driver.h"
|
|
|
|
#include "../../system.h"
|
|
|
|
#include "../../runloop.h"
|
|
|
|
#include "../../verbosity.h"
|
|
|
|
#include "../../tasks/tasks_internal.h"
|
2016-03-04 19:46:25 +01:00
|
|
|
|
2016-03-05 21:11:03 -05:00
|
|
|
static void zrmenu_main(zrmenu_handle_t *zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
2016-03-05 21:13:14 -05:00
|
|
|
struct zr_context *ctx = &zr->ctx;
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-06 14:13:20 -05:00
|
|
|
if (zr->window[ZRMENU_WND_MAIN].open)
|
2016-03-09 20:14:01 -05:00
|
|
|
zrmenu_wnd_main(zr);
|
2016-03-06 14:13:20 -05:00
|
|
|
if (zr->window[ZRMENU_WND_CONTROL].open)
|
2016-03-09 20:14:01 -05:00
|
|
|
zrmenu_wnd_control(zr);
|
2016-03-06 14:13:20 -05:00
|
|
|
if (zr->window[ZRMENU_WND_SHADER_PARAMETERS].open)
|
2016-03-09 20:14:01 -05:00
|
|
|
zrmenu_wnd_shader_parameters(zr);
|
2016-03-06 14:13:20 -05:00
|
|
|
if (zr->window[ZRMENU_WND_TEST].open)
|
2016-03-09 20:14:01 -05:00
|
|
|
zrmenu_wnd_test(zr);
|
2016-03-06 14:13:20 -05:00
|
|
|
if (zr->window[ZRMENU_WND_WIZARD].open)
|
2016-03-09 20:14:01 -05:00
|
|
|
zrmenu_wnd_wizard(zr);
|
2016-03-02 17:14:35 -05:00
|
|
|
|
2016-03-06 14:13:20 -05:00
|
|
|
zr->window[ZRMENU_WND_CONTROL].open = !zr_window_is_closed(ctx, "Control");
|
|
|
|
zr->window[ZRMENU_WND_SHADER_PARAMETERS].open = !zr_window_is_closed(ctx, "Shader Parameters");
|
|
|
|
zr->window[ZRMENU_WND_TEST].open = !zr_window_is_closed(ctx, "Test");
|
|
|
|
zr->window[ZRMENU_WND_WIZARD].open = !zr_window_is_closed(ctx, "Setup Wizard");
|
2016-03-05 22:24:01 -05:00
|
|
|
|
|
|
|
if(zr_window_is_closed(ctx, "Setup Wizard"))
|
2016-03-06 14:13:20 -05:00
|
|
|
zr->window[ZRMENU_WND_MAIN].open = true;
|
2016-03-05 22:24:01 -05:00
|
|
|
|
2016-03-05 21:13:14 -05:00
|
|
|
zr_buffer_info(&zr->status, &zr->ctx.memory);
|
2016-02-14 14:30:28 -05:00
|
|
|
}
|
|
|
|
|
2016-03-23 23:31:15 -05:00
|
|
|
static void zrmenu_input_gamepad(zrmenu_handle_t *zr)
|
|
|
|
{
|
|
|
|
switch (zr->action)
|
|
|
|
{
|
|
|
|
case MENU_ACTION_LEFT:
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_LEFT, 1);
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_RIGHT:
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_RIGHT, 1);
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_DOWN:
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_DOWN, 1);
|
|
|
|
break;
|
|
|
|
case MENU_ACTION_UP:
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_UP, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_UP, 0);
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_DOWN, 0);
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_LEFT, 0);
|
|
|
|
zr_input_key(&zr->ctx, ZR_KEY_RIGHT, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-25 23:08:33 -05:00
|
|
|
static void zrmenu_input_mouse_movement(struct zr_context *ctx)
|
2016-02-14 20:42:45 -05:00
|
|
|
{
|
|
|
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
2016-03-02 17:14:35 -05:00
|
|
|
|
2016-02-14 20:42:45 -05:00
|
|
|
zr_input_motion(ctx, mouse_x, mouse_y);
|
2016-03-05 01:26:45 -05:00
|
|
|
zr_input_scroll(ctx, menu_input_mouse_state(MENU_MOUSE_WHEEL_UP) -
|
|
|
|
menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN));
|
|
|
|
|
2016-02-14 20:42:45 -05:00
|
|
|
}
|
|
|
|
|
2016-02-25 23:08:33 -05:00
|
|
|
static void zrmenu_input_mouse_button(struct zr_context *ctx)
|
2016-02-14 20:42:45 -05:00
|
|
|
{
|
|
|
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
2016-02-14 21:12:06 -05:00
|
|
|
|
2016-02-25 21:29:38 +01:00
|
|
|
zr_input_button(ctx, ZR_BUTTON_LEFT,
|
|
|
|
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON));
|
|
|
|
zr_input_button(ctx, ZR_BUTTON_RIGHT,
|
|
|
|
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON));
|
2016-02-14 20:42:45 -05:00
|
|
|
}
|
|
|
|
|
2016-02-28 23:35:03 -05:00
|
|
|
static void zrmenu_input_keyboard(struct zr_context *ctx)
|
|
|
|
{
|
2016-03-02 17:14:35 -05:00
|
|
|
/* placeholder, it just presses 1 on right click
|
2016-02-28 23:35:03 -05:00
|
|
|
needs to be hooked up correctly
|
|
|
|
*/
|
|
|
|
if(menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON))
|
|
|
|
zr_input_char(ctx, '1');
|
|
|
|
}
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
static void zrmenu_context_reset_textures(zrmenu_handle_t *zr,
|
2016-02-14 14:30:28 -05:00
|
|
|
const char *iconpath)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2016-02-25 21:47:32 +01:00
|
|
|
for (i = 0; i < ZR_TEXTURE_LAST; i++)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
|
|
|
struct texture_image ti = {0};
|
|
|
|
char path[PATH_MAX_LENGTH] = {0};
|
|
|
|
|
|
|
|
switch(i)
|
|
|
|
{
|
2016-02-25 21:47:32 +01:00
|
|
|
case ZR_TEXTURE_POINTER:
|
2016-02-14 14:30:28 -05:00
|
|
|
fill_pathname_join(path, iconpath,
|
|
|
|
"pointer.png", sizeof(path));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string_is_empty(path) || !path_file_exists(path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
video_texture_image_load(&ti, path);
|
|
|
|
video_driver_texture_load(&ti,
|
2016-03-05 08:42:35 +01:00
|
|
|
TEXTURE_FILTER_MIPMAP_LINEAR, &zr->textures.list[i]);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
video_texture_image_free(&ti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 15:08:30 -05:00
|
|
|
static void zrmenu_get_message(void *data, const char *message)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)data;
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr || !message || !*message)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
strlcpy(zr->box_message, message, sizeof(zr->box_message));
|
2016-02-14 14:30:28 -05:00
|
|
|
}
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
static void zrmenu_draw_cursor(zrmenu_handle_t *zr,
|
2016-02-14 14:30:28 -05:00
|
|
|
float *color,
|
|
|
|
float x, float y, unsigned width, unsigned height)
|
|
|
|
{
|
|
|
|
menu_display_ctx_draw_t draw;
|
|
|
|
struct gfx_coords coords;
|
|
|
|
|
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = NULL;
|
|
|
|
coords.tex_coord = NULL;
|
|
|
|
coords.lut_tex_coord = NULL;
|
|
|
|
coords.color = (const float*)color;
|
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
|
|
|
|
|
|
|
draw.x = x - 32;
|
|
|
|
draw.y = (int)height - y - 32;
|
|
|
|
draw.width = 64;
|
|
|
|
draw.height = 64;
|
|
|
|
draw.coords = &coords;
|
|
|
|
draw.matrix_data = NULL;
|
2016-03-05 08:42:35 +01:00
|
|
|
draw.texture = zr->textures.list[ZR_TEXTURE_POINTER];
|
2016-02-14 14:30:28 -05:00
|
|
|
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw);
|
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL);
|
|
|
|
}
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
static void zrmenu_frame(void *data)
|
2016-03-02 17:14:35 -05:00
|
|
|
{
|
2016-02-14 14:30:28 -05:00
|
|
|
float white_bg[16]= {
|
|
|
|
0.98, 0.98, 0.98, 1,
|
|
|
|
0.98, 0.98, 0.98, 1,
|
|
|
|
0.98, 0.98, 0.98, 1,
|
|
|
|
0.98, 0.98, 0.98, 1,
|
|
|
|
};
|
2016-03-02 19:23:34 -05:00
|
|
|
|
2016-02-14 14:30:28 -05:00
|
|
|
unsigned width, height, ticker_limit, i;
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)data;
|
|
|
|
settings_t *settings = config_get_ptr();
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-07 00:27:22 -05:00
|
|
|
bool libretro_running = menu_display_ctl(
|
|
|
|
MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL);
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
video_driver_get_size(&width, &height);
|
|
|
|
|
2016-02-25 23:08:33 -05:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 21:13:14 -05:00
|
|
|
zr_input_begin(&zr->ctx);
|
2016-03-23 23:31:15 -05:00
|
|
|
zrmenu_input_gamepad(zr);
|
2016-03-05 21:13:14 -05:00
|
|
|
zrmenu_input_mouse_movement(&zr->ctx);
|
|
|
|
zrmenu_input_mouse_button(&zr->ctx);
|
|
|
|
zrmenu_input_keyboard(&zr->ctx);
|
2016-02-28 23:35:03 -05:00
|
|
|
|
2016-03-06 14:13:20 -05:00
|
|
|
if (width != zr->size.x || height != zr->size.y)
|
2016-03-05 00:50:49 -05:00
|
|
|
{
|
2016-03-06 14:13:20 -05:00
|
|
|
zr->size.x = width;
|
|
|
|
zr->size.y = height;
|
|
|
|
zr->size_changed = true;
|
2016-03-05 00:50:49 -05:00
|
|
|
}
|
|
|
|
|
2016-03-05 21:13:14 -05:00
|
|
|
zr_input_end(&zr->ctx);
|
2016-03-05 21:11:03 -05:00
|
|
|
zrmenu_main(zr);
|
2016-03-09 15:33:27 -05:00
|
|
|
zr_common_device_draw(&device, &zr->ctx, width, height, ZR_ANTI_ALIASING_ON);
|
2016-02-14 21:01:27 -05:00
|
|
|
|
2016-02-27 14:59:42 -05:00
|
|
|
if (settings->menu.mouse.enable && (settings->video.fullscreen
|
|
|
|
|| !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)))
|
|
|
|
{
|
|
|
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_draw_cursor(zr, &white_bg[0], mouse_x, mouse_y, width, height);
|
2016-02-27 14:59:42 -05:00
|
|
|
}
|
|
|
|
|
2016-02-14 14:30:28 -05:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, NULL);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL);
|
|
|
|
}
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
static void zrmenu_layout(zrmenu_handle_t *zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
|
|
|
void *fb_buf;
|
|
|
|
float scale_factor;
|
|
|
|
unsigned width, height, new_header_height;
|
|
|
|
|
|
|
|
video_driver_get_size(&width, &height);
|
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_GET_DPI, &scale_factor);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT,
|
|
|
|
&new_header_height);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-05 21:11:03 -05:00
|
|
|
static void zrmenu_init_device(zrmenu_handle_t *zr)
|
2016-03-05 00:50:49 -05:00
|
|
|
{
|
2016-03-05 22:54:56 -05:00
|
|
|
char buf[PATH_MAX_LENGTH];
|
|
|
|
fill_pathname_join(buf, zr->assets_directory,
|
|
|
|
"DroidSans.ttf", sizeof(buf));
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
zr_alloc.userdata.ptr = NULL;
|
2016-03-09 15:33:27 -05:00
|
|
|
zr_alloc.alloc = zr_common_mem_alloc;
|
|
|
|
zr_alloc.free = zr_common_mem_free;
|
2016-03-05 00:50:49 -05:00
|
|
|
zr_buffer_init(&device.cmds, &zr_alloc, 1024);
|
2016-03-09 15:33:27 -05:00
|
|
|
usrfnt = zr_common_font(&device, &font, buf, 16,
|
2016-03-05 00:50:49 -05:00
|
|
|
zr_font_default_glyph_ranges());
|
2016-03-05 21:13:14 -05:00
|
|
|
zr_init(&zr->ctx, &zr_alloc, &usrfnt);
|
2016-03-09 15:33:27 -05:00
|
|
|
zr_common_device_init(&device);
|
2016-03-05 22:54:56 -05:00
|
|
|
|
|
|
|
fill_pathname_join(buf, zr->assets_directory, "folder.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.folder = zr_common_image_load(buf);
|
2016-03-05 23:02:29 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "speaker.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.speaker = zr_common_image_load(buf);
|
2016-03-07 00:27:22 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "gamepad.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.gamepad = zr_common_image_load(buf);
|
2016-03-07 00:27:22 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "monitor.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.monitor = zr_common_image_load(buf);
|
2016-03-07 00:27:22 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "settings.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.settings = zr_common_image_load(buf);
|
2016-03-07 00:27:22 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "invader.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.invader = zr_common_image_load(buf);
|
2016-03-07 18:17:44 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "page_on.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.page_on = zr_common_image_load(buf);
|
2016-03-07 18:17:44 -05:00
|
|
|
fill_pathname_join(buf, zr->assets_directory, "page_off.png", sizeof(buf));
|
2016-03-09 15:33:27 -05:00
|
|
|
zr->icons.page_off = zr_common_image_load(buf);
|
2016-03-05 22:54:56 -05:00
|
|
|
|
2016-03-05 21:13:14 -05:00
|
|
|
zrmenu_set_style(&zr->ctx, THEME_DARK);
|
2016-03-06 16:19:12 -05:00
|
|
|
zr->size_changed = true;
|
2016-03-05 00:50:49 -05:00
|
|
|
}
|
|
|
|
|
2016-03-04 15:08:30 -05:00
|
|
|
static void *zrmenu_init(void **userdata)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
2016-02-14 16:17:34 -05:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = NULL;
|
2016-02-14 14:30:28 -05:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)
|
|
|
|
calloc(1, sizeof(*menu));
|
2016-02-25 23:08:33 -05:00
|
|
|
unsigned width, height = 0;
|
|
|
|
|
|
|
|
video_driver_get_size(&width, &height);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, NULL))
|
|
|
|
goto error;
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
zr = (zrmenu_handle_t*)calloc(1, sizeof(zrmenu_handle_t));
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
goto error;
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
*userdata = zr;
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 22:54:56 -05:00
|
|
|
fill_pathname_join(zr->assets_directory, settings->assets_directory,
|
|
|
|
"zahnrad", sizeof(zr->assets_directory));
|
2016-03-05 21:11:03 -05:00
|
|
|
zrmenu_init_device(zr);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-06 14:13:20 -05:00
|
|
|
zr->window[ZRMENU_WND_WIZARD].open = true;
|
2016-03-05 22:24:01 -05:00
|
|
|
|
2016-02-14 14:30:28 -05:00
|
|
|
return menu;
|
|
|
|
error:
|
|
|
|
if (menu)
|
|
|
|
free(menu);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-03-04 15:08:30 -05:00
|
|
|
static void zrmenu_free(void *data)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)data;
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
2016-02-14 16:17:34 -05:00
|
|
|
|
2016-03-04 15:08:30 -05:00
|
|
|
free(font.glyphs);
|
2016-03-05 21:13:14 -05:00
|
|
|
zr_free(&zr->ctx);
|
2016-03-04 15:08:30 -05:00
|
|
|
zr_buffer_free(&device.cmds);
|
2016-03-09 15:33:27 -05:00
|
|
|
zr_common_device_shutdown(&device);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
gfx_coord_array_free(&zr->list_block.carr);
|
2016-02-14 14:30:28 -05:00
|
|
|
font_driver_bind_block(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
static void wimp_context_bg_destroy(zrmenu_handle_t *zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-03 22:31:22 -05:00
|
|
|
static void zrmenu_context_destroy(void *data)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
|
|
|
unsigned i;
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)data;
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
|
|
|
|
2016-02-25 21:47:32 +01:00
|
|
|
for (i = 0; i < ZR_TEXTURE_LAST; i++)
|
2016-03-05 08:42:35 +01:00
|
|
|
video_driver_texture_unload((uintptr_t*)&zr->textures.list[i]);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL);
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
wimp_context_bg_destroy(zr);
|
2016-02-14 14:30:28 -05:00
|
|
|
}
|
|
|
|
|
2016-03-03 22:31:22 -05:00
|
|
|
static void zrmenu_context_reset(void *data)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
|
|
|
char iconpath[PATH_MAX_LENGTH] = {0};
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)data;
|
2016-02-14 14:30:28 -05:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-02-25 23:08:33 -05:00
|
|
|
unsigned width, height = 0;
|
|
|
|
|
|
|
|
video_driver_get_size(&width, &height);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
if (!zr || !settings)
|
2016-02-14 14:30:28 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
fill_pathname_join(iconpath, settings->assets_directory,
|
2016-02-27 15:02:13 -05:00
|
|
|
"zahnrad", sizeof(iconpath));
|
2016-02-14 14:30:28 -05:00
|
|
|
fill_pathname_slash(iconpath, sizeof(iconpath));
|
|
|
|
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_layout(zr);
|
2016-03-05 21:11:03 -05:00
|
|
|
zrmenu_init_device(zr);
|
2016-03-05 00:50:49 -05:00
|
|
|
|
|
|
|
wimp_context_bg_destroy(zr);
|
|
|
|
zrmenu_context_reset_textures(zr, iconpath);
|
2016-02-14 14:30:28 -05:00
|
|
|
|
|
|
|
rarch_task_push_image_load(settings->menu.wallpaper, "cb_menu_wallpaper",
|
|
|
|
menu_display_handle_wallpaper_upload, NULL);
|
|
|
|
}
|
|
|
|
|
2016-03-05 21:59:01 -05:00
|
|
|
static int zrmenu_environ(enum menu_environ_cb type, void *data, void *userdata)
|
2016-02-14 14:30:28 -05:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-03-03 22:31:22 -05:00
|
|
|
static bool zrmenu_init_list(void *data)
|
2016-03-02 22:40:38 -05:00
|
|
|
{
|
|
|
|
menu_displaylist_info_t info = {0};
|
|
|
|
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
|
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
|
|
|
|
|
|
|
strlcpy(info.label,
|
|
|
|
menu_hash_to_str(MENU_VALUE_HISTORY_TAB), sizeof(info.label));
|
|
|
|
|
2016-04-11 05:49:39 +02:00
|
|
|
menu_entries_add(menu_stack,
|
2016-03-02 22:40:38 -05:00
|
|
|
info.path, info.label, info.type, info.flags, 0);
|
|
|
|
|
|
|
|
event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL);
|
|
|
|
|
|
|
|
info.list = selection_buf;
|
|
|
|
|
|
|
|
if (menu_displaylist_ctl(DISPLAYLIST_HISTORY, &info))
|
|
|
|
{
|
|
|
|
info.need_push = true;
|
|
|
|
return menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-23 23:31:15 -05:00
|
|
|
static int zrmenu_iterate(void *data, void *userdata, enum menu_action action)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
size_t selection;
|
|
|
|
menu_entry_t entry;
|
|
|
|
zrmenu_handle_t *zr = (zrmenu_handle_t*)userdata;
|
|
|
|
|
|
|
|
if (!zr)
|
|
|
|
return -1;
|
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
menu_entry_get(&entry, 0, selection, NULL, false);
|
|
|
|
|
|
|
|
zr->action = action;
|
|
|
|
|
|
|
|
ret = menu_entry_action(&entry, selection, action);
|
|
|
|
if (ret)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-25 21:29:38 +01:00
|
|
|
menu_ctx_driver_t menu_ctx_zr = {
|
2016-02-14 14:30:28 -05:00
|
|
|
NULL,
|
2016-03-04 15:08:30 -05:00
|
|
|
zrmenu_get_message,
|
2016-03-23 23:31:15 -05:00
|
|
|
zrmenu_iterate,
|
2016-03-03 22:31:22 -05:00
|
|
|
NULL,
|
2016-03-05 00:50:49 -05:00
|
|
|
zrmenu_frame,
|
2016-03-04 15:08:30 -05:00
|
|
|
zrmenu_init,
|
|
|
|
zrmenu_free,
|
2016-03-03 22:31:22 -05:00
|
|
|
zrmenu_context_reset,
|
|
|
|
zrmenu_context_destroy,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
zrmenu_init_list,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2016-02-14 14:30:28 -05:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2016-02-26 12:21:42 +01:00
|
|
|
"zahnrad",
|
2016-03-05 21:59:01 -05:00
|
|
|
zrmenu_environ,
|
2016-02-26 15:57:22 +01:00
|
|
|
NULL,
|
2016-02-14 14:30:28 -05:00
|
|
|
};
|