summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2017-02-06 14:48:09 -0500
committerLioncash <mathew1800@gmail.com>2017-02-06 18:29:20 -0500
commitead076d335a88f4fccb520a00f9d618b72f28826 (patch)
tree63fe5425db567d8d75224af9245c58f1fc4e92f2 /Source/Core
parent0c7d9bbb73e77fb00e02eea3970389d8f449a7aa (diff)
NetWindow: Get rid of direct use of the main_window global
Utilizes the event system (which is what should have been done here initially), in order to prevent coupling between two different window frames. This also makes booting games more versatile using the UI event system, as the event can just act as a carrier for the filename, making directly calling boot functions unnecessary. All that's needed is for the event to propagate to the frame.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinWX/Frame.cpp4
-rw-r--r--Source/Core/DolphinWX/Frame.h2
-rw-r--r--Source/Core/DolphinWX/FrameTools.cpp4
-rw-r--r--Source/Core/DolphinWX/NetPlay/NetWindow.cpp15
-rw-r--r--Source/Core/DolphinWX/NetPlay/NetWindow.h1
5 files changed, 20 insertions, 6 deletions
diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp
index 1648163752..f35e964706 100644
--- a/Source/Core/DolphinWX/Frame.cpp
+++ b/Source/Core/DolphinWX/Frame.cpp
@@ -229,6 +229,8 @@ wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);
+wxDEFINE_EVENT(DOLPHIN_EVT_BOOT_SOFTWARE, wxCommandEvent);
+wxDEFINE_EVENT(DOLPHIN_EVT_STOP_SOFTWARE, wxCommandEvent);
// Event tables
BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
@@ -495,6 +497,8 @@ void CFrame::BindEvents()
Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this);
Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this);
Bind(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, &CFrame::OnUpdateLoadWiiMenuItem, this);
+ Bind(DOLPHIN_EVT_BOOT_SOFTWARE, &CFrame::OnPlay, this);
+ Bind(DOLPHIN_EVT_STOP_SOFTWARE, &CFrame::OnStop, this);
}
bool CFrame::RendererIsFullscreen()
diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h
index 98f60c200a..1ee82ed621 100644
--- a/Source/Core/DolphinWX/Frame.h
+++ b/Source/Core/DolphinWX/Frame.h
@@ -62,6 +62,8 @@ private:
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, wxCommandEvent);
+wxDECLARE_EVENT(DOLPHIN_EVT_BOOT_SOFTWARE, wxCommandEvent);
+wxDECLARE_EVENT(DOLPHIN_EVT_STOP_SOFTWARE, wxCommandEvent);
class CFrame : public CRenderFrame
{
diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp
index fb69f6ac0c..c40e6d0916 100644
--- a/Source/Core/DolphinWX/FrameTools.cpp
+++ b/Source/Core/DolphinWX/FrameTools.cpp
@@ -501,7 +501,7 @@ void CFrame::OnRecordExport(wxCommandEvent& WXUNUSED(event))
DoRecordingSave();
}
-void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
+void CFrame::OnPlay(wxCommandEvent& event)
{
if (Core::IsRunning())
{
@@ -526,7 +526,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
else
{
// Core is uninitialized, start the game
- BootGame("");
+ BootGame(WxStrToStr(event.GetString()));
}
}
diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp
index 75cf03885e..bd78185e7e 100644
--- a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp
+++ b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "DolphinWX/NetPlay/NetWindow.h"
+
#include <algorithm>
#include <cstddef>
#include <limits>
@@ -43,9 +45,7 @@
#include "DolphinWX/Frame.h"
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/ISOFile.h"
-#include "DolphinWX/Main.h"
#include "DolphinWX/NetPlay/ChangeGameDialog.h"
-#include "DolphinWX/NetPlay/NetWindow.h"
#include "DolphinWX/NetPlay/PadMapDialog.h"
#include "DolphinWX/WxUtils.h"
#include "MD5Dialog.h"
@@ -369,12 +369,19 @@ void NetPlayDialog::OnStart(wxCommandEvent&)
void NetPlayDialog::BootGame(const std::string& filename)
{
- main_frame->BootGame(filename);
+ wxCommandEvent play_event{DOLPHIN_EVT_BOOT_SOFTWARE, GetId()};
+ play_event.SetString(StrToWxStr(filename));
+ play_event.SetEventObject(this);
+
+ AddPendingEvent(play_event);
}
void NetPlayDialog::StopGame()
{
- main_frame->DoStop();
+ wxCommandEvent stop_event{DOLPHIN_EVT_STOP_SOFTWARE, GetId()};
+ stop_event.SetEventObject(this);
+
+ AddPendingEvent(stop_event);
}
// NetPlayUI methods called from ---NETPLAY--- thread
diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.h b/Source/Core/DolphinWX/NetPlay/NetWindow.h
index bc199c2581..a579de2f40 100644
--- a/Source/Core/DolphinWX/NetPlay/NetWindow.h
+++ b/Source/Core/DolphinWX/NetPlay/NetWindow.h
@@ -8,6 +8,7 @@
#include <vector>
#include <wx/frame.h>
+#include "Common/CommonTypes.h"
#include "Common/FifoQueue.h"
#include "Core/NetPlayClient.h"
#include "Core/NetPlayProto.h"