NetPlay: Disable the "Start" button while the game is running

This commit is contained in:
Jasper St. Pierre 2013-08-14 18:14:29 -04:00
parent 1c74e412e2
commit 998194246c
2 changed files with 10 additions and 3 deletions

View File

@ -283,6 +283,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize) : wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
, m_selected_game(game) , m_selected_game(game)
, m_game_list(game_list) , m_game_list(game_list)
, m_start_btn(NULL)
{ {
wxPanel* const panel = new wxPanel(this); wxPanel* const panel = new wxPanel(this);
@ -340,9 +341,10 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
if (is_hosting) if (is_hosting)
{ {
wxButton* const start_btn = new wxButton(panel, wxID_ANY, _("Start")); m_start_btn = new wxButton(panel, wxID_ANY, _("Start"));
start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this); m_start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this);
bottom_szr->Add(start_btn); bottom_szr->Add(m_start_btn);
bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 ); bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 );
wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20") wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20")
, wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE); , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE);
@ -463,12 +465,16 @@ void NetPlayDiag::OnMsgStartGame()
{ {
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME);
GetEventHandler()->AddPendingEvent(evt); GetEventHandler()->AddPendingEvent(evt);
if (m_start_btn)
m_start_btn->Disable();
} }
void NetPlayDiag::OnMsgStopGame() void NetPlayDiag::OnMsgStopGame()
{ {
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME);
GetEventHandler()->AddPendingEvent(evt); GetEventHandler()->AddPendingEvent(evt);
if (m_start_btn)
m_start_btn->Enable();
} }
void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event) void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event)

View File

@ -100,6 +100,7 @@ private:
std::string m_selected_game; std::string m_selected_game;
wxButton* m_game_btn; wxButton* m_game_btn;
wxButton* m_start_btn;
std::vector<int> m_playerids; std::vector<int> m_playerids;