NetPlay: some code cleanup, added a stop button (sometimes works), host can now change the game after starting a session

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5430 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak 2010-05-02 23:01:50 +00:00
parent 6c407b5fa0
commit fd1ea33fb2
4 changed files with 286 additions and 125 deletions

View File

@ -71,12 +71,7 @@ NetPlayClient::~NetPlayClient()
}
}
NetPlayServer::Player::Player()
{
memset(pad_map, -1, sizeof(pad_map));
}
NetPlayClient::Player::Player()
NetPlay::Player::Player()
{
memset(pad_map, -1, sizeof(pad_map));
}
@ -88,7 +83,7 @@ NetPlayServer::NetPlayServer(const u16 port, const std::string& name, NetPlayDia
if (m_socket.Listen(port))
{
Player player;
Client player;
player.pid = 0;
player.revision = NETPLAY_DOLPHIN_VER;
player.socket = m_socket;
@ -221,7 +216,8 @@ void NetPlayServer::Entry()
if (0 == OnData(rpac, ready_socket))
break;
case sf::Socket::Disconnected :
//case sf::Socket::Disconnected :
default :
m_crit.other.Enter();
OnDisconnect(ready_socket);
m_crit.other.Leave();
@ -233,7 +229,7 @@ void NetPlayServer::Entry()
// close listening socket and client sockets
{
std::map<sf::SocketTCP, Player>::reverse_iterator
std::map<sf::SocketTCP, Client>::reverse_iterator
i = m_players.rbegin(),
e = m_players.rend();
for ( ; i!=e; ++i)
@ -263,14 +259,14 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
if (m_players.size() >= 255)
return CON_ERR_SERVER_FULL;
Player player;
Client player;
player.socket = socket;
rpac >> player.revision;
rpac >> player.name;
// give new client first available id
player.pid = 0;
std::map<sf::SocketTCP, Player>::const_iterator
std::map<sf::SocketTCP, Client>::const_iterator
i,
e = m_players.end();
for (PlayerId p = 1; 0 == player.pid; ++p)
@ -297,7 +293,7 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
for (i = m_players.begin(); i!=e; ++i)
{
if (i->second.pad_map[m] >= 0)
is_mapped[i->second.pad_map[m]] = true;
is_mapped[(unsigned)i->second.pad_map[m]] = true;
}
}
@ -386,12 +382,13 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
m_players.erase(m_players.find(socket));
m_crit.players.Leave();
UpdateGUI();
// alert other players of disconnect
m_crit.send.Enter();
SendToClients(spac);
m_crit.send.Leave();
UpdateGUI();
return 0;
}
@ -404,9 +401,19 @@ void NetPlay::UpdateGUI()
}
}
void NetPlay::AppendChatGUI(const std::string& msg)
{
if (m_dialog)
{
m_dialog->chat_msgs.Push(msg);
// silly
UpdateGUI();
}
}
void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid)
{
std::map<sf::SocketTCP, Player>::iterator
std::map<sf::SocketTCP, Client>::iterator
i = m_players.begin(),
e = m_players.end();
for ( ; i!=e; ++i)
@ -444,21 +451,19 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
std::ostringstream ss;
ss << player.name << '[' << (char)(player.pid+'0') << "]: " << msg;
m_dialog->chat_msgs.Push(ss.str());
UpdateGUI();
AppendChatGUI(ss.str());
}
break;
case NP_MSG_PAD_DATA :
{
PadMapping map;
PadMapping map = 0;
NetPad np;
packet >> map >> np.nHi >> np.nLo;
// check if client's pad indeed maps in game
if (map >= 0 && map < 4)
map = player.pad_map[map];
map = player.pad_map[(unsigned)map];
else
map = -1;
@ -469,7 +474,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
// add to pad buffer
m_crit.buffer.Enter();
m_pad_buffer[map].push(np);
m_pad_buffer[(unsigned)map].push(np);
m_crit.buffer.Leave();
// relay to clients
@ -543,8 +548,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
std::ostringstream ss;
ss << player.name << '[' << (char)(pid+'0') << "]: " << msg;
m_dialog->chat_msgs.Push(ss.str());
UpdateGUI();
AppendChatGUI(ss.str());
}
break;
@ -566,13 +570,14 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_PAD_DATA :
{
PadMapping map;
PadMapping map = 0;
NetPad np;
packet >> map >> np.nHi >> np.nLo;
// trusting server for good map value (>=0 && <4)
// add to pad buffer
m_crit.buffer.Enter();
m_pad_buffer[map].push(np);
m_pad_buffer[(unsigned)map].push(np);
m_crit.buffer.Leave();
}
break;
@ -584,7 +589,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
m_crit.other.Leave();
// update gui
wxCommandEvent evt(wxEVT_THREAD, 45);
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);
}
@ -592,8 +598,14 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_START_GAME :
{
// kinda silly
wxCommandEvent evt(wxEVT_THREAD, 46);
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME);
m_dialog->GetEventHandler()->AddPendingEvent(evt);
}
break;
case NP_MSG_STOP_GAME :
{
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME);
m_dialog->GetEventHandler()->AddPendingEvent(evt);
}
break;
@ -620,7 +632,8 @@ void NetPlayClient::Entry()
OnData(rpac);
break;
case sf::Socket::Disconnected :
//case sf::Socket::Disconnected :
default :
PanicAlert("Lost connection to server! If the game is running, it will likely hang!");
m_do_loop = false;
break;
@ -633,13 +646,12 @@ void NetPlayClient::Entry()
return;
}
template <typename P>
static inline std::string PlayerToString(const P& p)
std::string NetPlay::Player::ToString() const
{
std::ostringstream ss;
ss << p.name << '[' << (char)(p.pid+'0') << "] : " << p.revision << " |";
ss << name << '[' << (char)(pid+'0') << "] : " << revision << " |";
for (unsigned int i=0; i<4; ++i)
ss << (p.pad_map[i]>=0 ? (char)(p.pad_map[i]+'1') : '-');
ss << (pad_map[i]>=0 ? (char)(pad_map[i]+'1') : '-');
ss << '|';
return ss.str();
}
@ -654,7 +666,7 @@ void NetPlayClient::GetPlayerList(std::string &list)
i = m_players.begin(),
e = m_players.end();
for ( ; i!=e; ++i)
ss << PlayerToString(i->second) << '\n';
ss << i->second.ToString() << '\n';
list = ss.str();
@ -667,11 +679,11 @@ void NetPlayServer::GetPlayerList(std::string &list)
std::ostringstream ss;
std::map<sf::SocketTCP, Player>::const_iterator
std::map<sf::SocketTCP, Client>::const_iterator
i = m_players.begin(),
e = m_players.end();
for ( ; i!=e; ++i)
ss << PlayerToString(i->second) << '\n';
ss << i->second.ToString() << '\n';
list = ss.str();
@ -739,7 +751,7 @@ bool NetPlayServer::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
// add to buffer
m_crit.buffer.Enter();
m_pad_buffer[in_game_num].push(np);
m_pad_buffer[(unsigned)in_game_num].push(np);
m_crit.buffer.Leave();
// send to clients
@ -753,6 +765,37 @@ bool NetPlayServer::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
m_crit.send.Leave();
}
m_crit.players.Leave();
// get pad from pad buffer and send to game
GetBufferedPad(pad_nb, netvalues);
return true;
}
bool NetPlayServer::ChangeGame(const std::string &game)
{
m_crit.other.Enter();
m_selected_game = game;
// send changed game to clients
sf::Packet spac;
spac << (MessageId)NP_MSG_CHANGE_GAME;
spac << game;
m_crit.players.Enter();
m_crit.send.Enter();
SendToClients(spac);
m_crit.send.Leave();
m_crit.players.Leave();
m_crit.other.Leave();
return true;
}
void NetPlay::GetBufferedPad(const u8 pad_nb, NetPad* const netvalues)
{
// get padstate from buffer and send to game
m_crit.buffer.Enter();
while (0 == m_pad_buffer[pad_nb].size())
@ -765,18 +808,6 @@ bool NetPlayServer::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
*netvalues = m_pad_buffer[pad_nb].front();
m_pad_buffer[pad_nb].pop();
m_crit.buffer.Leave();
m_crit.players.Leave();
return true;
}
bool NetPlayServer::SetSelectedGame(const std::string &game)
{
// warning removal
game.size();
return true;
}
bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_status, NetPad* const netvalues)
@ -793,7 +824,7 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
// add to buffer
m_crit.buffer.Enter();
m_pad_buffer[in_game_num].push(np);
m_pad_buffer[(unsigned)in_game_num].push(np);
m_crit.buffer.Leave();
// send to server
@ -807,32 +838,43 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, const SPADStatus* const pad_stat
m_crit.send.Leave();
}
// get padstate from buffer and send to game
m_crit.buffer.Enter();
while (0 == m_pad_buffer[pad_nb].size())
{
m_crit.buffer.Leave();
// wait for receiving thread to push some data
Common::SleepCurrentThread(1);
m_crit.buffer.Enter();
}
*netvalues = m_pad_buffer[pad_nb].front();
m_pad_buffer[pad_nb].pop();
m_crit.buffer.Leave();
m_crit.players.Leave();
// get pad from pad buffer and send to game
GetBufferedPad(pad_nb, netvalues);
return true;
}
bool NetPlayClient::SetSelectedGame(const std::string &game)
bool NetPlayClient::ChangeGame(const std::string &game)
{
// warning removal
game.size();
// idk, nothing is needed here
return true;
}
bool NetPlayServer::StartGame(const std::string &path)
{
if (false == NetPlay::StartGame(path))
return false;
// tell clients to start game
sf::Packet spac;
spac << (MessageId)NP_MSG_START_GAME;
m_crit.players.Enter();
m_crit.send.Enter();
SendToClients(spac);
m_crit.send.Leave();
m_crit.players.Leave();
return true;
}
bool NetPlay::StartGame(const std::string &path)
{
m_crit.other.Enter();
@ -842,25 +884,26 @@ bool NetPlayServer::StartGame(const std::string &path)
return false;
}
AppendChatGUI(" -- STARTING GAME -- ");
m_is_running = true;
::NetClass_ptr = this;
// temporary / testing
m_crit.buffer.Enter();
// testing
NetPad np;
for (unsigned int i=0; i<TEMP_FIXED_BUFFER; ++i)
for (unsigned int p=0; p<4; ++p)
for (unsigned int p=0; p<4; ++p)
{
// no clear method ?
while (m_pad_buffer[p].size())
m_pad_buffer[p].pop();
// temporary
for (unsigned int i=0; i<TEMP_FIXED_BUFFER; ++i)
m_pad_buffer[p].push(np);
}
m_crit.buffer.Leave();
// tell clients to start game
sf::Packet spac;
spac << (MessageId)NP_MSG_START_GAME;
m_crit.send.Enter();
SendToClients(spac);
m_crit.send.Leave();
// boot game
::main_frame->BootGame(path);
//BootManager::BootCore(path);
@ -870,30 +913,47 @@ bool NetPlayServer::StartGame(const std::string &path)
return true;
}
bool NetPlayClient::StartGame(const std::string &path)
bool NetPlay::StopGame()
{
m_crit.other.Enter();
m_is_running = true;
::NetClass_ptr = this;
if (false == m_is_running)
{
PanicAlert("Game isn't running!");
return false;
}
m_crit.buffer.Enter();
// testing
NetPad np;
for (unsigned int i=0; i<TEMP_FIXED_BUFFER; ++i)
for (unsigned int p=0; p<4; ++p)
m_pad_buffer[p].push(np);
m_crit.buffer.Leave();
AppendChatGUI(" -- STOPPING GAME -- ");
// boot game
::main_frame->BootGame(path);
//BootManager::BootCore(path);
// stop game
::main_frame->DoStop();
m_is_running = false;
::NetClass_ptr = false;
m_crit.other.Leave();
return true;
}
bool NetPlayServer::StopGame()
{
if (false == NetPlay::StopGame())
return false;
// tell clients to stop game
sf::Packet spac;
spac << (MessageId)NP_MSG_STOP_GAME;
m_crit.players.Enter();
m_crit.send.Enter();
SendToClients(spac);
m_crit.send.Leave();
m_crit.players.Leave();
return true;
}
// Actual Core function which is called on every frame
int CSIDevice_GCController::GetNetInput(u8 numPAD, SPADStatus PadStatus, u32 *PADStatus)
{

View File

@ -30,7 +30,7 @@ public:
u32 nLo;
};
#define NETPLAY_VERSION "Dolphin NetPlay 2.0"
#define NETPLAY_VERSION "Dolphin NetPlay 2.1"
#ifdef _M_X64
#define NP_ARCH "x64"
@ -58,6 +58,7 @@ public:
#define NP_MSG_START_GAME 0xA0
#define NP_MSG_CHANGE_GAME 0xA1
#define NP_MSG_STOP_GAME 0xA2
#define NP_MSG_READY 0xD0
#define NP_MSG_NOT_READY 0xD1
@ -85,21 +86,36 @@ public:
// Send and receive pads values
virtual bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues) = 0;
virtual bool SetSelectedGame(const std::string& game) = 0;
virtual bool ChangeGame(const std::string& game) = 0;
virtual void GetPlayerList(std::string& list) = 0;
virtual void SendChatMessage(const std::string& msg) = 0;
virtual bool StartGame(const std::string &path) = 0;
virtual bool StartGame(const std::string &path);
virtual bool StopGame();
protected:
//NetPlay(Common::ThreadFunc entry, void* arg) : m_thread(entry, arg) {}
void NetPlay::GetBufferedPad(const u8 pad_nb, NetPad* const netvalues);
void UpdateGUI();
void AppendChatGUI(const std::string& msg);
struct
{
Common::CriticalSection send, players, buffer, other;
} m_crit;
class Player
{
public:
Player();
std::string ToString() const;
PlayerId pid;
std::string name;
PadMapping pad_map[4];
std::string revision;
};
//LockingQueue<NetPad> m_pad_buffer[4];
std::queue<NetPad> m_pad_buffer[4];
@ -128,21 +144,17 @@ public:
// Send and receive pads values
bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues);
bool SetSelectedGame(const std::string& game);
bool ChangeGame(const std::string& game);
void SendChatMessage(const std::string& msg);
bool StartGame(const std::string &path);
bool StopGame();
private:
class Player
class Client : public Player
{
public:
Player();
PlayerId pid;
sf::SocketTCP socket;
std::string name;
PadMapping pad_map[4];
std::string revision;
};
void SendToClients(sf::Packet& packet, const PlayerId skip_pid = 0);
@ -150,7 +162,7 @@ private:
unsigned int OnDisconnect(sf::SocketTCP& socket);
unsigned int OnData(sf::Packet& packet, sf::SocketTCP& socket);
std::map<sf::SocketTCP, Player> m_players;
std::map<sf::SocketTCP, Client> m_players;
};
class NetPlayClient : public NetPlay
@ -165,22 +177,10 @@ public:
// Send and receive pads values
bool GetNetPads(const u8 pad_nb, const SPADStatus* const, NetPad* const netvalues);
bool SetSelectedGame(const std::string& game);
bool ChangeGame(const std::string& game);
void SendChatMessage(const std::string& msg);
bool StartGame(const std::string &path);
private:
class Player
{
public:
Player();
PlayerId pid;
std::string name;
PadMapping pad_map[4];
std::string revision;
};
unsigned int OnData(sf::Packet& packet);
PlayerId m_pid;

View File

@ -30,7 +30,7 @@ END_EVENT_TABLE()
NetPlay* netplay_ptr = NULL;
NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* 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)
, m_game_list(game_list)
{
@ -63,7 +63,6 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* parent, const CGameListCtrl* const
m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, wxT("2626"));
wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, wxT("Connect"));
//connect_button->Disable();
_connect_macro_(connect_btn, NetPlaySetupDiag::OnJoin, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxStaticText* const alert_lbl = new wxStaticText(connect_tab, wxID_ANY
@ -100,7 +99,6 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* parent, const CGameListCtrl* const
m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, wxT("2626"));
wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, wxT("Host"));
//host_button->Disable();
_connect_macro_(host_btn, NetPlaySetupDiag::OnHost, wxEVT_COMMAND_BUTTON_CLICKED, this);
m_game_lbox = new wxListBox(host_tab, wxID_ANY);
@ -136,7 +134,7 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* parent, const CGameListCtrl* const
panel->SetSizerAndFit(main_szr);
//wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL);
//diag_szr->Add(panel);
//diag_szr->Add(panel, 1, wxEXPAND);
//SetSizerAndFit(diag_szr);
main_szr->SetSizeHints(this);
@ -223,7 +221,7 @@ void NetPlaySetupDiag::OnQuit(wxCommandEvent& event)
Destroy();
}
NetPlayDiag::NetPlayDiag(wxWindow* parent, const CGameListCtrl* const game_list
NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list
, const std::string& game, const bool is_hosting)
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
, m_selected_game(game)
@ -234,7 +232,11 @@ NetPlayDiag::NetPlayDiag(wxWindow* parent, const CGameListCtrl* const game_list
// top crap
m_game_btn = new wxButton(panel, wxID_ANY
, wxString(m_selected_game.c_str(), *wxConvCurrent).Prepend(wxT(" Game : ")), wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
m_game_btn->Disable();
if (is_hosting)
_connect_macro_(m_game_btn, NetPlayDiag::OnChangeGame, wxEVT_COMMAND_BUTTON_CLICKED, this);
else
m_game_btn->Disable();
// middle crap
@ -283,6 +285,9 @@ NetPlayDiag::NetPlayDiag(wxWindow* parent, const CGameListCtrl* const game_list
wxButton* const start_btn = new wxButton(panel, wxID_ANY, wxT("Start"));
_connect_macro_(start_btn, NetPlayDiag::OnStart, wxEVT_COMMAND_BUTTON_CLICKED, this);
bottom_szr->Add(start_btn);
wxButton* const stop_btn = new wxButton(panel, wxID_ANY, wxT("Stop [buggy]"));
_connect_macro_(stop_btn, NetPlayDiag::OnStop, wxEVT_COMMAND_BUTTON_CLICKED, this);
bottom_szr->Add(stop_btn);
}
bottom_szr->AddStretchSpacer(1);
@ -351,6 +356,14 @@ void NetPlayDiag::OnStart(wxCommandEvent& event)
PanicAlert("Game not found!!");
}
void NetPlayDiag::OnStop(wxCommandEvent& event)
{
// warning removal
event.GetId();
::netplay_ptr->StopGame();
}
void NetPlayDiag::OnQuit(wxCommandEvent& event)
{
// warning removal
@ -376,15 +389,26 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
switch (event.GetId())
{
case 45 :
case NP_GUI_EVT_CHANGE_GAME :
// update selected game :/
{
m_selected_game.assign(event.GetString().mb_str());
m_game_btn->SetLabel(event.GetString().Prepend(wxT(" Game : ")));
}
break;
case 46 :
case NP_GUI_EVT_START_GAME :
// client start game :/
{
wxCommandEvent evt;
OnStart(evt);
}
break;
case NP_GUI_EVT_STOP_GAME :
// client stop game
{
wxCommandEvent evt;
OnStop(evt);
}
break;
}
@ -397,3 +421,59 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
m_chat_text->AppendText(wxString(s.c_str(), *wxConvCurrent).Append(wxT('\n')));
}
}
void NetPlayDiag::OnChangeGame(wxCommandEvent& event)
{
// warning removal
event.GetId();
wxString game_name;
ChangeGameDiag* const cgd = new ChangeGameDiag(this, m_game_list, game_name);
cgd->ShowModal();
if (game_name.length())
{
m_selected_game = std::string(game_name.mb_str());
::netplay_ptr->ChangeGame(m_selected_game);
m_game_btn->SetLabel(game_name.Prepend(wxT(" Game : ")));
}
}
ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name)
: wxDialog(parent, wxID_ANY, wxT("Change Game"), wxDefaultPosition, wxDefaultSize)
, m_game_name(game_name)
{
wxPanel* const panel = new wxPanel(this);
m_game_lbox = new wxListBox(panel, wxID_ANY);
_connect_macro_(m_game_lbox, ChangeGameDiag::OnPick, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, this);
// fill list with games
std::istringstream ss(game_list->GetGameNames());
std::string game;
while (std::getline(ss,game))
m_game_lbox->Append(wxString(game.c_str(), *wxConvCurrent));
wxButton* const ok_btn = new wxButton(panel, wxID_ANY, wxT("Change"));
_connect_macro_(ok_btn, ChangeGameDiag::OnPick, wxEVT_COMMAND_BUTTON_CLICKED, this);
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 5);
szr->Add(ok_btn, 0, wxALL | wxALIGN_RIGHT, 5);
panel->SetSizerAndFit(szr);
wxBoxSizer* const dlg_szr = new wxBoxSizer(wxVERTICAL);
dlg_szr->Add(panel, 1, wxEXPAND);
SetSizerAndFit(dlg_szr);
}
void ChangeGameDiag::OnPick(wxCommandEvent& event)
{
// warning removal
event.GetId();
// return the selected game name
m_game_name = m_game_lbox->GetStringSelection();
Destroy();
}

View File

@ -48,10 +48,17 @@
#include "LockingQueue.h"
enum
{
NP_GUI_EVT_CHANGE_GAME = 45,
NP_GUI_EVT_START_GAME,
NP_GUI_EVT_STOP_GAME,
};
class NetPlaySetupDiag : public wxFrame
{
public:
NetPlaySetupDiag(wxWindow* parent, const CGameListCtrl* const game_list);
NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list);
private:
void OnJoin(wxCommandEvent& event);
@ -71,7 +78,7 @@ private:
class NetPlayDiag : public wxFrame
{
public:
NetPlayDiag(wxWindow* parent, const CGameListCtrl* const game_list
NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list
, const std::string& game, const bool is_hosting = false);
~NetPlayDiag();
@ -79,6 +86,7 @@ public:
//std::string chat_msg;
void OnStart(wxCommandEvent& event);
void OnStop(wxCommandEvent& event);
private:
DECLARE_EVENT_TABLE()
@ -86,6 +94,7 @@ private:
void OnChat(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnThread(wxCommandEvent& event);
void OnChangeGame(wxCommandEvent& event);
wxListBox* m_player_lbox;
wxTextCtrl* m_chat_text;
@ -100,5 +109,17 @@ private:
DECLARE_EVENT_TYPE(wxEVT_THREAD, -1)
class ChangeGameDiag : public wxDialog
{
public:
ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name);
private:
void OnPick(wxCommandEvent& event);
wxListBox* m_game_lbox;
wxString& m_game_name;
};
#endif // _NETWINDOW_H_