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-01-12 18:11:51 +00:00
|
|
|
#include "../menu_driver.h"
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "../menu.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
|
|
|
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../../settings_data.h"
|
|
|
|
#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
|
2014-06-01 00:33:43 +00: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 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
|
|
|
|
2015-01-26 09:54:13 +00:00
|
|
|
static int rmenu_xui_entry_iterate(unsigned action)
|
|
|
|
{
|
|
|
|
const char *label = NULL;
|
|
|
|
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)
|
|
|
|
menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf,
|
|
|
|
driver.menu->selection_ptr);
|
|
|
|
|
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL);
|
|
|
|
|
|
|
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
|
|
|
|
driver.menu_ctx->set_texture(driver.menu);
|
|
|
|
|
|
|
|
if (cbs && cbs->action_iterate)
|
|
|
|
return cbs->action_iterate(label, action);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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];
|
|
|
|
snprintf(str, sizeof(str), "%s - %s", PACKAGE_VERSION, g_extern.title_buf);
|
|
|
|
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-01-12 23:48:26 +00:00
|
|
|
HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex)
|
|
|
|
{
|
|
|
|
CONST BYTE *pbTextureData = 0;
|
|
|
|
UINT cbTextureData = 0;
|
|
|
|
HXUIRESOURCE hResource = 0;
|
|
|
|
BOOL bIsMemoryResource = FALSE;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Format specific code to initialize pImageInfo and create our texture
|
|
|
|
D3DXIMAGE_INFO pSrc;
|
|
|
|
|
|
|
|
// Cast our d3d device into our IDirect3DDevice9* interface
|
|
|
|
IDirect3DDevice9 * d3dDevice = (IDirect3DDevice9*)pDevice->GetD3DDevice();
|
|
|
|
if( d3dDevice == NULL )
|
|
|
|
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");
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
if (bIsMemoryResource && hResource != 0)
|
|
|
|
{
|
|
|
|
XuiResourceReleaseBuffer(hResource, pbTextureData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XuiFree((LPVOID)pbTextureData);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hResource != 0)
|
|
|
|
{
|
|
|
|
XuiResourceClose(hResource);
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
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;
|
2014-05-30 20:37:23 +00:00
|
|
|
TypefaceDescriptor typeface = {0};
|
2012-01-22 20:47:34 +00:00
|
|
|
|
2014-06-10 00:06:10 +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
|
|
|
|
2014-03-25 09:19:02 +00:00
|
|
|
d3d_video_t *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");
|
|
|
|
|
2012-11-20 00:40:52 +00:00
|
|
|
D3DPRESENT_PARAMETERS d3dpp;
|
2012-11-20 01:51:00 +00: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 22:54:35 +00:00
|
|
|
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 */
|
2013-04-18 13:33:25 +00:00
|
|
|
typeface.szTypeface = L"Arial Unicode MS";
|
|
|
|
typeface.szLocator = L"file://game:/media/rarch.ttf";
|
|
|
|
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
|
|
|
|
2014-09-02 14:03:17 +00:00
|
|
|
if (driver.video_data && driver.video_poke
|
|
|
|
&& driver.video_poke->set_texture_enable)
|
2014-03-25 09:19:02 +00:00
|
|
|
driver.video_poke->set_texture_frame(driver.video_data, 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;
|
2014-03-09 17:25:52 +00:00
|
|
|
|
2014-12-03 21:26:35 +00:00
|
|
|
struct string_list *list = string_split(msg, "\n");
|
2014-10-02 19:57:01 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2015-01-27 14:35:31 +00:00
|
|
|
|
|
|
|
if (!list)
|
2014-12-03 21:26:35 +00:00
|
|
|
return;
|
|
|
|
|
2015-01-27 14:35:31 +00:00
|
|
|
if (!d3d || list->elems == 0)
|
2014-12-03 21:26:35 +00:00
|
|
|
{
|
|
|
|
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 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
|
|
|
|
2014-12-03 21:26:35 +00:00
|
|
|
if (driver.video_poke && driver.video_poke->set_osd_msg)
|
|
|
|
driver.video_poke->set_osd_msg(driver.video_data,
|
2014-11-08 18:31:11 +00:00
|
|
|
msg, &font_parms, NULL);
|
2014-12-03 21:26:35 +00:00
|
|
|
}
|
2012-04-17 03:35:25 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 20:37:23 +00:00
|
|
|
static void rmenu_xui_frame(void)
|
2013-03-09 21:30:35 +00:00
|
|
|
{
|
2014-05-30 20:37:23 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2014-03-07 19:17:25 +00:00
|
|
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
2013-04-19 21:22:58 +00:00
|
|
|
|
2014-03-05 18:03:25 +00: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 16:01:32 +00:00
|
|
|
d3d_set_viewport(d3dr, &vp_full);
|
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
|
|
|
D3DXMATRIX matOrigView;
|
|
|
|
XuiRenderGetViewTransform( app.GetDC(), &matOrigView );
|
2013-04-19 19:04:08 +00:00
|
|
|
|
2013-05-09 16:44:35 +00:00
|
|
|
XUIMessage msg;
|
|
|
|
XUIMessageRender msgRender;
|
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
|
|
|
|
2014-03-09 17:25:52 +00: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 16:44:35 +00:00
|
|
|
XuiRenderEnd( app.GetDC() );
|
2014-03-05 18:03:25 +00:00
|
|
|
|
2014-09-12 16:01:32 +00:00
|
|
|
d3d_set_viewport(d3dr, &d3d->final_viewport);
|
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-01-12 23:48:26 +00:00
|
|
|
if (g_extern.content_is_init)
|
|
|
|
XuiElementSetShow(m_background, FALSE);
|
|
|
|
else
|
|
|
|
XuiElementSetShow(m_background, TRUE);
|
2014-02-28 16:50:55 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 19:51:12 +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-01-10 12:00:47 +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-01-10 12:00:47 +00:00
|
|
|
HXUIOBJ hVisual = NULL, hControl = NULL, hTextLeft = NULL, hTextRight = NULL, hRightEdge = NULL;
|
|
|
|
LPCWSTR currText;
|
|
|
|
float width, height;
|
2015-01-12 23:48:26 +00:00
|
|
|
XUIRect pRect;
|
2015-01-10 12:00:47 +00:00
|
|
|
D3DXVECTOR3 textPos, rightEdgePos;
|
|
|
|
|
|
|
|
hControl = XuiListGetItemControl(m_menulist, index);
|
|
|
|
if (XuiHandleIsValid(hControl))
|
|
|
|
XuiControlGetVisual(hControl, &hVisual);
|
|
|
|
if(XuiHandleIsValid(hVisual))
|
|
|
|
{
|
|
|
|
XuiElementGetChildById(hVisual, L"LeftText", &hTextLeft);
|
|
|
|
if(XuiHandleIsValid(hTextLeft))
|
|
|
|
{
|
|
|
|
currText = XuiTextElementGetText(hTextLeft);
|
|
|
|
XuiElementGetBounds(hTextLeft, &width, &height);
|
|
|
|
if (!currText || wcscmp(currText, leftText) || width <= 5)
|
|
|
|
{
|
2015-01-12 23:48:26 +00:00
|
|
|
XuiTextElementMeasureText(hTextLeft, leftText, &pRect);
|
|
|
|
XuiElementSetBounds(hTextLeft, pRect.GetWidth(), height);
|
2015-01-10 12:00:47 +00:00
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
2015-01-12 23:48:26 +00:00
|
|
|
XuiTextElementMeasureText(hTextRight, rightText, &pRect);
|
|
|
|
XuiElementSetBounds(hTextRight, pRect.GetWidth(), height);
|
2015-01-10 12:00:47 +00:00
|
|
|
XuiElementGetPosition(hTextLeft, &textPos);
|
|
|
|
|
|
|
|
XuiElementGetChildById(hVisual, L"graphic_CapRight", &hRightEdge);
|
|
|
|
XuiElementGetPosition(hRightEdge, &rightEdgePos);
|
|
|
|
|
2015-01-12 23:48:26 +00:00
|
|
|
textPos.x = rightEdgePos.x - (pRect.GetWidth() + textPos.x);
|
2015-01-10 12:00:47 +00:00
|
|
|
XuiElementSetPosition(hTextRight, &textPos);
|
|
|
|
}
|
|
|
|
XuiTextElementSetText(hTextRight, rightText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
|
2015-01-10 12:00:47 +00:00
|
|
|
static void rmenu_xui_render(void)
|
|
|
|
{
|
|
|
|
size_t end, i;
|
|
|
|
char title[PATH_MAX_LENGTH];
|
|
|
|
const char *dir = NULL, *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
|
|
|
|
if (!driver.menu || driver.menu->need_refresh &&
|
|
|
|
g_extern.is_menu && !driver.menu->msg_force)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rmenu_xui_render_background();
|
|
|
|
|
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type);
|
|
|
|
|
|
|
|
if (XuiHandleIsValid(m_menutitle))
|
|
|
|
{
|
|
|
|
get_title(label, dir, menu_type, title, sizeof(title));
|
|
|
|
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitle, strw_buffer);
|
|
|
|
menu_ticker_line(title, RXUI_TERM_WIDTH - 3, g_extern.frame_count / 15, title, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XuiHandleIsValid(m_menutitle))
|
|
|
|
{
|
|
|
|
const char *core_name = g_extern.menu.info.library_name;
|
|
|
|
if (!core_name)
|
|
|
|
core_name = g_extern.system.info.library_name;
|
|
|
|
if (!core_name)
|
|
|
|
core_name = "No Core";
|
|
|
|
|
|
|
|
const char *core_version = g_extern.menu.info.library_version;
|
|
|
|
if (!core_version)
|
|
|
|
core_version = g_extern.system.info.library_version;
|
|
|
|
if (!core_version)
|
|
|
|
core_version = "";
|
|
|
|
|
|
|
|
snprintf(title, sizeof(title), "%s - %s %s",
|
|
|
|
PACKAGE_VERSION, core_name, core_version);
|
|
|
|
|
|
|
|
mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t));
|
|
|
|
XuiTextElementSetText(m_menutitlebottom, strw_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
end = menu_list_get_size(driver.menu->menu_list);
|
|
|
|
for (i = 0; i < end; i++)
|
2015-01-31 16:19:12 +00:00
|
|
|
{
|
|
|
|
wchar_t msg_left[PATH_MAX_LENGTH], msg_right[PATH_MAX_LENGTH];
|
|
|
|
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
|
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
|
|
|
rarch_setting_t *setting = NULL;
|
|
|
|
|
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
|
|
|
&entry_label, &type);
|
|
|
|
|
|
|
|
setting = (rarch_setting_t*)setting_data_find_setting(
|
|
|
|
driver.menu->list_settings,
|
|
|
|
driver.menu->menu_list->selection_buf->list[i].label);
|
|
|
|
(void)setting;
|
|
|
|
|
|
|
|
disp_set_label(driver.menu->menu_list->selection_buf,
|
|
|
|
&w, type, i, label,
|
|
|
|
type_str, sizeof(type_str),
|
|
|
|
entry_label, path,
|
|
|
|
path_buf, sizeof(path_buf));
|
|
|
|
|
|
|
|
mbstowcs(msg_left, path_buf, sizeof(msg_left) / sizeof(wchar_t));
|
|
|
|
mbstowcs(msg_right, type_str, sizeof(msg_right) / sizeof(wchar_t));
|
|
|
|
rmenu_xui_set_list_text(i, msg_left, msg_right);
|
|
|
|
}
|
2015-01-10 12:00:47 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, driver.menu->selection_ptr);
|
|
|
|
|
|
|
|
if (driver.menu->keyboard.display)
|
|
|
|
{
|
|
|
|
char msg[1024];
|
|
|
|
const char *str = *driver.menu->keyboard.buffer;
|
|
|
|
if (!str)
|
|
|
|
str = "";
|
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
|
|
|
rmenu_xui_render_messagebox(msg);
|
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
}
|
|
|
|
|
2014-08-31 17:47:45 +00:00
|
|
|
static void rmenu_xui_populate_entries(void *data, const char *path,
|
|
|
|
const char *label, unsigned i)
|
2014-03-08 05:15:52 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
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
|
|
|
|
2014-06-10 00:06:10 +00:00
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-03-08 05:15:52 +00:00
|
|
|
}
|
2014-02-28 16:50:55 +00:00
|
|
|
|
2014-10-12 21:44:10 +00:00
|
|
|
static void rmenu_xui_navigation_clear(void *data, bool pending_push)
|
2014-04-13 21:41:47 +00:00
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-10-12 21:44:10 +00:00
|
|
|
|
|
|
|
(void)pending_push;
|
|
|
|
|
|
|
|
if (menu)
|
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-04-13 21:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_navigation_set_visible(void *data)
|
|
|
|
{
|
2014-06-10 00:06:10 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
|
|
|
XuiListSetCurSelVisible(m_menulist, menu->selection_ptr);
|
2014-04-13 21:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rmenu_xui_navigation_alphabet(void *data, size_t *ptr_out)
|
|
|
|
{
|
|
|
|
XuiListSetCurSelVisible(m_menulist, *ptr_out);
|
|
|
|
}
|
|
|
|
|
2014-09-02 14:03:17 +00:00
|
|
|
static void rmenu_xui_list_insert(void *data,
|
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
|
|
|
{
|
|
|
|
(void)data;
|
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);
|
|
|
|
}
|
|
|
|
|
2014-10-20 17:18:18 +00:00
|
|
|
static void rmenu_xui_list_delete(void *data, size_t idx,
|
2014-10-10 20:36:30 +00:00
|
|
|
size_t list_size)
|
2014-04-13 22:09:52 +00:00
|
|
|
{
|
|
|
|
(void)data;
|
2014-10-20 17:18:18 +00:00
|
|
|
(void)idx;
|
2015-01-12 23:48:26 +00:00
|
|
|
int x = XuiListGetItemCount( m_menulist );
|
|
|
|
if( list_size > x ) list_size = x;
|
|
|
|
if( list_size > 0 ) XuiListDeleteItems(m_menulist, 0, list_size);
|
2014-04-13 22:09:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 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-11-25 02:49:26 +00:00
|
|
|
static void rmenu_xui_update_core_info(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
2014-12-23 20:21:49 +00:00
|
|
|
menu_update_libretro_info(&g_extern.menu.info);
|
2014-11-25 02:49:26 +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,
|
2014-10-08 23:31:11 +00:00
|
|
|
NULL,
|
2013-11-19 05:09:14 +00:00
|
|
|
rmenu_xui_free,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-03-08 05:15:52 +00:00
|
|
|
rmenu_xui_populate_entries,
|
2014-02-28 20:15:16 +00:00
|
|
|
NULL,
|
2014-10-01 13:17:34 +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,
|
2014-09-03 12:57:29 +00:00
|
|
|
NULL,
|
2014-11-25 02:49:26 +00:00
|
|
|
rmenu_xui_update_core_info,
|
2015-01-26 09:54:13 +00:00
|
|
|
rmenu_xui_entry_iterate,
|
2013-09-19 13:01:17 +00:00
|
|
|
"rmenu_xui",
|
2014-02-28 18:22:32 +00:00
|
|
|
};
|