From bb622836b28816590d60f2bfaf048d2536c386f9 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 11 May 2015 01:09:44 +0200 Subject: [PATCH] Traversal: Add a read-only text for server:port with a "reset to default" button Clicking it will set the config file back to stun.dolphin-emu.org with port 6262. --- .../DolphinWX/NetPlay/NetPlaySetupFrame.cpp | 29 +++++++++++++++++++ .../DolphinWX/NetPlay/NetPlaySetupFrame.h | 3 ++ 2 files changed, 32 insertions(+) diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp index 58db8ea89a..754b3c8b01 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp @@ -70,6 +70,10 @@ NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl trav_szr->Add(m_direct_traversal, 0, wxRIGHT); + m_trav_reset_btn = new wxButton(panel, wxID_ANY, _("Reset Traversal Settings")); + m_trav_reset_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnResetTraversal, this); + trav_szr->Add(m_trav_reset_btn, 0, wxCENTER | wxRIGHT); + wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL); wxStaticText* const nick_lbl = new wxStaticText(panel, wxID_ANY, _("Nickname :")); std::string nickname; @@ -78,6 +82,13 @@ NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl nick_szr->Add(nick_lbl, 0, wxCENTER); nick_szr->Add(m_nickname_text, 0, wxALL, 5); + std::string centralPort; + GetTraversalPort(netplay_section, ¢ralPort); + std::string centralServer; + GetTraversalServer(netplay_section, ¢ralServer); + + m_traversal_lbl = new wxStaticText(panel, wxID_ANY, _("Traversal: ") + centralServer + ":" + centralPort); + // tabs wxNotebook* const notebook = new wxNotebook(panel, wxID_ANY); wxPanel* const connect_tab = new wxPanel(notebook, wxID_ANY); @@ -174,6 +185,7 @@ NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const CGameListCtrl wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); main_szr->Add(trav_szr, 0, wxALL | wxALIGN_LEFT); main_szr->Add(nick_szr, 0, wxALL | wxALIGN_LEFT, 5); + main_szr->Add(m_traversal_lbl, 0, wxALL | wxALIGN_LEFT, 5); main_szr->Add(notebook, 1, wxLEFT | wxRIGHT | wxEXPAND, 5); main_szr->Add(quit_btn, 0, wxALL | wxALIGN_RIGHT, 5); @@ -342,6 +354,19 @@ void NetPlaySetupFrame::OnJoin(wxCommandEvent&) MakeNetPlayDiag(port, "", false); } +void NetPlaySetupFrame::OnResetTraversal(wxCommandEvent& event) +{ + IniFile inifile; + const std::string dolphin_ini = File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini"; + inifile.Load(dolphin_ini); + IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); + netplay_section.Set("TraversalServer", (std::string) "stun.dolphin-emu.org"); + netplay_section.Set("TraversalPort", (std::string) "6262"); + inifile.Save(dolphin_ini); + + m_traversal_lbl->SetLabelText(_("Traversal: ") + "stun.dolphin-emu.org:6262"); +} + void NetPlaySetupFrame::OnChoice(wxCommandEvent& event) { int sel = m_direct_traversal->GetSelection(); @@ -351,6 +376,8 @@ void NetPlaySetupFrame::OnChoice(wxCommandEvent& event) if (sel == 1) { + m_traversal_lbl->Show(); + m_trav_reset_btn->Show(); //Traversal //client tab { @@ -373,6 +400,8 @@ void NetPlaySetupFrame::OnChoice(wxCommandEvent& event) } else { + m_traversal_lbl->Hide(); + m_trav_reset_btn->Hide(); // Direct // Client tab { diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h index a0fcbfefda..ed4becc865 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.h @@ -26,6 +26,7 @@ private: void OnHost(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); void OnChoice(wxCommandEvent& event); + void OnResetTraversal(wxCommandEvent& event); void MakeNetPlayDiag(int port, const std::string& game, bool is_hosting); @@ -37,6 +38,8 @@ private: wxTextCtrl* m_connect_port_text; wxTextCtrl* m_connect_ip_text; wxChoice* m_direct_traversal; + wxStaticText* m_traversal_lbl; + wxButton* m_trav_reset_btn; wxListBox* m_game_lbox; #ifdef USE_UPNP