2013-04-17 21:43:35 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:43:35 -06:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <mutex>
|
2008-12-07 22:30:24 -07:00
|
|
|
#include <string>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <utility>
|
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/buffer.h>
|
|
|
|
#include <wx/cmdline.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/imagpng.h>
|
2014-02-18 18:56:29 -07:00
|
|
|
#include <wx/intl.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <wx/language.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/thread.h>
|
|
|
|
#include <wx/timer.h>
|
|
|
|
#include <wx/utils.h>
|
|
|
|
#include <wx/window.h>
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/CPUDetect.h"
|
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/Thread.h"
|
2014-06-05 17:29:54 -06:00
|
|
|
#include "Common/Logging/LogManager.h"
|
2010-02-19 21:18:19 -07:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-06-19 18:43:57 -06:00
|
|
|
#include "Core/Core.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Core/CoreParameter.h"
|
2014-07-08 06:29:26 -06:00
|
|
|
#include "Core/Host.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Core/Movie.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Core/HW/Wiimote.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
|
|
|
#include "DolphinWX/Main.h"
|
2014-08-03 18:07:27 -06:00
|
|
|
#include "DolphinWX/SoftwareVideoConfigDialog.h"
|
2014-08-02 00:21:03 -06:00
|
|
|
#include "DolphinWX/VideoConfigDiag.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/JitWindow.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-10-04 13:12:15 -06:00
|
|
|
#include "UICommon/UICommon.h"
|
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2014-02-18 04:09:38 -07:00
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2012-12-30 18:29:36 -07:00
|
|
|
#ifdef _WIN32
|
2013-03-15 09:45:43 -06:00
|
|
|
|
|
|
|
#ifndef SM_XVIRTUALSCREEN
|
|
|
|
#define SM_XVIRTUALSCREEN 76
|
|
|
|
#endif
|
2013-03-15 13:41:13 -06:00
|
|
|
#ifndef SM_YVIRTUALSCREEN
|
|
|
|
#define SM_YVIRTUALSCREEN 77
|
|
|
|
#endif
|
2013-03-15 09:45:43 -06:00
|
|
|
#ifndef SM_CXVIRTUALSCREEN
|
|
|
|
#define SM_CXVIRTUALSCREEN 78
|
|
|
|
#endif
|
|
|
|
#ifndef SM_CYVIRTUALSCREEN
|
|
|
|
#define SM_CYVIRTUALSCREEN 79
|
|
|
|
#endif
|
|
|
|
|
2012-12-30 18:29:36 -07:00
|
|
|
#endif
|
|
|
|
|
2013-03-14 14:25:41 -06:00
|
|
|
#ifdef __APPLE__
|
2013-03-14 14:46:27 -06:00
|
|
|
#import <AppKit/AppKit.h>
|
2013-03-14 14:25:41 -06:00
|
|
|
#endif
|
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
class wxFrame;
|
|
|
|
|
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)
|
|
|
|
|
2010-03-18 08:34:37 -06:00
|
|
|
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
|
|
|
|
2014-03-09 14:14:26 -06:00
|
|
|
CFrame* main_frame = nullptr;
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2011-02-19 14:53:53 -07:00
|
|
|
bool DolphinApp::Initialize(int& c, wxChar **v)
|
|
|
|
{
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
|
|
|
XInitThreads();
|
2013-10-28 23:23:17 -06:00
|
|
|
#endif
|
2011-02-19 14:53:53 -07:00
|
|
|
return wxApp::Initialize(c, v);
|
|
|
|
}
|
|
|
|
|
2014-11-14 12:46:49 -07: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()
|
|
|
|
{
|
2014-11-08 17:26:20 -07:00
|
|
|
Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this);
|
|
|
|
Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this);
|
|
|
|
|
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;
|
2014-11-24 15:17:31 -07:00
|
|
|
bool selectPerfDir = false;
|
2009-09-05 20:55:14 -06:00
|
|
|
|
2011-02-02 09:34:12 -07:00
|
|
|
wxString videoBackendName;
|
|
|
|
wxString audioEmulationName;
|
2013-08-24 21:15:55 -06:00
|
|
|
wxString userPath;
|
2014-11-24 15:17:31 -07:00
|
|
|
wxString perfDir;
|
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",
|
2014-11-13 19:28:27 -07:00
|
|
|
"Loads the specified file (ELF, DOL, GCM, ISO, WBFS, CISO, GCZ, 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
|
|
|
|
},
|
2013-03-12 23:37:35 -06:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "m", "movie",
|
|
|
|
"Play a movie file",
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2013-08-24 21:15:55 -06:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "U", "user",
|
|
|
|
"User folder path",
|
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2014-11-24 15:17:31 -07:00
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION, "P", "perf_dir",
|
2015-01-03 07:42:28 -07:00
|
|
|
"Directory for Linux perf perf-$pid.map file",
|
2014-11-24 15:17:31 -07:00
|
|
|
wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
|
|
|
|
},
|
2010-03-18 08:34:37 -06:00
|
|
|
{
|
2014-03-09 14:14:26 -06:00
|
|
|
wxCMD_LINE_NONE, nullptr, nullptr, nullptr, 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);
|
2015-02-13 02:34:18 -07:00
|
|
|
LoadFile = false;
|
2014-10-03 05:39:51 -06:00
|
|
|
if (argc == 2 && File::Exists(argv[1].ToUTF8().data()))
|
2014-09-30 07:21:34 -06:00
|
|
|
{
|
|
|
|
LoadFile = true;
|
|
|
|
FileToLoad = argv[1];
|
|
|
|
}
|
|
|
|
else if (parser.Parse() != 0)
|
2010-03-18 08:34:37 -06:00
|
|
|
{
|
|
|
|
return false;
|
2013-10-28 23:23:17 -06:00
|
|
|
}
|
2011-01-10 17:07:22 -07:00
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
UseDebugger = parser.Found("debugger");
|
|
|
|
UseLogger = parser.Found("logger");
|
2014-09-30 07:21:34 -06:00
|
|
|
if (!LoadFile)
|
|
|
|
LoadFile = parser.Found("exec", &FileToLoad);
|
2014-05-17 11:17:28 -06:00
|
|
|
BatchMode = parser.Found("batch");
|
|
|
|
selectVideoBackend = parser.Found("video_backend", &videoBackendName);
|
|
|
|
selectAudioEmulation = parser.Found("audio_emulation", &audioEmulationName);
|
2014-11-24 15:17:31 -07:00
|
|
|
selectPerfDir = parser.Found("perf_dir", &perfDir);
|
2014-05-17 11:17:28 -06:00
|
|
|
playMovie = parser.Found("movie", &movieFile);
|
2015-02-25 02:23:42 -07:00
|
|
|
parser.Found("user", &userPath);
|
2010-03-18 08:34:37 -06:00
|
|
|
#endif // wxUSE_CMDLINE_PARSER
|
|
|
|
|
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
|
|
|
|
2015-03-15 23:30:38 -06:00
|
|
|
#if wxUSE_ON_FATAL_EXCEPTION
|
2011-01-11 18:27:01 -07:00
|
|
|
wxHandleFatalExceptions(true);
|
2010-03-18 08:34:37 -06:00
|
|
|
#endif
|
|
|
|
|
2015-02-25 02:23:42 -07:00
|
|
|
UICommon::SetUserDirectory(userPath.ToStdString());
|
2014-10-04 13:12:15 -06:00
|
|
|
UICommon::CreateDirectories();
|
2015-03-04 06:45:36 -07:00
|
|
|
InitLanguageSupport(); // The language setting is loaded from the user directory
|
2014-10-04 13:12:15 -06:00
|
|
|
UICommon::Init();
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2014-11-24 15:17:31 -07:00
|
|
|
if (selectPerfDir)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_perfDir =
|
|
|
|
WxStrToStr(perfDir);
|
|
|
|
}
|
|
|
|
|
2011-02-02 09:34:12 -07:00
|
|
|
if (selectVideoBackend && videoBackendName != wxEmptyString)
|
|
|
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend =
|
2013-02-27 21:37:38 -07:00
|
|
|
WxStrToStr(videoBackendName);
|
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-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
|
|
|
if (File::Exists("www.dolphin-emulator.com.txt"))
|
|
|
|
{
|
2012-12-30 19:27:36 -07:00
|
|
|
File::Delete("www.dolphin-emulator.com.txt");
|
2014-11-04 21:13:25 -07:00
|
|
|
wxMessageDialog dlg(nullptr, _(
|
|
|
|
"This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please "
|
2014-11-06 19:34:38 -07:00
|
|
|
"download Dolphin from the official website instead: https://dolphin-emu.org/"),
|
2014-11-04 21:13:25 -07:00
|
|
|
_("Unofficial version detected"), wxOK | wxICON_WARNING);
|
|
|
|
dlg.ShowModal();
|
|
|
|
|
2014-11-06 19:34:38 -07:00
|
|
|
wxLaunchDefaultBrowser("https://dolphin-emu.org/?ref=badver");
|
2014-11-04 21:13:25 -07:00
|
|
|
|
2012-12-30 18:29:36 -07:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
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
|
2013-03-15 09:45:43 -06:00
|
|
|
int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
|
|
|
int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
2013-03-15 13:41:13 -06:00
|
|
|
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
2013-10-28 23:23:17 -06:00
|
|
|
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
2013-03-15 07:19:39 -06:00
|
|
|
if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y)
|
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
|
|
|
|
|
2014-11-08 17:26:20 -07:00
|
|
|
main_frame = new CFrame(nullptr, wxID_ANY,
|
2013-02-27 21:37:38 -07:00
|
|
|
StrToWxStr(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
|
|
|
|
2014-11-08 17:26:20 -07:00
|
|
|
AfterInit();
|
2011-03-15 19:50:46 -06:00
|
|
|
|
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;
|
2014-11-08 17:26:20 -07:00
|
|
|
main_frame->BootGame(WxStrToStr(FileToLoad));
|
2011-01-19 20:26:51 -07:00
|
|
|
}
|
2009-01-04 14:53:41 -07:00
|
|
|
|
2014-11-08 17:26:20 -07:00
|
|
|
void DolphinApp::AfterInit()
|
2011-01-19 20:26:51 -07:00
|
|
|
{
|
2011-01-20 19:56:54 -07:00
|
|
|
if (!BatchMode)
|
|
|
|
main_frame->UpdateGameList();
|
|
|
|
|
2013-03-12 23:37:35 -06:00
|
|
|
if (playMovie && movieFile != wxEmptyString)
|
|
|
|
{
|
2014-03-12 13:33:41 -06:00
|
|
|
if (Movie::PlayInput(WxStrToStr(movieFile)))
|
2013-03-12 23:37:35 -06:00
|
|
|
{
|
|
|
|
if (LoadFile && FileToLoad != wxEmptyString)
|
|
|
|
{
|
|
|
|
main_frame->BootGame(WxStrToStr(FileToLoad));
|
|
|
|
}
|
|
|
|
else
|
2013-04-07 23:16:50 -06:00
|
|
|
{
|
2014-11-08 17:26:20 -07:00
|
|
|
main_frame->BootGame("");
|
2013-04-07 23:16:50 -06:00
|
|
|
}
|
2013-03-12 23:37:35 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-03 04:24:55 -06:00
|
|
|
// First check if we have an exec command line.
|
2013-03-12 23:37:35 -06:00
|
|
|
else if (LoadFile && FileToLoad != wxEmptyString)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
2013-02-27 21:37:38 -07:00
|
|
|
main_frame->BootGame(WxStrToStr(FileToLoad));
|
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
|
|
|
{
|
2013-03-12 23:37:35 -06:00
|
|
|
main_frame->BootGame("");
|
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));
|
2014-06-15 23:12:43 -06:00
|
|
|
ini.GetOrCreateSection("Interface")->Get("Language", &language, wxLANGUAGE_DEFAULT);
|
2011-01-04 21:35:46 -07:00
|
|
|
|
|
|
|
// Load language if possible, fall back to system default otherwise
|
2014-03-10 05:30:55 -06: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
|
2013-09-21 12:20:38 -06:00
|
|
|
m_locale->AddCatalogLookupPathPrefix(StrToWxStr(File::GetExeDirectory() + DIR_SEP "Languages"));
|
2011-01-04 21:35:46 -07:00
|
|
|
#endif
|
|
|
|
|
2014-05-17 11:17:28 -06:00
|
|
|
m_locale->AddCatalog("dolphin-emu");
|
2011-01-04 21:35:46 -07:00
|
|
|
|
2014-03-10 05:30:55 -06:00
|
|
|
if (!m_locale->IsOk())
|
2011-01-04 21:35:46 -07:00
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("Error loading selected language. Falling back to system default."), _("Error"));
|
2011-01-04 21:35:46 -07:00
|
|
|
delete m_locale;
|
|
|
|
m_locale = new wxLocale(wxLANGUAGE_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-24 19:46:46 -06:00
|
|
|
wxMessageBox(_("The selected language is not supported by your system. Falling back to system default."), _("Error"));
|
2011-01-04 21:35:46 -07:00
|
|
|
m_locale = new wxLocale(wxLANGUAGE_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-10 04:14:21 -06:00
|
|
|
void DolphinApp::OnEndSession(wxCloseEvent& event)
|
|
|
|
{
|
2014-11-13 19:28:27 -07:00
|
|
|
// Close if we've received wxEVT_END_SESSION (ignore wxEVT_QUERY_END_SESSION)
|
2013-09-10 04:14:21 -06:00
|
|
|
if (!event.CanVeto())
|
|
|
|
{
|
|
|
|
main_frame->Close(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-15 21:34:41 -07:00
|
|
|
int DolphinApp::OnExit()
|
|
|
|
{
|
2014-10-04 13:12:15 -06:00
|
|
|
UICommon::Shutdown();
|
2010-02-15 21:34:41 -07:00
|
|
|
|
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-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-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
|
2013-02-27 21:37:38 -07:00
|
|
|
return wxYES == wxMessageBox(StrToWxStr(text), StrToWxStr(caption),
|
2014-09-29 23:28:01 -06:00
|
|
|
(yes_no) ? wxYES_NO : wxOK, wxWindow::FindFocus());
|
2010-11-10 17:55:06 -07:00
|
|
|
#ifdef __WXGTK__
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC);
|
2014-05-17 11:17:28 -06:00
|
|
|
event.SetString(StrToWxStr(caption) + ":" + StrToWxStr(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
|
|
|
{
|
2013-03-03 17:40:50 -07:00
|
|
|
return WxStrToStr(wxGetTranslation(wxString::FromUTF8(text)));
|
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
|
|
|
void* Host_GetRenderHandle()
|
|
|
|
{
|
2013-04-07 23:16:50 -06:00
|
|
|
return main_frame->GetRenderHandle();
|
2011-02-12 14:25:49 -07:00
|
|
|
}
|
|
|
|
|
2014-11-13 19:28:27 -07:00
|
|
|
// OK, this thread boundary is DANGEROUS on Linux
|
2008-12-07 22:30:24 -07:00
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFY_MAP_LOADED);
|
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()
|
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_DISASM_DIALOG);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_GUI);
|
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
|
|
|
|
2014-03-12 13:33:41 -06:00
|
|
|
void Host_UpdateTitle(const std::string& title)
|
2010-04-15 14:58:34 -06:00
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_TITLE);
|
2013-02-27 21:37:38 -07:00
|
|
|
event.SetString(StrToWxStr(title));
|
2010-04-15 14:58:34 -06:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
2011-01-24 20:30:12 -07:00
|
|
|
void Host_RequestRenderWindowSize(int width, int height)
|
2011-01-06 21:57:59 -07:00
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_WINDOW_SIZE_REQUEST);
|
2011-01-31 21:35:25 -07:00
|
|
|
event.SetClientData(new std::pair<int, int>(width, height));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2010-04-11 19:33:10 -06:00
|
|
|
}
|
|
|
|
|
2014-07-26 04:43:49 -06:00
|
|
|
void Host_RequestFullscreen(bool enable_fullscreen)
|
2014-07-16 07:53:33 -06:00
|
|
|
{
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FULLSCREEN_REQUEST);
|
2014-07-26 04:43:49 -06:00
|
|
|
event.SetInt(enable_fullscreen ? 1 : 0);
|
2014-07-16 07:53:33 -06:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|
|
|
|
|
2011-02-12 14:25:49 -07:00
|
|
|
void Host_SetStartupDebuggingParameters()
|
|
|
|
{
|
|
|
|
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
|
|
|
if (main_frame->g_pCodeWindow)
|
2013-04-07 23:16:50 -06:00
|
|
|
{
|
2011-02-12 14:25:49 -07:00
|
|
|
StartUp.bBootToPause = main_frame->g_pCodeWindow->BootToPause();
|
|
|
|
StartUp.bAutomaticStart = main_frame->g_pCodeWindow->AutomaticStart();
|
|
|
|
StartUp.bJITNoBlockCache = main_frame->g_pCodeWindow->JITNoBlockCache();
|
2014-10-08 20:02:02 -06:00
|
|
|
StartUp.bJITNoBlockLinking = main_frame->g_pCodeWindow->JITNoBlockLinking();
|
2011-02-12 14:25:49 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StartUp.bBootToPause = false;
|
|
|
|
}
|
|
|
|
StartUp.bEnableDebugging = main_frame->g_pCodeWindow ? true : false; // RUNNING_DEBUG
|
|
|
|
}
|
|
|
|
|
2008-12-07 22:30:24 -07:00
|
|
|
void Host_SetWiiMoteConnectionState(int _State)
|
|
|
|
{
|
|
|
|
static int currentState = -1;
|
|
|
|
if (_State == currentState)
|
|
|
|
return;
|
|
|
|
currentState = _State;
|
|
|
|
|
2014-12-20 18:36:26 -07:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_STATUS_BAR);
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-03-10 05:30:55 -06:00
|
|
|
switch (_State)
|
2008-12-07 22:30:24 -07:00
|
|
|
{
|
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
|
|
|
|
2013-07-10 14:07:57 -06:00
|
|
|
NOTICE_LOG(WIIMOTE, "%s", static_cast<const char*>(event.GetString().c_str()));
|
2013-05-31 22:01:31 -06: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
|
|
|
|
2014-07-16 08:24:40 -06:00
|
|
|
bool Host_UIHasFocus()
|
|
|
|
{
|
|
|
|
return main_frame->UIHasFocus();
|
|
|
|
}
|
|
|
|
|
2010-04-11 19:33:10 -06:00
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
|
|
|
return main_frame->RendererHasFocus();
|
|
|
|
}
|
2011-01-07 08:18:00 -07:00
|
|
|
|
2015-01-04 09:09:56 -07:00
|
|
|
bool Host_RendererIsFullscreen()
|
|
|
|
{
|
|
|
|
return main_frame->RendererIsFullscreen();
|
|
|
|
}
|
|
|
|
|
2011-01-07 08:18:00 -07:00
|
|
|
void Host_ConnectWiimote(int wm_idx, bool connect)
|
|
|
|
{
|
|
|
|
CFrame::ConnectWiimote(wm_idx, connect);
|
|
|
|
}
|
2014-08-02 00:21:03 -06:00
|
|
|
|
|
|
|
void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
|
|
|
|
const std::string& config_name)
|
|
|
|
{
|
2014-08-03 18:07:27 -06:00
|
|
|
if (backend_name == "Direct3D" || backend_name == "OpenGL")
|
|
|
|
{
|
|
|
|
VideoConfigDiag diag((wxWindow*)parent, backend_name, config_name);
|
|
|
|
diag.ShowModal();
|
|
|
|
}
|
|
|
|
else if (backend_name == "Software Renderer")
|
|
|
|
{
|
|
|
|
SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name, config_name);
|
|
|
|
diag.ShowModal();
|
|
|
|
}
|
2014-08-02 00:21:03 -06:00
|
|
|
}
|