From dde3471b629900887041d7e24582110fa5877ece Mon Sep 17 00:00:00 2001 From: Michael M Date: Wed, 2 Aug 2017 16:52:26 -0700 Subject: [PATCH] WX: make Netplay use new-style config --- Source/Core/Core/CMakeLists.txt | 1 + Source/Core/Core/Config/NetplaySettings.cpp | 36 +++++ Source/Core/Core/Config/NetplaySettings.h | 32 +++++ .../Core/ConfigLoaders/IsSettingSaveable.cpp | 3 + Source/Core/Core/Core.vcxproj | 2 + Source/Core/Core/Core.vcxproj.filters | 6 + Source/Core/DolphinWX/GameListCtrl.cpp | 12 +- .../DolphinWX/NetPlay/NetPlayLauncher.cpp | 52 ++----- .../Core/DolphinWX/NetPlay/NetPlayLauncher.h | 9 +- .../DolphinWX/NetPlay/NetPlaySetupFrame.cpp | 133 ++++++------------ 10 files changed, 134 insertions(+), 152 deletions(-) create mode 100644 Source/Core/Core/Config/NetplaySettings.cpp create mode 100644 Source/Core/Core/Config/NetplaySettings.h diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 761eee33e3..109cca19c3 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -26,6 +26,7 @@ set(SRCS Boot/DolReader.cpp Boot/ElfReader.cpp Config/GraphicsSettings.cpp + Config/NetplaySettings.cpp ConfigLoaders/BaseConfigLoader.cpp ConfigLoaders/GameConfigLoader.cpp ConfigLoaders/IsSettingSaveable.cpp diff --git a/Source/Core/Core/Config/NetplaySettings.cpp b/Source/Core/Core/Config/NetplaySettings.cpp new file mode 100644 index 0000000000..3b0082329d --- /dev/null +++ b/Source/Core/Core/Config/NetplaySettings.cpp @@ -0,0 +1,36 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "Core/Config/NetplaySettings.h" + +#include "Common/Config/Config.h" + +namespace Config +{ +static constexpr u16 DEFAULT_LISTEN_PORT = 2626; + +// Configuration Information + +// Main.NetPlay + +const ConfigInfo NETPLAY_TRAVERSAL_SERVER{{System::Main, "NetPlay", "TraversalServer"}, + "stun.dolphin-emu.org"}; +const ConfigInfo NETPLAY_TRAVERSAL_PORT{{System::Main, "NetPlay", "TraversalPort"}, 6262}; +const ConfigInfo NETPLAY_TRAVERSAL_CHOICE{{System::Main, "NetPlay", "TraversalChoice"}, + "direct"}; +const ConfigInfo NETPLAY_HOST_CODE{{System::Main, "NetPlay", "HostCode"}, "00000000"}; + +const ConfigInfo NETPLAY_HOST_PORT{{System::Main, "NetPlay", "HostPort"}, DEFAULT_LISTEN_PORT}; +const ConfigInfo NETPLAY_ADDRESS{{System::Main, "NetPlay", "Address"}, "127.0.0.1"}; +const ConfigInfo NETPLAY_CONNECT_PORT{{System::Main, "NetPlay", "ConnectPort"}, + DEFAULT_LISTEN_PORT}; +const ConfigInfo NETPLAY_LISTEN_PORT{{System::Main, "NetPlay", "ListenPort"}, + DEFAULT_LISTEN_PORT}; + +const ConfigInfo NETPLAY_NICKNAME{{System::Main, "NetPlay", "Nickname"}, "Player"}; +const ConfigInfo NETPLAY_SELECTED_HOST_GAME{ + {System::Main, "NetPlay", "SelectedHostGame"}, ""}; +const ConfigInfo NETPLAY_USE_UPNP{{System::Main, "NetPlay", "UseUPNP"}, false}; + +} // namespace Config diff --git a/Source/Core/Core/Config/NetplaySettings.h b/Source/Core/Core/Config/NetplaySettings.h new file mode 100644 index 0000000000..1978fdeb84 --- /dev/null +++ b/Source/Core/Core/Config/NetplaySettings.h @@ -0,0 +1,32 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "Common/CommonTypes.h" +#include "Common/Config/Config.h" + +namespace Config +{ +// Configuration Information + +// Main.NetPlay + +extern const ConfigInfo NETPLAY_TRAVERSAL_SERVER; +extern const ConfigInfo NETPLAY_TRAVERSAL_PORT; +extern const ConfigInfo NETPLAY_TRAVERSAL_CHOICE; +extern const ConfigInfo NETPLAY_HOST_CODE; + +extern const ConfigInfo NETPLAY_HOST_PORT; +extern const ConfigInfo NETPLAY_ADDRESS; +extern const ConfigInfo NETPLAY_CONNECT_PORT; +extern const ConfigInfo NETPLAY_LISTEN_PORT; + +extern const ConfigInfo NETPLAY_NICKNAME; +extern const ConfigInfo NETPLAY_SELECTED_HOST_GAME; +extern const ConfigInfo NETPLAY_USE_UPNP; + +} // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 939f6b778e..0349fa6ed6 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -17,6 +17,9 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location) if (config_location.system == Config::System::Logger) return true; + if (config_location.system == Config::System::Main && config_location.section == "NetPlay") + return true; + const static std::vector s_setting_saveable{ // Graphics.Hardware diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index a5d8c85456..b24a48ef2f 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -46,6 +46,7 @@ + @@ -301,6 +302,7 @@ + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 49b139432a..6839621c7d 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -874,6 +874,9 @@ Config + + Config + IOS\Network\NCD @@ -1523,6 +1526,9 @@ Config + + Config + IOS\Network\NCD diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index a0fe527d4b..4cd9f178f7 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -46,6 +46,7 @@ #include "Common/SysConf.h" #include "Common/Thread.h" #include "Core/Boot/Boot.h" +#include "Core/Config/NetplaySettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/DVD/DVDInterface.h" @@ -1334,20 +1335,13 @@ void GameListCtrl::OnNetPlayHost(wxCommandEvent& WXUNUSED(event)) if (!iso) return; - IniFile ini_file; - const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX); - ini_file.Load(dolphin_ini); - IniFile::Section& netplay_section = *ini_file.GetOrCreateSection("NetPlay"); - NetPlayHostConfig config; - config.FromIniConfig(netplay_section); + config.FromConfig(); config.game_name = iso->GetUniqueIdentifier(); config.game_list_ctrl = this; config.SetDialogInfo(m_parent); - netplay_section.Set("SelectedHostGame", config.game_name); - ini_file.Save(dolphin_ini); - + Config::SetBaseOrCurrent(Config::NETPLAY_SELECTED_HOST_GAME, config.game_name); NetPlayLauncher::Host(config); } diff --git a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp index ed99715d86..307a03385e 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.cpp @@ -6,8 +6,8 @@ #include #include "Common/CommonTypes.h" -#include "Common/IniFile.h" #include "Common/StringUtil.h" +#include "Core/Config/NetplaySettings.h" #include "DolphinWX/NetPlay/NetPlayLauncher.h" #include "DolphinWX/NetPlay/NetWindow.h" #include "DolphinWX/WxUtils.h" @@ -92,36 +92,6 @@ bool NetPlayLauncher::Join(const NetPlayJoinConfig& config) } } -const std::string NetPlayLaunchConfig::DEFAULT_TRAVERSAL_HOST = "stun.dolphin-emu.org"; - -std::string -NetPlayLaunchConfig::GetTraversalHostFromIniConfig(const IniFile::Section& netplay_section) -{ - std::string host; - - netplay_section.Get("TraversalServer", &host, DEFAULT_TRAVERSAL_HOST); - host = StripSpaces(host); - - if (host.empty()) - return DEFAULT_TRAVERSAL_HOST; - - return host; -} - -u16 NetPlayLaunchConfig::GetTraversalPortFromIniConfig(const IniFile::Section& netplay_section) -{ - std::string port_str; - unsigned long port; - - netplay_section.Get("TraversalPort", &port_str, std::to_string(DEFAULT_TRAVERSAL_PORT)); - StrToWxStr(port_str).ToULong(&port); - - if (port == 0) - port = DEFAULT_TRAVERSAL_PORT; - - return static_cast(port); -} - void NetPlayLaunchConfig::SetDialogInfo(wxWindow* parent) { parent_window = parent; @@ -138,26 +108,20 @@ void NetPlayLaunchConfig::SetDialogInfo(wxWindow* parent) } } -void NetPlayHostConfig::FromIniConfig(IniFile::Section& netplay_section) +void NetPlayHostConfig::FromConfig() { - netplay_section.Get("Nickname", &player_name, "Player"); + player_name = Config::Get(Config::NETPLAY_NICKNAME); - std::string traversal_choice_setting; - netplay_section.Get("TraversalChoice", &traversal_choice_setting, "direct"); + const std::string traversal_choice_setting = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); use_traversal = traversal_choice_setting == "traversal"; if (!use_traversal) { - unsigned long lport = 0; - std::string port_setting; - netplay_section.Get("HostPort", &port_setting, std::to_string(DEFAULT_LISTEN_PORT)); - StrToWxStr(port_setting).ToULong(&lport); - - listen_port = static_cast(lport); + listen_port = Config::Get(Config::NETPLAY_HOST_PORT); } else { - traversal_port = GetTraversalPortFromIniConfig(netplay_section); - traversal_host = GetTraversalHostFromIniConfig(netplay_section); + traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); + traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); } -} \ No newline at end of file +} diff --git a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.h b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.h index 2d7d4b8f26..ddc92f6f34 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.h +++ b/Source/Core/DolphinWX/NetPlay/NetPlayLauncher.h @@ -6,7 +6,6 @@ #include #include "Common/CommonTypes.h" -#include "Common/IniFile.h" class GameListCtrl; class wxRect; @@ -15,12 +14,8 @@ class wxWindow; class NetPlayLaunchConfig { public: - static std::string GetTraversalHostFromIniConfig(const IniFile::Section& netplay_section); - static u16 GetTraversalPortFromIniConfig(const IniFile::Section& netplay_section); void SetDialogInfo(wxWindow* parent); - static const std::string DEFAULT_TRAVERSAL_HOST; - static constexpr u16 DEFAULT_TRAVERSAL_PORT = 6262; const wxRect window_defaults{wxDefaultCoord, wxDefaultCoord, 768, 768 - 128}; std::string player_name; @@ -35,9 +30,7 @@ public: class NetPlayHostConfig : public NetPlayLaunchConfig { public: - void FromIniConfig(IniFile::Section& netplay_section); - - static constexpr u16 DEFAULT_LISTEN_PORT = 2626; + void FromConfig(); std::string game_name; u16 listen_port = 0; diff --git a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp index f285abe487..0be4d31810 100644 --- a/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetPlaySetupFrame.cpp @@ -22,16 +22,16 @@ #include "DolphinWX/WxUtils.h" #include "Common/FileUtil.h" -#include "Common/IniFile.h" +#include "Core/Config/NetplaySettings.h" #include "Core/NetPlayClient.h" #include "Core/NetPlayServer.h" namespace { -wxString GetTraversalLabelText(IniFile::Section& section) +wxString GetTraversalLabelText() { - std::string server = NetPlayLaunchConfig::GetTraversalHostFromIniConfig(section); - std::string port = std::to_string(NetPlayLaunchConfig::GetTraversalPortFromIniConfig(section)); + std::string server = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); + std::string port = std::to_string(Config::Get(Config::NETPLAY_TRAVERSAL_PORT)); return wxString::Format(_("Traversal Server: %s"), (server + ":" + port).c_str()); } } // Anonymous namespace @@ -39,54 +39,28 @@ wxString GetTraversalLabelText(IniFile::Section& section) NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const GameListCtrl* const game_list) : wxFrame(parent, wxID_ANY, _("Dolphin NetPlay Setup")), m_game_list(game_list) { - IniFile inifile; - inifile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); - CreateGUI(); SetIcons(WxUtils::GetDolphinIconBundle()); { - std::string temp; - netplay_section.Get("Nickname", &temp, "Player"); - m_nickname_text->SetValue(StrToWxStr(temp)); - - temp.clear(); - netplay_section.Get("HostCode", &temp, "00000000"); - m_connect_hashcode_text->SetValue(StrToWxStr(temp)); - - temp.clear(); - netplay_section.Get("Address", &temp, "127.0.0.1"); - m_connect_ip_text->SetValue(StrToWxStr(temp)); - - temp.clear(); - netplay_section.Get("ConnectPort", &temp, - std::to_string(NetPlayHostConfig::DEFAULT_LISTEN_PORT)); - m_connect_port_text->SetValue(StrToWxStr(temp)); - - temp.clear(); - netplay_section.Get("HostPort", &temp, std::to_string(NetPlayHostConfig::DEFAULT_LISTEN_PORT)); - m_host_port_text->SetValue(StrToWxStr(temp)); - - temp.clear(); - if (netplay_section.Get("SelectedHostGame", &temp, "")) - m_game_lbox->SetStringSelection(StrToWxStr(temp)); + m_nickname_text->SetValue(StrToWxStr(Config::Get(Config::NETPLAY_NICKNAME))); + m_connect_hashcode_text->SetValue(StrToWxStr(Config::Get(Config::NETPLAY_HOST_CODE))); + m_connect_ip_text->SetValue(StrToWxStr(Config::Get(Config::NETPLAY_ADDRESS))); + m_connect_port_text->SetValue( + StrToWxStr(std::to_string(Config::Get(Config::NETPLAY_CONNECT_PORT)))); + m_host_port_text->SetValue(StrToWxStr(std::to_string(Config::Get(Config::NETPLAY_HOST_PORT)))); + m_game_lbox->SetStringSelection(StrToWxStr(Config::Get(Config::NETPLAY_SELECTED_HOST_GAME))); #ifdef USE_UPNP - bool use_upnp = false; - netplay_section.Get("UseUPNP", &use_upnp, false); - m_upnp_chk->SetValue(use_upnp); + m_upnp_chk->SetValue(Config::Get(Config::NETPLAY_USE_UPNP)); #endif - unsigned int listen_port = 0; - netplay_section.Get("ListenPort", &listen_port, 0); + unsigned int listen_port = Config::Get(Config::NETPLAY_LISTEN_PORT); m_traversal_listen_port_enabled->SetValue(listen_port != 0); m_traversal_listen_port->Enable(m_traversal_listen_port_enabled->IsChecked()); m_traversal_listen_port->SetValue(listen_port); - temp.clear(); - netplay_section.Get("TraversalChoice", &temp, "direct"); - if (temp == "traversal") + if (Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE) == "traversal") { m_direct_traversal->Select(TRAVERSAL_CHOICE); } @@ -95,7 +69,7 @@ NetPlaySetupFrame::NetPlaySetupFrame(wxWindow* const parent, const GameListCtrl* m_direct_traversal->Select(DIRECT_CHOICE); } - m_traversal_lbl->SetLabelText(GetTraversalLabelText(netplay_section)); + m_traversal_lbl->SetLabelText(GetTraversalLabelText()); } Center(); @@ -184,8 +158,7 @@ wxNotebook* NetPlaySetupFrame::CreateNotebookGUI(wxWindow* parent) m_connect_hashcode_text->Hide(); m_client_port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port:")); - m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, - std::to_string(NetPlayHostConfig::DEFAULT_LISTEN_PORT)); + m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, ""); wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect")); connect_btn->Bind(wxEVT_BUTTON, &NetPlaySetupFrame::OnJoin, this); @@ -224,8 +197,7 @@ wxNotebook* NetPlaySetupFrame::CreateNotebookGUI(wxWindow* parent) // host tab { m_host_port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port:")); - m_host_port_text = - new wxTextCtrl(host_tab, wxID_ANY, std::to_string(NetPlayHostConfig::DEFAULT_LISTEN_PORT)); + m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, ""); m_traversal_listen_port_enabled = new wxCheckBox(host_tab, wxID_ANY, _("Force Listen Port:")); m_traversal_listen_port = new wxSpinCtrl(host_tab, wxID_ANY, "", wxDefaultPosition, @@ -277,11 +249,6 @@ wxNotebook* NetPlaySetupFrame::CreateNotebookGUI(wxWindow* parent) NetPlaySetupFrame::~NetPlaySetupFrame() { - IniFile inifile; - const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX); - inifile.Load(dolphin_ini); - IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); - std::string travChoice; switch (m_direct_traversal->GetSelection()) { @@ -293,25 +260,28 @@ NetPlaySetupFrame::~NetPlaySetupFrame() break; } - netplay_section.Set("TraversalChoice", travChoice); - netplay_section.Set("Nickname", WxStrToStr(m_nickname_text->GetValue())); + Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_CHOICE, travChoice); + Config::SetBaseOrCurrent(Config::NETPLAY_NICKNAME, WxStrToStr(m_nickname_text->GetValue())); if (m_direct_traversal->GetCurrentSelection() == DIRECT_CHOICE) - netplay_section.Set("Address", WxStrToStr(m_connect_ip_text->GetValue())); + Config::SetBaseOrCurrent(Config::NETPLAY_ADDRESS, WxStrToStr(m_connect_ip_text->GetValue())); else - netplay_section.Set("HostCode", WxStrToStr(m_connect_hashcode_text->GetValue())); + Config::SetBaseOrCurrent(Config::NETPLAY_HOST_CODE, + WxStrToStr(m_connect_hashcode_text->GetValue())); - netplay_section.Set("ConnectPort", WxStrToStr(m_connect_port_text->GetValue())); - netplay_section.Set("HostPort", WxStrToStr(m_host_port_text->GetValue())); - netplay_section.Set("ListenPort", m_traversal_listen_port_enabled->IsChecked() ? - m_traversal_listen_port->GetValue() : - 0); + Config::SetBaseOrCurrent(Config::NETPLAY_CONNECT_PORT, + static_cast(WxStrToUL(m_connect_port_text->GetValue()))); + Config::SetBaseOrCurrent(Config::NETPLAY_HOST_PORT, + static_cast(WxStrToUL(m_host_port_text->GetValue()))); + Config::SetBaseOrCurrent(Config::NETPLAY_LISTEN_PORT, + static_cast(m_traversal_listen_port_enabled->IsChecked() ? + m_traversal_listen_port->GetValue() : + 0)); #ifdef USE_UPNP - netplay_section.Set("UseUPNP", m_upnp_chk->GetValue(), false); + Config::SetBaseOrCurrent(Config::NETPLAY_USE_UPNP, m_upnp_chk->GetValue()); #endif - inifile.Save(dolphin_ini); main_frame->m_netplay_setup_frame = nullptr; } @@ -328,11 +298,6 @@ void NetPlaySetupFrame::DoHost() return; } - IniFile ini_file; - const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX); - ini_file.Load(dolphin_ini); - IniFile::Section& netplay_section = *ini_file.GetOrCreateSection("NetPlay"); - NetPlayHostConfig host_config; host_config.game_name = WxStrToStr(m_game_lbox->GetStringSelection()); host_config.use_traversal = m_direct_traversal->GetCurrentSelection() == TRAVERSAL_CHOICE; @@ -355,11 +320,10 @@ void NetPlaySetupFrame::DoHost() host_config.listen_port = static_cast(listen_port); } - host_config.traversal_port = NetPlayLaunchConfig::GetTraversalPortFromIniConfig(netplay_section); - host_config.traversal_host = NetPlayLaunchConfig::GetTraversalHostFromIniConfig(netplay_section); + host_config.traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); + host_config.traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); - netplay_section.Set("SelectedHostGame", host_config.game_name); - ini_file.Save(dolphin_ini); + Config::SetBaseOrCurrent(Config::NETPLAY_SELECTED_HOST_GAME, host_config.game_name); if (NetPlayLauncher::Host(host_config)) { @@ -374,10 +338,6 @@ void NetPlaySetupFrame::OnJoin(wxCommandEvent&) void NetPlaySetupFrame::DoJoin() { - IniFile inifile; - inifile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); - NetPlayJoinConfig join_config; join_config.use_traversal = m_direct_traversal->GetCurrentSelection() == TRAVERSAL_CHOICE; join_config.player_name = WxStrToStr(m_nickname_text->GetValue()); @@ -394,8 +354,8 @@ void NetPlaySetupFrame::DoJoin() else join_config.connect_host = WxStrToStr(m_connect_ip_text->GetValue()); - join_config.traversal_port = NetPlayLaunchConfig::GetTraversalPortFromIniConfig(netplay_section); - join_config.traversal_host = NetPlayLaunchConfig::GetTraversalHostFromIniConfig(netplay_section); + join_config.traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); + join_config.traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); if (NetPlayLauncher::Join(join_config)) { @@ -405,15 +365,12 @@ void NetPlaySetupFrame::DoJoin() void NetPlaySetupFrame::OnResetTraversal(wxCommandEvent& event) { - IniFile inifile; - const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX); - inifile.Load(dolphin_ini); - IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); - netplay_section.Delete("TraversalServer"); - netplay_section.Delete("TraversalPort"); - inifile.Save(dolphin_ini); + Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_SERVER, + Config::NETPLAY_TRAVERSAL_SERVER.default_value); + Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_PORT, + Config::NETPLAY_TRAVERSAL_PORT.default_value); - m_traversal_lbl->SetLabelText(GetTraversalLabelText(netplay_section)); + m_traversal_lbl->SetLabelText(GetTraversalLabelText()); } void NetPlaySetupFrame::OnTraversalListenPortChanged(wxCommandEvent& event) @@ -424,9 +381,6 @@ void NetPlaySetupFrame::OnTraversalListenPortChanged(wxCommandEvent& event) void NetPlaySetupFrame::OnDirectTraversalChoice(wxCommandEvent& event) { int sel = m_direct_traversal->GetSelection(); - IniFile inifile; - inifile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay"); if (sel == TRAVERSAL_CHOICE) { @@ -463,10 +417,7 @@ void NetPlaySetupFrame::OnDirectTraversalChoice(wxCommandEvent& event) // 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_connect_ip_text->SetLabelText(Config::Get(Config::NETPLAY_ADDRESS)); m_client_port_lbl->Show(); m_connect_port_text->Show();