2012-01-22 00:43:54 +00:00
|
|
|
/* 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 21:22:54 +00:00
|
|
|
#include <stdint.h>
|
2012-01-24 00:06:12 +00:00
|
|
|
#include <crtdefs.h>
|
|
|
|
#include <tchar.h>
|
2012-01-22 00:43:54 +00:00
|
|
|
#include <xtl.h>
|
2012-01-22 20:47:34 +00:00
|
|
|
#include "xdk360_video.h"
|
2012-01-22 01:05:09 +00:00
|
|
|
#include "menu.h"
|
2012-01-23 23:29:03 +00:00
|
|
|
#include "shared.h"
|
2012-01-22 00:43:54 +00:00
|
|
|
|
2012-01-24 00:06:12 +00:00
|
|
|
#include "../general.h"
|
|
|
|
|
2012-01-22 21:45:32 +00:00
|
|
|
CSSNES app;
|
|
|
|
HXUIOBJ hMainScene;
|
2012-01-22 20:47:34 +00:00
|
|
|
|
2012-01-22 00:43:54 +00:00
|
|
|
/* Register custom classes */
|
|
|
|
HRESULT CSSNES::RegisterXuiClasses (void)
|
|
|
|
{
|
2012-01-24 05:55:27 +00:00
|
|
|
CSSNESMain::Register();
|
|
|
|
CSSNESSettings::Register();
|
2012-01-23 04:10:23 +00:00
|
|
|
return S_OK;
|
2012-01-22 00:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unregister custom classes */
|
|
|
|
HRESULT CSSNES::UnregisterXuiClasses (void)
|
|
|
|
{
|
2012-01-24 05:55:27 +00:00
|
|
|
CSSNESMain::Unregister();
|
|
|
|
CSSNESSettings::Unregister();
|
2012-01-22 00:43:54 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-24 05:55:27 +00:00
|
|
|
HRESULT CSSNESSettings::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
GetChildById(L"XuiBtnRewind", &m_rewind);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CSSNESMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
2012-01-23 23:02:02 +00:00
|
|
|
{
|
|
|
|
GetChildById(L"XuiBtnRomBrowser", &m_filebrowser);
|
2012-01-23 23:29:03 +00:00
|
|
|
GetChildById(L"XuiBtnSettings", &m_settings);
|
2012-01-23 23:02:02 +00:00
|
|
|
GetChildById(L"XuiBtnQuit", &m_quit);
|
|
|
|
GetChildById(L"XuiTxtTitle", &m_title);
|
2012-01-24 05:11:01 +00:00
|
|
|
GetChildById(L"XuiTxtCoreText", &m_core);
|
|
|
|
const char * core_text = snes_library_id();
|
|
|
|
char package_version[32];
|
|
|
|
sprintf(package_version, "SSNES %s", PACKAGE_VERSION);
|
|
|
|
DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0);
|
|
|
|
DWORD dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0);
|
|
|
|
wchar_t * core_text_utf = new wchar_t[dwNum];
|
|
|
|
wchar_t * package_version_utf = new wchar_t[dwNum_package];
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, core_text, -1, core_text_utf, dwNum);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, package_version, -1, package_version_utf, dwNum_package);
|
|
|
|
m_core.SetText(core_text_utf);
|
|
|
|
m_title.SetText(package_version_utf);
|
|
|
|
delete []core_text_utf;
|
|
|
|
delete []package_version_utf;
|
2012-01-23 23:02:02 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-24 05:55:27 +00:00
|
|
|
HRESULT CSSNESSettings::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
|
|
|
{
|
|
|
|
bHandled = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT CSSNESMain::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
2012-01-23 23:02:02 +00:00
|
|
|
{
|
2012-01-24 05:55:27 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-01-23 23:02:02 +00:00
|
|
|
if ( hObjPressed == m_filebrowser )
|
|
|
|
{
|
2012-02-02 18:01:52 +00:00
|
|
|
g_console->menu_enable = false;
|
|
|
|
g_console->mode_switch = MODE_EMULATION;
|
2012-01-23 23:29:03 +00:00
|
|
|
init_ssnes = 1;
|
2012-01-23 23:02:02 +00:00
|
|
|
}
|
2012-01-24 05:55:27 +00:00
|
|
|
else if ( hObjPressed == m_settings )
|
|
|
|
{
|
|
|
|
HXUIOBJ hSSNESSettings;
|
2012-01-25 06:19:07 +00:00
|
|
|
hr = XuiSceneCreate(L"file://game:/media/", L"ssnes_settings.xur", NULL, &hSSNESSettings);
|
2012-01-24 05:55:27 +00:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
SSNES_ERR("Failed to load scene.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
NavigateForward(hSSNESSettings);
|
|
|
|
}
|
2012-01-23 23:32:44 +00:00
|
|
|
else if ( hObjPressed == m_quit )
|
|
|
|
{
|
2012-02-02 18:01:52 +00:00
|
|
|
g_console->menu_enable = false;
|
|
|
|
g_console->mode_switch = MODE_EXIT;
|
2012-01-23 23:32:44 +00:00
|
|
|
init_ssnes = 0;
|
|
|
|
}
|
2012-01-23 23:02:02 +00:00
|
|
|
|
|
|
|
bHandled = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-22 20:47:34 +00:00
|
|
|
int menu_init (void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
xdk360_video_t *vid = (xdk360_video_t*)g_d3d;
|
|
|
|
|
2012-01-22 21:45:32 +00:00
|
|
|
hr = app.InitShared(vid->xdk360_render_device, &vid->d3dpp, XuiPNGTextureLoader);
|
2012-01-22 20:47:34 +00:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-01-24 00:06:12 +00:00
|
|
|
SSNES_ERR("Failed initializing XUI application.\n");
|
2012-01-22 20:47:34 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register font */
|
2012-01-23 20:49:21 +00:00
|
|
|
hr = app.RegisterDefaultTypeface(L"Arial Unicode MS", L"file://game:/media/ssnes.ttf" );
|
2012-01-22 20:47:34 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-01-24 00:06:12 +00:00
|
|
|
SSNES_ERR("Failed to register default typeface.\n");
|
2012-01-22 20:47:34 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-01-23 20:30:59 +00:00
|
|
|
hr = app.LoadSkin( L"file://game:/media/ssnes_scene_skin.xur");
|
2012-01-23 04:10:23 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-01-24 00:06:12 +00:00
|
|
|
SSNES_ERR("Failed to load skin.\n");
|
2012-01-24 00:09:34 +00:00
|
|
|
return 1;
|
2012-01-23 04:10:23 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 06:19:07 +00:00
|
|
|
hr = XuiSceneCreate(L"file://game:/media/", L"ssnes_main.xur", NULL, &hMainScene);
|
2012-01-23 04:10:23 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-01-25 06:19:07 +00:00
|
|
|
SSNES_ERR("Failed to create scene 'ssnes_main.xur'.\n");
|
2012-01-24 00:09:34 +00:00
|
|
|
return 1;
|
2012-01-23 04:10:23 +00:00
|
|
|
}
|
2012-01-22 21:45:32 +00:00
|
|
|
|
2012-01-25 06:19:07 +00:00
|
|
|
XuiSceneNavigateFirst(app.GetRootObj(), hMainScene, XUSER_INDEX_FOCUS);
|
|
|
|
|
2012-01-22 20:47:34 +00:00
|
|
|
return 0;
|
2012-01-22 21:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void menu_loop(void)
|
|
|
|
{
|
2012-02-02 18:01:52 +00:00
|
|
|
g_console->menu_enable = true;
|
2012-01-23 21:22:54 +00:00
|
|
|
|
2012-01-22 21:45:32 +00:00
|
|
|
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 21:22:54 +00:00
|
|
|
vid->xdk360_render_device->Present(NULL, NULL, NULL, NULL);
|
2012-02-02 18:01:52 +00:00
|
|
|
}while(g_console->menu_enable);
|
2012-01-23 23:02:02 +00:00
|
|
|
}
|