From 42908c5b2eb4556a8fd058ef43b6cdf67d97444f Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 8 Feb 2011 15:36:15 +0000 Subject: [PATCH] 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 --- Source/Core/Core/CMakeLists.txt | 3 ++ Source/Core/Core/Core.vcproj | 20 ++++++++ Source/Core/Core/Core.vcxproj | 4 ++ Source/Core/Core/Core.vcxproj.filters | 15 ++++++ Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp | 6 +-- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp | 10 ---- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h | 1 - Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 2 - .../Core/Src/HW/SI_DeviceGCController.cpp | 6 --- .../Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 3 -- .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp | 6 --- .../Core/{DolphinWX => Core}/Src/NetPlay.cpp | 39 +++------------ Source/Core/{DolphinWX => Core}/Src/NetPlay.h | 28 +++++++---- .../{DolphinWX => Core}/Src/NetPlayClient.cpp | 27 ++++------ .../{DolphinWX => Core}/Src/NetPlayServer.cpp | 16 +++--- Source/Core/Core/Src/SConscript | 3 ++ Source/Core/DolphinWX/CMakeLists.txt | 3 -- Source/Core/DolphinWX/Dolphin.vcxproj | 4 -- Source/Core/DolphinWX/DolphinWX.vcproj | 16 ------ Source/Core/DolphinWX/Src/MainNoGUI.cpp | 3 +- Source/Core/DolphinWX/Src/NetWindow.cpp | 49 ++++++++++++++++++- Source/Core/DolphinWX/Src/NetWindow.h | 15 +++++- Source/Core/DolphinWX/Src/SConscript | 3 -- 23 files changed, 152 insertions(+), 130 deletions(-) rename Source/Core/{DolphinWX => Core}/Src/NetPlay.cpp (92%) rename Source/Core/{DolphinWX => Core}/Src/NetPlay.h (88%) rename Source/Core/{DolphinWX => Core}/Src/NetPlayClient.cpp (89%) rename Source/Core/{DolphinWX => Core}/Src/NetPlayServer.cpp (98%) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 7abd2fc2d5..7211dd8776 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -10,6 +10,9 @@ set(SRCS Src/ActionReplay.cpp Src/GeckoCodeConfig.cpp Src/GeckoCode.cpp Src/MemTools.cpp + Src/NetPlay.cpp + Src/NetPlayClient.cpp + Src/NetPlayServer.cpp Src/OnFrame.cpp Src/PatchEngine.cpp Src/State.cpp diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 3164c3c034..fb933283de 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1885,6 +1885,26 @@ + + + + + + + + + + diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 475d5cedbb..9f8a7d97b8 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -326,6 +326,9 @@ + + + @@ -516,6 +519,7 @@ + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 341071aeb3..f8d14b8631 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -525,6 +525,15 @@ HW %28Flipper/Hollywood%29\Wiimote + + NetPlay + + + NetPlay + + + NetPlay + @@ -977,6 +986,9 @@ PowerPC + + NetPlay + @@ -1109,5 +1121,8 @@ {1c21a3e1-b791-4a23-b0d5-ed2b2c34007f} + + {231ceb02-1122-402a-87a8-094a9ed768c2} + \ No newline at end of file diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp index f56cc444ce..35fc88eeb8 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp @@ -90,16 +90,12 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size) // Always add the ROM. DSPSymbols::AutoDisassembly(0x8000, 0x9000); -#if defined(HAVE_WX) && HAVE_WX - Host_RefreshDSPDebuggerWindow(); -#endif + DSPHost_UpdateDebugger(); return ector_crc; } void DSPHost_UpdateDebugger() { -#if defined(HAVE_WX) && HAVE_WX Host_RefreshDSPDebuggerWindow(); -#endif } diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index 06a904dd62..2f995e61cc 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -100,14 +100,6 @@ void DSPLLE::dsp_thread(DSPLLE *lpParameter) } } -void DSPLLE::DSP_DebugBreak() -{ -#if defined(HAVE_WX) && HAVE_WX - // if (m_DebuggerFrame) - // m_DebuggerFrame->DebugBreak(); -#endif -} - void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) { m_hWnd = hWnd; @@ -148,9 +140,7 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) if (m_bDSPThread) m_hDSPThread = std::thread(dsp_thread, this); -#if defined(HAVE_WX) && HAVE_WX Host_RefreshDSPDebuggerWindow(); -#endif } void DSPLLE::DSP_StopSoundStream() diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h index b40b9a7c98..0d80993020 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h @@ -43,7 +43,6 @@ public: virtual void DSP_Update(int cycles); virtual void DSP_StopSoundStream(); virtual void DSP_ClearAudioBuffer(bool mute); - void DSP_DebugBreak(); private: static void dsp_thread(DSPLLE* lpParameter); diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index 280ff4f5fd..5a8e322fb3 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -343,10 +343,8 @@ u32 CEXIIPL::GetGCTime() u64 ltime = 0; const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000 -#if defined(HAVE_WX) && HAVE_WX // hack in some netplay stuff ltime = NetPlay_GetGCTime(); -#endif if (Frame::IsRecordingInput() || Frame::IsPlayingInput()) ltime = 1234567890; // TODO: Should you be able to set a custom time in movies? else if (0 == ltime) diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index dbd4c8db20..8cb56a4304 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -129,7 +129,6 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); -#if defined(HAVE_WX) && HAVE_WX u32 netValues[2]; if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues)) { @@ -137,7 +136,6 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) _Low = netValues[1]; // last 4 bytes return true; } -#endif Frame::SetPolledDevice(); @@ -257,12 +255,8 @@ void CSIDevice_GCController::SendCommand(u32 _Cmd, u8 _Poll) unsigned int uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard unsigned int uStrength = command.Parameter2; -#if defined(HAVE_WX) && HAVE_WX // get the correct pad number that should rumble locally when using netplay const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); -#else - const u8 numPAD = 0; -#endif if (numPAD < 4) Pad::Rumble(numPAD, uType, uStrength); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index da8b06748c..595e6a9ba3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -502,10 +502,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() { if (m_WiiMotes[i].IsConnected() && m_WiimoteUpdate_Freq == 15 / (i + 1)) { - #if defined(HAVE_WX) && HAVE_WX NetPlay_WiimoteUpdate(i); - #endif - Wiimote::Update(i); //return true; } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index a77820d6a8..1acf496a1a 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -253,11 +253,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) _dbg_assert_msg_(WII_IPC_WIIMOTE, DoesChannelExist(pHeader->dcid), "L2CAP: SendACLPacket to unknown channel %i", pHeader->dcid); CChannelMap::iterator itr= m_Channel.find(pHeader->dcid); - #if defined(HAVE_WX) && HAVE_WX const int number = NetPlay_GetWiimoteNum(m_ConnectionHandle & 0xFF); - #else - const int number = 0; - #endif if (itr != m_Channel.end()) { @@ -854,10 +850,8 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) { - #if defined(HAVE_WX) && HAVE_WX if (NetPlay_WiimoteInput(m_ConnectionHandle & 0xFF, scid, _pData, _Size)) return; - #endif // Allocate DataFrame u8 DataFrame[1024]; diff --git a/Source/Core/DolphinWX/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp similarity index 92% rename from Source/Core/DolphinWX/Src/NetPlay.cpp rename to Source/Core/Core/Src/NetPlay.cpp index 8f37d4ffe9..7aa77d3fb6 100644 --- a/Source/Core/DolphinWX/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -16,7 +16,6 @@ // http://code.google.com/p/dolphin-emu/ #include "NetPlay.h" -#include "NetWindow.h" // for wiimote #include "IPC_HLE/WII_IPC_HLE_Device_usb.h" @@ -25,22 +24,17 @@ #include "HW/SI_DeviceGCController.h" // for gctime #include "HW/EXI_DeviceIPL.h" -// to start/stop game -#include "Frame.h" // for wiimote/ OSD messages #include "Core.h" Common::CriticalSection crit_netplay_ptr; static NetPlay* netplay_ptr = NULL; -extern CFrame* main_frame; #define RPT_SIZE_HACK (1 << 16) -DEFINE_EVENT_TYPE(wxEVT_THREAD) - // called from ---GUI--- thread -NetPlay::NetPlay() - : m_is_running(false), m_do_loop(true) +NetPlay::NetPlay(NetPlayUI* dialog) + : m_dialog(dialog), m_is_running(false), m_do_loop(true) { m_target_buffer_size = 20; ClearBuffers(); @@ -74,27 +68,6 @@ NetPlay::Player::Player() memset(pad_map, -1, sizeof(pad_map)); } -// called from ---NETPLAY--- thread -void NetPlay::UpdateGUI() -{ - if (m_dialog) - { - wxCommandEvent evt(wxEVT_THREAD, 1); - m_dialog->GetEventHandler()->AddPendingEvent(evt); - } -} - -// called from ---NETPLAY--- thread -void NetPlay::AppendChatGUI(const std::string& msg) -{ - if (m_dialog) - { - m_dialog->chat_msgs.Push(msg); - // silly - UpdateGUI(); - } -} - // called from ---GUI--- thread std::string NetPlay::Player::ToString() const { @@ -256,7 +229,7 @@ bool NetPlay::StartGame(const std::string &path) return false; } - AppendChatGUI(" -- STARTING GAME -- "); + m_dialog->AppendChat(" -- STARTING GAME -- "); m_is_running = true; NetPlay_Enable(this); @@ -264,7 +237,7 @@ bool NetPlay::StartGame(const std::string &path) ClearBuffers(); // boot game - ::main_frame->BootGame(path); + m_dialog->BootGame(path); // temporary NetWiimote nw; @@ -286,13 +259,13 @@ bool NetPlay::StopGame() return false; } - AppendChatGUI(" -- STOPPING GAME -- "); + m_dialog->AppendChat(" -- STOPPING GAME -- "); m_is_running = false; NetPlay_Disable(); // stop game - ::main_frame->DoStop(); + m_dialog->StopGame(); return true; } diff --git a/Source/Core/DolphinWX/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h similarity index 88% rename from Source/Core/DolphinWX/Src/NetPlay.h rename to Source/Core/Core/Src/NetPlay.h index fc0f01a401..6a7d149ea5 100644 --- a/Source/Core/DolphinWX/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -17,8 +17,6 @@ #include "FifoQueue.h" -class NetPlayDiag; - class NetPad { public: @@ -90,14 +88,28 @@ private: Common::CriticalSection& m_crit; }; +class NetPlayUI +{ +public: + virtual void BootGame(const std::string& filename) = 0; + virtual void StopGame() = 0; + + virtual void Update() = 0; + virtual void AppendChat(const std::string& msg) = 0; + + virtual void OnMsgChangeGame(const std::string& filename) = 0; + virtual void OnMsgStartGame() = 0; + virtual void OnMsgStopGame() = 0; +}; + class NetPlay { public: - NetPlay(); + NetPlay(NetPlayUI* _dialog); virtual ~NetPlay(); //virtual void ThreadFunc() = 0; - bool is_connected; + bool is_connected; // Send and receive pads values void WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size); @@ -117,8 +129,6 @@ public: protected: //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); void ClearBuffers(); - void UpdateGUI(); - void AppendChatGUI(const std::string& msg); virtual void SendPadState(const PadMapping local_nb, const NetPad& np) = 0; struct @@ -145,7 +155,7 @@ protected: NetWiimote m_wiimote_input[4]; - NetPlayDiag* m_dialog; + NetPlayUI* m_dialog; sf::SocketTCP m_socket; std::thread m_thread; sf::Selector m_selector; @@ -172,7 +182,7 @@ class NetPlayServer : public NetPlay public: void ThreadFunc(); - NetPlayServer(const u16 port, const std::string& name, NetPlayDiag* const npd = NULL, const std::string& game = ""); + NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog, const std::string& game = ""); ~NetPlayServer(); void GetPlayerList(std::string& list, std::vector& pid_list); @@ -221,7 +231,7 @@ class NetPlayClient : public NetPlay public: void ThreadFunc(); - NetPlayClient(const std::string& address, const u16 port, const std::string& name, NetPlayDiag* const npd = NULL); + NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name); ~NetPlayClient(); void GetPlayerList(std::string& list, std::vector& pid_list); diff --git a/Source/Core/DolphinWX/Src/NetPlayClient.cpp b/Source/Core/Core/Src/NetPlayClient.cpp similarity index 89% rename from Source/Core/DolphinWX/Src/NetPlayClient.cpp rename to Source/Core/Core/Src/NetPlayClient.cpp index beeafc0e5b..5c767effd4 100644 --- a/Source/Core/DolphinWX/Src/NetPlayClient.cpp +++ b/Source/Core/Core/Src/NetPlayClient.cpp @@ -1,5 +1,4 @@ #include "NetPlay.h" -#include "NetWindow.h" // called from ---GUI--- thread NetPlayClient::~NetPlayClient() @@ -12,9 +11,8 @@ NetPlayClient::~NetPlayClient() } // called from ---GUI--- thread -NetPlayClient::NetPlayClient(const std::string& address, const u16 port, const std::string& name, NetPlayDiag* const npd) +NetPlayClient::NetPlayClient(const std::string& address, const u16 port, NetPlayUI* dialog, const std::string& name) : NetPlay(dialog) { - m_dialog = npd; is_connected = false; // why is false successful? documentation says true is @@ -66,7 +64,7 @@ NetPlayClient::NetPlayClient(const std::string& address, const u16 port, const s m_players[m_pid] = player; m_local_player = &m_players[m_pid]; - UpdateGUI(); + m_dialog->Update(); //PanicAlertT("Connection successful: assigned player id: %d", m_pid); is_connected = true; @@ -99,7 +97,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) m_players[player.pid] = player; m_crit.players.Leave(); - UpdateGUI(); + m_dialog->Update(); } break; @@ -112,7 +110,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) m_players.erase(m_players.find(pid)); m_crit.players.Leave(); - UpdateGUI(); + m_dialog->Update(); } break; @@ -130,7 +128,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) std::ostringstream ss; ss << player.name << '[' << (char)(pid+'0') << "]: " << msg; - AppendChatGUI(ss.str()); + m_dialog->AppendChat(ss.str()); } break; @@ -146,7 +144,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> player.pad_map[i]; m_crit.players.Leave(); - UpdateGUI(); + m_dialog->Update(); } break; @@ -179,10 +177,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) m_crit.game.Leave(); // update gui - 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(m_selected_game.c_str(), *wxConvCurrent)); - m_dialog->GetEventHandler()->AddPendingEvent(evt); + m_dialog->OnMsgChangeGame(m_selected_game); } break; @@ -192,15 +187,13 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> m_current_game; m_crit.game.Leave(); - wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); - m_dialog->GetEventHandler()->AddPendingEvent(evt); + m_dialog->OnMsgStartGame(); } break; case NP_MSG_STOP_GAME : { - wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); - m_dialog->GetEventHandler()->AddPendingEvent(evt); + m_dialog->OnMsgStopGame(); } break; @@ -254,7 +247,7 @@ void NetPlayClient::ThreadFunc() default : m_is_running = false; NetPlay_Disable(); - AppendChatGUI("< LOST CONNECTION TO SERVER >"); + m_dialog->AppendChat("< LOST CONNECTION TO SERVER >"); PanicAlertT("Lost connection to server!"); m_do_loop = false; break; diff --git a/Source/Core/DolphinWX/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp similarity index 98% rename from Source/Core/DolphinWX/Src/NetPlayServer.cpp rename to Source/Core/Core/Src/NetPlayServer.cpp index e9905a9fe0..9e5e852ef5 100644 --- a/Source/Core/DolphinWX/Src/NetPlayServer.cpp +++ b/Source/Core/Core/Src/NetPlayServer.cpp @@ -1,5 +1,4 @@ #include "NetPlay.h" -#include "NetWindow.h" // called from ---GUI--- thread NetPlayServer::~NetPlayServer() @@ -12,9 +11,8 @@ NetPlayServer::~NetPlayServer() } // called from ---GUI--- thread -NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDiag* const npd, const std::string& game) +NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayUI* dialog, const std::string& game) : NetPlay(dialog) { - m_dialog = npd; m_selected_game = game; m_update_pings = true; @@ -35,7 +33,7 @@ NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDia m_local_player = &m_players[m_socket]; //PanicAlertT("Listening"); - UpdateGUI(); + m_dialog->Update(); is_connected = true; @@ -246,7 +244,7 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket) // add client to selector/ used for receiving m_selector.Add(socket); - UpdateGUI(); + m_dialog->Update(); return 0; } @@ -281,7 +279,7 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket) CritLocker send_lock(m_crit.send); // lock send SendToClients(spac); - UpdateGUI(); + m_dialog->Update(); return 0; } @@ -345,7 +343,7 @@ bool NetPlayServer::SetPadMapping(const int pid, const int map[]) CritLocker send_lock(m_crit.send); // lock send UpdatePadMapping(); // sync pad mappings with everyone - UpdateGUI(); + m_dialog->Update(); return true; } @@ -439,7 +437,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket) std::ostringstream ss; ss << player.name << '[' << (char)(player.pid+'0') << "]: " << msg; - AppendChatGUI(ss.str()); + m_dialog->AppendChat(ss.str()); } break; @@ -489,7 +487,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket) //PanicAlertT("good pong"); player.ping = ping; } - UpdateGUI(); + m_dialog->Update(); } break; diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index ecaa7ec3bb..75cdfc565e 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -12,6 +12,9 @@ files = [ "CoreParameter.cpp", "CoreRerecording.cpp", "CoreTiming.cpp", + "NetPlay.cpp", + "NetPlayClient.cpp", + "NetPlayServer.cpp", "OnFrame.cpp", "MemTools.cpp", "PatchEngine.cpp", diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 6a8355fe43..1a71b4028a 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -34,9 +34,6 @@ if(wxWidgets_FOUND) Src/Main.cpp Src/MemcardManager.cpp Src/MemoryCards/GCMemcard.cpp - Src/NetPlay.cpp - Src/NetPlayClient.cpp - Src/NetPlayServer.cpp Src/NetWindow.cpp Src/PatchAddEdit.cpp Src/PHackSettings.cpp diff --git a/Source/Core/DolphinWX/Dolphin.vcxproj b/Source/Core/DolphinWX/Dolphin.vcxproj index 12774db94d..2e57aaba78 100644 --- a/Source/Core/DolphinWX/Dolphin.vcxproj +++ b/Source/Core/DolphinWX/Dolphin.vcxproj @@ -242,9 +242,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / - - - @@ -281,7 +278,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / - diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index 8fba9b8f39..b2ddf3180f 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -943,22 +943,6 @@ - - - - - - - - diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 444a0e642f..33c8d1d81d 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -48,7 +48,8 @@ bool rendererHasFocus = true; bool running = true; -void Host_NotifyMapLoaded(){} +void Host_NotifyMapLoaded() {} +void Host_RefreshDSPDebuggerWindow() {} void Host_ShowJitResults(unsigned int address){} 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 @@ -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(); diff --git a/Source/Core/DolphinWX/Src/NetWindow.h b/Source/Core/DolphinWX/Src/NetWindow.h index 74ad892e61..88812bb236 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.h +++ b/Source/Core/DolphinWX/Src/NetWindow.h @@ -35,6 +35,8 @@ #include "FifoQueue.h" +#include "NetPlay.h" + enum { NP_GUI_EVT_CHANGE_GAME = 45, @@ -62,7 +64,7 @@ private: const CGameListCtrl* const m_game_list; }; -class NetPlayDiag : public wxFrame +class NetPlayDiag : public wxFrame, public NetPlayUI { public: NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list @@ -74,6 +76,17 @@ public: void OnStart(wxCommandEvent& event); void OnStop(wxCommandEvent& event); + // implementation of NetPlayUI methods + void BootGame(const std::string& filename); + void StopGame(); + + void Update(); + void AppendChat(const std::string& msg); + + void OnMsgChangeGame(const std::string& filename); + void OnMsgStartGame(); + void OnMsgStopGame(); + private: DECLARE_EVENT_TABLE() diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index da1cc661a1..0f6342826e 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -33,9 +33,6 @@ else: 'MemcardManager.cpp', 'MemoryCards/GCMemcard.cpp', 'MemoryCards/WiiSaveCrypted.cpp', - 'NetPlay.cpp', - 'NetPlayClient.cpp', - 'NetPlayServer.cpp', 'NetWindow.cpp', 'UDPConfigDiag.cpp', 'WiimoteConfigDiag.cpp',