2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// This program 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 Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program 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 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2010-07-19 21:23:25 -06:00
|
|
|
#include "Common.h"
|
|
|
|
#include "CommonPaths.h"
|
2010-02-19 21:18:19 -07:00
|
|
|
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
2009-10-29 15:12:11 -06:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
#include "CPUDetect.h"
|
|
|
|
#include "IniFile.h"
|
|
|
|
#include "FileUtil.h"
|
2009-02-22 14:16:12 -07:00
|
|
|
|
|
|
|
#include "Host.h" // Core
|
2010-10-12 13:42:29 -06:00
|
|
|
#include "HW/Wiimote.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-02-22 14:16:12 -07:00
|
|
|
#include "Globals.h" // Local
|
|
|
|
#include "Main.h"
|
2009-01-17 16:41:21 -07:00
|
|
|
#include "ConfigManager.h"
|
2011-02-12 23:06:32 -07:00
|
|
|
#include "Debugger/CodeWindow.h"
|
|
|
|
#include "Debugger/JitWindow.h"
|
2009-01-08 17:09:07 -07:00
|
|
|
#include "ExtendedTrace.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
#include "BootManager.h"
|
2010-01-22 14:41:25 -07:00
|
|
|
#include "Frame.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
#include "VideoBackendBase.h"
|
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
#include <wx/intl.h>
|
|
|
|
|
2012-12-30 18:29:36 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <shellapi.h>
|
|
|
|
#endif
|
|
|
|
|
2012-12-25 05:51:13 -07:00
|
|
|
// Nvidia drivers >= v302 will check if the application exports a global
|
|
|
|
// variable named NvOptimusEnablement to know if it should run the app in high
|
|
|
|
// performance graphics mode or using the IGP.
|
|
|
|
#ifdef WIN32
|
|
|
|
extern "C" {
|
|
|
|
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-09-03 14:00:09 -06:00
|
|
|
// Main window
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
IMPLEMENT_APP(DolphinApp)
|
|
|
|
|
2011-03-15 19:50:46 -06:00
|
|
|
BEGIN_EVENT_TABLE(DolphinApp, wxApp)
|
|
|
|
EVT_TIMER(wxID_ANY, DolphinApp::AfterInit)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
bool wxMsgAlert(const char*, const char*, bool, int);
|
2011-01-13 17:15:08 -07:00
|
|
|
std::string wxStringTranslator(const char *);
|
2008-12-14 05:30:37 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
CFrame* main_frame = NULL;
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
//Has no error handling.
|
|
|
|
//I think that if an error occurs here there's no way to handle it anyway.
|
|
|
|
LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) {
|
|
|
|
//EnterCriticalSection(&g_uefcs);
|
|
|
|
|
2011-03-11 03:21:46 -07:00
|
|
|
File::IOFile file("exceptioninfo.txt", "a");
|
|
|
|
file.Seek(0, SEEK_END);
|
|
|
|
etfprint(file.GetHandle(), "\n");
|
2009-01-08 17:09:07 -07:00
|
|
|
//etfprint(file, g_buildtime);
|
|
|
|
//etfprint(file, "\n");
|
2008-12-07 22:30:24 -07:00
|
|
|
//dumpCurrentDate(file);
|
2011-03-11 03:21:46 -07:00
|
|
|
etfprintf(file.GetHandle(), "Unhandled Exception\n Code: 0x%08X\n",
|
2008-12-07 22:30:24 -07:00
|
|
|
e->ExceptionRecord->ExceptionCode);
|
|
|
|
#ifndef _M_X64
|
2011-03-11 03:21:46 -07:00
|
|
|
STACKTRACE2(file.GetHandle(), e->ContextRecord->Eip, e->ContextRecord->Esp, e->ContextRecord->Ebp);
|
2008-12-07 22:30:24 -07:00
|
|
|
#else
|
2011-03-11 03:21:46 -07:00
|
|
|
STACKTRACE2(file.GetHandle(), e->ContextRecord->Rip, e->ContextRecord->Rsp, e->ContextRecord->Rbp);
|
2008-12-07 22:30:24 -07:00
|
|
|
#endif
|
2011-03-11 03:21:46 -07:00
|
|
|
file.Close();
|
2008-12-07 22:30:24 -07:00
|
|
|
_flushall();
|
|
|
|
|
|
|
|
//LeaveCriticalSection(&g_uefcs);
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-19 14:53:53 -07:00
|
|
|
bool DolphinApp::Initialize(int& c, wxChar **v)
|
|
|
|
{
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
|
|
|
XInitThreads();
|
|
|
|
#endif
|
|
|
|
return wxApp::Initialize(c, v);
|
|
|
|
}
|
|
|
|
|
2009-07-11 22:10:52 -06:00
|
|
|
// The `main program' equivalent that creates the main window and return the main frame
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
bool DolphinApp::OnInit()
|
|
|
|
{
|
2011-01-04 21:35:46 -07:00
|
|
|
InitLanguageSupport();
|
|
|
|
|
2009-01-04 14:53:41 -07:00
|
|
|
// Declarations and definitions
|
|
|
|
bool UseDebugger = false;
|
2009-09-01 09:16:44 -06:00
|
|
|
bool UseLogger = false;
|
2011-02-02 09:34:12 -07:00
|
|
|
bool selectVideoBackend = false;
|
2012-12-22 16:25:52 -07:00
|
|
|
bool selectAudioEmulation = false;
|
2009-09-05 20:55:14 -06:00
|
|
|
|
2011-02-02 09:34:12 -07:00
|
|
|
wxString videoBackendName;
|
|
|
|
wxString audioEmulationName;
|
2009-09-05 20:55:14 -06:00
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
#if wxUSE_CMDLINE_PARSER // Parse command lines
|
|
|
|
wxCmdLineEntryDesc cmdLineDesc[] =
|
|
|
|
{
|
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_SWITCH, "h", "help",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Show this help message",
|
2010-03-18 08:34:37 -06:00
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
|
|
|
|
},
|
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_SWITCH, "d", "debugger",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Opens the debugger",
|
2011-02-14 14:58:53 -07:00
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
|
2010-03-18 08:34:37 -06:00
|
|
|
},
|
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_SWITCH, "l", "logger",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Opens the logger",
|
2011-02-14 14:58:53 -07:00
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
|
2010-03-18 08:34:37 -06:00
|
|
|
},
|
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_OPTION, "e", "exec",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Loads the specified file (DOL,ELF,GCM,ISO,WAD)",
|
2010-03-18 08:34:37 -06:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2010-07-08 17:27:51 -06:00
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_SWITCH, "b", "batch",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Exit Dolphin with emulator",
|
2011-02-14 14:58:53 -07:00
|
|
|
wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
|
2010-07-08 17:27:51 -06:00
|
|
|
},
|
2010-03-18 08:34:37 -06:00
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_OPTION, "V", "video_backend",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Specify a video backend",
|
2010-03-18 08:34:37 -06:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
2012-03-18 03:31:19 -06:00
|
|
|
wxCMD_LINE_OPTION, "A", "audio_emulation",
|
2012-11-16 15:46:28 -07:00
|
|
|
"Low level (LLE) or high level (HLE) audio",
|
2010-03-18 08:34:37 -06:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
|
|
|
{
|
2011-02-14 14:58:53 -07:00
|
|
|
wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0
|
2010-03-18 08:34:37 -06:00
|
|
|
}
|
|
|
|
};
|
2011-01-10 17:07:22 -07:00
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
// Gets the command line parameters
|
|
|
|
wxCmdLineParser parser(cmdLineDesc, argc, argv);
|
|
|
|
if (parser.Parse() != 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-10 17:07:22 -07:00
|
|
|
|
2011-01-11 18:03:49 -07:00
|
|
|
UseDebugger = parser.Found(wxT("debugger"));
|
|
|
|
UseLogger = parser.Found(wxT("logger"));
|
|
|
|
LoadFile = parser.Found(wxT("exec"), &FileToLoad);
|
|
|
|
BatchMode = parser.Found(wxT("batch"));
|
2011-02-02 09:34:12 -07:00
|
|
|
selectVideoBackend = parser.Found(wxT("video_backend"),
|
|
|
|
&videoBackendName);
|
2012-12-22 16:25:52 -07:00
|
|
|
selectAudioEmulation = parser.Found(wxT("audio_emulation"),
|
|
|
|
&audioEmulationName);
|
2010-03-18 08:34:37 -06:00
|
|
|
#endif // wxUSE_CMDLINE_PARSER
|
|
|
|
|
|
|
|
#if defined _DEBUG && defined _WIN32
|
|
|
|
int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
|
|
|
tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF;
|
|
|
|
_CrtSetDbgFlag(tmpflag);
|
|
|
|
#endif
|
2010-02-15 21:34:41 -07:00
|
|
|
|
2011-01-13 08:32:14 -07:00
|
|
|
// Register message box and translation handlers
|
2010-03-18 08:34:37 -06:00
|
|
|
RegisterMsgAlertHandler(&wxMsgAlert);
|
2011-01-12 19:05:58 -07:00
|
|
|
RegisterStringTranslator(&wxStringTranslator);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-08-10 18:35:07 -06:00
|
|
|
// "ExtendedTrace" looks freakin dangerous!!!
|
2010-03-18 08:34:37 -06:00
|
|
|
#ifdef _WIN32
|
|
|
|
EXTENDEDTRACEINITIALIZE(".");
|
|
|
|
SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
|
2011-01-21 09:54:37 -07:00
|
|
|
#elif wxUSE_ON_FATAL_EXCEPTION
|
2011-01-11 18:27:01 -07:00
|
|
|
wxHandleFatalExceptions(true);
|
2010-03-18 08:34:37 -06:00
|
|
|
#endif
|
|
|
|
|
2009-08-10 18:35:07 -06:00
|
|
|
// TODO: if First Boot
|
|
|
|
if (!cpu_info.bSSE2)
|
|
|
|
{
|
2011-01-12 19:05:58 -07:00
|
|
|
PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
|
|
|
|
"Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
|
|
|
|
"Sayonara!\n");
|
2009-08-10 18:35:07 -06:00
|
|
|
return false;
|
|
|
|
}
|
2010-03-18 08:34:37 -06:00
|
|
|
|
2010-07-22 02:09:14 -06:00
|
|
|
#ifdef _WIN32
|
2011-06-11 14:45:09 -06:00
|
|
|
if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent)))
|
2009-07-11 22:10:52 -06:00
|
|
|
{
|
2011-06-11 14:45:09 -06:00
|
|
|
INFO_LOG(CONSOLE, "set working directory failed");
|
2009-07-11 22:10:52 -06:00
|
|
|
}
|
2010-12-26 17:26:52 -07:00
|
|
|
#else
|
2010-03-18 08:34:37 -06:00
|
|
|
//create all necessary directories in user directory
|
|
|
|
//TODO : detect the revision and upgrade where necessary
|
2011-02-28 20:06:14 -07:00
|
|
|
File::CopyDir(std::string(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP),
|
|
|
|
File::GetUserPath(D_GAMECONFIG_IDX));
|
|
|
|
File::CopyDir(std::string(SHARED_USER_DIR MAPS_DIR DIR_SEP),
|
|
|
|
File::GetUserPath(D_MAPS_IDX));
|
|
|
|
File::CopyDir(std::string(SHARED_USER_DIR SHADERS_DIR DIR_SEP),
|
|
|
|
File::GetUserPath(D_SHADERS_IDX));
|
|
|
|
File::CopyDir(std::string(SHARED_USER_DIR WII_USER_DIR DIR_SEP),
|
|
|
|
File::GetUserPath(D_WIIUSER_IDX));
|
|
|
|
File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP),
|
|
|
|
File::GetUserPath(D_OPENCL_IDX));
|
2010-02-02 14:56:29 -07:00
|
|
|
#endif
|
2011-08-25 22:49:20 -06:00
|
|
|
File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
|
|
|
|
File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
|
2010-02-02 14:56:29 -07:00
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
LogManager::Init();
|
|
|
|
SConfig::Init();
|
2011-01-30 18:28:32 -07:00
|
|
|
VideoBackend::PopulateList();
|
2010-10-12 13:42:29 -06:00
|
|
|
WiimoteReal::LoadSettings();
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2011-02-02 09:34:12 -07:00
|
|
|
if (selectVideoBackend && videoBackendName != wxEmptyString)
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend =
|
|
|
|
std::string(videoBackendName.mb_str());
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2012-12-22 16:25:52 -07:00
|
|
|
if (selectAudioEmulation)
|
2012-12-22 23:24:30 -07:00
|
|
|
{
|
2012-12-22 16:25:52 -07:00
|
|
|
if (audioEmulationName == "HLE")
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true;
|
|
|
|
else if (audioEmulationName == "LLE")
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false;
|
2012-12-22 23:24:30 -07:00
|
|
|
}
|
2012-12-22 16:25:52 -07:00
|
|
|
|
2011-02-02 09:34:12 -07:00
|
|
|
VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2010-08-01 09:48:11 -06:00
|
|
|
// Enable the PNG image handler for screenshots
|
|
|
|
wxImage::AddHandler(new wxPNGHandler);
|
2009-09-05 20:55:14 -06:00
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2010-01-18 11:01:03 -07:00
|
|
|
int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX;
|
|
|
|
int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY;
|
|
|
|
int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth;
|
|
|
|
int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight;
|
2009-09-15 15:35:32 -06:00
|
|
|
|
2012-12-30 18:29:36 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (File::Exists("www.dolphin-emulator.com.txt"))
|
|
|
|
{
|
2012-12-30 19:27:36 -07:00
|
|
|
File::Delete("www.dolphin-emulator.com.txt");
|
2012-12-30 18:29:36 -07:00
|
|
|
MessageBox(NULL,
|
|
|
|
L"This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please "
|
|
|
|
L"download Dolphin from the official website instead: http://dolphin-emu.org/",
|
|
|
|
L"Unofficial version detected", MB_OK | MB_ICONWARNING);
|
|
|
|
ShellExecute(NULL, L"open", L"http://dolphin-emu.org/?ref=badver", NULL, NULL, SW_SHOWDEFAULT);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-02 11:21:20 -07:00
|
|
|
// The following is not needed with X11, where window managers
|
|
|
|
// do not allow windows to be created off the desktop.
|
2010-01-25 05:17:48 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Out of desktop check
|
|
|
|
HWND hDesktop = GetDesktopWindow();
|
|
|
|
RECT rc;
|
|
|
|
GetWindowRect(hDesktop, &rc);
|
|
|
|
if (rc.right < x + w || rc.bottom < y + h)
|
2011-02-02 11:21:20 -07:00
|
|
|
x = y = wxDefaultCoord;
|
|
|
|
#elif defined __APPLE__
|
|
|
|
if (y < 1)
|
|
|
|
y = wxDefaultCoord;
|
2010-01-25 05:17:48 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-08 09:25:01 -06:00
|
|
|
main_frame = new CFrame((wxFrame*)NULL, wxID_ANY,
|
2011-08-21 15:30:19 -06:00
|
|
|
wxString::FromAscii(scm_rev_str),
|
2010-07-08 09:25:01 -06:00
|
|
|
wxPoint(x, y), wxSize(w, h),
|
2010-07-08 17:27:51 -06:00
|
|
|
UseDebugger, BatchMode, UseLogger);
|
2010-07-07 16:00:41 -06:00
|
|
|
SetTopWindow(main_frame);
|
2011-01-15 03:33:07 -07:00
|
|
|
main_frame->SetMinSize(wxSize(400, 300));
|
2010-07-07 16:00:41 -06:00
|
|
|
|
2011-03-15 19:50:46 -06:00
|
|
|
// Postpone final actions until event handler is running.
|
|
|
|
// Updating the game list makes use of wxProgressDialog which may
|
|
|
|
// only be run after OnInit() when the event handler is running.
|
|
|
|
m_afterinit = new wxTimer(this, wxID_ANY);
|
|
|
|
m_afterinit->Start(1, wxTIMER_ONE_SHOT);
|
|
|
|
|
2010-07-07 16:00:41 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-19 20:26:51 -07:00
|
|
|
void DolphinApp::MacOpenFile(const wxString &fileName)
|
2010-07-07 16:00:41 -06:00
|
|
|
{
|
2011-01-19 20:26:51 -07:00
|
|
|
FileToLoad = fileName;
|
|
|
|
LoadFile = true;
|
2010-07-07 16:00:41 -06:00
|
|
|
|
2011-03-15 19:50:46 -06:00
|
|
|
if (m_afterinit == NULL)
|
2011-01-19 20:26:51 -07:00
|
|
|
main_frame->BootGame(std::string(FileToLoad.mb_str()));
|
|
|
|
}
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2011-03-15 19:50:46 -06:00
|
|
|
void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event))
|
2011-01-19 20:26:51 -07:00
|
|
|
{
|
2011-03-15 19:50:46 -06:00
|
|
|
delete m_afterinit;
|
|
|
|
m_afterinit = NULL;
|
|
|
|
|
2011-01-20 19:56:54 -07:00
|
|
|
if (!BatchMode)
|
|
|
|
main_frame->UpdateGameList();
|
|
|
|
|
2010-07-03 04:24:55 -06:00
|
|
|
// First check if we have an exec command line.
|
|
|
|
if (LoadFile && FileToLoad != wxEmptyString)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-07-03 04:24:55 -06:00
|
|
|
main_frame->BootGame(std::string(FileToLoad.mb_str()));
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2010-07-07 16:00:41 -06:00
|
|
|
// If we have selected Automatic Start, start the default ISO,
|
|
|
|
// or if no default ISO exists, start the last loaded ISO
|
2009-09-07 06:40:43 -06:00
|
|
|
else if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-08-24 19:50:27 -06:00
|
|
|
if (main_frame->g_pCodeWindow->AutomaticStart())
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2009-08-24 19:50:27 -06:00
|
|
|
if(!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM.empty()
|
2011-02-28 20:06:14 -07:00
|
|
|
&& File::Exists(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultGCM))
|
2009-08-24 19:50:27 -06:00
|
|
|
{
|
2010-04-16 21:17:36 -06:00
|
|
|
main_frame->BootGame(SConfig::GetInstance().m_LocalCoreStartupParameter.
|
2010-03-18 08:34:37 -06:00
|
|
|
m_strDefaultGCM);
|
2009-08-24 19:50:27 -06:00
|
|
|
}
|
|
|
|
else if(!SConfig::GetInstance().m_LastFilename.empty()
|
2011-02-28 20:06:14 -07:00
|
|
|
&& File::Exists(SConfig::GetInstance().m_LastFilename))
|
2009-08-24 19:50:27 -06:00
|
|
|
{
|
2010-04-16 21:17:36 -06:00
|
|
|
main_frame->BootGame(SConfig::GetInstance().m_LastFilename);
|
2009-08-24 19:50:27 -06:00
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
void DolphinApp::InitLanguageSupport()
|
|
|
|
{
|
2011-01-08 10:35:34 -07:00
|
|
|
unsigned int language = 0;
|
2011-01-04 21:35:46 -07:00
|
|
|
|
|
|
|
IniFile ini;
|
2011-02-28 20:06:14 -07:00
|
|
|
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
2011-01-10 12:26:36 -07:00
|
|
|
ini.Get("Interface", "Language", &language, wxLANGUAGE_DEFAULT);
|
2011-01-04 21:35:46 -07:00
|
|
|
|
|
|
|
// Load language if possible, fall back to system default otherwise
|
2011-01-10 12:26:36 -07:00
|
|
|
if(wxLocale::IsAvailable(language))
|
2011-01-04 21:35:46 -07:00
|
|
|
{
|
2011-01-10 12:26:36 -07:00
|
|
|
m_locale = new wxLocale(language);
|
2011-01-04 21:35:46 -07:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
m_locale->AddCatalogLookupPathPrefix(wxT("Languages"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_locale->AddCatalog(wxT("dolphin-emu"));
|
|
|
|
|
|
|
|
if(!m_locale->IsOk())
|
|
|
|
{
|
2011-01-14 08:09:30 -07:00
|
|
|
PanicAlertT("Error loading selected language. Falling back to system default.");
|
2011-01-04 21:35:46 -07:00
|
|
|
delete m_locale;
|
|
|
|
m_locale = new wxLocale(wxLANGUAGE_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 08:09:30 -07:00
|
|
|
PanicAlertT("The selected language is not supported by your system. Falling back to system default.");
|
2011-01-04 21:35:46 -07:00
|
|
|
m_locale = new wxLocale(wxLANGUAGE_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-15 21:34:41 -07:00
|
|
|
int DolphinApp::OnExit()
|
|
|
|
{
|
2010-10-12 13:42:29 -06:00
|
|
|
WiimoteReal::Shutdown();
|
2010-06-19 20:17:53 -06:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (SConfig::GetInstance().m_WiiAutoUnpair)
|
2010-10-12 13:42:29 -06:00
|
|
|
WiimoteReal::UnPair();
|
2010-06-19 20:17:53 -06:00
|
|
|
#endif
|
2011-01-30 18:28:32 -07:00
|
|
|
VideoBackend::ClearList();
|
2010-02-15 21:34:41 -07:00
|
|
|
SConfig::Shutdown();
|
|
|
|
LogManager::Shutdown();
|
|
|
|
|
2011-01-04 21:35:46 -07:00
|
|
|
delete m_locale;
|
|
|
|
|
2010-02-15 21:34:41 -07:00
|
|
|
return wxApp::OnExit();
|
|
|
|
}
|
|
|
|
|
2011-01-11 18:27:01 -07:00
|
|
|
void DolphinApp::OnFatalException()
|
|
|
|
{
|
|
|
|
WiimoteReal::Shutdown();
|
|
|
|
}
|
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-09-03 14:00:09 -06:00
|
|
|
// Talk to GUI
|
2009-09-05 19:40:44 -06:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
void Host_SysMessage(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
|
|
|
|
//wxMessageBox(wxString::FromAscii(msg));
|
|
|
|
PanicAlert("%s", msg);
|
|
|
|
}
|
|
|
|
|
2009-01-23 17:45:46 -07:00
|
|
|
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
|
2008-12-28 11:50:24 -07:00
|
|
|
{
|
2010-11-10 17:55:06 -07:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
if (wxIsMainThread())
|
|
|
|
#endif
|
2011-01-13 08:32:14 -07:00
|
|
|
return wxYES == wxMessageBox(wxString::FromUTF8(text),
|
2011-01-13 13:53:37 -07:00
|
|
|
wxString::FromUTF8(caption),
|
2011-02-26 19:27:43 -07:00
|
|
|
(yes_no) ? wxYES_NO : wxOK, wxGetActiveWindow());
|
2010-11-10 17:55:06 -07:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC);
|
2011-07-15 08:49:34 -06:00
|
|
|
event.SetString(wxString::FromUTF8(caption) + wxT(":") + wxString::FromUTF8(text));
|
2010-11-10 17:55:06 -07:00
|
|
|
event.SetInt(yes_no);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
main_frame->panic_event.Wait();
|
|
|
|
return main_frame->bPanicResult;
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:15:08 -07:00
|
|
|
std::string wxStringTranslator(const char *text)
|
2011-01-12 19:05:58 -07:00
|
|
|
{
|
2011-01-13 17:15:08 -07:00
|
|
|
return (const char *)wxString(wxGetTranslation(wxString::From8BitData(text))).ToUTF8();
|
2011-01-12 19:05:58 -07:00
|
|
|
}
|
|
|
|
|
2009-03-20 12:25:36 -06:00
|
|
|
// Accessor for the main window class
|
|
|
|
CFrame* DolphinApp::GetCFrame()
|
|
|
|
{
|
|
|
|
return main_frame;
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-07 06:40:43 -06:00
|
|
|
void Host_Message(int Id)
|
|
|
|
{
|
2010-07-18 20:09:34 -06:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, Id);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-09-07 06:40:43 -06:00
|
|
|
}
|
|
|
|
|
2011-02-12 14:25:49 -07:00
|
|
|
#ifdef _WIN32
|
|
|
|
extern "C" HINSTANCE wxGetInstance();
|
|
|
|
void* Host_GetInstance()
|
|
|
|
{
|
|
|
|
return (void*)wxGetInstance();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void* Host_GetInstance()
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void* Host_GetRenderHandle()
|
|
|
|
{
|
|
|
|
return main_frame->GetRenderHandle();
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
// OK, this thread boundary is DANGEROUS on linux
|
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFYMAPLOADED);
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateLogDisplay()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATELOGDISPLAY);
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEDISASMDIALOG);
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-07-15 09:09:20 -06:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-11 14:37:55 -06:00
|
|
|
void Host_ShowJitResults(unsigned int address)
|
|
|
|
{
|
2011-02-24 20:56:14 -07:00
|
|
|
if (main_frame->g_pCodeWindow && main_frame->g_pCodeWindow->m_JitWindow)
|
|
|
|
main_frame->g_pCodeWindow->m_JitWindow->ViewAddr(address);
|
2009-07-11 14:37:55 -06:00
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
2009-09-27 15:28:09 -06:00
|
|
|
|
2010-04-15 14:58:34 -06:00
|
|
|
void Host_UpdateTitle(const char* title)
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATETITLE);
|
|
|
|
event.SetString(wxString::FromAscii(title));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_UpdateBreakPointView()
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATEBREAKPOINTS);
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2009-09-03 01:59:24 -06:00
|
|
|
if (main_frame->g_pCodeWindow)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->g_pCodeWindow->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 09:40:38 -07:00
|
|
|
bool Host_GetKeyState(int keycode)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
2011-03-15 17:09:12 -06:00
|
|
|
return (0 != GetAsyncKeyState(keycode));
|
2011-01-30 15:02:47 -07:00
|
|
|
#elif defined __WXGTK__
|
2011-03-15 06:50:58 -06:00
|
|
|
std::unique_lock<std::recursive_mutex> lk(main_frame->keystate_lock, std::try_to_lock);
|
|
|
|
if (!lk.owns_lock())
|
2011-03-05 21:31:43 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
bool key_pressed;
|
|
|
|
if (!wxIsMainThread()) wxMutexGuiEnter();
|
|
|
|
key_pressed = wxGetKeyState(wxKeyCode(keycode));
|
|
|
|
if (!wxIsMainThread()) wxMutexGuiLeave();
|
|
|
|
return key_pressed;
|
2011-01-30 09:40:38 -07:00
|
|
|
#else
|
|
|
|
return wxGetKeyState(wxKeyCode(keycode));
|
|
|
|
#endif
|
|
|
|
}
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-01-06 21:57:59 -07:00
|
|
|
void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height)
|
2010-04-11 19:33:10 -06:00
|
|
|
{
|
2011-01-06 21:57:59 -07:00
|
|
|
main_frame->GetRenderWindowSize(x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2011-01-24 20:30:12 -07:00
|
|
|
void Host_RequestRenderWindowSize(int width, int height)
|
2011-01-06 21:57:59 -07:00
|
|
|
{
|
2011-01-31 21:35:25 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_WINDOWSIZEREQUEST);
|
|
|
|
event.SetClientData(new std::pair<int, int>(width, height));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2010-04-11 19:33:10 -06:00
|
|
|
}
|
|
|
|
|
2011-02-12 14:25:49 -07:00
|
|
|
void Host_SetStartupDebuggingParameters()
|
|
|
|
{
|
|
|
|
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
|
|
|
if (main_frame->g_pCodeWindow)
|
|
|
|
{
|
|
|
|
StartUp.bBootToPause = main_frame->g_pCodeWindow->BootToPause();
|
|
|
|
StartUp.bAutomaticStart = main_frame->g_pCodeWindow->AutomaticStart();
|
|
|
|
StartUp.bJITNoBlockCache = main_frame->g_pCodeWindow->JITNoBlockCache();
|
|
|
|
StartUp.bJITBlockLinking = main_frame->g_pCodeWindow->JITBlockLinking();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StartUp.bBootToPause = false;
|
|
|
|
}
|
|
|
|
StartUp.bEnableDebugging = main_frame->g_pCodeWindow ? true : false; // RUNNING_DEBUG
|
|
|
|
}
|
|
|
|
|
2009-02-15 23:18:18 -07:00
|
|
|
void Host_UpdateStatusBar(const char* _pText, int Field)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
2009-02-15 23:18:18 -07:00
|
|
|
// Set the event string
|
2008-12-07 22:30:24 -07:00
|
|
|
event.SetString(wxString::FromAscii(_pText));
|
2009-02-15 23:18:18 -07:00
|
|
|
// Update statusbar field
|
|
|
|
event.SetInt(Field);
|
|
|
|
// Post message
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Host_SetWiiMoteConnectionState(int _State)
|
|
|
|
{
|
|
|
|
static int currentState = -1;
|
|
|
|
if (_State == currentState)
|
|
|
|
return;
|
|
|
|
currentState = _State;
|
|
|
|
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
|
|
|
|
|
|
|
|
switch(_State)
|
|
|
|
{
|
2011-01-05 10:56:08 -07:00
|
|
|
case 0: event.SetString(_("Not connected")); break;
|
|
|
|
case 1: event.SetString(_("Connecting...")); break;
|
|
|
|
case 2: event.SetString(_("Wiimote Connected")); break;
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2009-02-15 23:18:18 -07:00
|
|
|
// Update field 1 or 2
|
2009-12-31 20:55:39 -07:00
|
|
|
event.SetInt(1);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2010-01-20 04:49:11 -07:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-07 22:30:24 -07:00
|
|
|
}
|
2010-04-11 19:33:10 -06:00
|
|
|
|
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
|
|
|
return main_frame->RendererHasFocus();
|
|
|
|
}
|
2011-01-07 08:18:00 -07:00
|
|
|
|
|
|
|
void Host_ConnectWiimote(int wm_idx, bool connect)
|
|
|
|
{
|
|
|
|
CFrame::ConnectWiimote(wm_idx, connect);
|
|
|
|
}
|