2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
#include <OptionParser.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2017-12-25 17:07:29 +00:00
|
|
|
#include <optional>
|
2008-12-08 05:30:24 +00:00
|
|
|
#include <string>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <wx/app.h>
|
|
|
|
#include <wx/buffer.h>
|
|
|
|
#include <wx/cmdline.h>
|
2016-11-10 16:55:21 +00:00
|
|
|
#include <wx/evtloop.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/imagpng.h>
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <wx/intl.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/language.h>
|
2017-05-14 20:49:25 +00:00
|
|
|
#include <wx/menu.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/thread.h>
|
|
|
|
#include <wx/timer.h>
|
2016-12-07 18:20:37 +00:00
|
|
|
#include <wx/tooltip.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/utils.h>
|
|
|
|
#include <wx/window.h>
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-06-05 23:29:54 +00:00
|
|
|
#include "Common/Logging/LogManager.h"
|
2017-04-07 01:55:43 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Common/Thread.h"
|
2017-09-09 19:52:35 +00:00
|
|
|
#include "Common/Version.h"
|
2010-02-20 04:18:19 +00:00
|
|
|
|
2016-06-18 00:43:59 +00:00
|
|
|
#include "Core/Analytics.h"
|
2017-10-01 22:09:07 +00:00
|
|
|
#include "Core/Boot/Boot.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-06-20 00:43:57 +00:00
|
|
|
#include "Core/Core.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "Core/HW/Wiimote.h"
|
2014-07-08 12:29:26 +00:00
|
|
|
#include "Core/Host.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Core/Movie.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/JitWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
|
|
|
#include "DolphinWX/Main.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/NetPlay/NetWindow.h"
|
2014-08-04 00:07:27 +00:00
|
|
|
#include "DolphinWX/SoftwareVideoConfigDialog.h"
|
2017-07-12 07:11:29 +00:00
|
|
|
#include "DolphinWX/UINeedsControllerState.h"
|
2014-08-02 06:21:03 +00:00
|
|
|
#include "DolphinWX/VideoConfigDiag.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
#include "UICommon/CommandLineParse.h"
|
2014-10-04 19:12:15 +00:00
|
|
|
#include "UICommon/UICommon.h"
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-18 11:09:38 +00:00
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#endif
|
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-03 20:00:09 +00:00
|
|
|
// Main window
|
2009-09-06 01:40:44 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
IMPLEMENT_APP(DolphinApp)
|
|
|
|
|
2017-07-26 04:11:17 +00:00
|
|
|
bool wxMsgAlert(const char*, const char*, bool, MsgType);
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string wxStringTranslator(const char*);
|
2008-12-14 12:30:37 +00:00
|
|
|
|
2014-03-09 20:14:26 +00:00
|
|
|
CFrame* main_frame = nullptr;
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
bool DolphinApp::Initialize(int& c, wxChar** v)
|
2011-02-19 21:53:53 +00:00
|
|
|
{
|
|
|
|
#if defined HAVE_X11 && HAVE_X11
|
2016-06-24 08:43:46 +00:00
|
|
|
XInitThreads();
|
2013-10-29 05:23:17 +00:00
|
|
|
#endif
|
2016-06-24 08:43:46 +00:00
|
|
|
return wxApp::Initialize(c, v);
|
2011-02-19 21:53:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-14 19:46:49 +00:00
|
|
|
// The 'main program' equivalent that creates the main window and return the main frame
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
void DolphinApp::OnInitCmdLine(wxCmdLineParser& parser)
|
|
|
|
{
|
|
|
|
parser.SetCmdLine("");
|
|
|
|
}
|
|
|
|
|
2017-02-27 01:35:31 +00:00
|
|
|
bool DolphinApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
bool DolphinApp::OnInit()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!wxApp::OnInit())
|
|
|
|
return false;
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this);
|
|
|
|
Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this);
|
|
|
|
Bind(wxEVT_IDLE, &DolphinApp::OnIdle, this);
|
2016-10-28 01:50:09 +00:00
|
|
|
Bind(wxEVT_ACTIVATE_APP, &DolphinApp::OnActivate, this);
|
2014-11-09 00:26:20 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Register message box and translation handlers
|
|
|
|
RegisterMsgAlertHandler(&wxMsgAlert);
|
|
|
|
RegisterStringTranslator(&wxStringTranslator);
|
2015-08-27 10:59:23 +00:00
|
|
|
|
|
|
|
#if wxUSE_ON_FATAL_EXCEPTION
|
2016-06-24 08:43:46 +00:00
|
|
|
wxHandleFatalExceptions(true);
|
2015-08-27 10:59:23 +00:00
|
|
|
#endif
|
|
|
|
|
2017-03-22 12:32:24 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
|
|
|
|
HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
if (console_attached && stdout_handle)
|
|
|
|
{
|
|
|
|
freopen("CONOUT$", "w", stdout);
|
|
|
|
freopen("CONOUT$", "w", stderr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
ParseCommandLine();
|
|
|
|
|
2017-08-04 17:31:05 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
FreeConsole();
|
|
|
|
#endif
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
UICommon::SetUserDirectory(m_user_path.ToStdString());
|
|
|
|
UICommon::CreateDirectories();
|
|
|
|
InitLanguageSupport(); // The language setting is loaded from the user directory
|
|
|
|
UICommon::Init();
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
if (m_select_video_backend && !m_video_backend_name.empty())
|
|
|
|
SConfig::GetInstance().m_strVideoBackend = WxStrToStr(m_video_backend_name);
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
if (m_select_audio_emulation)
|
|
|
|
SConfig::GetInstance().bDSPHLE = (m_audio_emulation_name.Upper() == "HLE");
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
VideoBackendBase::ActivateBackend(SConfig::GetInstance().m_strVideoBackend);
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
DolphinAnalytics::Instance()->ReportDolphinStart("wx");
|
2016-06-18 00:43:59 +00:00
|
|
|
|
2016-12-07 18:20:37 +00:00
|
|
|
wxToolTip::Enable(!SConfig::GetInstance().m_DisableTooltips);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Enable the PNG image handler for screenshots
|
|
|
|
wxImage::AddHandler(new wxPNGHandler);
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2017-06-12 21:08:04 +00:00
|
|
|
// Silent PNG warnings from some homebrew banners: "iCCP: known incorrect sRGB profile"
|
|
|
|
wxImage::SetDefaultLoadFlags(wxImage::GetDefaultLoadFlags() & ~wxImage::Load_Verbose);
|
|
|
|
|
2016-08-14 19:54:01 +00:00
|
|
|
// We have to copy the size and position out of SConfig now because CFrame's OnMove
|
|
|
|
// handler will corrupt them during window creation (various APIs like SetMenuBar cause
|
|
|
|
// event dispatch including WM_MOVE/WM_SIZE)
|
|
|
|
wxRect window_geometry(SConfig::GetInstance().iPosX, SConfig::GetInstance().iPosY,
|
|
|
|
SConfig::GetInstance().iWidth, SConfig::GetInstance().iHeight);
|
2017-09-09 19:52:35 +00:00
|
|
|
main_frame = new CFrame(nullptr, wxID_ANY, StrToWxStr(Common::scm_rev_str), window_geometry,
|
2016-06-24 08:43:46 +00:00
|
|
|
m_use_debugger, m_batch_mode, m_use_logger);
|
|
|
|
SetTopWindow(main_frame);
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AfterInit();
|
2009-09-06 02:55:14 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
return true;
|
2015-08-27 10:59:23 +00:00
|
|
|
}
|
2009-09-06 02:55:14 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
void DolphinApp::ParseCommandLine()
|
2015-08-27 10:59:23 +00:00
|
|
|
{
|
2016-01-17 11:15:03 +00:00
|
|
|
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
|
2017-11-26 16:22:37 +00:00
|
|
|
|
|
|
|
// Manually convert each argument to a UTF-8 std::string, because the implicit
|
|
|
|
// conversion of wxCmdLineArgsArray to char** calls ToAscii (which is undesired).
|
|
|
|
std::vector<std::string> utf8_argv;
|
|
|
|
for (int i = 1; i < argc; ++i)
|
|
|
|
utf8_argv.emplace_back(argv[i].utf8_str());
|
|
|
|
optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), utf8_argv);
|
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
std::vector<std::string> args = parser->args();
|
2015-08-27 10:59:23 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
if (options.is_set("exec"))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-10-01 22:09:07 +00:00
|
|
|
m_boot = BootParameters::GenerateFromFile(static_cast<const char*>(options.get("exec")));
|
|
|
|
}
|
|
|
|
else if (options.is_set("nand_title"))
|
|
|
|
{
|
|
|
|
const std::string hex_string = static_cast<const char*>(options.get("nand_title"));
|
|
|
|
if (hex_string.length() == 16)
|
|
|
|
{
|
|
|
|
const u64 title_id = std::stoull(hex_string, nullptr, 16);
|
|
|
|
m_boot = std::make_unique<BootParameters>(BootParameters::NANDTitle{title_id});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WxUtils::ShowErrorDialog(_("The title ID is invalid."));
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2016-01-17 11:15:03 +00:00
|
|
|
else if (args.size())
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-10-01 22:09:07 +00:00
|
|
|
m_boot = BootParameters::GenerateFromFile(args.front());
|
2016-01-17 11:15:03 +00:00
|
|
|
args.erase(args.begin());
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
m_use_debugger = options.is_set("debugger");
|
|
|
|
m_use_logger = options.is_set("logger");
|
|
|
|
m_batch_mode = options.is_set("batch");
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
m_confirm_stop = options.is_set("confirm");
|
|
|
|
m_confirm_setting = options.get("confirm");
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-01-17 11:15:03 +00:00
|
|
|
m_select_video_backend = options.is_set("video_backend");
|
|
|
|
m_video_backend_name = static_cast<const char*>(options.get("video_backend"));
|
|
|
|
|
|
|
|
m_select_audio_emulation = options.is_set("audio_emulation");
|
|
|
|
m_audio_emulation_name = static_cast<const char*>(options.get("audio_emulation"));
|
|
|
|
|
|
|
|
m_play_movie = options.is_set("movie");
|
|
|
|
m_movie_file = static_cast<const char*>(options.get("movie"));
|
|
|
|
|
|
|
|
m_user_path = static_cast<const char*>(options.get("user"));
|
2010-07-07 22:00:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-21 19:28:49 +00:00
|
|
|
#ifdef __APPLE__
|
2015-08-27 10:59:23 +00:00
|
|
|
void DolphinApp::MacOpenFile(const wxString& fileName)
|
2010-07-07 22:00:41 +00:00
|
|
|
{
|
2017-10-01 22:09:07 +00:00
|
|
|
main_frame->StartGame(BootParameters::GenerateFromFile(fileName.ToStdString()));
|
2011-01-20 03:26:51 +00:00
|
|
|
}
|
2015-06-21 19:28:49 +00:00
|
|
|
#endif
|
2009-01-04 21:53:41 +00:00
|
|
|
|
2014-11-09 00:26:20 +00:00
|
|
|
void DolphinApp::AfterInit()
|
2011-01-20 03:26:51 +00:00
|
|
|
{
|
2017-04-26 21:27:13 +00:00
|
|
|
#if defined(USE_ANALYTICS) && USE_ANALYTICS
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!SConfig::GetInstance().m_analytics_permission_asked)
|
|
|
|
{
|
|
|
|
int answer =
|
|
|
|
wxMessageBox(_("If authorized, Dolphin can collect data on its performance, "
|
|
|
|
"feature usage, and configuration, as well as data on your system's "
|
|
|
|
"hardware and operating system.\n\n"
|
|
|
|
"No private data is ever collected. This data helps us understand "
|
|
|
|
"how people and emulated games use Dolphin and prioritize our "
|
|
|
|
"efforts. It also helps us identify rare configurations that are "
|
|
|
|
"causing bugs, performance and stability issues.\n"
|
|
|
|
"This authorization can be revoked at any time through Dolphin's "
|
|
|
|
"settings.\n\n"
|
|
|
|
"Do you authorize Dolphin to report this information to Dolphin's "
|
|
|
|
"developers?"),
|
|
|
|
_("Usage statistics reporting"), wxYES_NO, main_frame);
|
|
|
|
|
|
|
|
SConfig::GetInstance().m_analytics_permission_asked = true;
|
|
|
|
SConfig::GetInstance().m_analytics_enabled = (answer == wxYES);
|
|
|
|
SConfig::GetInstance().SaveSettings();
|
|
|
|
|
|
|
|
DolphinAnalytics::Instance()->ReloadConfig();
|
|
|
|
}
|
2017-04-26 21:27:13 +00:00
|
|
|
#endif
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (m_confirm_stop)
|
2016-01-17 11:15:03 +00:00
|
|
|
SConfig::GetInstance().bConfirmStop = m_confirm_setting;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (m_play_movie && !m_movie_file.empty())
|
|
|
|
{
|
2017-12-25 17:07:29 +00:00
|
|
|
std::optional<std::string> savestate_path;
|
|
|
|
if (Movie::PlayInput(WxStrToStr(m_movie_file), &savestate_path))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-10-01 22:09:07 +00:00
|
|
|
if (m_boot)
|
2017-12-25 17:07:29 +00:00
|
|
|
{
|
|
|
|
m_boot->savestate_path = savestate_path;
|
2017-10-01 22:09:07 +00:00
|
|
|
main_frame->StartGame(std::move(m_boot));
|
2017-12-25 17:07:29 +00:00
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
else
|
2017-12-25 17:07:29 +00:00
|
|
|
{
|
|
|
|
main_frame->BootGame("", savestate_path);
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// First check if we have an exec command line.
|
2017-10-01 22:09:07 +00:00
|
|
|
else if (m_boot)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-10-01 22:09:07 +00:00
|
|
|
main_frame->StartGame(std::move(m_boot));
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
// If we have selected Automatic Start, start the default ISO,
|
|
|
|
// or if no default ISO exists, start the last loaded ISO
|
2017-05-14 20:49:25 +00:00
|
|
|
else if (m_use_debugger)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-14 20:49:25 +00:00
|
|
|
if (main_frame->GetMenuBar()->IsChecked(IDM_AUTOMATIC_START))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
main_frame->BootGame("");
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-28 01:50:09 +00:00
|
|
|
void DolphinApp::OnActivate(wxActivateEvent& ev)
|
|
|
|
{
|
|
|
|
m_is_active = ev.GetActive();
|
|
|
|
}
|
|
|
|
|
2011-01-05 04:35:46 +00:00
|
|
|
void DolphinApp::InitLanguageSupport()
|
|
|
|
{
|
2016-08-12 12:01:09 +00:00
|
|
|
std::string language_code;
|
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
|
|
|
ini.GetOrCreateSection("Interface")->Get("LanguageCode", &language_code, "");
|
|
|
|
}
|
|
|
|
int language = wxLANGUAGE_UNKNOWN;
|
|
|
|
if (language_code.empty())
|
|
|
|
{
|
|
|
|
language = wxLANGUAGE_DEFAULT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const wxLanguageInfo* language_info = wxLocale::FindLanguageInfo(StrToWxStr(language_code));
|
|
|
|
if (language_info)
|
|
|
|
language = language_info->Language;
|
|
|
|
}
|
2011-01-05 04:35:46 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Load language if possible, fall back to system default otherwise
|
|
|
|
if (wxLocale::IsAvailable(language))
|
|
|
|
{
|
|
|
|
m_locale.reset(new wxLocale(language));
|
2011-01-05 04:35:46 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
// Specify where dolphins *.gmo files are located on each operating system
|
2016-08-03 14:36:32 +00:00
|
|
|
#ifdef __WXMSW__
|
2016-06-24 08:43:46 +00:00
|
|
|
m_locale->AddCatalogLookupPathPrefix(StrToWxStr(File::GetExeDirectory() + DIR_SEP "Languages"));
|
2016-08-03 14:36:32 +00:00
|
|
|
#elif defined(__WXGTK__)
|
2016-06-24 08:43:46 +00:00
|
|
|
m_locale->AddCatalogLookupPathPrefix(StrToWxStr(DATA_DIR "../locale"));
|
2016-08-03 14:36:32 +00:00
|
|
|
#elif defined(__WXOSX__)
|
2016-06-24 08:43:46 +00:00
|
|
|
m_locale->AddCatalogLookupPathPrefix(
|
|
|
|
StrToWxStr(File::GetBundleDirectory() + "Contents/Resources"));
|
2011-01-05 04:35:46 +00:00
|
|
|
#endif
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
m_locale->AddCatalog("dolphin-emu");
|
|
|
|
|
|
|
|
if (!m_locale->IsOk())
|
|
|
|
{
|
|
|
|
wxMessageBox(_("Error loading selected language. Falling back to system default."),
|
|
|
|
_("Error"));
|
|
|
|
m_locale.reset(new wxLocale(wxLANGUAGE_DEFAULT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxMessageBox(
|
|
|
|
_("The selected language is not supported by your system. Falling back to system default."),
|
|
|
|
_("Error"));
|
|
|
|
m_locale.reset(new wxLocale(wxLANGUAGE_DEFAULT));
|
|
|
|
}
|
2017-07-21 10:46:12 +00:00
|
|
|
|
|
|
|
// wxWidgets sets the C locale for us, but not the C++ locale, so let's do that ourselves
|
|
|
|
UICommon::SetLocale(language_code);
|
2011-01-05 04:35:46 +00:00
|
|
|
}
|
|
|
|
|
2013-09-10 10:14:21 +00:00
|
|
|
void DolphinApp::OnEndSession(wxCloseEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// Close if we've received wxEVT_END_SESSION (ignore wxEVT_QUERY_END_SESSION)
|
|
|
|
if (!event.CanVeto())
|
|
|
|
{
|
|
|
|
main_frame->Close(true);
|
|
|
|
}
|
2013-09-10 10:14:21 +00:00
|
|
|
}
|
|
|
|
|
2010-02-16 04:34:41 +00:00
|
|
|
int DolphinApp::OnExit()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
Core::Shutdown();
|
|
|
|
UICommon::Shutdown();
|
2010-02-16 04:34:41 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
return wxApp::OnExit();
|
2010-02-16 04:34:41 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 01:27:01 +00:00
|
|
|
void DolphinApp::OnFatalException()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
WiimoteReal::Shutdown();
|
2011-01-12 01:27:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-12 01:18:30 +00:00
|
|
|
void DolphinApp::OnIdle(wxIdleEvent& ev)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
ev.Skip();
|
|
|
|
Core::HostDispatchJobs();
|
2016-05-12 01:18:30 +00:00
|
|
|
}
|
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-03 20:00:09 +00:00
|
|
|
// Talk to GUI
|
2009-09-06 01:40:44 +00:00
|
|
|
|
2017-07-26 04:11:17 +00:00
|
|
|
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, MsgType /*style*/)
|
2008-12-28 18:50:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (wxIsMainThread())
|
|
|
|
{
|
|
|
|
NetPlayDialog*& npd = NetPlayDialog::GetInstance();
|
2016-07-21 14:36:27 +00:00
|
|
|
if (npd != nullptr && npd->IsShown())
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
npd->AppendChat("/!\\ " + std::string{text});
|
|
|
|
return true;
|
|
|
|
}
|
2017-01-07 21:43:27 +00:00
|
|
|
return wxYES == wxMessageBox(StrToWxStr(text), StrToWxStr(caption),
|
|
|
|
wxSTAY_ON_TOP | ((yes_no) ? wxYES_NO : wxOK),
|
2016-07-21 14:36:27 +00:00
|
|
|
wxWindow::FindFocus());
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC);
|
|
|
|
event.SetString(StrToWxStr(caption) + ":" + StrToWxStr(text));
|
|
|
|
event.SetInt(yes_no);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2017-05-01 00:11:01 +00:00
|
|
|
main_frame->m_panic_event.Wait();
|
|
|
|
return main_frame->m_panic_result;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string wxStringTranslator(const char* text)
|
2011-01-13 02:05:58 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return WxStrToStr(wxGetTranslation(wxString::FromUTF8(text)));
|
2011-01-13 02:05:58 +00:00
|
|
|
}
|
|
|
|
|
2009-03-20 18:25:36 +00:00
|
|
|
// Accessor for the main window class
|
|
|
|
CFrame* DolphinApp::GetCFrame()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return main_frame;
|
2009-03-20 18:25:36 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2018-05-28 17:03:29 +00:00
|
|
|
void Host_Message(HostMessageID id)
|
2009-09-07 12:40:43 +00:00
|
|
|
{
|
2018-05-28 17:03:29 +00:00
|
|
|
if (id == HostMessageID::WMUserJobDispatch)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
// Trigger a wxEVT_IDLE
|
|
|
|
wxWakeUpIdle();
|
|
|
|
return;
|
|
|
|
}
|
2018-05-28 17:03:29 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, static_cast<int>(id));
|
2016-06-24 08:43:46 +00:00
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-09-07 12:40:43 +00:00
|
|
|
}
|
|
|
|
|
2011-02-12 21:25:49 +00:00
|
|
|
void* Host_GetRenderHandle()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return main_frame->GetRenderHandle();
|
2011-02-12 21:25:49 +00:00
|
|
|
}
|
|
|
|
|
2014-11-14 02:28:27 +00:00
|
|
|
// OK, this thread boundary is DANGEROUS on Linux
|
2008-12-08 05:30:24 +00:00
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_NOTIFY_MAP_LOADED);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2017-05-01 00:11:01 +00:00
|
|
|
if (main_frame->m_code_window)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-01 00:11:01 +00:00
|
|
|
main_frame->m_code_window->GetEventHandler()->AddPendingEvent(event);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_DISASM_DIALOG);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2009-07-15 15:09:20 +00:00
|
|
|
|
2017-05-01 00:11:01 +00:00
|
|
|
if (main_frame->m_code_window)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-01 00:11:01 +00:00
|
|
|
main_frame->m_code_window->GetEventHandler()->AddPendingEvent(event);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_GUI);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2017-05-01 00:11:01 +00:00
|
|
|
if (main_frame->m_code_window)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-05-01 00:11:01 +00:00
|
|
|
main_frame->m_code_window->GetEventHandler()->AddPendingEvent(event);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2009-09-27 21:28:09 +00:00
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void Host_UpdateTitle(const std::string& title)
|
2010-04-15 20:58:34 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_TITLE);
|
|
|
|
event.SetString(StrToWxStr(title));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2010-04-15 20:58:34 +00:00
|
|
|
}
|
|
|
|
|
2011-01-25 03:30:12 +00:00
|
|
|
void Host_RequestRenderWindowSize(int width, int height)
|
2011-01-07 04:57:59 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_WINDOW_SIZE_REQUEST);
|
|
|
|
event.SetClientData(new std::pair<int, int>(width, height));
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
2010-04-12 01:33:10 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 07:11:29 +00:00
|
|
|
bool Host_UINeedsControllerState()
|
2014-07-16 14:24:40 +00:00
|
|
|
{
|
2017-07-12 07:11:29 +00:00
|
|
|
return wxGetApp().IsActiveThreadsafe() && GetUINeedsControllerState();
|
2014-07-16 14:24:40 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:33:10 +00:00
|
|
|
bool Host_RendererHasFocus()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return main_frame->RendererHasFocus();
|
2010-04-12 01:33:10 +00:00
|
|
|
}
|
2011-01-07 15:18:00 +00:00
|
|
|
|
2015-01-04 16:09:56 +00:00
|
|
|
bool Host_RendererIsFullscreen()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
return main_frame->RendererIsFullscreen();
|
2015-01-04 16:09:56 +00:00
|
|
|
}
|
|
|
|
|
2016-06-26 06:06:23 +00:00
|
|
|
void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
|
2014-08-02 06:21:03 +00:00
|
|
|
{
|
2017-04-07 01:55:43 +00:00
|
|
|
wxWindow* const parent_window = static_cast<wxWindow*>(parent);
|
|
|
|
|
2014-02-03 13:02:17 +00:00
|
|
|
if (backend_name == "Software Renderer")
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-04-07 01:55:43 +00:00
|
|
|
SoftwareVideoConfigDialog diag(parent_window, backend_name);
|
2016-06-24 08:43:46 +00:00
|
|
|
diag.ShowModal();
|
|
|
|
}
|
2014-02-03 13:02:17 +00:00
|
|
|
else
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2017-04-07 01:55:43 +00:00
|
|
|
VideoConfigDiag diag(parent_window, backend_name);
|
2016-06-24 08:43:46 +00:00
|
|
|
diag.ShowModal();
|
|
|
|
}
|
2014-08-02 06:21:03 +00:00
|
|
|
}
|
2016-11-10 16:55:21 +00:00
|
|
|
|
|
|
|
void Host_YieldToUI()
|
|
|
|
{
|
|
|
|
wxGetApp().GetMainLoop()->YieldFor(wxEVT_CATEGORY_UI);
|
|
|
|
}
|
2017-06-25 15:35:24 +00:00
|
|
|
|
|
|
|
void Host_UpdateProgressDialog(const char* caption, int position, int total)
|
|
|
|
{
|
|
|
|
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_PROGRESS_DIALOG);
|
2017-12-04 09:26:51 +00:00
|
|
|
event.SetString(StrToWxStr(caption));
|
2017-06-25 15:35:24 +00:00
|
|
|
event.SetInt(position);
|
|
|
|
event.SetExtraLong(total);
|
|
|
|
main_frame->GetEventHandler()->AddPendingEvent(event);
|
|
|
|
}
|