diff options
| author | NeoBrainX <NeoBrainX@googlemail.com> | 2011-02-08 15:36:15 +0000 |
|---|---|---|
| committer | NeoBrainX <NeoBrainX@googlemail.com> | 2011-02-08 15:36:15 +0000 |
| commit | 42908c5b2eb4556a8fd058ef43b6cdf67d97444f (patch) | |
| tree | 302f9570c49a36e592a3fd074b7dfec248c42ac0 /Source/Core/DolphinWX/Src/NetWindow.cpp | |
| parent | dbd381755b96568edfd56810ea8cd6be175062cf (diff) | |
Remove any wx-specific code from Core.
Move NetPlay code from DolphinWX to Core.
Even NetPlay with nowx should be possible now if anyone felt like implementing a CLI for it ;)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7119 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DolphinWX/Src/NetWindow.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/Src/NetWindow.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index a5c82aedb6..4a6c294030 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -20,6 +20,7 @@ #include "NetPlay.h" #include "NetWindow.h" +#include "Frame.h" #include <sstream> @@ -27,11 +28,13 @@ #define NETPLAY_TITLEBAR "Dolphin NetPlay" +DEFINE_EVENT_TYPE(wxEVT_THREAD) BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread) END_EVENT_TABLE() static NetPlay* netplay_ptr = NULL; +extern CFrame* main_frame; NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list) : wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize) @@ -218,7 +221,7 @@ void NetPlaySetupDiag::OnJoin(wxCommandEvent&) unsigned long port = 0; m_connect_port_text->GetValue().ToULong(&port); ::netplay_ptr = new NetPlayClient(std::string(m_connect_ip_text->GetValue().mb_str()) - , (u16)port, std::string(m_nickname_text->GetValue().mb_str()), npd); + , (u16)port, npd, std::string(m_nickname_text->GetValue().mb_str())); if (::netplay_ptr->is_connected) { //NetPlayServerDiag* const npsd = @@ -381,6 +384,50 @@ void NetPlayDiag::OnStop(wxCommandEvent&) ::netplay_ptr->StopGame(); } +void NetPlayDiag::BootGame(const std::string& filename) +{ + main_frame->BootGame(filename); +} + +void NetPlayDiag::StopGame() +{ + main_frame->DoStop(); +} + +// NetPlayUI methods called from ---NETPLAY--- thread +void NetPlayDiag::Update() +{ + wxCommandEvent evt(wxEVT_THREAD, 1); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDiag::AppendChat(const std::string& msg) +{ + chat_msgs.Push(msg); + // silly + Update(); +} + +void NetPlayDiag::OnMsgChangeGame(const std::string& filename) +{ + wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_CHANGE_GAME); + // TODO: using a wxString in AddPendingEvent from another thread is unsafe i guess? + evt.SetString(wxString(filename.c_str(), *wxConvCurrent)); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDiag::OnMsgStartGame() +{ + wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); + GetEventHandler()->AddPendingEvent(evt); +} + +void NetPlayDiag::OnMsgStopGame() +{ + wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); + GetEventHandler()->AddPendingEvent(evt); +} + void NetPlayDiag::OnPadBuffHelp(wxCommandEvent&) { const u64 time = ((NetPlayServer*)::netplay_ptr)->CalculateMinimumBufferTime(); |
