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
This commit is contained in:
NeoBrainX 2011-02-08 15:36:15 +00:00
parent dbd381755b
commit 42908c5b2e
23 changed files with 152 additions and 130 deletions

View File

@ -10,6 +10,9 @@ set(SRCS Src/ActionReplay.cpp
Src/GeckoCodeConfig.cpp Src/GeckoCodeConfig.cpp
Src/GeckoCode.cpp Src/GeckoCode.cpp
Src/MemTools.cpp Src/MemTools.cpp
Src/NetPlay.cpp
Src/NetPlayClient.cpp
Src/NetPlayServer.cpp
Src/OnFrame.cpp Src/OnFrame.cpp
Src/PatchEngine.cpp Src/PatchEngine.cpp
Src/State.cpp Src/State.cpp

View File

@ -1885,6 +1885,26 @@
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter
Name="NetPlay"
>
<File
RelativePath=".\Src\NetPlay.cpp"
>
</File>
<File
RelativePath=".\Src\NetPlay.h"
>
</File>
<File
RelativePath=".\Src\NetPlayClient.cpp"
>
</File>
<File
RelativePath=".\Src\NetPlayServer.cpp"
>
</File>
</Filter>
<File <File
RelativePath=".\CMakeLists.txt" RelativePath=".\CMakeLists.txt"
> >

View File

@ -326,6 +326,9 @@
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" /> <ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" />
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.cpp" /> <ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.cpp" />
<ClCompile Include="Src\MemTools.cpp" /> <ClCompile Include="Src\MemTools.cpp" />
<ClCompile Include="Src\NetPlay.cpp" />
<ClCompile Include="Src\NetPlayClient.cpp" />
<ClCompile Include="Src\NetPlayServer.cpp" />
<ClCompile Include="Src\OnFrame.cpp" /> <ClCompile Include="Src\OnFrame.cpp" />
<ClCompile Include="Src\PatchEngine.cpp" /> <ClCompile Include="Src\PatchEngine.cpp" />
<ClCompile Include="Src\DSPEmulator.cpp" /> <ClCompile Include="Src\DSPEmulator.cpp" />
@ -516,6 +519,7 @@
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" /> <ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" />
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.h" /> <ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_WiiMote.h" />
<ClInclude Include="Src\MemTools.h" /> <ClInclude Include="Src\MemTools.h" />
<ClInclude Include="Src\NetPlay.h" />
<ClInclude Include="Src\OnFrame.h" /> <ClInclude Include="Src\OnFrame.h" />
<ClInclude Include="Src\PatchEngine.h" /> <ClInclude Include="Src\PatchEngine.h" />
<ClInclude Include="Src\DSPEmulator.h" /> <ClInclude Include="Src\DSPEmulator.h" />

View File

@ -525,6 +525,15 @@
<ClCompile Include="Src\HW\Wiimote.cpp"> <ClCompile Include="Src\HW\Wiimote.cpp">
<Filter>HW %28Flipper/Hollywood%29\Wiimote</Filter> <Filter>HW %28Flipper/Hollywood%29\Wiimote</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Src\NetPlay.cpp">
<Filter>NetPlay</Filter>
</ClCompile>
<ClCompile Include="Src\NetPlayServer.cpp">
<Filter>NetPlay</Filter>
</ClCompile>
<ClCompile Include="Src\NetPlayClient.cpp">
<Filter>NetPlay</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Src\ConfigManager.h" /> <ClInclude Include="Src\ConfigManager.h" />
@ -977,6 +986,9 @@
<Filter>PowerPC</Filter> <Filter>PowerPC</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Src\DolLoader.h" /> <ClInclude Include="Src\DolLoader.h" />
<ClInclude Include="Src\NetPlay.h">
<Filter>NetPlay</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="CMakeLists.txt" /> <None Include="CMakeLists.txt" />
@ -1109,5 +1121,8 @@
<Filter Include="HW %28Flipper/Hollywood%29\Wiimote\Real"> <Filter Include="HW %28Flipper/Hollywood%29\Wiimote\Real">
<UniqueIdentifier>{1c21a3e1-b791-4a23-b0d5-ed2b2c34007f}</UniqueIdentifier> <UniqueIdentifier>{1c21a3e1-b791-4a23-b0d5-ed2b2c34007f}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="NetPlay">
<UniqueIdentifier>{231ceb02-1122-402a-87a8-094a9ed768c2}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -90,16 +90,12 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
// Always add the ROM. // Always add the ROM.
DSPSymbols::AutoDisassembly(0x8000, 0x9000); DSPSymbols::AutoDisassembly(0x8000, 0x9000);
#if defined(HAVE_WX) && HAVE_WX DSPHost_UpdateDebugger();
Host_RefreshDSPDebuggerWindow();
#endif
return ector_crc; return ector_crc;
} }
void DSPHost_UpdateDebugger() void DSPHost_UpdateDebugger()
{ {
#if defined(HAVE_WX) && HAVE_WX
Host_RefreshDSPDebuggerWindow(); Host_RefreshDSPDebuggerWindow();
#endif
} }

View File

@ -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) void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
{ {
m_hWnd = hWnd; m_hWnd = hWnd;
@ -148,9 +140,7 @@ void DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
if (m_bDSPThread) if (m_bDSPThread)
m_hDSPThread = std::thread(dsp_thread, this); m_hDSPThread = std::thread(dsp_thread, this);
#if defined(HAVE_WX) && HAVE_WX
Host_RefreshDSPDebuggerWindow(); Host_RefreshDSPDebuggerWindow();
#endif
} }
void DSPLLE::DSP_StopSoundStream() void DSPLLE::DSP_StopSoundStream()

View File

@ -43,7 +43,6 @@ public:
virtual void DSP_Update(int cycles); virtual void DSP_Update(int cycles);
virtual void DSP_StopSoundStream(); virtual void DSP_StopSoundStream();
virtual void DSP_ClearAudioBuffer(bool mute); virtual void DSP_ClearAudioBuffer(bool mute);
void DSP_DebugBreak();
private: private:
static void dsp_thread(DSPLLE* lpParameter); static void dsp_thread(DSPLLE* lpParameter);

View File

@ -343,10 +343,8 @@ u32 CEXIIPL::GetGCTime()
u64 ltime = 0; u64 ltime = 0;
const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000 const u32 cJanuary2000 = 0x386D4380; // Seconds between 1.1.1970 and 1.1.2000
#if defined(HAVE_WX) && HAVE_WX
// hack in some netplay stuff // hack in some netplay stuff
ltime = NetPlay_GetGCTime(); ltime = NetPlay_GetGCTime();
#endif
if (Frame::IsRecordingInput() || Frame::IsPlayingInput()) if (Frame::IsRecordingInput() || Frame::IsPlayingInput())
ltime = 1234567890; // TODO: Should you be able to set a custom time in movies? ltime = 1234567890; // TODO: Should you be able to set a custom time in movies?
else if (0 == ltime) else if (0 == ltime)

View File

@ -129,7 +129,6 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); Pad::GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
#if defined(HAVE_WX) && HAVE_WX
u32 netValues[2]; u32 netValues[2];
if (NetPlay_GetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues)) 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 _Low = netValues[1]; // last 4 bytes
return true; return true;
} }
#endif
Frame::SetPolledDevice(); 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 uType = command.Parameter1; // 0 = stop, 1 = rumble, 2 = stop hard
unsigned int uStrength = command.Parameter2; unsigned int uStrength = command.Parameter2;
#if defined(HAVE_WX) && HAVE_WX
// get the correct pad number that should rumble locally when using netplay // get the correct pad number that should rumble locally when using netplay
const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber); const u8 numPAD = NetPlay_GetPadNum(ISIDevice::m_iDeviceNumber);
#else
const u8 numPAD = 0;
#endif
if (numPAD < 4) if (numPAD < 4)
Pad::Rumble(numPAD, uType, uStrength); Pad::Rumble(numPAD, uType, uStrength);

View File

@ -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 (m_WiiMotes[i].IsConnected() && m_WiimoteUpdate_Freq == 15 / (i + 1))
{ {
#if defined(HAVE_WX) && HAVE_WX
NetPlay_WiimoteUpdate(i); NetPlay_WiimoteUpdate(i);
#endif
Wiimote::Update(i);
//return true; //return true;
} }
} }

View File

@ -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); _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); CChannelMap::iterator itr= m_Channel.find(pHeader->dcid);
#if defined(HAVE_WX) && HAVE_WX
const int number = NetPlay_GetWiimoteNum(m_ConnectionHandle & 0xFF); const int number = NetPlay_GetWiimoteNum(m_ConnectionHandle & 0xFF);
#else
const int number = 0;
#endif
if (itr != m_Channel.end()) 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) 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)) if (NetPlay_WiimoteInput(m_ConnectionHandle & 0xFF, scid, _pData, _Size))
return; return;
#endif
// Allocate DataFrame // Allocate DataFrame
u8 DataFrame[1024]; u8 DataFrame[1024];

View File

@ -16,7 +16,6 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "NetPlay.h" #include "NetPlay.h"
#include "NetWindow.h"
// for wiimote // for wiimote
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h" #include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
@ -25,22 +24,17 @@
#include "HW/SI_DeviceGCController.h" #include "HW/SI_DeviceGCController.h"
// for gctime // for gctime
#include "HW/EXI_DeviceIPL.h" #include "HW/EXI_DeviceIPL.h"
// to start/stop game
#include "Frame.h"
// for wiimote/ OSD messages // for wiimote/ OSD messages
#include "Core.h" #include "Core.h"
Common::CriticalSection crit_netplay_ptr; Common::CriticalSection crit_netplay_ptr;
static NetPlay* netplay_ptr = NULL; static NetPlay* netplay_ptr = NULL;
extern CFrame* main_frame;
#define RPT_SIZE_HACK (1 << 16) #define RPT_SIZE_HACK (1 << 16)
DEFINE_EVENT_TYPE(wxEVT_THREAD)
// called from ---GUI--- thread // called from ---GUI--- thread
NetPlay::NetPlay() NetPlay::NetPlay(NetPlayUI* dialog)
: m_is_running(false), m_do_loop(true) : m_dialog(dialog), m_is_running(false), m_do_loop(true)
{ {
m_target_buffer_size = 20; m_target_buffer_size = 20;
ClearBuffers(); ClearBuffers();
@ -74,27 +68,6 @@ NetPlay::Player::Player()
memset(pad_map, -1, sizeof(pad_map)); 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 // called from ---GUI--- thread
std::string NetPlay::Player::ToString() const std::string NetPlay::Player::ToString() const
{ {
@ -256,7 +229,7 @@ bool NetPlay::StartGame(const std::string &path)
return false; return false;
} }
AppendChatGUI(" -- STARTING GAME -- "); m_dialog->AppendChat(" -- STARTING GAME -- ");
m_is_running = true; m_is_running = true;
NetPlay_Enable(this); NetPlay_Enable(this);
@ -264,7 +237,7 @@ bool NetPlay::StartGame(const std::string &path)
ClearBuffers(); ClearBuffers();
// boot game // boot game
::main_frame->BootGame(path); m_dialog->BootGame(path);
// temporary // temporary
NetWiimote nw; NetWiimote nw;
@ -286,13 +259,13 @@ bool NetPlay::StopGame()
return false; return false;
} }
AppendChatGUI(" -- STOPPING GAME -- "); m_dialog->AppendChat(" -- STOPPING GAME -- ");
m_is_running = false; m_is_running = false;
NetPlay_Disable(); NetPlay_Disable();
// stop game // stop game
::main_frame->DoStop(); m_dialog->StopGame();
return true; return true;
} }

View File

@ -17,8 +17,6 @@
#include "FifoQueue.h" #include "FifoQueue.h"
class NetPlayDiag;
class NetPad class NetPad
{ {
public: public:
@ -90,14 +88,28 @@ private:
Common::CriticalSection& m_crit; 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 class NetPlay
{ {
public: public:
NetPlay(); NetPlay(NetPlayUI* _dialog);
virtual ~NetPlay(); virtual ~NetPlay();
//virtual void ThreadFunc() = 0; //virtual void ThreadFunc() = 0;
bool is_connected; bool is_connected;
// Send and receive pads values // Send and receive pads values
void WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size); void WiimoteInput(int _number, u16 _channelID, const void* _pData, u32 _Size);
@ -117,8 +129,6 @@ public:
protected: protected:
//void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues);
void ClearBuffers(); void ClearBuffers();
void UpdateGUI();
void AppendChatGUI(const std::string& msg);
virtual void SendPadState(const PadMapping local_nb, const NetPad& np) = 0; virtual void SendPadState(const PadMapping local_nb, const NetPad& np) = 0;
struct struct
@ -145,7 +155,7 @@ protected:
NetWiimote m_wiimote_input[4]; NetWiimote m_wiimote_input[4];
NetPlayDiag* m_dialog; NetPlayUI* m_dialog;
sf::SocketTCP m_socket; sf::SocketTCP m_socket;
std::thread m_thread; std::thread m_thread;
sf::Selector<sf::SocketTCP> m_selector; sf::Selector<sf::SocketTCP> m_selector;
@ -172,7 +182,7 @@ class NetPlayServer : public NetPlay
public: public:
void ThreadFunc(); 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(); ~NetPlayServer();
void GetPlayerList(std::string& list, std::vector<int>& pid_list); void GetPlayerList(std::string& list, std::vector<int>& pid_list);
@ -221,7 +231,7 @@ class NetPlayClient : public NetPlay
public: public:
void ThreadFunc(); 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(); ~NetPlayClient();
void GetPlayerList(std::string& list, std::vector<int>& pid_list); void GetPlayerList(std::string& list, std::vector<int>& pid_list);

View File

@ -1,5 +1,4 @@
#include "NetPlay.h" #include "NetPlay.h"
#include "NetWindow.h"
// called from ---GUI--- thread // called from ---GUI--- thread
NetPlayClient::~NetPlayClient() NetPlayClient::~NetPlayClient()
@ -12,9 +11,8 @@ NetPlayClient::~NetPlayClient()
} }
// called from ---GUI--- thread // 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; is_connected = false;
// why is false successful? documentation says true is // 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_players[m_pid] = player;
m_local_player = &m_players[m_pid]; m_local_player = &m_players[m_pid];
UpdateGUI(); m_dialog->Update();
//PanicAlertT("Connection successful: assigned player id: %d", m_pid); //PanicAlertT("Connection successful: assigned player id: %d", m_pid);
is_connected = true; is_connected = true;
@ -99,7 +97,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
m_players[player.pid] = player; m_players[player.pid] = player;
m_crit.players.Leave(); m_crit.players.Leave();
UpdateGUI(); m_dialog->Update();
} }
break; break;
@ -112,7 +110,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
m_players.erase(m_players.find(pid)); m_players.erase(m_players.find(pid));
m_crit.players.Leave(); m_crit.players.Leave();
UpdateGUI(); m_dialog->Update();
} }
break; break;
@ -130,7 +128,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
std::ostringstream ss; std::ostringstream ss;
ss << player.name << '[' << (char)(pid+'0') << "]: " << msg; ss << player.name << '[' << (char)(pid+'0') << "]: " << msg;
AppendChatGUI(ss.str()); m_dialog->AppendChat(ss.str());
} }
break; break;
@ -146,7 +144,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> player.pad_map[i]; packet >> player.pad_map[i];
m_crit.players.Leave(); m_crit.players.Leave();
UpdateGUI(); m_dialog->Update();
} }
break; break;
@ -179,10 +177,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
m_crit.game.Leave(); m_crit.game.Leave();
// update gui // update gui
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_CHANGE_GAME); m_dialog->OnMsgChangeGame(m_selected_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);
} }
break; break;
@ -192,15 +187,13 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> m_current_game; packet >> m_current_game;
m_crit.game.Leave(); m_crit.game.Leave();
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); m_dialog->OnMsgStartGame();
m_dialog->GetEventHandler()->AddPendingEvent(evt);
} }
break; break;
case NP_MSG_STOP_GAME : case NP_MSG_STOP_GAME :
{ {
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); m_dialog->OnMsgStopGame();
m_dialog->GetEventHandler()->AddPendingEvent(evt);
} }
break; break;
@ -254,7 +247,7 @@ void NetPlayClient::ThreadFunc()
default : default :
m_is_running = false; m_is_running = false;
NetPlay_Disable(); NetPlay_Disable();
AppendChatGUI("< LOST CONNECTION TO SERVER >"); m_dialog->AppendChat("< LOST CONNECTION TO SERVER >");
PanicAlertT("Lost connection to server!"); PanicAlertT("Lost connection to server!");
m_do_loop = false; m_do_loop = false;
break; break;

View File

@ -1,5 +1,4 @@
#include "NetPlay.h" #include "NetPlay.h"
#include "NetWindow.h"
// called from ---GUI--- thread // called from ---GUI--- thread
NetPlayServer::~NetPlayServer() NetPlayServer::~NetPlayServer()
@ -12,9 +11,8 @@ NetPlayServer::~NetPlayServer()
} }
// called from ---GUI--- thread // 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_selected_game = game;
m_update_pings = true; 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]; m_local_player = &m_players[m_socket];
//PanicAlertT("Listening"); //PanicAlertT("Listening");
UpdateGUI(); m_dialog->Update();
is_connected = true; is_connected = true;
@ -246,7 +244,7 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
// add client to selector/ used for receiving // add client to selector/ used for receiving
m_selector.Add(socket); m_selector.Add(socket);
UpdateGUI(); m_dialog->Update();
return 0; return 0;
} }
@ -281,7 +279,7 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
CritLocker send_lock(m_crit.send); // lock send CritLocker send_lock(m_crit.send); // lock send
SendToClients(spac); SendToClients(spac);
UpdateGUI(); m_dialog->Update();
return 0; return 0;
} }
@ -345,7 +343,7 @@ bool NetPlayServer::SetPadMapping(const int pid, const int map[])
CritLocker send_lock(m_crit.send); // lock send CritLocker send_lock(m_crit.send); // lock send
UpdatePadMapping(); // sync pad mappings with everyone UpdatePadMapping(); // sync pad mappings with everyone
UpdateGUI(); m_dialog->Update();
return true; return true;
} }
@ -439,7 +437,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
std::ostringstream ss; std::ostringstream ss;
ss << player.name << '[' << (char)(player.pid+'0') << "]: " << msg; ss << player.name << '[' << (char)(player.pid+'0') << "]: " << msg;
AppendChatGUI(ss.str()); m_dialog->AppendChat(ss.str());
} }
break; break;
@ -489,7 +487,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
//PanicAlertT("good pong"); //PanicAlertT("good pong");
player.ping = ping; player.ping = ping;
} }
UpdateGUI(); m_dialog->Update();
} }
break; break;

View File

@ -12,6 +12,9 @@ files = [
"CoreParameter.cpp", "CoreParameter.cpp",
"CoreRerecording.cpp", "CoreRerecording.cpp",
"CoreTiming.cpp", "CoreTiming.cpp",
"NetPlay.cpp",
"NetPlayClient.cpp",
"NetPlayServer.cpp",
"OnFrame.cpp", "OnFrame.cpp",
"MemTools.cpp", "MemTools.cpp",
"PatchEngine.cpp", "PatchEngine.cpp",

View File

@ -34,9 +34,6 @@ if(wxWidgets_FOUND)
Src/Main.cpp Src/Main.cpp
Src/MemcardManager.cpp Src/MemcardManager.cpp
Src/MemoryCards/GCMemcard.cpp Src/MemoryCards/GCMemcard.cpp
Src/NetPlay.cpp
Src/NetPlayClient.cpp
Src/NetPlayServer.cpp
Src/NetWindow.cpp Src/NetWindow.cpp
Src/PatchAddEdit.cpp Src/PatchAddEdit.cpp
Src/PHackSettings.cpp Src/PHackSettings.cpp

View File

@ -242,9 +242,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<ClCompile Include="Src\MemcardManager.cpp" /> <ClCompile Include="Src\MemcardManager.cpp" />
<ClCompile Include="Src\MemoryCards\GCMemcard.cpp" /> <ClCompile Include="Src\MemoryCards\GCMemcard.cpp" />
<ClCompile Include="Src\MemoryCards\WiiSaveCrypted.cpp" /> <ClCompile Include="Src\MemoryCards\WiiSaveCrypted.cpp" />
<ClCompile Include="Src\NetPlay.cpp" />
<ClCompile Include="Src\NetPlayClient.cpp" />
<ClCompile Include="Src\NetPlayServer.cpp" />
<ClCompile Include="Src\NetWindow.cpp" /> <ClCompile Include="Src\NetWindow.cpp" />
<ClCompile Include="Src\PatchAddEdit.cpp" /> <ClCompile Include="Src\PatchAddEdit.cpp" />
<ClCompile Include="Src\PHackSettings.cpp" /> <ClCompile Include="Src\PHackSettings.cpp" />
@ -281,7 +278,6 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
<ClInclude Include="Src\MemcardManager.h" /> <ClInclude Include="Src\MemcardManager.h" />
<ClInclude Include="Src\MemoryCards\GCMemcard.h" /> <ClInclude Include="Src\MemoryCards\GCMemcard.h" />
<ClInclude Include="Src\MemoryCards\WiiSaveCrypted.h" /> <ClInclude Include="Src\MemoryCards\WiiSaveCrypted.h" />
<ClInclude Include="Src\NetPlay.h" />
<ClInclude Include="Src\NetWindow.h" /> <ClInclude Include="Src\NetWindow.h" />
<ClInclude Include="Src\PatchAddEdit.h" /> <ClInclude Include="Src\PatchAddEdit.h" />
<ClInclude Include="Src\PHackSettings.h" /> <ClInclude Include="Src\PHackSettings.h" />

View File

@ -943,22 +943,6 @@
<Filter <Filter
Name="NetPlay" Name="NetPlay"
> >
<File
RelativePath=".\Src\NetPlay.cpp"
>
</File>
<File
RelativePath=".\Src\NetPlay.h"
>
</File>
<File
RelativePath=".\Src\NetPlayClient.cpp"
>
</File>
<File
RelativePath=".\Src\NetPlayServer.cpp"
>
</File>
<File <File
RelativePath=".\Src\NetWindow.cpp" RelativePath=".\Src\NetWindow.cpp"
> >

View File

@ -48,7 +48,8 @@
bool rendererHasFocus = true; bool rendererHasFocus = true;
bool running = true; bool running = true;
void Host_NotifyMapLoaded(){} void Host_NotifyMapLoaded() {}
void Host_RefreshDSPDebuggerWindow() {}
void Host_ShowJitResults(unsigned int address){} void Host_ShowJitResults(unsigned int address){}

View File

@ -20,6 +20,7 @@
#include "NetPlay.h" #include "NetPlay.h"
#include "NetWindow.h" #include "NetWindow.h"
#include "Frame.h"
#include <sstream> #include <sstream>
@ -27,11 +28,13 @@
#define NETPLAY_TITLEBAR "Dolphin NetPlay" #define NETPLAY_TITLEBAR "Dolphin NetPlay"
DEFINE_EVENT_TYPE(wxEVT_THREAD)
BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame) BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread)
END_EVENT_TABLE() END_EVENT_TABLE()
static NetPlay* netplay_ptr = NULL; static NetPlay* netplay_ptr = NULL;
extern CFrame* main_frame;
NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list) NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list)
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize) : wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
@ -218,7 +221,7 @@ void NetPlaySetupDiag::OnJoin(wxCommandEvent&)
unsigned long port = 0; unsigned long port = 0;
m_connect_port_text->GetValue().ToULong(&port); m_connect_port_text->GetValue().ToULong(&port);
::netplay_ptr = new NetPlayClient(std::string(m_connect_ip_text->GetValue().mb_str()) ::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) if (::netplay_ptr->is_connected)
{ {
//NetPlayServerDiag* const npsd = //NetPlayServerDiag* const npsd =
@ -381,6 +384,50 @@ void NetPlayDiag::OnStop(wxCommandEvent&)
::netplay_ptr->StopGame(); ::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&) void NetPlayDiag::OnPadBuffHelp(wxCommandEvent&)
{ {
const u64 time = ((NetPlayServer*)::netplay_ptr)->CalculateMinimumBufferTime(); const u64 time = ((NetPlayServer*)::netplay_ptr)->CalculateMinimumBufferTime();

View File

@ -35,6 +35,8 @@
#include "FifoQueue.h" #include "FifoQueue.h"
#include "NetPlay.h"
enum enum
{ {
NP_GUI_EVT_CHANGE_GAME = 45, NP_GUI_EVT_CHANGE_GAME = 45,
@ -62,7 +64,7 @@ private:
const CGameListCtrl* const m_game_list; const CGameListCtrl* const m_game_list;
}; };
class NetPlayDiag : public wxFrame class NetPlayDiag : public wxFrame, public NetPlayUI
{ {
public: public:
NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list
@ -74,6 +76,17 @@ public:
void OnStart(wxCommandEvent& event); void OnStart(wxCommandEvent& event);
void OnStop(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: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@ -33,9 +33,6 @@ else:
'MemcardManager.cpp', 'MemcardManager.cpp',
'MemoryCards/GCMemcard.cpp', 'MemoryCards/GCMemcard.cpp',
'MemoryCards/WiiSaveCrypted.cpp', 'MemoryCards/WiiSaveCrypted.cpp',
'NetPlay.cpp',
'NetPlayClient.cpp',
'NetPlayServer.cpp',
'NetWindow.cpp', 'NetWindow.cpp',
'UDPConfigDiag.cpp', 'UDPConfigDiag.cpp',
'WiimoteConfigDiag.cpp', 'WiimoteConfigDiag.cpp',