diff options
Diffstat (limited to 'Source/Core/DolphinWX/NetWindow.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/NetWindow.cpp | 429 |
1 files changed, 335 insertions, 94 deletions
diff --git a/Source/Core/DolphinWX/NetWindow.cpp b/Source/Core/DolphinWX/NetWindow.cpp index eb15e533a0..8d99a9403b 100644 --- a/Source/Core/DolphinWX/NetWindow.cpp +++ b/Source/Core/DolphinWX/NetWindow.cpp @@ -27,6 +27,7 @@ #include <wx/string.h> #include <wx/textctrl.h> #include <wx/translation.h> +#include <wx/clipbrd.h> #include "Common/CommonTypes.h" #include "Common/FifoQueue.h" @@ -53,6 +54,26 @@ static NetPlayServer* netplay_server = nullptr; static NetPlayClient* netplay_client = nullptr; NetPlayDiag *NetPlayDiag::npd = nullptr; + +static wxString FailureReasonStringForHostLabel(int reason) +{ + switch (reason) + { + case TraversalClient::BadHost: + return _("(Error: Bad host)"); + case TraversalClient::VersionTooOld: + return _("(Error: Dolphin too old)"); + case TraversalClient::ServerForgotAboutUs: + return _("(Error: Disconnected)"); + case TraversalClient::SocketSendError: + return _("(Error: Socket)"); + case TraversalClient::ResendTimeout: + return _("(Error: Timeout)"); + default: + return _("(Error: Unknown)"); + } +} + static std::string BuildGameName(const GameListItem& game) { // Lang needs to be consistent @@ -93,7 +114,6 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* nick_szr->Add(nick_lbl, 0, wxCENTER); nick_szr->Add(m_nickname_text, 0, wxALL, 5); - // tabs wxNotebook* const notebook = new wxNotebook(panel, wxID_ANY); wxPanel* const connect_tab = new wxPanel(notebook, wxID_ANY); @@ -101,85 +121,91 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* wxPanel* const host_tab = new wxPanel(notebook, wxID_ANY); notebook->AddPage(host_tab, _("Host")); + m_direct_traversal = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(75, -1)); + m_direct_traversal->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &NetPlaySetupDiag::OnChoice, this); + m_direct_traversal->Append(_("Traversal")); + m_direct_traversal->Append(_("Direct")); + m_direct_traversal->Select(0); // connect tab { - wxStaticText* const ip_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Address :")); - - std::string address; - netplay_section.Get("Address", &address, "localhost"); - m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(address)); - - wxStaticText* const port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port :")); - - // string? w/e - std::string port; - netplay_section.Get("ConnectPort", &port, "2626"); - m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(port)); - - wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect")); - connect_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnJoin, this); - - wxStaticText* const alert_lbl = new wxStaticText(connect_tab, wxID_ANY, - _("ALERT:\n\n" - "Netplay will only work with the following settings:\n" - " - DSP Emulator Engine Must be the same on all computers!\n" - " - DSP on Dedicated Thread [OFF]\n" - " - Manually set the extensions for each Wiimote\n" - "\n" - "All players should use the same Dolphin version and settings.\n" - "All memory cards must be identical between players or disabled.\n" - "Wiimote support is probably terrible. Don't use it.\n" - "\n" - "The host must have the chosen TCP port open/forwarded!\n")); - - wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL); - top_szr->Add(ip_lbl, 0, wxCENTER | wxRIGHT, 5); - top_szr->Add(m_connect_ip_text, 3); - top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT | wxLEFT, 5); - top_szr->Add(m_connect_port_text, 1); - - wxBoxSizer* const con_szr = new wxBoxSizer(wxVERTICAL); - con_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5); - con_szr->AddStretchSpacer(1); - con_szr->Add(alert_lbl, 0, wxLEFT | wxRIGHT | wxEXPAND, 5); - con_szr->AddStretchSpacer(1); - con_szr->Add(connect_btn, 0, wxALL | wxALIGN_RIGHT, 5); - - connect_tab->SetSizerAndFit(con_szr); + m_ip_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Host Code :")); + + std::string address; + netplay_section.Get("HostCode", &address, "00000000"); + m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(address)); + + m_client_port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port :")); + + // string? w/e + std::string port; + netplay_section.Get("ConnectPort", &port, "2626"); + m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(port)); + + wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect")); + connect_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnJoin, this); + + wxStaticText* const alert_lbl = new wxStaticText(connect_tab, wxID_ANY, + _("ALERT:\n\n" + "Netplay will only work with the following settings:\n" + " - DSP Emulator Engine Must be the same on all computers!\n" + " - DSP on Dedicated Thread [OFF]\n" + " - Manually set the extensions for each Wiimote\n" + "\n" + "All players should use the same Dolphin version and settings.\n" + "All memory cards must be identical between players or disabled.\n" + "Wiimote support is probably terrible. Don't use it.\n" + "\n" + "If connecting directly host must have the chosen UDP port open/forwarded!\n")); + + wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL); + + top_szr->Add(m_ip_lbl, 0, wxCENTER | wxRIGHT, 5); + top_szr->Add(m_connect_ip_text, 3); + top_szr->Add(m_client_port_lbl, 0, wxCENTER | wxRIGHT | wxLEFT, 5); + top_szr->Add(m_connect_port_text, 1); + + wxBoxSizer* const con_szr = new wxBoxSizer(wxVERTICAL); + con_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5); + con_szr->AddStretchSpacer(1); + con_szr->Add(alert_lbl, 0, wxLEFT | wxRIGHT | wxEXPAND, 5); + con_szr->AddStretchSpacer(1); + con_szr->Add(connect_btn, 0, wxALL | wxALIGN_RIGHT, 5); + + connect_tab->SetSizerAndFit(con_szr); } // host tab { - wxStaticText* const port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port :")); + m_host_port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port :")); - // string? w/e - std::string port; - netplay_section.Get("HostPort", &port, "2626"); - m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port)); + // string? w/e + std::string port; + netplay_section.Get("HostPort", &port, "2626"); + m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port)); - wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host")); - host_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnHost, this); + wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host")); + host_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnHost, this); - m_game_lbox = new wxListBox(host_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT); - m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &NetPlaySetupDiag::OnHost, this); + m_game_lbox = new wxListBox(host_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT); + m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &NetPlaySetupDiag::OnHost, this); - FillWithGameNames(m_game_lbox, *game_list); + FillWithGameNames(m_game_lbox, *game_list); - wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL); - top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5); - top_szr->Add(m_host_port_text, 0); + wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL); + top_szr->Add(m_host_port_lbl, 0, wxCENTER | wxRIGHT, 5); + top_szr->Add(m_host_port_text, 0); #ifdef USE_UPNP - m_upnp_chk = new wxCheckBox(host_tab, wxID_ANY, _("Forward port (UPnP)")); - top_szr->Add(m_upnp_chk, 0, wxALL | wxALIGN_RIGHT, 5); + m_upnp_chk = new wxCheckBox(host_tab, wxID_ANY, _("Forward port (UPnP)")); + top_szr->Add(m_upnp_chk, 0, wxALL | wxALIGN_RIGHT, 5); #endif - wxBoxSizer* const host_szr = new wxBoxSizer(wxVERTICAL); - host_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5); - host_szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxEXPAND, 5); - host_szr->Add(host_btn, 0, wxALL | wxALIGN_RIGHT, 5); + wxBoxSizer* const host_szr = new wxBoxSizer(wxVERTICAL); + host_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5); + host_szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxEXPAND, 5); + host_szr->Add(host_btn, 0, wxALL | wxALIGN_RIGHT, 5); - host_tab->SetSizerAndFit(host_szr); + host_tab->SetSizerAndFit(host_szr); } // bottom row @@ -202,6 +228,21 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* Center(); Show(); + + // Needs to be done last or it set up the spacing on the page correctly + //client tab + { + m_client_port_lbl->Show(false); + m_connect_port_text->Show(false); + } + + //server tab + { + m_host_port_lbl->Show(false); + m_host_port_text->Show(false); + m_upnp_chk->Show(false); + } + } NetPlaySetupDiag::~NetPlaySetupDiag() @@ -212,7 +253,14 @@ NetPlaySetupDiag::~NetPlaySetupDiag() IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); netplay_section.Set("Nickname", WxStrToStr(m_nickname_text->GetValue())); - netplay_section.Set("Address", WxStrToStr(m_connect_ip_text->GetValue())); + if (m_direct_traversal->GetCurrentSelection() == 1) + { + netplay_section.Set("Address", WxStrToStr(m_connect_ip_text->GetValue())); + } + else + { + netplay_section.Set("HostCode", WxStrToStr(m_connect_ip_text->GetValue())); + } netplay_section.Set("ConnectPort", WxStrToStr(m_connect_port_text->GetValue())); netplay_section.Set("HostPort", WxStrToStr(m_host_port_text->GetValue())); @@ -230,7 +278,13 @@ void NetPlaySetupDiag::MakeNetPlayDiag(int port, const std::string &game, bool i else ip = WxStrToStr(m_connect_ip_text->GetValue()); - netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue())); + bool trav; + if (!is_hosting && m_direct_traversal->GetCurrentSelection() == 0) + trav = true; + else + trav = false; + + netplay_client = new NetPlayClient(ip, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()), trav); if (netplay_client->is_connected) { npd->Show(); @@ -259,9 +313,15 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&) std::string game(WxStrToStr(m_game_lbox->GetStringSelection())); + bool trav; + if (m_direct_traversal->GetCurrentSelection() == 0) + trav = true; + else + trav = false; + unsigned long port = 0; m_host_port_text->GetValue().ToULong(&port); - netplay_server = new NetPlayServer(u16(port)); + netplay_server = new NetPlayServer(u16(port), trav); netplay_server->ChangeGame(game); netplay_server->AdjustPadBufferSize(INITIAL_PAD_BUFFER_SIZE); if (netplay_server->is_connected) @@ -270,7 +330,8 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&) if (m_upnp_chk->GetValue()) netplay_server->TryPortmapping(port); #endif - MakeNetPlayDiag(port, game, true); + MakeNetPlayDiag(netplay_server->GetPort(), game, true); + netplay_server->SetNetPlayUI(NetPlayDiag::GetInstance()); } else { @@ -292,17 +353,75 @@ void NetPlaySetupDiag::OnJoin(wxCommandEvent&) MakeNetPlayDiag(port, "", false); } +void NetPlaySetupDiag::OnChoice(wxCommandEvent& event) +{ + int sel = m_direct_traversal->GetSelection(); + IniFile inifile; + inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini"); + IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); + + if (sel == 0) + { + //Traversal + //client tab + { + m_ip_lbl->SetLabelText("Host Code: "); + + std::string address; + netplay_section.Get("HostCode", &address, "00000000"); + m_connect_ip_text->SetLabelText(address); + + m_client_port_lbl->Show(false); + m_connect_port_text->Show(false); + } + + //server tab + { + m_host_port_lbl->Show(false); + m_host_port_text->Show(false); + m_upnp_chk->Show(false); + } + } + else + { + //Direct + //client tab + { + m_ip_lbl->SetLabelText("IP Address :"); + + std::string address; + netplay_section.Get("Address", &address, "127.0.0.1"); + m_connect_ip_text->SetLabelText(address); + + m_client_port_lbl->Show(true); + m_connect_port_text->Show(true); + } + + //server tab + { + m_host_port_lbl->Show(true); + m_host_port_text->Show(true); + m_upnp_chk->Show(true); + } + } +} + void NetPlaySetupDiag::OnQuit(wxCommandEvent&) { Destroy(); } NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list, - const std::string& game, const bool is_hosting) + const std::string& game, const bool is_hosting) : wxFrame(parent, wxID_ANY, _("Dolphin NetPlay")) , m_selected_game(game) , m_start_btn(nullptr) , m_game_list(game_list) + , m_host_type_choice(nullptr) + , m_host_label(nullptr) + , m_host_copy_btn(nullptr) + , m_host_copy_btn_is_retry(false) + , m_is_hosting(is_hosting) { Bind(wxEVT_THREAD, &NetPlayDiag::OnThread, this); @@ -310,10 +429,10 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game // top crap m_game_btn = new wxButton(panel, wxID_ANY, - StrToWxStr(m_selected_game).Prepend(_(" Game : ")), - wxDefaultPosition, wxDefaultSize, wxBU_LEFT); + StrToWxStr(m_selected_game).Prepend(_(" Game : ")), + wxDefaultPosition, wxDefaultSize, wxBU_LEFT); - if (is_hosting) + if (m_is_hosting) m_game_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnChangeGame, this); else m_game_btn->Disable(); @@ -343,9 +462,34 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game m_player_lbox = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(256, -1)); wxStaticBoxSizer* const player_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Players")); - player_szr->Add(m_player_lbox, 1, wxEXPAND); + // player list - if (is_hosting) + if (m_is_hosting && g_TraversalClient) + { + wxBoxSizer* const host_szr = new wxBoxSizer(wxHORIZONTAL); + m_host_type_choice = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(60, -1)); + m_host_type_choice->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &NetPlayDiag::OnChoice, this); + m_host_type_choice->Append(_("ID:")); + host_szr->Add(m_host_type_choice); + + m_host_label = new wxStaticText(panel, wxID_ANY, "555.555.555.555:55555", wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE | wxALIGN_LEFT); + // Update() should fix this immediately. + m_host_label->SetLabel(_("")); + host_szr->Add(m_host_label, 1, wxLEFT | wxCENTER, 5); + + m_host_copy_btn = new wxButton(panel, wxID_ANY, _("Copy")); + m_host_copy_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnCopyIP, this); + m_host_copy_btn->Disable(); + host_szr->Add(m_host_copy_btn, 0, wxLEFT | wxCENTER, 5); + player_szr->Add(host_szr, 0, wxEXPAND | wxBOTTOM, 5); + m_host_type_choice->Select(0); + + UpdateHostLabel(); + } + + player_szr->Add(m_player_lbox, 1, wxEXPAND); + + if (m_is_hosting) { m_player_lbox->Bind(wxEVT_LISTBOX, &NetPlayDiag::OnPlayerSelect, this); m_kick_btn = new wxButton(panel, wxID_ANY, _("Kick Player")); @@ -398,7 +542,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game panel->SetSizerAndFit(main_szr); main_szr->SetSizeHints(this); - SetSize(512, 512-128); + SetSize(512, 512 - 128); Center(); } @@ -531,6 +675,11 @@ void NetPlayDiag::OnQuit(wxCommandEvent&) // update gui void NetPlayDiag::OnThread(wxThreadEvent& event) { + if (m_is_hosting && m_host_label && g_TraversalClient) + { + UpdateHostLabel(); + } + // player list m_playerids.clear(); std::string tmps; @@ -563,8 +712,8 @@ void NetPlayDiag::OnThread(wxThreadEvent& event) // flash window in taskbar when someone joins if window isn't active static u8 numPlayers = 1; bool focus = (wxWindow::FindFocus() == this || (wxWindow::FindFocus() != nullptr && wxWindow::FindFocus()->GetParent() == this) || - (wxWindow::FindFocus() != nullptr && wxWindow::FindFocus()->GetParent() != nullptr - && wxWindow::FindFocus()->GetParent()->GetParent() == this)); + (wxWindow::FindFocus() != nullptr && wxWindow::FindFocus()->GetParent() != nullptr + && wxWindow::FindFocus()->GetParent()->GetParent() == this)); if (netplay_server != nullptr && numPlayers < m_playerids.size() && !focus) { RequestUserAttention(); @@ -575,25 +724,25 @@ void NetPlayDiag::OnThread(wxThreadEvent& event) { case NP_GUI_EVT_CHANGE_GAME: // update selected game :/ - { + { m_selected_game.assign(WxStrToStr(event.GetString())); wxString button_label = event.GetString(); m_game_btn->SetLabel(button_label.Prepend(_(" Game : "))); - } - break; - case NP_GUI_EVT_START_GAME : + } + break; + case NP_GUI_EVT_START_GAME: // client start game :/ - { + { netplay_client->StartGame(FindGame()); - } - break; - case NP_GUI_EVT_STOP_GAME : + } + break; + case NP_GUI_EVT_STOP_GAME: // client stop game - { + { netplay_client->StopGame(); - } - break; + } + break; } // chat messages @@ -660,6 +809,98 @@ bool NetPlayDiag::IsRecording() return m_record_chkbox->GetValue(); } + +void NetPlayDiag::OnCopyIP(wxCommandEvent&) +{ + if (m_host_copy_btn_is_retry) + { + g_TraversalClient->ReconnectToServer(); + Update(); + } + else + { + if (wxTheClipboard->Open()) + { + wxTheClipboard->SetData(new wxTextDataObject(m_host_label->GetLabel())); + wxTheClipboard->Close(); + } + } +} + +void NetPlayDiag::OnChoice(wxCommandEvent& event) +{ + UpdateHostLabel(); +} + + +void NetPlayDiag::UpdateHostLabel() +{ + wxString label = _(" (internal IP)"); + auto DeLabel = [=](wxString str) { + if (str == _("Localhost")) + return std::string("!local!"); + return WxStrToStr(str.Left(str.Len() - label.Len())); + }; + auto EnLabel = [=](std::string str) -> wxString { + if (str == "!local!") + return _("Localhost"); + return StrToWxStr(str) + label; + }; + int sel = m_host_type_choice->GetSelection(); + if (sel == 0) + { + // the traversal ID + switch (g_TraversalClient->m_State) + { + case TraversalClient::Connecting: + m_host_label->SetForegroundColour(*wxLIGHT_GREY); + m_host_label->SetLabel("..."); + m_host_copy_btn->SetLabel(_("Copy")); + m_host_copy_btn->Disable(); + break; + case TraversalClient::Connected: + m_host_label->SetForegroundColour(*wxBLACK); + m_host_label->SetLabel(wxString(g_TraversalClient->m_HostId.data(), g_TraversalClient->m_HostId.size())); + m_host_copy_btn->SetLabel(_("Copy")); + m_host_copy_btn->Enable(); + m_host_copy_btn_is_retry = false; + break; + case TraversalClient::Failure: + m_host_label->SetForegroundColour(*wxBLACK); + m_host_label->SetLabel(FailureReasonStringForHostLabel(g_TraversalClient->m_FailureReason)); + m_host_copy_btn->SetLabel(_("Retry")); + m_host_copy_btn->Enable(); + m_host_copy_btn_is_retry = true; + break; + } + } + else if (sel != wxNOT_FOUND) // wxNOT_FOUND shouldn't generally happen + { + m_host_label->SetForegroundColour(*wxBLACK); + m_host_label->SetLabel(netplay_server->GetInterfaceHost(DeLabel(m_host_type_choice->GetString(sel)))); + m_host_copy_btn->SetLabel(_("Copy")); + m_host_copy_btn->Enable(); + m_host_copy_btn_is_retry = false; + } + + auto set = netplay_server->GetInterfaceSet(); + for (const std::string& iface : set) + { + wxString wxIface = EnLabel(iface); + if (m_host_type_choice->FindString(wxIface) == wxNOT_FOUND) + m_host_type_choice->Append(wxIface); + } + for (unsigned i = 1, count = m_host_type_choice->GetCount(); i != count; i++) + { + if (set.find(DeLabel(m_host_type_choice->GetString(i))) == set.end()) + { + m_host_type_choice->Delete(i); + i--; + count--; + } + } +} + ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* const game_list, wxString& game_name) : wxDialog(parent, wxID_ANY, _("Change Game")) , m_game_name(game_name) @@ -728,16 +969,16 @@ PadMapDiag::PadMapDiag(wxWindow* const parent, PadMapping map[], PadMapping wiim v_szr->Add(new wxStaticText(this, wxID_ANY, (wxString(_("Wiimote ")) + (wxChar)('0' + i))), 1, wxALIGN_CENTER_HORIZONTAL); - m_map_cbox[i+4] = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, player_names); - m_map_cbox[i+4]->Bind(wxEVT_CHOICE, &PadMapDiag::OnAdjust, this); + m_map_cbox[i + 4] = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, player_names); + m_map_cbox[i + 4]->Bind(wxEVT_CHOICE, &PadMapDiag::OnAdjust, this); if (m_wiimapping[i] == -1) - m_map_cbox[i+4]->Select(0); + m_map_cbox[i + 4]->Select(0); else for (unsigned int j = 0; j < m_player_list.size(); j++) if (m_wiimapping[i] == m_player_list[j]->pid) - m_map_cbox[i+4]->Select(j + 1); + m_map_cbox[i + 4]->Select(j + 1); - v_szr->Add(m_map_cbox[i+4], 1); + v_szr->Add(m_map_cbox[i + 4], 1); h_szr->Add(v_szr, 1, wxTOP | wxEXPAND, 20); h_szr->AddSpacer(10); @@ -763,7 +1004,7 @@ void PadMapDiag::OnAdjust(wxCommandEvent& event) else m_mapping[i] = -1; - player_idx = m_map_cbox[i+4]->GetSelection(); + player_idx = m_map_cbox[i + 4]->GetSelection(); if (player_idx > 0) m_wiimapping[i] = m_player_list[player_idx - 1]->pid; else |
