RetroArch/360/menu.cpp

124 lines
3.0 KiB
C++
Raw Normal View History

/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES.
*
* SSNES is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with SSNES.
* If not, see <http://www.gnu.org/licenses/>.
*/
2012-01-23 22:22:54 +01:00
#include <stdint.h>
#include <xtl.h>
2012-01-22 21:47:34 +01:00
#include "xdk360_video.h"
#include "menu.h"
#include "shared.h"
CSSNES app;
HXUIOBJ hMainScene;
2012-01-23 22:22:54 +01:00
uint32_t menu_is_running;
2012-01-22 21:47:34 +01:00
/* Register custom classes */
HRESULT CSSNES::RegisterXuiClasses (void)
{
2012-01-23 21:30:59 +01:00
CMyMainScene::Register();
return S_OK;
}
/* Unregister custom classes */
HRESULT CSSNES::UnregisterXuiClasses (void)
{
2012-01-23 21:30:59 +01:00
CMyMainScene::Unregister();
return S_OK;
}
2012-01-24 00:02:02 +01:00
HRESULT CMyMainScene::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
{
GetChildById(L"XuiBtnRomBrowser", &m_filebrowser);
GetChildById(L"XuiBtnSettings", &m_settings);
2012-01-24 00:02:02 +01:00
GetChildById(L"XuiBtnQuit", &m_quit);
GetChildById(L"XuiTxtTitle", &m_title);
return S_OK;
}
HRESULT CMyMainScene::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
if ( hObjPressed == m_filebrowser )
{
menu_is_running = false;
mode_switch = MODE_EMULATION;
init_ssnes = 1;
2012-01-24 00:02:02 +01:00
}
bHandled = TRUE;
return S_OK;
}
2012-01-22 21:47:34 +01:00
int menu_init (void)
{
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
hr = app.InitShared(vid->xdk360_render_device, &vid->d3dpp, XuiPNGTextureLoader);
2012-01-22 21:47:34 +01:00
if (FAILED(hr))
{
OutputDebugString("Failed initializing XUI application.\n");
return 1;
}
/* Register font */
2012-01-23 21:49:21 +01:00
hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/ssnes.ttf" );
2012-01-22 21:47:34 +01:00
if (FAILED(hr))
{
OutputDebugString("Failed to register default typeface.\n");
return 1;
}
2012-01-23 21:30:59 +01:00
hr = app.LoadSkin( L"file://game:/media/ssnes_scene_skin.xur");
if (FAILED(hr))
{
OutputDebugString("Failed to load skin.\n");
}
2012-01-23 21:36:54 +01:00
hr = app.LoadFirstScene( L"file://game:/media/", L"ssnes_main.xur", NULL);
if (FAILED(hr))
{
OutputDebugString("Failed to load first scene.\n");
}
2012-01-22 21:47:34 +01:00
return 0;
}
void menu_loop(void)
{
2012-01-23 22:22:54 +01:00
menu_is_running = true;
HRESULT hr;
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
do
{
vid->xdk360_render_device->Clear(0, NULL,
D3DCLEAR_TARGET | D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER,
D3DCOLOR_ARGB(255, 32, 32, 64), 1.0, 0);
app.RunFrame(); /* Update XUI */
hr = app.Render(); /* Render XUI */
hr = XuiTimersRun(); /* Update XUI timers */
/* Present the frame */
2012-01-23 22:22:54 +01:00
vid->xdk360_render_device->Present(NULL, NULL, NULL, NULL);
}while(menu_is_running);
2012-01-24 00:02:02 +01:00
}