Skip to content

Commit

Permalink
Merge pull request #4840 from lioncash/net
Browse files Browse the repository at this point in the history
NetWindow: Eliminate usages of the main_window global
  • Loading branch information
Parlane committed Feb 8, 2017
2 parents 691abc2 + c41f587 commit f456fce
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
4 changes: 4 additions & 0 deletions Source/Core/DolphinWX/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
35 changes: 20 additions & 15 deletions Source/Core/DolphinWX/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class CRenderFrame : public wxFrame

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
{
Expand All @@ -88,29 +90,16 @@ class CFrame : public CRenderFrame
wxCheatsWindow* g_CheatsWindow = nullptr;
TASInputDlg* g_TASInputDlg[8];

void DoPause();
void DoStop();
bool TriggerSTMPowerEvent();
void OnStopped();
void DoRecordingSave();
void UpdateGUI();
void UpdateGameList();
void ToggleLogWindow(bool bShow);
void ToggleLogConfigWindow(bool bShow);
void PostEvent(wxCommandEvent& event);
void StatusBarMessage(const char* Text, ...);
void ClearStatusBar();
void OnRenderWindowSizeRequest(int width, int height);
void BootGame(const std::string& filename);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);
bool RendererHasFocus();
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);

const CGameListCtrl* GetGameListCtrl() const;
Expand Down Expand Up @@ -232,7 +221,25 @@ class CFrame : public CRenderFrame
// Override window proc for tricks like screensaver disabling
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#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
void PostEvent(wxCommandEvent& event);
void OnRenderParentClose(wxCloseEvent& event);
void OnRenderParentMove(wxMoveEvent& event);

void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);

Expand All @@ -245,7 +252,6 @@ class CFrame : public CRenderFrame
void UpdateLoadWiiMenuItem() const;

void OnOpen(wxCommandEvent& event); // File menu
void DoOpen(bool Boot);
void OnRefresh(wxCommandEvent& event);
void OnBootDrive(wxCommandEvent& event);

Expand Down Expand Up @@ -291,7 +297,6 @@ class CFrame : public CRenderFrame
void OnMove(wxMoveEvent& event);
void OnResize(wxSizeEvent& event);
void OnToggleToolbar(wxCommandEvent& event);
void DoToggleToolbar(bool);
void OnToggleStatusbar(wxCommandEvent& event);
void OnToggleWindow(wxCommandEvent& event);

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinWX/FrameTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -526,7 +526,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
else
{
// Core is uninitialized, start the game
BootGame("");
BootGame(WxStrToStr(event.GetString()));
}
}

Expand Down
15 changes: 11 additions & 4 deletions Source/Core/DolphinWX/NetPlay/NetWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinWX/NetPlay/NetWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f456fce

Please sign in to comment.