2012-04-21 21:13:50 +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
|
2015-01-07 17:24:13 +00:00
|
|
|
* Copyright (C) 2015- - Swizzy
|
2012-01-22 00:43:54 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2012-01-22 00:43:54 +00: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 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2012-01-22 00:43:54 +00: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 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2012-01-22 00:43:54 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-01-23 21:22:54 +00:00
|
|
|
#include <stdint.h>
|
2015-01-26 09:54:13 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2012-01-22 00:43:54 +00:00
|
|
|
#include <xtl.h>
|
2013-03-09 21:30:35 +00:00
|
|
|
#include <xui.h>
|
|
|
|
#include <xuiapp.h>
|
2013-01-09 16:49:43 +00:00
|
|
|
|
2015-04-12 17:13:21 +00:00
|
|
|
#include <file/file_path.h>
|
|
|
|
|
2015-01-12 18:11:51 +00:00
|
|
|
#include "../menu_driver.h"
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "../menu.h"
|
2015-05-10 09:23:00 +00:00
|
|
|
#include "../menu_entry.h"
|
2014-10-17 20:53:30 +00:00
|
|
|
#include "../menu_list.h"
|
2015-01-26 09:54:13 +00:00
|
|
|
#include "../menu_input.h"
|
2012-07-28 14:10:31 +00:00
|
|
|
|
2015-01-12 20:53:04 +00:00
|
|
|
#include "../../gfx/video_context_driver.h"
|
2012-09-30 16:29:32 +00:00
|
|
|
|
2015-03-20 23:49:55 +00:00
|
|
|
#include "../../settings.h"
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../../general.h"
|
2012-01-24 00:06:12 +00:00
|
|
|
|
2015-01-07 21:23:45 +00:00
|
|
|
#include "../../gfx/d3d/d3d.h"
|
2014-09-12 16:01:32 +00:00
|
|
|
|
2014-09-02 23:51:29 +00:00
|
|
|
#include "shared.h"
|
|
|
|
|
2013-11-19 05:42:27 +00:00
|
|
|
#define XUI_CONTROL_NAVIGATE_OK (XUI_CONTROL_NAVIGATE_RIGHT + 1)
|
|
|
|
|
2014-02-28 20:24:39 +00: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 20:15:16 +00:00
|
|
|
#define RXUI_TERM_START_X 15
|
|
|
|
#define RXUI_TERM_START_Y 27
|
2015-02-11 21:34:07 +00:00
|
|
|
#define RXUI_TERM_WIDTH (((menu->frame_buf.width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE)))
|
|
|
|
#define RXUI_TERM_HEIGHT (((menu->frame_buf.height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1)
|
2013-03-30 07:16:58 +00:00
|
|
|
|
2013-05-09 13:12:22 +00:00
|
|
|
HXUIOBJ m_menulist;
|
|
|
|
HXUIOBJ m_menutitle;
|
2013-05-09 16:12:54 +00:00
|
|
|
HXUIOBJ m_menutitlebottom;
|
2015-01-12 23:48:26 +00:00
|
|
|
HXUIOBJ m_background;
|
2013-05-06 01:05:21 +00:00
|
|
|
HXUIOBJ m_back;
|
2013-05-10 15:14:22 +00:00
|
|
|
HXUIOBJ root_menu;
|
|
|
|
HXUIOBJ current_menu;
|
2014-03-09 17:25:52 +00:00
|
|
|
static msg_queue_t *xui_msg_queue;
|
2013-05-06 00:44:13 +00:00
|
|
|
|
2013-03-09 21:30:35 +00:00
|
|
|
class CRetroArch : public CXuiModule
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual HRESULT RegisterXuiClasses();
|
|
|
|
virtual HRESULT UnregisterXuiClasses();
|
|
|
|
};
|
|
|
|
|
2013-05-10 01:54:20 +00: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 16:44:35 +00:00
|
|
|
|
2013-05-10 01:54:20 +00:00
|
|
|
CREATE_CLASS(CRetroArchMain, L"RetroArchMain");
|
2013-03-09 21:30:35 +00:00
|
|
|
|
2012-05-29 13:25:39 +00:00
|
|
|
CRetroArch app;
|
2012-07-28 20:36:49 +00:00
|
|
|
|
2015-01-07 19:42:36 +00:00
|
|
|
wchar_t strw_buffer[PATH_MAX_LENGTH];
|
2012-01-22 20:47:34 +00:00
|
|
|
|
2012-01-22 00:43:54 +00:00
|
|
|
/* Register custom classes */
|
2012-04-21 21:48:05 +00:00
|
|
|
HRESULT CRetroArch::RegisterXuiClasses (void)
|
2012-01-22 00:43:54 +00:00
|
|
|
{
|
2012-04-21 22:11:48 +00:00
|
|
|
CRetroArchMain::Register();
|
2012-04-10 19:23:42 +00:00
|
|
|
|
2012-05-29 02:39:54 +00:00
|
|
|
return 0;
|
2012-01-22 00:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unregister custom classes */
|
2012-04-21 21:48:05 +00:00
|
|
|
HRESULT CRetroArch::UnregisterXuiClasses (void)
|
2012-01-22 00:43:54 +00:00
|
|
|
{
|
2013-05-08 00:11:06 +00:00
|
|
|
XuiUnregisterClass(L"RetroArchMain");
|
2012-04-10 19:23:42 +00:00
|
|
|
|
2012-05-29 02:39:54 +00:00
|
|
|
return 0;
|
2012-01-22 00:43:54 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 01:56:57 +00:00
|
|
|
HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
2012-01-24 05:55:27 +00:00
|
|
|
{
|
2015-03-21 04:42:49 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2013-05-09 16:12:54 +00:00
|
|
|
GetChildById(L"XuiMenuList", &m_menulist);
|
2013-05-09 13:12:22 +00:00
|
|
|
GetChildById(L"XuiTxtTitle", &m_menutitle);
|
2013-05-09 16:12:54 +00:00
|
|
|
GetChildById(L"XuiTxtBottom", &m_menutitlebottom);
|
2015-01-12 23:48:26 +00:00
|
|
|
GetChildById(L"XuiBackground", &m_background);
|
2013-05-09 16:12:54 +00:00
|
|
|
|
2015-01-10 12:00:47 +00:00
|
|
|
if (XuiHandleIsValid(m_menutitlebottom))
|
|
|
|
{
|
|
|
|
char str[PATH_MAX_LENGTH];
|
2015-03-21 04:42:49 +00:00
|
|
|
snprintf(str, sizeof(str), "%s - %s", PACKAGE_VERSION, global->title_buf);
|
2015-01-10 12:00:47 +00:00
|
|
|
mbstowcs(strw_buffer, str, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
|
|
|
|
}
|
2012-06-30 11:37:18 +00:00
|
|
|
|
2012-05-29 02:39:54 +00:00
|
|
|
return 0;
|
2012-01-24 05:55:27 +00:00
|
|
|
}
|
|
|
|
|
2015-02-01 07:13:09 +00:00
|
|
|
HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName,
|
|
|
|
XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex)
|
2015-01-12 23:48:26 +00:00
|
|
|
{
|
2015-02-01 07:13:09 +00:00
|
|
|
D3DXIMAGE_INFO pSrc;
|
|
|
|
CONST BYTE *pbTextureData = 0;
|
|
|
|
UINT cbTextureData = 0;
|
|
|
|
HXUIRESOURCE hResource = 0;
|
|
|
|
BOOL bIsMemoryResource = FALSE;
|
|
|
|
IDirect3DDevice9 * d3dDevice = NULL;
|
|
|
|
HRESULT hr = XuiResourceOpenNoLoc(szFileName, &hResource,
|
|
|
|
&bIsMemoryResource);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (bIsMemoryResource)
|
|
|
|
{
|
|
|
|
hr = XuiResourceGetBuffer(hResource, &pbTextureData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
cbTextureData = XuiResourceGetTotalSize(hResource);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = XuiResourceRead(hResource, NULL, 0, &cbTextureData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
pbTextureData = (BYTE *)XuiAlloc(cbTextureData);
|
|
|
|
if (pbTextureData == 0)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = XuiResourceRead(hResource, (BYTE*)pbTextureData, cbTextureData, &cbTextureData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
XuiResourceClose(hResource);
|
|
|
|
hResource = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cast our d3d device into our IDirect3DDevice9* interface */
|
|
|
|
d3dDevice = (IDirect3DDevice9*)pDevice->GetD3DDevice();
|
|
|
|
if(!d3dDevice)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* Create our texture based on our conditions */
|
|
|
|
hr = D3DXCreateTextureFromFileInMemoryEx(
|
|
|
|
d3dDevice,
|
|
|
|
pbTextureData,
|
|
|
|
cbTextureData,
|
|
|
|
D3DX_DEFAULT_NONPOW2,
|
|
|
|
D3DX_DEFAULT_NONPOW2,
|
|
|
|
1,
|
|
|
|
D3DUSAGE_CPU_CACHED_MEMORY,
|
|
|
|
D3DFMT_LIN_A8R8G8B8,
|
|
|
|
D3DPOOL_DEFAULT,
|
|
|
|
D3DX_FILTER_NONE,
|
|
|
|
D3DX_FILTER_NONE,
|
|
|
|
0,
|
|
|
|
&pSrc,
|
|
|
|
NULL,
|
|
|
|
ppTex
|
|
|
|
);
|
|
|
|
|
|
|
|
if(hr != D3DXERR_INVALIDDATA )
|
|
|
|
{
|
|
|
|
pImageInfo->Depth = pSrc.Depth;
|
|
|
|
pImageInfo->Format = pSrc.Format;
|
|
|
|
pImageInfo->Height = pSrc.Height;
|
|
|
|
pImageInfo->ImageFileFormat = pSrc.ImageFileFormat;
|
|
|
|
pImageInfo->MipLevels = pSrc.MipLevels;
|
|
|
|
pImageInfo->ResourceType = pSrc.ResourceType;
|
|
|
|
pImageInfo->Width = pSrc.Width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RARCH_ERR("D3DXERR_INVALIDDATA Encountered\n");
|
2015-01-12 23:48:26 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
2015-02-01 07:13:09 +00:00
|
|
|
if (bIsMemoryResource && hResource != 0)
|
|
|
|
XuiResourceReleaseBuffer(hResource, pbTextureData);
|
|
|
|
else
|
|
|
|
XuiFree((LPVOID)pbTextureData);
|
|
|
|
|
|
|
|
if (hResource != 0)
|
|
|
|
XuiResourceClose(hResource);
|
|
|
|
return hr;
|
2015-01-12 23:48:26 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
static void* rmenu_xui_init(void)
|
2012-01-22 20:47:34 +00:00
|
|
|
{
|
2012-04-10 19:23:42 +00:00
|
|
|
HRESULT hr;
|
2015-02-01 07:13:09 +00:00
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
|
|
|
d3d_video_t *d3d;
|
|
|
|
video_info_t video_info = {0};
|
2014-05-30 20:37:23 +00:00
|
|
|
TypefaceDescriptor typeface = {0};
|
2015-03-20 21:22:06 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-21 21:48:27 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-20 21:22:06 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
2014-05-27 15:13:53 +00:00
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
if (!menu)
|
2013-10-17 18:16:07 +00:00
|
|
|
return NULL;
|
2013-04-18 13:04:09 +00:00
|
|
|
|
2015-03-21 21:48:27 +00:00
|
|
|
d3d= (d3d_video_t*)driver->video_data;
|
2012-04-10 19:23:42 +00:00
|
|
|
|
2014-10-02 19:57:01 +00:00
|
|
|
if (d3d->resolution_hd_enable)
|
2013-01-08 16:15:43 +00:00
|
|
|
RARCH_LOG("HD menus enabled.\n");
|
|
|
|
|
2015-03-20 21:22:06 +00:00
|
|
|
video_info.vsync = settings->video.vsync;
|
2012-11-20 01:51:00 +00:00
|
|
|
video_info.force_aspect = false;
|
2015-03-20 21:22:06 +00:00
|
|
|
video_info.smooth = settings->video.smooth;
|
|
|
|
video_info.input_scale = 2;
|
|
|
|
video_info.fullscreen = true;
|
|
|
|
video_info.rgb32 = false;
|
2012-11-20 01:51:00 +00:00
|
|
|
|
2014-03-05 21:10:36 +00:00
|
|
|
d3d_make_d3dpp(d3d, &video_info, &d3dpp);
|
2015-01-12 23:48:26 +00:00
|
|
|
|
|
|
|
hr = app.InitShared(d3d->dev, &d3dpp, (PFN_XUITEXTURELOADER)XuiTextureLoader);
|
2012-04-10 19:23:42 +00:00
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
if (FAILED(hr))
|
2012-04-10 19:23:42 +00:00
|
|
|
{
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("Failed initializing XUI application.\n");
|
2014-05-30 19:51:12 +00:00
|
|
|
goto error;
|
2012-04-10 19:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Register font */
|
2015-03-21 21:48:27 +00:00
|
|
|
typeface.szTypeface = L"Arial Unicode MS";
|
|
|
|
typeface.szLocator = L"file://game:/media/rarch.ttf";
|
2013-04-18 13:33:25 +00:00
|
|
|
typeface.szReserved1 = NULL;
|
2013-05-09 16:44:35 +00:00
|
|
|
|
2013-04-18 13:33:25 +00:00
|
|
|
hr = XuiRegisterTypeface( &typeface, TRUE );
|
2014-05-30 19:51:12 +00:00
|
|
|
if (FAILED(hr))
|
2012-04-10 19:23:42 +00:00
|
|
|
{
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("Failed to register default typeface.\n");
|
2014-05-30 19:51:12 +00:00
|
|
|
goto error;
|
2012-04-10 19:23:42 +00:00
|
|
|
}
|
|
|
|
|
2014-09-02 14:03:17 +00:00
|
|
|
hr = XuiLoadVisualFromBinary(
|
|
|
|
L"file://game:/media/rarch_scene_skin.xur", NULL);
|
2014-05-30 19:51:12 +00:00
|
|
|
if (FAILED(hr))
|
2012-04-10 19:23:42 +00:00
|
|
|
{
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("Failed to load skin.\n");
|
2014-05-30 19:51:12 +00:00
|
|
|
goto error;
|
2012-04-10 19:23:42 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 19:57:01 +00:00
|
|
|
hr = XuiSceneCreate(d3d->resolution_hd_enable ?
|
2014-09-02 14:03:17 +00:00
|
|
|
L"file://game:/media/hd/" : L"file://game:/media/sd/",
|
|
|
|
L"rarch_main.xur", NULL, &root_menu);
|
2014-05-30 19:51:12 +00:00
|
|
|
if (FAILED(hr))
|
2012-04-10 19:23:42 +00:00
|
|
|
{
|
2012-04-21 21:25:32 +00:00
|
|
|
RARCH_ERR("Failed to create scene 'rarch_main.xur'.\n");
|
2014-05-30 19:51:12 +00:00
|
|
|
goto error;
|
2012-04-10 19:23:42 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 15:14:22 +00:00
|
|
|
current_menu = root_menu;
|
2014-09-02 14:03:17 +00:00
|
|
|
hr = XuiSceneNavigateFirst(app.GetRootObj(),
|
|
|
|
current_menu, XUSER_INDEX_FOCUS);
|
2014-05-30 19:51:12 +00:00
|
|
|
if (FAILED(hr))
|
2013-01-08 16:15:43 +00:00
|
|
|
{
|
|
|
|
RARCH_ERR("XuiSceneNavigateFirst failed.\n");
|
2014-05-30 19:51:12 +00:00
|
|
|
goto error;
|
2013-01-08 16:15:43 +00:00
|
|
|
}
|
2012-04-10 19:23:42 +00:00
|
|
|
|
2015-03-22 18:15:34 +00:00
|
|
|
video_driver_set_texture_frame(NULL,
|
2013-04-13 20:38:57 +00:00
|
|
|
true, 0, 0, 1.0f);
|
2013-04-18 13:04:09 +00:00
|
|
|
|
2014-03-09 17:25:52 +00:00
|
|
|
xui_msg_queue = msg_queue_new(16);
|
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
return menu;
|
2014-05-30 19:51:12 +00:00
|
|
|
|
|
|
|
error:
|
2014-06-10 00:06:10 +00:00
|
|
|
free(menu);
|
2014-05-30 19:51:12 +00:00
|
|
|
return NULL;
|
2012-01-22 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
2013-11-19 05:09:14 +00:00
|
|
|
static void rmenu_xui_free(void *data)
|
2012-04-17 03:35:25 +00:00
|
|
|
{
|
2013-11-03 05:34:49 +00:00
|
|
|
(void)data;
|
2012-05-29 13:25:39 +00:00
|
|
|
app.Uninit();
|
2014-03-09 17:25:52 +00:00
|
|
|
|
|
|
|
if (xui_msg_queue)
|
|
|
|
msg_queue_free(xui_msg_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xui_render_message(const char *msg)
|
|
|
|
{
|
2014-12-03 21:26:35 +00:00
|
|
|
struct font_params font_parms;
|
|
|
|
size_t i = 0;
|
|
|
|
size_t j = 0;
|
2015-02-11 05:59:19 +00:00
|
|
|
struct string_list *list = NULL;
|
2015-03-21 21:48:27 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
|
2015-01-27 14:35:31 +00:00
|
|
|
|
2015-02-11 05:59:19 +00:00
|
|
|
if (!d3d)
|
2014-12-03 21:26:35 +00:00
|
|
|
return;
|
2015-02-11 05:59:19 +00:00
|
|
|
|
|
|
|
list = string_split(msg, "\n");
|
2014-12-03 21:26:35 +00:00
|
|
|
|
2015-02-11 05:59:19 +00:00
|
|
|
if (!list)
|
2014-12-03 21:26:35 +00:00
|
|
|
return;
|
2015-02-11 05:59:19 +00:00
|
|
|
|
|
|
|
if (list->elems == 0)
|
|
|
|
goto end;
|
2014-12-03 21:26:35 +00:00
|
|
|
|
|
|
|
for (i = 0; i < list->size; i++, j++)
|
|
|
|
{
|
|
|
|
char *msg = (char*)list->elems[i].data;
|
|
|
|
unsigned msglen = strlen(msg);
|
2014-10-02 19:57:01 +00:00
|
|
|
float msg_width = d3d->resolution_hd_enable ? 160 : 100;
|
2014-12-03 21:26:35 +00:00
|
|
|
float msg_height = 120;
|
|
|
|
float msg_offset = 32;
|
2014-03-09 17:25:52 +00:00
|
|
|
|
2014-12-03 21:26:35 +00:00
|
|
|
font_parms.x = msg_width;
|
|
|
|
font_parms.y = msg_height + (msg_offset * j);
|
|
|
|
font_parms.scale = 21;
|
2014-03-09 17:25:52 +00:00
|
|
|
|
2015-03-22 17:48:24 +00:00
|
|
|
video_driver_set_osd_msg(msg, &font_parms, NULL);
|
2014-12-03 21:26:35 +00:00
|
|
|
}
|
2015-02-11 05:59:19 +00:00
|
|
|
|
|
|
|
end:
|
|
|
|
string_list_free(list);
|
2012-04-17 03:35:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_frame(void)
|
2013-03-09 21:30:35 +00:00
|
|
|
{
|
2015-02-01 07:13:09 +00:00
|
|
|
XUIMessage msg;
|
|
|
|
XUIMessageRender msgRender;
|
|
|
|
D3DXMATRIX matOrigView;
|
2015-02-13 18:00:34 +00:00
|
|
|
LPDIRECT3DDEVICE d3dr;
|
2015-04-26 16:08:17 +00:00
|
|
|
const char *message;
|
2015-05-09 16:12:15 +00:00
|
|
|
D3DVIEWPORT vp_full = {0};
|
2015-02-13 18:00:34 +00:00
|
|
|
d3d_video_t *d3d = NULL;
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-03-21 21:48:27 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-04-26 03:44:30 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-02-13 18:00:34 +00:00
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
|
|
|
|
2015-03-21 21:48:27 +00:00
|
|
|
d3d = (d3d_video_t*)driver->video_data;
|
2015-02-13 18:00:34 +00:00
|
|
|
|
|
|
|
if (!d3d)
|
|
|
|
return;
|
|
|
|
|
|
|
|
d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
|
|
|
|
|
|
|
if (!d3dr)
|
|
|
|
return;
|
2013-04-19 21:22:58 +00:00
|
|
|
|
2015-04-26 14:46:56 +00:00
|
|
|
menu_display_set_viewport(menu);
|
2014-03-05 18:03:25 +00:00
|
|
|
|
2014-03-05 02:55:16 +00:00
|
|
|
app.RunFrame();
|
|
|
|
XuiTimersRun();
|
2013-05-09 16:44:35 +00:00
|
|
|
XuiRenderBegin( app.GetDC(), D3DCOLOR_ARGB( 255, 0, 0, 0 ) );
|
2013-04-19 19:04:08 +00:00
|
|
|
|
2013-05-09 16:44:35 +00:00
|
|
|
XuiRenderGetViewTransform( app.GetDC(), &matOrigView );
|
2013-04-19 19:04:08 +00:00
|
|
|
|
2015-01-07 20:51:10 +00:00
|
|
|
XuiMessageRender( &msg, &msgRender, app.GetDC(), 0xffffffff, XUI_BLEND_NORMAL );
|
2013-05-09 16:44:35 +00:00
|
|
|
XuiSendMessage( app.GetRootObj(), &msg );
|
2013-04-19 19:04:08 +00:00
|
|
|
|
2013-05-09 16:44:35 +00:00
|
|
|
XuiRenderSetViewTransform( app.GetDC(), &matOrigView );
|
2013-04-19 19:04:08 +00:00
|
|
|
|
2015-04-26 16:08:17 +00:00
|
|
|
message = rarch_main_msg_queue_pull();
|
2014-03-09 17:25:52 +00:00
|
|
|
|
|
|
|
if (message)
|
|
|
|
xui_render_message(message);
|
|
|
|
else
|
|
|
|
{
|
2015-04-26 16:08:17 +00:00
|
|
|
message = rarch_main_msg_queue_pull();
|
2014-03-09 17:25:52 +00:00
|
|
|
if (message)
|
|
|
|
xui_render_message(message);
|
|
|
|
}
|
|
|
|
|
2013-05-09 16:44:35 +00:00
|
|
|
XuiRenderEnd( app.GetDC() );
|
2014-03-05 18:03:25 +00:00
|
|
|
|
2015-04-26 16:08:17 +00:00
|
|
|
menu_display_unset_viewport(menu);
|
2013-03-10 02:34:37 +00:00
|
|
|
}
|
2013-09-19 13:01:17 +00:00
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
static void blit_line(int x, int y, const char *message, bool green)
|
2014-02-28 16:50:55 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-30 19:51:12 +00:00
|
|
|
static void rmenu_xui_render_background(void)
|
2014-02-28 16:50:55 +00:00
|
|
|
{
|
2015-03-21 04:42:49 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
if (global->content_is_init)
|
2015-01-12 23:48:26 +00:00
|
|
|
XuiElementSetShow(m_background, FALSE);
|
|
|
|
else
|
|
|
|
XuiElementSetShow(m_background, TRUE);
|
2014-02-28 16:50:55 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_render_messagebox(const char *message)
|
2014-02-28 16:50:55 +00:00
|
|
|
{
|
2014-03-09 17:25:52 +00:00
|
|
|
msg_queue_clear(xui_msg_queue);
|
|
|
|
msg_queue_push(xui_msg_queue, message, 2, 1);
|
2014-02-28 16:50:55 +00:00
|
|
|
}
|
|
|
|
|
2015-02-01 07:13:09 +00:00
|
|
|
static void rmenu_xui_set_list_text(int index, const wchar_t* leftText,
|
|
|
|
const wchar_t* rightText)
|
2014-02-28 16:50:55 +00:00
|
|
|
{
|
2015-02-01 07:13:09 +00:00
|
|
|
LPCWSTR currText;
|
|
|
|
float width, height;
|
|
|
|
XUIRect pRect;
|
|
|
|
D3DXVECTOR3 textPos, rightEdgePos;
|
|
|
|
HXUIOBJ hVisual = NULL, hControl = NULL, hTextLeft = NULL,
|
|
|
|
hTextRight = NULL, hRightEdge = NULL;
|
|
|
|
|
|
|
|
hControl = XuiListGetItemControl(m_menulist, index);
|
|
|
|
|
|
|
|
if (XuiHandleIsValid(hControl))
|
|
|
|
XuiControlGetVisual(hControl, &hVisual);
|
|
|
|
|
|
|
|
if(!XuiHandleIsValid(hVisual))
|
|
|
|
return;
|
|
|
|
|
|
|
|
XuiElementGetChildById(hVisual, L"LeftText", &hTextLeft);
|
|
|
|
|
|
|
|
if (!XuiHandleIsValid(hTextLeft))
|
|
|
|
return;
|
|
|
|
|
|
|
|
currText = XuiTextElementGetText(hTextLeft);
|
|
|
|
XuiElementGetBounds(hTextLeft, &width, &height);
|
|
|
|
|
|
|
|
if (!currText || wcscmp(currText, leftText) || width <= 5)
|
|
|
|
{
|
|
|
|
XuiTextElementMeasureText(hTextLeft, leftText, &pRect);
|
|
|
|
XuiElementSetBounds(hTextLeft, pRect.GetWidth(), height);
|
|
|
|
}
|
|
|
|
|
|
|
|
XuiTextElementSetText(hTextLeft, leftText);
|
|
|
|
XuiElementGetChildById(hVisual, L"RightText", &hTextRight);
|
|
|
|
|
|
|
|
if(XuiHandleIsValid(hTextRight))
|
|
|
|
{
|
|
|
|
currText = XuiTextElementGetText(hTextRight);
|
|
|
|
XuiElementGetBounds(hTextRight, &width, &height);
|
|
|
|
|
|
|
|
if (!currText || wcscmp(currText, rightText) || width <= 5)
|
|
|
|
{
|
|
|
|
XuiTextElementMeasureText(hTextRight, rightText, &pRect);
|
|
|
|
XuiElementSetBounds(hTextRight, pRect.GetWidth(), height);
|
|
|
|
XuiElementGetPosition(hTextLeft, &textPos);
|
|
|
|
|
|
|
|
XuiElementGetChildById(hVisual, L"graphic_CapRight", &hRightEdge);
|
|
|
|
XuiElementGetPosition(hRightEdge, &rightEdgePos);
|
|
|
|
|
|
|
|
textPos.x = rightEdgePos.x - (pRect.GetWidth() + textPos.x);
|
|
|
|
XuiElementSetPosition(hTextRight, &textPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
XuiTextElementSetText(hTextRight, rightText);
|
|
|
|
}
|
2015-01-10 12:00:47 +00:00
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_render(void)
|
2015-01-10 12:00:47 +00:00
|
|
|
{
|
|
|
|
size_t end, i;
|
|
|
|
char title[PATH_MAX_LENGTH];
|
|
|
|
const char *dir = NULL, *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
2015-05-09 15:54:19 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
uint64_t frame_count = video_driver_get_frame_count();
|
2015-01-10 12:00:47 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
if (!menu)
|
|
|
|
return;
|
2015-05-15 20:06:42 +00:00
|
|
|
if (menu_needs_refresh() &&
|
2015-05-19 18:11:57 +00:00
|
|
|
menu_driver_alive() && !menu->msg_force)
|
2015-01-10 12:00:47 +00:00
|
|
|
return;
|
|
|
|
|
2015-05-18 21:14:56 +00:00
|
|
|
menu_display_fb_unset_dirty();
|
2015-05-12 12:43:54 +00:00
|
|
|
menu->animation_is_active = false;
|
|
|
|
menu->label.is_updated = false;
|
2015-03-08 18:51:25 +00:00
|
|
|
|
2015-01-10 12:00:47 +00:00
|
|
|
rmenu_xui_render_background();
|
|
|
|
|
|
|
|
if (XuiHandleIsValid(m_menutitle))
|
|
|
|
{
|
2015-05-14 22:07:07 +00:00
|
|
|
menu_entries_get_title(title, sizeof(title));
|
2015-01-10 12:00:47 +00:00
|
|
|
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitle, strw_buffer);
|
2015-05-09 15:54:19 +00:00
|
|
|
menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, (unsigned int)frame_count / 15, title, true);
|
2015-01-10 12:00:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (XuiHandleIsValid(m_menutitle))
|
|
|
|
{
|
2015-05-21 02:45:40 +00:00
|
|
|
menu_entries_get_core_title(title, sizeof(title));
|
2015-01-10 12:00:47 +00:00
|
|
|
|
|
|
|
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
|
|
|
|
}
|
|
|
|
|
2015-05-14 22:03:06 +00:00
|
|
|
end = menu_entries_get_end();
|
2015-01-10 12:00:47 +00:00
|
|
|
for (i = 0; i < end; i++)
|
2015-01-31 16:19:12 +00:00
|
|
|
{
|
2015-05-07 07:44:29 +00:00
|
|
|
menu_entry_t entry;
|
2015-06-01 13:05:32 +00:00
|
|
|
char entry_label[PATH_MAX_LENGTH], entry_value[PATH_MAX_LENGTH];
|
2015-01-31 16:19:12 +00:00
|
|
|
wchar_t msg_left[PATH_MAX_LENGTH], msg_right[PATH_MAX_LENGTH];
|
2015-05-07 07:44:29 +00:00
|
|
|
|
2015-05-10 09:23:00 +00:00
|
|
|
menu_entry_get(&entry, i, NULL, true);
|
2015-06-01 12:59:15 +00:00
|
|
|
menu_entry_get_value(i, entry_value, sizeof(entry_value));
|
2015-06-01 13:05:32 +00:00
|
|
|
menu_entry_get_label(i, entry_label, sizeof(entry_label));
|
2015-05-07 07:44:29 +00:00
|
|
|
|
2015-06-01 13:05:32 +00:00
|
|
|
mbstowcs(msg_left, entry_label, sizeof(msg_left) / sizeof(wchar_t));
|
2015-06-01 12:59:15 +00:00
|
|
|
mbstowcs(msg_right, entry_value, sizeof(msg_right) / sizeof(wchar_t));
|
2015-01-31 16:19:12 +00:00
|
|
|
rmenu_xui_set_list_text(i, msg_left, msg_right);
|
|
|
|
}
|
2015-02-13 23:51:17 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr);
|
2015-01-10 12:00:47 +00:00
|
|
|
|
2015-02-11 19:28:54 +00:00
|
|
|
if (menu->keyboard.display)
|
2015-01-10 12:00:47 +00:00
|
|
|
{
|
|
|
|
char msg[1024];
|
2015-02-11 19:28:54 +00:00
|
|
|
const char *str = *menu->keyboard.buffer;
|
2015-01-10 12:00:47 +00:00
|
|
|
if (!str)
|
|
|
|
str = "";
|
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
|
|
|
rmenu_xui_render_messagebox(msg);
|
2015-01-10 12:00:47 +00:00
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_populate_entries(const char *path,
|
2014-08-31 17:47:45 +00:00
|
|
|
const char *label, unsigned i)
|
2014-03-08 05:15:52 +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)
|
|
|
|
return;
|
|
|
|
|
2014-08-31 17:29:42 +00:00
|
|
|
(void)label;
|
2014-08-31 17:47:45 +00:00
|
|
|
(void)path;
|
2014-08-31 17:29:42 +00:00
|
|
|
|
2015-02-13 23:51:17 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr);
|
2014-03-08 05:15:52 +00:00
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_navigation_clear(bool pending_push)
|
2014-04-13 21:41:47 +00:00
|
|
|
{
|
2015-03-21 22:56:42 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2014-10-12 21:44:10 +00:00
|
|
|
|
|
|
|
if (menu)
|
2015-02-13 23:51:17 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr);
|
2014-04-13 21:41:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_navigation_set_visible(void)
|
2014-04-13 21:41: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)
|
2015-02-13 23:51:17 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr);
|
2014-04-13 21:41:47 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_navigation_alphabet(size_t *ptr_out)
|
2014-04-13 21:41:47 +00:00
|
|
|
{
|
|
|
|
XuiListSetCurSelVisible(m_menulist, *ptr_out);
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_list_insert(file_list_t *list,
|
2014-09-09 04:25:52 +00:00
|
|
|
const char *path, const char *, size_t list_size)
|
2014-04-13 22:09:52 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
wchar_t buf[PATH_MAX_LENGTH];
|
2014-04-13 22:09:52 +00:00
|
|
|
|
|
|
|
XuiListInsertItems(m_menulist, list_size, 1);
|
|
|
|
mbstowcs(buf, path, sizeof(buf) / sizeof(wchar_t));
|
|
|
|
XuiListSetText(m_menulist, list_size, buf);
|
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_list_delete(file_list_t *list, size_t idx,
|
2014-10-10 20:36:30 +00:00
|
|
|
size_t list_size)
|
2014-04-13 22:09:52 +00:00
|
|
|
{
|
2015-02-01 07:13:09 +00:00
|
|
|
int x = XuiListGetItemCount( m_menulist );
|
|
|
|
|
2014-10-20 17:18:18 +00:00
|
|
|
(void)idx;
|
2015-02-01 07:13:09 +00:00
|
|
|
|
2015-04-03 00:41:37 +00:00
|
|
|
if( list_size > x)
|
2015-02-01 07:13:09 +00:00
|
|
|
list_size = x;
|
2015-04-03 00:41:37 +00:00
|
|
|
if( list_size > 0)
|
2015-02-01 07:13:09 +00:00
|
|
|
XuiListDeleteItems(m_menulist, 0, list_size);
|
2014-04-13 22:09:52 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 18:00:34 +00:00
|
|
|
static void rmenu_xui_list_clear(file_list_t *list)
|
2014-04-13 22:09:52 +00:00
|
|
|
{
|
|
|
|
XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist));
|
|
|
|
}
|
|
|
|
|
2015-02-11 19:40:48 +00:00
|
|
|
static void rmenu_xui_list_set_selection(file_list_t *list)
|
2014-04-13 22:09:52 +00:00
|
|
|
{
|
2014-08-30 13:50:42 +00:00
|
|
|
if (list)
|
|
|
|
XuiListSetCurSel(m_menulist, file_list_get_directory_ptr(list));
|
2014-04-13 22:09:52 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
2013-11-04 15:23:37 +00:00
|
|
|
NULL,
|
2014-03-09 17:25:52 +00:00
|
|
|
rmenu_xui_render_messagebox,
|
2014-02-28 16:50:55 +00:00
|
|
|
rmenu_xui_render,
|
2014-04-01 02:45:00 +00:00
|
|
|
rmenu_xui_frame,
|
2013-11-19 05:09:14 +00:00
|
|
|
rmenu_xui_init,
|
|
|
|
rmenu_xui_free,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-03-08 05:15:52 +00:00
|
|
|
rmenu_xui_populate_entries,
|
2015-02-11 20:06:50 +00:00
|
|
|
NULL,
|
2014-04-13 21:41:47 +00:00
|
|
|
rmenu_xui_navigation_clear,
|
|
|
|
rmenu_xui_navigation_set_visible,
|
|
|
|
rmenu_xui_navigation_set_visible,
|
2014-12-23 20:25:02 +00:00
|
|
|
rmenu_xui_navigation_clear,
|
2014-04-13 21:41:47 +00:00
|
|
|
rmenu_xui_navigation_set_visible,
|
|
|
|
rmenu_xui_navigation_alphabet,
|
|
|
|
rmenu_xui_navigation_alphabet,
|
2014-04-13 22:09:52 +00:00
|
|
|
rmenu_xui_list_insert,
|
|
|
|
rmenu_xui_list_delete,
|
|
|
|
rmenu_xui_list_clear,
|
2014-12-23 20:25:02 +00:00
|
|
|
NULL,
|
2014-04-13 22:09:52 +00:00
|
|
|
rmenu_xui_list_set_selection,
|
2015-02-12 23:12:15 +00:00
|
|
|
NULL,
|
2013-09-19 13:01:17 +00:00
|
|
|
"rmenu_xui",
|
2015-05-19 19:05:40 +00:00
|
|
|
NULL,
|
2014-02-28 18:22:32 +00:00
|
|
|
};
|