mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
(Rmenu XUI) Cleanups
This commit is contained in:
parent
1f3ff10246
commit
6060849910
@ -180,123 +180,116 @@ HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName, XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex)
|
HRESULT XuiTextureLoader(IXuiDevice *pDevice, LPCWSTR szFileName,
|
||||||
|
XUIImageInfo *pImageInfo, IDirect3DTexture9 **ppTex)
|
||||||
{
|
{
|
||||||
CONST BYTE *pbTextureData = 0;
|
D3DXIMAGE_INFO pSrc;
|
||||||
UINT cbTextureData = 0;
|
CONST BYTE *pbTextureData = 0;
|
||||||
HXUIRESOURCE hResource = 0;
|
UINT cbTextureData = 0;
|
||||||
BOOL bIsMemoryResource = FALSE;
|
HXUIRESOURCE hResource = 0;
|
||||||
HRESULT hr;
|
BOOL bIsMemoryResource = FALSE;
|
||||||
|
IDirect3DDevice9 * d3dDevice = NULL;
|
||||||
|
HRESULT hr = XuiResourceOpenNoLoc(szFileName, &hResource,
|
||||||
|
&bIsMemoryResource);
|
||||||
|
|
||||||
hr = XuiResourceOpenNoLoc(szFileName, &hResource, &bIsMemoryResource);
|
if (FAILED(hr))
|
||||||
if (FAILED(hr))
|
return 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 (bIsMemoryResource)
|
||||||
if (pbTextureData == 0)
|
{
|
||||||
{
|
hr = XuiResourceGetBuffer(hResource, &pbTextureData);
|
||||||
hr = E_OUTOFMEMORY;
|
if (FAILED(hr))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
cbTextureData = XuiResourceGetTotalSize(hResource);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = XuiResourceRead(hResource, NULL, 0, &cbTextureData);
|
||||||
|
if (FAILED(hr))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
hr = XuiResourceRead(hResource, (BYTE*)pbTextureData, cbTextureData, &cbTextureData);
|
pbTextureData = (BYTE *)XuiAlloc(cbTextureData);
|
||||||
if (FAILED(hr))
|
if (pbTextureData == 0)
|
||||||
goto cleanup;
|
{
|
||||||
|
hr = E_OUTOFMEMORY;
|
||||||
XuiResourceClose(hResource);
|
goto cleanup;
|
||||||
hResource = 0;
|
}
|
||||||
|
|
||||||
}
|
hr = XuiResourceRead(hResource, (BYTE*)pbTextureData, cbTextureData, &cbTextureData);
|
||||||
|
if (FAILED(hr))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
//Format specific code to initialize pImageInfo and create our texture
|
XuiResourceClose(hResource);
|
||||||
D3DXIMAGE_INFO pSrc;
|
hResource = 0;
|
||||||
|
|
||||||
// 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
|
/* Cast our d3d device into our IDirect3DDevice9* interface */
|
||||||
hr = D3DXCreateTextureFromFileInMemoryEx(
|
d3dDevice = (IDirect3DDevice9*)pDevice->GetD3DDevice();
|
||||||
d3dDevice,
|
if(!d3dDevice)
|
||||||
pbTextureData,
|
goto cleanup;
|
||||||
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 )
|
/* Create our texture based on our conditions */
|
||||||
{
|
hr = D3DXCreateTextureFromFileInMemoryEx(
|
||||||
pImageInfo->Depth = pSrc.Depth;
|
d3dDevice,
|
||||||
pImageInfo->Format = pSrc.Format;
|
pbTextureData,
|
||||||
pImageInfo->Height = pSrc.Height;
|
cbTextureData,
|
||||||
pImageInfo->ImageFileFormat = pSrc.ImageFileFormat;
|
D3DX_DEFAULT_NONPOW2,
|
||||||
pImageInfo->MipLevels = pSrc.MipLevels;
|
D3DX_DEFAULT_NONPOW2,
|
||||||
pImageInfo->ResourceType = pSrc.ResourceType;
|
1,
|
||||||
pImageInfo->Width = pSrc.Width;
|
D3DUSAGE_CPU_CACHED_MEMORY,
|
||||||
}
|
D3DFMT_LIN_A8R8G8B8,
|
||||||
else
|
D3DPOOL_DEFAULT,
|
||||||
RARCH_ERR("D3DXERR_INVALIDDATA Encountered\n");
|
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:
|
cleanup:
|
||||||
|
|
||||||
if (bIsMemoryResource && hResource != 0)
|
if (bIsMemoryResource && hResource != 0)
|
||||||
{
|
XuiResourceReleaseBuffer(hResource, pbTextureData);
|
||||||
XuiResourceReleaseBuffer(hResource, pbTextureData);
|
else
|
||||||
}
|
XuiFree((LPVOID)pbTextureData);
|
||||||
else
|
|
||||||
{
|
|
||||||
XuiFree((LPVOID)pbTextureData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hResource != 0)
|
if (hResource != 0)
|
||||||
{
|
XuiResourceClose(hResource);
|
||||||
XuiResourceClose(hResource);
|
return hr;
|
||||||
}
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* rmenu_xui_init(void)
|
static void* rmenu_xui_init(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
|
d3d_video_t *d3d;
|
||||||
|
video_info_t video_info = {0};
|
||||||
TypefaceDescriptor typeface = {0};
|
TypefaceDescriptor typeface = {0};
|
||||||
|
|
||||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||||
|
|
||||||
if (!menu)
|
if (!menu)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
d3d_video_t *d3d= (d3d_video_t*)driver.video_data;
|
d3d= (d3d_video_t*)driver.video_data;
|
||||||
|
|
||||||
if (d3d->resolution_hd_enable)
|
if (d3d->resolution_hd_enable)
|
||||||
RARCH_LOG("HD menus enabled.\n");
|
RARCH_LOG("HD menus enabled.\n");
|
||||||
|
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
|
||||||
video_info_t video_info = {0};
|
|
||||||
|
|
||||||
video_info.vsync = g_settings.video.vsync;
|
video_info.vsync = g_settings.video.vsync;
|
||||||
video_info.force_aspect = false;
|
video_info.force_aspect = false;
|
||||||
@ -424,10 +417,13 @@ static void xui_render_message(const char *msg)
|
|||||||
|
|
||||||
static void rmenu_xui_frame(void)
|
static void rmenu_xui_frame(void)
|
||||||
{
|
{
|
||||||
|
XUIMessage msg;
|
||||||
|
XUIMessageRender msgRender;
|
||||||
|
D3DXMATRIX matOrigView;
|
||||||
|
D3DVIEWPORT vp_full;
|
||||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
|
|
||||||
D3DVIEWPORT vp_full;
|
|
||||||
vp_full.X = 0;
|
vp_full.X = 0;
|
||||||
vp_full.Y = 0;
|
vp_full.Y = 0;
|
||||||
vp_full.Width = d3d->screen_width;
|
vp_full.Width = d3d->screen_width;
|
||||||
@ -440,11 +436,8 @@ static void rmenu_xui_frame(void)
|
|||||||
XuiTimersRun();
|
XuiTimersRun();
|
||||||
XuiRenderBegin( app.GetDC(), D3DCOLOR_ARGB( 255, 0, 0, 0 ) );
|
XuiRenderBegin( app.GetDC(), D3DCOLOR_ARGB( 255, 0, 0, 0 ) );
|
||||||
|
|
||||||
D3DXMATRIX matOrigView;
|
|
||||||
XuiRenderGetViewTransform( app.GetDC(), &matOrigView );
|
XuiRenderGetViewTransform( app.GetDC(), &matOrigView );
|
||||||
|
|
||||||
XUIMessage msg;
|
|
||||||
XUIMessageRender msgRender;
|
|
||||||
XuiMessageRender( &msg, &msgRender, app.GetDC(), 0xffffffff, XUI_BLEND_NORMAL );
|
XuiMessageRender( &msg, &msgRender, app.GetDC(), 0xffffffff, XUI_BLEND_NORMAL );
|
||||||
XuiSendMessage( app.GetRootObj(), &msg );
|
XuiSendMessage( app.GetRootObj(), &msg );
|
||||||
|
|
||||||
@ -484,51 +477,61 @@ static void rmenu_xui_render_messagebox(const char *message)
|
|||||||
msg_queue_push(xui_msg_queue, message, 2, 1);
|
msg_queue_push(xui_msg_queue, message, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_xui_set_list_text(int index, const wchar_t* leftText, const wchar_t* rightText)
|
static void rmenu_xui_set_list_text(int index, const wchar_t* leftText,
|
||||||
|
const wchar_t* rightText)
|
||||||
{
|
{
|
||||||
HXUIOBJ hVisual = NULL, hControl = NULL, hTextLeft = NULL, hTextRight = NULL, hRightEdge = NULL;
|
LPCWSTR currText;
|
||||||
LPCWSTR currText;
|
float width, height;
|
||||||
float width, height;
|
XUIRect pRect;
|
||||||
XUIRect pRect;
|
D3DXVECTOR3 textPos, rightEdgePos;
|
||||||
D3DXVECTOR3 textPos, rightEdgePos;
|
HXUIOBJ hVisual = NULL, hControl = NULL, hTextLeft = NULL,
|
||||||
|
hTextRight = NULL, hRightEdge = NULL;
|
||||||
|
|
||||||
hControl = XuiListGetItemControl(m_menulist, index);
|
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)
|
|
||||||
{
|
|
||||||
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);
|
if (XuiHandleIsValid(hControl))
|
||||||
XuiElementGetPosition(hRightEdge, &rightEdgePos);
|
XuiControlGetVisual(hControl, &hVisual);
|
||||||
|
|
||||||
textPos.x = rightEdgePos.x - (pRect.GetWidth() + textPos.x);
|
if(!XuiHandleIsValid(hVisual))
|
||||||
XuiElementSetPosition(hTextRight, &textPos);
|
return;
|
||||||
}
|
|
||||||
XuiTextElementSetText(hTextRight, rightText);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_xui_render(void)
|
static void rmenu_xui_render(void)
|
||||||
@ -556,13 +559,14 @@ static void rmenu_xui_render(void)
|
|||||||
|
|
||||||
if (XuiHandleIsValid(m_menutitle))
|
if (XuiHandleIsValid(m_menutitle))
|
||||||
{
|
{
|
||||||
const char *core_name = g_extern.menu.info.library_name;
|
const char *core_version = NULL;
|
||||||
|
const char *core_name = g_extern.menu.info.library_name;
|
||||||
if (!core_name)
|
if (!core_name)
|
||||||
core_name = g_extern.system.info.library_name;
|
core_name = g_extern.system.info.library_name;
|
||||||
if (!core_name)
|
if (!core_name)
|
||||||
core_name = "No Core";
|
core_name = "No Core";
|
||||||
|
|
||||||
const char *core_version = g_extern.menu.info.library_version;
|
core_version = g_extern.menu.info.library_version;
|
||||||
if (!core_version)
|
if (!core_version)
|
||||||
core_version = g_extern.system.info.library_version;
|
core_version = g_extern.system.info.library_version;
|
||||||
if (!core_version)
|
if (!core_version)
|
||||||
@ -660,11 +664,15 @@ static void rmenu_xui_list_insert(void *data,
|
|||||||
static void rmenu_xui_list_delete(void *data, size_t idx,
|
static void rmenu_xui_list_delete(void *data, size_t idx,
|
||||||
size_t list_size)
|
size_t list_size)
|
||||||
{
|
{
|
||||||
|
int x = XuiListGetItemCount( m_menulist );
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
(void)idx;
|
(void)idx;
|
||||||
int x = XuiListGetItemCount( m_menulist );
|
|
||||||
if( list_size > x ) list_size = x;
|
if( list_size > x )
|
||||||
if( list_size > 0 ) XuiListDeleteItems(m_menulist, 0, list_size);
|
list_size = x;
|
||||||
|
if( list_size > 0 )
|
||||||
|
XuiListDeleteItems(m_menulist, 0, list_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rmenu_xui_list_clear(void *data)
|
static void rmenu_xui_list_clear(void *data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user