Merge pull request #4840 from lioncash/net

NetWindow: Eliminate usages of the main_window global
This commit is contained in:
Matthew Parlane 2017-02-08 18:12:56 +13:00 committed by GitHub
commit f456fcec48
5 changed files with 38 additions and 21 deletions

View File

@ -229,6 +229,8 @@ wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent); wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent); wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDEFINE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, 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 // Event tables
BEGIN_EVENT_TABLE(CFrame, CRenderFrame) 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_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this);
Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this); Bind(DOLPHIN_EVT_RELOAD_GAMELIST, &CFrame::OnReloadGameList, this);
Bind(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, &CFrame::OnUpdateLoadWiiMenuItem, 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() bool CFrame::RendererIsFullscreen()

View File

@ -62,6 +62,8 @@ private:
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent); wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
wxDECLARE_EVENT(DOLPHIN_EVT_UPDATE_LOAD_WII_MENU_ITEM, 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 class CFrame : public CRenderFrame
{ {
@ -88,29 +90,16 @@ public:
wxCheatsWindow* g_CheatsWindow = nullptr; wxCheatsWindow* g_CheatsWindow = nullptr;
TASInputDlg* g_TASInputDlg[8]; TASInputDlg* g_TASInputDlg[8];
void DoPause();
void DoStop(); void DoStop();
bool TriggerSTMPowerEvent();
void OnStopped();
void DoRecordingSave();
void UpdateGUI(); void UpdateGUI();
void UpdateGameList(); void UpdateGameList();
void ToggleLogWindow(bool bShow); void ToggleLogWindow(bool bShow);
void ToggleLogConfigWindow(bool bShow); void ToggleLogConfigWindow(bool bShow);
void PostEvent(wxCommandEvent& event);
void StatusBarMessage(const char* Text, ...); void StatusBarMessage(const char* Text, ...);
void ClearStatusBar(); void ClearStatusBar();
void OnRenderWindowSizeRequest(int width, int height);
void BootGame(const std::string& filename); void BootGame(const std::string& filename);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus(); bool RendererHasFocus();
bool RendererIsFullscreen(); bool RendererIsFullscreen();
void DoFullscreen(bool enable_fullscreen);
void DoExclusiveFullscreen(bool enable_fullscreen);
void ToggleDisplayMode(bool bFullscreen);
static void ConnectWiimote(int wm_idx, bool connect);
void UpdateTitle(const std::string& str);
void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY); void OpenGeneralConfiguration(wxWindowID tab_id = wxID_ANY);
const CGameListCtrl* GetGameListCtrl() const; const CGameListCtrl* GetGameListCtrl() const;
@ -232,7 +221,25 @@ private:
// Override window proc for tricks like screensaver disabling // Override window proc for tricks like screensaver disabling
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif #endif
void DoOpen(bool Boot);
void DoPause();
void DoToggleToolbar(bool);
void DoRecordingSave();
void DoFullscreen(bool enable_fullscreen);
void DoExclusiveFullscreen(bool enable_fullscreen);
void ToggleDisplayMode(bool bFullscreen);
bool TriggerSTMPowerEvent();
void OnStopped();
void OnRenderWindowSizeRequest(int width, int height);
void UpdateTitle(const std::string& str);
static void ConnectWiimote(int wm_idx, bool connect);
// Event functions // Event functions
void PostEvent(wxCommandEvent& event);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event); void OnHelp(wxCommandEvent& event);
@ -245,7 +252,6 @@ private:
void UpdateLoadWiiMenuItem() const; void UpdateLoadWiiMenuItem() const;
void OnOpen(wxCommandEvent& event); // File menu void OnOpen(wxCommandEvent& event); // File menu
void DoOpen(bool Boot);
void OnRefresh(wxCommandEvent& event); void OnRefresh(wxCommandEvent& event);
void OnBootDrive(wxCommandEvent& event); void OnBootDrive(wxCommandEvent& event);
@ -291,7 +297,6 @@ private:
void OnMove(wxMoveEvent& event); void OnMove(wxMoveEvent& event);
void OnResize(wxSizeEvent& event); void OnResize(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event); void OnToggleToolbar(wxCommandEvent& event);
void DoToggleToolbar(bool);
void OnToggleStatusbar(wxCommandEvent& event); void OnToggleStatusbar(wxCommandEvent& event);
void OnToggleWindow(wxCommandEvent& event); void OnToggleWindow(wxCommandEvent& event);

View File

@ -501,7 +501,7 @@ void CFrame::OnRecordExport(wxCommandEvent& WXUNUSED(event))
DoRecordingSave(); DoRecordingSave();
} }
void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) void CFrame::OnPlay(wxCommandEvent& event)
{ {
if (Core::IsRunning()) if (Core::IsRunning())
{ {
@ -526,7 +526,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
else else
{ {
// Core is uninitialized, start the game // Core is uninitialized, start the game
BootGame(""); BootGame(WxStrToStr(event.GetString()));
} }
} }

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinWX/NetPlay/NetWindow.h"
#include <algorithm> #include <algorithm>
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
@ -43,9 +45,7 @@
#include "DolphinWX/Frame.h" #include "DolphinWX/Frame.h"
#include "DolphinWX/GameListCtrl.h" #include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/ISOFile.h" #include "DolphinWX/ISOFile.h"
#include "DolphinWX/Main.h"
#include "DolphinWX/NetPlay/ChangeGameDialog.h" #include "DolphinWX/NetPlay/ChangeGameDialog.h"
#include "DolphinWX/NetPlay/NetWindow.h"
#include "DolphinWX/NetPlay/PadMapDialog.h" #include "DolphinWX/NetPlay/PadMapDialog.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#include "MD5Dialog.h" #include "MD5Dialog.h"
@ -369,12 +369,19 @@ void NetPlayDialog::OnStart(wxCommandEvent&)
void NetPlayDialog::BootGame(const std::string& filename) 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() 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 // NetPlayUI methods called from ---NETPLAY--- thread

View File

@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include <wx/frame.h> #include <wx/frame.h>
#include "Common/CommonTypes.h"
#include "Common/FifoQueue.h" #include "Common/FifoQueue.h"
#include "Core/NetPlayClient.h" #include "Core/NetPlayClient.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"