2012-04-21 23:13:50 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 17:46:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2015-01-07 18:24:13 +01:00
|
|
|
* Copyright (C) 2015- - Swizzy
|
2012-01-22 01:43:54 +01:00
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2012-01-22 01:43:54 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2012-01-22 01:43:54 +01:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 23:31:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2012-01-22 01:43:54 +01:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-01-23 22:22:54 +01:00
|
|
|
#include <stdint.h>
|
2012-01-22 01:43:54 +01:00
|
|
|
#include <xtl.h>
|
2013-03-09 22:30:35 +01:00
|
|
|
#include <xui.h>
|
|
|
|
#include <xuiapp.h>
|
2013-01-09 17:49:43 +01:00
|
|
|
|
2014-09-16 00:52:07 +02:00
|
|
|
#include "menu_display.h"
|
2014-10-17 22:53:30 +02:00
|
|
|
#include "../menu_list.h"
|
2013-12-29 04:26:34 +01:00
|
|
|
#include "../menu_common.h"
|
2012-07-28 16:10:31 +02:00
|
|
|
|
2014-10-28 19:54:23 +01:00
|
|
|
#include "../../gfx/gfx_common.h"
|
|
|
|
#include "../../gfx/gfx_context.h"
|
2012-09-30 18:29:32 +02:00
|
|
|
|
2014-10-28 19:54:23 +01:00
|
|
|
#include "../../settings_data.h"
|
|
|
|
#include "../../message_queue.h"
|
|
|
|
#include "../../general.h"
|
2012-01-24 01:06:12 +01:00
|
|
|
|
2014-09-14 06:45:47 +02:00
|
|
|
#include "../../gfx/d3d/d3d.hpp"
|
2014-09-12 18:01:32 +02:00
|
|
|
|
2014-09-03 01:51:29 +02:00
|
|
|
#include "shared.h"
|
|
|
|
|
2013-11-19 06:42:27 +01:00
|
|
|
#define XUI_CONTROL_NAVIGATE_OK (XUI_CONTROL_NAVIGATE_RIGHT + 1)
|
|
|
|
|
2014-02-28 21:24:39 +01:00
|
|
|
#define FONT_WIDTH 5
|
|
|
|
#define FONT_HEIGHT 10
|
|
|
|
#define FONT_WIDTH_STRIDE (FONT_WIDTH + 1)
|
|
|
|
#define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1)
|
2014-02-28 21:15:16 +01:00
|
|
|
#define RXUI_TERM_START_X 15
|
|
|
|
#define RXUI_TERM_START_Y 27
|
2014-06-01 02:33:43 +02:00
|
|
|
#define RXUI_TERM_WIDTH (((driver.menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE)))
|
|
|
|
#define RXUI_TERM_HEIGHT (((driver.menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1)
|
2013-03-30 08:16:58 +01:00
|
|
|
|
2013-05-09 15:12:22 +02:00
|
|
|
HXUIOBJ m_menulist;
|
|
|
|
HXUIOBJ m_menutitle;
|
2013-05-09 18:12:54 +02:00
|
|
|
HXUIOBJ m_menutitlebottom;
|
2013-05-06 03:05:21 +02:00
|
|
|
HXUIOBJ m_back;
|
2013-05-10 17:14:22 +02:00
|
|
|
HXUIOBJ root_menu;
|
|
|
|
HXUIOBJ current_menu;
|
2014-03-09 18:25:52 +01:00
|
|
|
static msg_queue_t *xui_msg_queue;
|
2013-05-06 02:44:13 +02:00
|
|
|
|
2013-03-09 22:30:35 +01:00
|
|
|
class CRetroArch : public CXuiModule
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual HRESULT RegisterXuiClasses();
|
|
|
|
virtual HRESULT UnregisterXuiClasses();
|
|
|
|
};
|
|
|
|
|
2013-05-10 03:54:20 +02:00
|
|
|
#define CREATE_CLASS(class_type, class_name) \
|
|
|
|
class class_type: public CXuiSceneImpl \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
HRESULT OnInit( XUIMessageInit* pInitData, int & bHandled ); \
|
|
|
|
HRESULT DispatchMessageMap(XUIMessage *pMessage) \
|
|
|
|
{ \
|
|
|
|
if (pMessage->dwMessage == XM_INIT) \
|
|
|
|
{ \
|
|
|
|
XUIMessageInit *pData = (XUIMessageInit *) pMessage->pvData; \
|
|
|
|
return OnInit(pData, pMessage->bHandled); \
|
|
|
|
} \
|
|
|
|
return __super::DispatchMessageMap(pMessage); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static HRESULT Register() \
|
|
|
|
{ \
|
|
|
|
HXUICLASS hClass; \
|
|
|
|
XUIClass cls; \
|
|
|
|
memset(&cls, 0x00, sizeof(cls)); \
|
|
|
|
cls.szClassName = class_name; \
|
|
|
|
cls.szBaseClassName = XUI_CLASS_SCENE; \
|
|
|
|
cls.Methods.CreateInstance = (PFN_CREATEINST) (CreateInstance); \
|
|
|
|
cls.Methods.DestroyInstance = (PFN_DESTROYINST) DestroyInstance; \
|
|
|
|
cls.Methods.ObjectProc = (PFN_OBJECT_PROC) _ObjectProc; \
|
|
|
|
cls.pPropDefs = _GetPropDef(&cls.dwPropDefCount); \
|
|
|
|
HRESULT hr = XuiRegisterClass(&cls, &hClass); \
|
|
|
|
if (FAILED(hr)) \
|
|
|
|
return hr; \
|
|
|
|
return S_OK; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static HRESULT APIENTRY CreateInstance(HXUIOBJ hObj, void **ppvObj) \
|
|
|
|
{ \
|
|
|
|
*ppvObj = NULL; \
|
|
|
|
class_type *pThis = new class_type(); \
|
|
|
|
if (!pThis) \
|
|
|
|
return E_OUTOFMEMORY; \
|
|
|
|
pThis->m_hObj = hObj; \
|
|
|
|
HRESULT hr = pThis->OnCreate(); \
|
|
|
|
if (FAILED(hr)) \
|
|
|
|
{ \
|
|
|
|
DestroyInstance(pThis); \
|
|
|
|
return hr; \
|
|
|
|
} \
|
|
|
|
*ppvObj = pThis; \
|
|
|
|
return S_OK; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static HRESULT APIENTRY DestroyInstance(void *pvObj) \
|
|
|
|
{ \
|
|
|
|
class_type *pThis = (class_type *) pvObj; \
|
|
|
|
delete pThis; \
|
|
|
|
return S_OK; \
|
|
|
|
} \
|
|
|
|
}
|
2013-05-09 18:44:35 +02:00
|
|
|
|
2013-05-10 03:54:20 +02:00
|
|
|
CREATE_CLASS(CRetroArchMain, L"RetroArchMain");
|
2013-03-09 22:30:35 +01:00
|
|
|
|
2012-05-29 15:25:39 +02:00
|
|
|
CRetroArch app;
|
2012-07-28 22:36:49 +02:00
|
|
|
|
2015-01-07 20:42:36 +01:00
|
|
|
wchar_t strw_buffer[PATH_MAX_LENGTH];
|
2012-01-22 21:47:34 +01:00
|
|
|
|
2012-01-22 01:43:54 +01:00
|
|
|
/* Register custom classes */
|
2012-04-21 23:48:05 +02:00
|
|
|
HRESULT CRetroArch::RegisterXuiClasses (void)
|
2012-01-22 01:43:54 +01:00
|
|
|
{
|
2012-04-22 00:11:48 +02:00
|
|
|
CRetroArchMain::Register();
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2012-05-29 04:39:54 +02:00
|
|
|
return 0;
|
2012-01-22 01:43:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unregister custom classes */
|
2012-04-21 23:48:05 +02:00
|
|
|
HRESULT CRetroArch::UnregisterXuiClasses (void)
|
2012-01-22 01:43:54 +01:00
|
|
|
{
|
2013-05-08 02:11:06 +02:00
|
|
|
XuiUnregisterClass(L"RetroArchMain");
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2012-05-29 04:39:54 +02:00
|
|
|
return 0;
|
2012-01-22 01:43:54 +01:00
|
|
|
}
|
|
|
|
|
2012-08-22 03:56:57 +02:00
|
|
|
HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
2012-01-24 06:55:27 +01:00
|
|
|
{
|
2013-05-09 18:12:54 +02:00
|
|
|
GetChildById(L"XuiMenuList", &m_menulist);
|
2013-05-09 15:12:22 +02:00
|
|
|
GetChildById(L"XuiTxtTitle", &m_menutitle);
|
2013-05-09 18:12:54 +02:00
|
|
|
GetChildById(L"XuiTxtBottom", &m_menutitlebottom);
|
|
|
|
|
2015-01-07 20:42:36 +01:00
|
|
|
char str[PATH_MAX_LENGTH];
|
2014-03-02 22:52:48 +01:00
|
|
|
snprintf(str, sizeof(str), "%s - %s", PACKAGE_VERSION, g_extern.title_buf);
|
2014-02-28 21:15:16 +01:00
|
|
|
mbstowcs(strw_buffer, str, sizeof(strw_buffer) / sizeof(wchar_t));
|
2014-03-02 22:52:48 +01:00
|
|
|
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
|
2012-06-30 13:37:18 +02:00
|
|
|
|
2012-05-29 04:39:54 +02:00
|
|
|
return 0;
|
2012-01-24 06:55:27 +01:00
|
|
|
}
|
|
|
|
|
2014-03-25 10:19:02 +01:00
|
|
|
static void* rmenu_xui_init(void)
|
2012-01-22 21:47:34 +01:00
|
|
|
{
|
2012-04-10 21:23:42 +02:00
|
|
|
HRESULT hr;
|
2014-05-30 22:37:23 +02:00
|
|
|
TypefaceDescriptor typeface = {0};
|
2012-01-22 21:47:34 +01:00
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
2014-05-27 17:13:53 +02:00
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
if (!menu)
|
2013-10-17 14:16:07 -04:00
|
|
|
return NULL;
|
2013-04-18 15:04:09 +02:00
|
|
|
|
2014-03-25 10:19:02 +01:00
|
|
|
d3d_video_t *d3d= (d3d_video_t*)driver.video_data;
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2014-10-02 21:57:01 +02:00
|
|
|
if (d3d->resolution_hd_enable)
|
2013-01-08 17:15:43 +01:00
|
|
|
RARCH_LOG("HD menus enabled.\n");
|
|
|
|
|
2012-11-20 01:40:52 +01:00
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
2012-11-20 02:51:00 +01:00
|
|
|
video_info_t video_info = {0};
|
|
|
|
|
|
|
|
video_info.vsync = g_settings.video.vsync;
|
|
|
|
video_info.force_aspect = false;
|
|
|
|
video_info.smooth = g_settings.video.smooth;
|
|
|
|
video_info.input_scale = 2;
|
|
|
|
video_info.fullscreen = true;
|
2012-11-20 23:54:35 +01:00
|
|
|
video_info.rgb32 = false;
|
2012-11-20 02:51:00 +01:00
|
|
|
|
2014-03-05 22:10:36 +01:00
|
|
|
d3d_make_d3dpp(d3d, &video_info, &d3dpp);
|
2012-11-20 01:40:52 +01:00
|
|
|
|
2014-03-05 22:10:36 +01:00
|
|
|
hr = app.InitShared(d3d->dev, &d3dpp, XuiPNGTextureLoader);
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
if (FAILED(hr))
|
2012-04-10 21:23:42 +02:00
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Failed initializing XUI application.\n");
|
2014-05-30 21:51:12 +02:00
|
|
|
goto error;
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Register font */
|
2013-04-18 15:33:25 +02:00
|
|
|
typeface.szTypeface = L"Arial Unicode MS";
|
|
|
|
typeface.szLocator = L"file://game:/media/rarch.ttf";
|
|
|
|
typeface.szReserved1 = NULL;
|
2013-05-09 18:44:35 +02:00
|
|
|
|
2013-04-18 15:33:25 +02:00
|
|
|
hr = XuiRegisterTypeface( &typeface, TRUE );
|
2014-05-30 21:51:12 +02:00
|
|
|
if (FAILED(hr))
|
2012-04-10 21:23:42 +02:00
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Failed to register default typeface.\n");
|
2014-05-30 21:51:12 +02:00
|
|
|
goto error;
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
hr = XuiLoadVisualFromBinary(
|
|
|
|
L"file://game:/media/rarch_scene_skin.xur", NULL);
|
2014-05-30 21:51:12 +02:00
|
|
|
if (FAILED(hr))
|
2012-04-10 21:23:42 +02:00
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Failed to load skin.\n");
|
2014-05-30 21:51:12 +02:00
|
|
|
goto error;
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
2014-10-02 21:57:01 +02:00
|
|
|
hr = XuiSceneCreate(d3d->resolution_hd_enable ?
|
2014-09-02 16:03:17 +02:00
|
|
|
L"file://game:/media/hd/" : L"file://game:/media/sd/",
|
|
|
|
L"rarch_main.xur", NULL, &root_menu);
|
2014-05-30 21:51:12 +02:00
|
|
|
if (FAILED(hr))
|
2012-04-10 21:23:42 +02:00
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Failed to create scene 'rarch_main.xur'.\n");
|
2014-05-30 21:51:12 +02:00
|
|
|
goto error;
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
2013-05-10 17:14:22 +02:00
|
|
|
current_menu = root_menu;
|
2014-09-02 16:03:17 +02:00
|
|
|
hr = XuiSceneNavigateFirst(app.GetRootObj(),
|
|
|
|
current_menu, XUSER_INDEX_FOCUS);
|
2014-05-30 21:51:12 +02:00
|
|
|
if (FAILED(hr))
|
2013-01-08 17:15:43 +01:00
|
|
|
{
|
|
|
|
RARCH_ERR("XuiSceneNavigateFirst failed.\n");
|
2014-05-30 21:51:12 +02:00
|
|
|
goto error;
|
2013-01-08 17:15:43 +01:00
|
|
|
}
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
if (driver.video_data && driver.video_poke
|
|
|
|
&& driver.video_poke->set_texture_enable)
|
2014-03-25 10:19:02 +01:00
|
|
|
driver.video_poke->set_texture_frame(driver.video_data, NULL,
|
2013-04-13 22:38:57 +02:00
|
|
|
true, 0, 0, 1.0f);
|
2013-04-18 15:04:09 +02:00
|
|
|
|
2014-03-09 18:25:52 +01:00
|
|
|
xui_msg_queue = msg_queue_new(16);
|
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
return menu;
|
2014-05-30 21:51:12 +02:00
|
|
|
|
|
|
|
error:
|
2014-06-10 02:06:10 +02:00
|
|
|
free(menu);
|
2014-05-30 21:51:12 +02:00
|
|
|
return NULL;
|
2012-01-22 22:45:32 +01:00
|
|
|
}
|
|
|
|
|
2013-11-19 06:09:14 +01:00
|
|
|
static void rmenu_xui_free(void *data)
|
2012-04-17 05:35:25 +02:00
|
|
|
{
|
2013-11-03 06:34:49 +01:00
|
|
|
(void)data;
|
2012-05-29 15:25:39 +02:00
|
|
|
app.Uninit();
|
2014-03-09 18:25:52 +01:00
|
|
|
|
|
|
|
if (xui_msg_queue)
|
|
|
|
msg_queue_free(xui_msg_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xui_render_message(const char *msg)
|
|
|
|
{
|
2014-12-03 16:26:35 -05:00
|
|
|
struct font_params font_parms;
|
|
|
|
size_t i = 0;
|
|
|
|
size_t j = 0;
|
2014-03-09 18:25:52 +01:00
|
|
|
|
2014-12-03 16:26:35 -05:00
|
|
|
struct string_list *list = string_split(msg, "\n");
|
2014-10-02 21:57:01 +02:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2014-12-03 16:26:35 -05:00
|
|
|
if (!list || !d3d)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (list->elems == 0)
|
|
|
|
{
|
|
|
|
string_list_free(list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < list->size; i++, j++)
|
|
|
|
{
|
|
|
|
char *msg = (char*)list->elems[i].data;
|
|
|
|
unsigned msglen = strlen(msg);
|
|
|
|
#if 0
|
|
|
|
if (msglen > RMENU_TERM_WIDTH)
|
|
|
|
{
|
|
|
|
msg[RMENU_TERM_WIDTH - 2] = '.';
|
|
|
|
msg[RMENU_TERM_WIDTH - 1] = '.';
|
|
|
|
msg[RMENU_TERM_WIDTH - 0] = '.';
|
|
|
|
msg[RMENU_TERM_WIDTH + 1] = '\0';
|
|
|
|
msglen = RMENU_TERM_WIDTH;
|
|
|
|
}
|
|
|
|
#endif
|
2014-10-02 21:57:01 +02:00
|
|
|
float msg_width = d3d->resolution_hd_enable ? 160 : 100;
|
2014-12-03 16:26:35 -05:00
|
|
|
float msg_height = 120;
|
|
|
|
float msg_offset = 32;
|
2014-03-09 18:25:52 +01:00
|
|
|
|
2014-12-03 16:26:35 -05:00
|
|
|
font_parms.x = msg_width;
|
|
|
|
font_parms.y = msg_height + (msg_offset * j);
|
|
|
|
font_parms.scale = 21;
|
2014-03-09 18:25:52 +01:00
|
|
|
|
2014-12-03 16:26:35 -05:00
|
|
|
if (driver.video_poke && driver.video_poke->set_osd_msg)
|
|
|
|
driver.video_poke->set_osd_msg(driver.video_data,
|
2014-11-08 19:31:11 +01:00
|
|
|
msg, &font_parms, NULL);
|
2014-12-03 16:26:35 -05:00
|
|
|
}
|
2012-04-17 05:35:25 +02:00
|
|
|
}
|
|
|
|
|
2014-05-30 22:37:23 +02:00
|
|
|
static void rmenu_xui_frame(void)
|
2013-03-09 22:30:35 +01:00
|
|
|
{
|
2014-05-30 22:37:23 +02:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2014-03-07 20:17:25 +01:00
|
|
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
2013-04-19 23:22:58 +02:00
|
|
|
|
2014-03-05 19:03:25 +01:00
|
|
|
D3DVIEWPORT vp_full;
|
|
|
|
vp_full.X = 0;
|
|
|
|
vp_full.Y = 0;
|
|
|
|
vp_full.Width = d3d->screen_width;
|
|
|
|
vp_full.Height = d3d->screen_height;
|
|
|
|
vp_full.MinZ = 0.0f;
|
|
|
|
vp_full.MaxZ = 1.0f;
|
2014-09-12 18:01:32 +02:00
|
|
|
d3d_set_viewport(d3dr, &vp_full);
|
2014-03-05 19:03:25 +01:00
|
|
|
|
2014-03-05 03:55:16 +01:00
|
|
|
app.RunFrame();
|
|
|
|
XuiTimersRun();
|
2013-05-09 18:44:35 +02:00
|
|
|
XuiRenderBegin( app.GetDC(), D3DCOLOR_ARGB( 255, 0, 0, 0 ) );
|
2013-04-19 21:04:08 +02:00
|
|
|
|
2013-05-09 18:44:35 +02:00
|
|
|
D3DXMATRIX matOrigView;
|
|
|
|
XuiRenderGetViewTransform( app.GetDC(), &matOrigView );
|
2013-04-19 21:04:08 +02:00
|
|
|
|
2013-05-09 18:44:35 +02:00
|
|
|
XUIMessage msg;
|
|
|
|
XUIMessageRender msgRender;
|
2015-01-07 21:51:10 +01:00
|
|
|
XuiMessageRender( &msg, &msgRender, app.GetDC(), 0xffffffff, XUI_BLEND_NORMAL );
|
2013-05-09 18:44:35 +02:00
|
|
|
XuiSendMessage( app.GetRootObj(), &msg );
|
2013-04-19 21:04:08 +02:00
|
|
|
|
2013-05-09 18:44:35 +02:00
|
|
|
XuiRenderSetViewTransform( app.GetDC(), &matOrigView );
|
2013-04-19 21:04:08 +02:00
|
|
|
|
2014-03-09 18:25:52 +01:00
|
|
|
const char *message = msg_queue_pull(xui_msg_queue);
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
xui_render_message(message);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *message = msg_queue_pull(g_extern.msg_queue);
|
|
|
|
if (message)
|
|
|
|
xui_render_message(message);
|
|
|
|
}
|
|
|
|
|
2013-05-09 18:44:35 +02:00
|
|
|
XuiRenderEnd( app.GetDC() );
|
2014-03-05 19:03:25 +01:00
|
|
|
|
2014-09-12 18:01:32 +02:00
|
|
|
d3d_set_viewport(d3dr, &d3d->final_viewport);
|
2013-03-10 03:34:37 +01:00
|
|
|
}
|
2013-09-19 15:01:17 +02:00
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
static void blit_line(int x, int y, const char *message, bool green)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
static void rmenu_xui_render_background(void)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
static void rmenu_xui_render_messagebox(const char *message)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
2014-03-09 18:25:52 +01:00
|
|
|
msg_queue_clear(xui_msg_queue);
|
|
|
|
msg_queue_push(xui_msg_queue, message, 2, 1);
|
2014-02-28 17:50:55 +01:00
|
|
|
}
|
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
static void rmenu_xui_render(void)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
2014-05-30 21:51:12 +02:00
|
|
|
size_t begin, end;
|
|
|
|
char title[256];
|
|
|
|
const char *dir = NULL;
|
2014-08-30 15:50:42 +02:00
|
|
|
const char *label = NULL;
|
2014-05-30 21:51:12 +02:00
|
|
|
unsigned menu_type = 0;
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-05-31 22:34:45 +02:00
|
|
|
if (!driver.menu || driver.menu->need_refresh &&
|
2014-09-25 06:33:28 +02:00
|
|
|
g_extern.is_menu && !driver.menu->msg_force)
|
2014-02-28 17:50:55 +01:00
|
|
|
return;
|
|
|
|
|
2014-10-21 05:44:09 +02:00
|
|
|
end = menu_list_get_size(driver.menu->menu_list);
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-05-30 21:51:12 +02:00
|
|
|
rmenu_xui_render_background();
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-10-18 01:59:16 +02:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, &dir,
|
2014-09-02 16:03:17 +02:00
|
|
|
&label, &menu_type);
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2015-01-07 21:51:10 +01:00
|
|
|
get_title(label, dir, menu_type, title, sizeof(title));
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-03-02 22:52:48 +01:00
|
|
|
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitle, strw_buffer);
|
|
|
|
|
2014-02-28 17:50:55 +01:00
|
|
|
char title_buf[256];
|
2014-09-02 16:03:17 +02:00
|
|
|
menu_ticker_line(title_buf, RXUI_TERM_WIDTH - 3,
|
|
|
|
g_extern.frame_count / 15, title, true);
|
2014-05-30 21:51:12 +02:00
|
|
|
blit_line(RXUI_TERM_START_X + 15, 15, title_buf, true);
|
2014-02-28 17:50:55 +01:00
|
|
|
|
|
|
|
char title_msg[64];
|
2014-09-07 07:12:10 +02:00
|
|
|
const char *core_name = g_extern.menu.info.library_name;
|
2014-02-28 17:50:55 +01:00
|
|
|
if (!core_name)
|
|
|
|
core_name = g_extern.system.info.library_name;
|
|
|
|
if (!core_name)
|
|
|
|
core_name = "No Core";
|
|
|
|
|
2014-09-07 07:12:10 +02:00
|
|
|
const char *core_version = g_extern.menu.info.library_version;
|
2014-02-28 17:50:55 +01:00
|
|
|
if (!core_version)
|
|
|
|
core_version = g_extern.system.info.library_version;
|
|
|
|
if (!core_version)
|
|
|
|
core_version = "";
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
snprintf(title_msg, sizeof(title_msg), "%s - %s %s",
|
|
|
|
PACKAGE_VERSION, core_name, core_version);
|
2015-01-06 14:17:40 +01:00
|
|
|
|
|
|
|
mbstowcs(strw_buffer, title_msg, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
|
2014-02-28 17:50:55 +01:00
|
|
|
|
|
|
|
unsigned x, y;
|
|
|
|
size_t i;
|
|
|
|
|
2014-02-28 21:15:16 +01:00
|
|
|
x = RXUI_TERM_START_X;
|
|
|
|
y = RXUI_TERM_START_Y;
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2015-01-07 21:51:10 +01:00
|
|
|
for (i = 0; i < end; i++/*, y += FONT_HEIGHT_STRIDE */)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
2015-01-07 21:51:10 +01:00
|
|
|
char type_str[PATH_MAX_LENGTH],entry_title_buf[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
2014-09-11 01:57:25 +02:00
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
2014-09-10 18:26:02 +02:00
|
|
|
bool selected = false;
|
2014-09-11 01:57:25 +02:00
|
|
|
|
2014-10-21 05:44:09 +02:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
2014-09-11 01:57:25 +02:00
|
|
|
&entry_label, &type);
|
2014-09-10 18:26:02 +02:00
|
|
|
|
2014-10-21 05:44:09 +02:00
|
|
|
disp_set_label(driver.menu->menu_list->selection_buf,
|
2014-12-03 16:26:35 -05:00
|
|
|
&w, type, i, label,
|
2014-09-10 18:26:02 +02:00
|
|
|
type_str, sizeof(type_str),
|
2014-09-11 01:57:25 +02:00
|
|
|
entry_label, path,
|
|
|
|
path_buf, sizeof(path_buf));
|
2014-09-10 18:26:02 +02:00
|
|
|
|
|
|
|
selected = (i == driver.menu->selection_ptr);
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-03-01 00:01:11 +01:00
|
|
|
#if 0
|
2014-06-10 01:42:26 +02:00
|
|
|
if ((type == MENU_FILE_PLAIN || type == MENU_FILE_DIRECTORY))
|
2014-02-28 21:15:16 +01:00
|
|
|
menu_ticker_line(entry_title_buf, RXUI_TERM_WIDTH - (w + 1 + 2), g_extern.frame_count / 15, path, selected);
|
2014-02-28 17:50:55 +01:00
|
|
|
else
|
|
|
|
menu_ticker_line(type_str_buf, w, g_extern.frame_count / 15, type_str, selected);
|
2014-03-01 00:01:11 +01:00
|
|
|
#endif
|
2015-01-07 21:51:10 +01:00
|
|
|
HXUIOBJ hVisual = NULL;
|
|
|
|
HXUIOBJ hControl = XuiListGetItemControl(m_menulist, i);
|
|
|
|
if (XuiHandleIsValid(hControl))
|
|
|
|
XuiControlGetVisual(hControl, &hVisual);
|
|
|
|
if(XuiHandleIsValid(hVisual))
|
|
|
|
{
|
|
|
|
HXUIOBJ hTextLeft = NULL, hTextRight = NULL;
|
|
|
|
XuiElementGetChildById(hVisual, L"LeftText", &hTextLeft);
|
|
|
|
XuiElementGetChildById(hVisual, L"RightText", &hTextRight);
|
|
|
|
wchar_t msg_w[256];
|
|
|
|
if(XuiHandleIsValid(hTextLeft))
|
|
|
|
{
|
|
|
|
mbstowcs(msg_w, path_buf, sizeof(msg_w) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(hTextLeft, msg_w);
|
|
|
|
}
|
|
|
|
if(XuiHandleIsValid(hTextRight))
|
|
|
|
{
|
|
|
|
mbstowcs(msg_w, type_str, sizeof(msg_w) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(hTextRight, msg_w);
|
|
|
|
}
|
|
|
|
}
|
2014-02-28 17:50:55 +01:00
|
|
|
}
|
|
|
|
|
2014-05-31 22:34:45 +02:00
|
|
|
if (driver.menu->keyboard.display)
|
2014-02-28 17:50:55 +01:00
|
|
|
{
|
|
|
|
char msg[1024];
|
2014-05-31 22:34:45 +02:00
|
|
|
const char *str = *driver.menu->keyboard.buffer;
|
2014-02-28 17:50:55 +01:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
2014-05-31 22:34:45 +02:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
2014-05-30 22:37:23 +02:00
|
|
|
rmenu_xui_render_messagebox(msg);
|
2014-02-28 17:50:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-31 19:47:45 +02:00
|
|
|
static void rmenu_xui_populate_entries(void *data, const char *path,
|
|
|
|
const char *label, unsigned i)
|
2014-03-08 06:15:52 +01:00
|
|
|
{
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-08-31 19:29:42 +02:00
|
|
|
(void)label;
|
2014-08-31 19:47:45 +02:00
|
|
|
(void)path;
|
2014-08-31 19:29:42 +02:00
|
|
|
|
2014-06-10 02:06:10 +02:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-03-08 06:15:52 +01:00
|
|
|
}
|
2014-02-28 17:50:55 +01:00
|
|
|
|
2014-10-12 23:44:10 +02:00
|
|
|
static void rmenu_xui_navigation_clear(void *data, bool pending_push)
|
2014-04-13 23:41:47 +02:00
|
|
|
{
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-10-12 23:44:10 +02:00
|
|
|
|
|
|
|
(void)pending_push;
|
|
|
|
|
|
|
|
if (menu)
|
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-04-13 23:41:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_navigation_set_visible(void *data)
|
|
|
|
{
|
2014-06-10 02:06:10 +02:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-04-13 23:41:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_navigation_alphabet(void *data, size_t *ptr_out)
|
|
|
|
{
|
|
|
|
XuiListSetCurSelVisible(m_menulist, *ptr_out);
|
|
|
|
}
|
|
|
|
|
2014-09-02 16:03:17 +02:00
|
|
|
static void rmenu_xui_list_insert(void *data,
|
2014-09-09 06:25:52 +02:00
|
|
|
const char *path, const char *, size_t list_size)
|
2014-04-14 00:09:52 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
2015-01-07 20:42:36 +01:00
|
|
|
wchar_t buf[PATH_MAX_LENGTH];
|
2014-04-14 00:09:52 +02:00
|
|
|
|
|
|
|
XuiListInsertItems(m_menulist, list_size, 1);
|
|
|
|
mbstowcs(buf, path, sizeof(buf) / sizeof(wchar_t));
|
|
|
|
XuiListSetText(m_menulist, list_size, buf);
|
|
|
|
}
|
|
|
|
|
2014-10-20 19:18:18 +02:00
|
|
|
static void rmenu_xui_list_delete(void *data, size_t idx,
|
2014-10-10 22:36:30 +02:00
|
|
|
size_t list_size)
|
2014-04-14 00:09:52 +02:00
|
|
|
{
|
|
|
|
(void)data;
|
2014-10-20 19:18:18 +02:00
|
|
|
(void)idx;
|
2014-04-14 00:09:52 +02:00
|
|
|
XuiListDeleteItems(m_menulist, 0, list_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_list_clear(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_list_set_selection(void *data)
|
|
|
|
{
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
2014-08-30 15:50:42 +02:00
|
|
|
if (list)
|
|
|
|
XuiListSetCurSel(m_menulist, file_list_get_directory_ptr(list));
|
2014-04-14 00:09:52 +02:00
|
|
|
}
|
|
|
|
|
2014-11-25 03:49:26 +01:00
|
|
|
static void rmenu_xui_update_core_info(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
2014-12-23 21:21:49 +01:00
|
|
|
menu_update_libretro_info(&g_extern.menu.info);
|
2014-11-25 03:49:26 +01:00
|
|
|
}
|
|
|
|
|
2014-09-11 07:06:20 +02:00
|
|
|
menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
2013-11-04 16:23:37 +01:00
|
|
|
NULL,
|
2014-03-09 18:25:52 +01:00
|
|
|
rmenu_xui_render_messagebox,
|
2014-02-28 17:50:55 +01:00
|
|
|
rmenu_xui_render,
|
2014-04-01 04:45:00 +02:00
|
|
|
rmenu_xui_frame,
|
2013-11-19 06:09:14 +01:00
|
|
|
rmenu_xui_init,
|
2014-10-09 01:31:11 +02:00
|
|
|
NULL,
|
2013-11-19 06:09:14 +01:00
|
|
|
rmenu_xui_free,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-03-08 06:15:52 +01:00
|
|
|
rmenu_xui_populate_entries,
|
2014-02-28 21:15:16 +01:00
|
|
|
NULL,
|
2014-10-01 15:17:34 +02:00
|
|
|
NULL,
|
2014-04-13 23:41:47 +02:00
|
|
|
rmenu_xui_navigation_clear,
|
|
|
|
rmenu_xui_navigation_set_visible,
|
|
|
|
rmenu_xui_navigation_set_visible,
|
2014-12-23 21:25:02 +01:00
|
|
|
rmenu_xui_navigation_clear,
|
2014-04-13 23:41:47 +02:00
|
|
|
rmenu_xui_navigation_set_visible,
|
|
|
|
rmenu_xui_navigation_alphabet,
|
|
|
|
rmenu_xui_navigation_alphabet,
|
2014-04-14 00:09:52 +02:00
|
|
|
rmenu_xui_list_insert,
|
|
|
|
rmenu_xui_list_delete,
|
|
|
|
rmenu_xui_list_clear,
|
2014-12-23 21:25:02 +01:00
|
|
|
NULL,
|
2014-04-14 00:09:52 +02:00
|
|
|
rmenu_xui_list_set_selection,
|
2014-09-03 14:57:29 +02:00
|
|
|
NULL,
|
2014-11-25 03:49:26 +01:00
|
|
|
rmenu_xui_update_core_info,
|
2014-04-14 02:32:54 +02:00
|
|
|
&menu_ctx_backend_common,
|
2013-09-19 15:01:17 +02:00
|
|
|
"rmenu_xui",
|
2014-02-28 19:22:32 +01:00
|
|
|
};
|