WX: make Netplay use new-style config
This commit is contained in:
parent
f8fea83e67
commit
dde3471b62
|
@ -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
|
||||
|
|
|
@ -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<std::string> NETPLAY_TRAVERSAL_SERVER{{System::Main, "NetPlay", "TraversalServer"},
|
||||
"stun.dolphin-emu.org"};
|
||||
const ConfigInfo<u16> NETPLAY_TRAVERSAL_PORT{{System::Main, "NetPlay", "TraversalPort"}, 6262};
|
||||
const ConfigInfo<std::string> NETPLAY_TRAVERSAL_CHOICE{{System::Main, "NetPlay", "TraversalChoice"},
|
||||
"direct"};
|
||||
const ConfigInfo<std::string> NETPLAY_HOST_CODE{{System::Main, "NetPlay", "HostCode"}, "00000000"};
|
||||
|
||||
const ConfigInfo<u16> NETPLAY_HOST_PORT{{System::Main, "NetPlay", "HostPort"}, DEFAULT_LISTEN_PORT};
|
||||
const ConfigInfo<std::string> NETPLAY_ADDRESS{{System::Main, "NetPlay", "Address"}, "127.0.0.1"};
|
||||
const ConfigInfo<u16> NETPLAY_CONNECT_PORT{{System::Main, "NetPlay", "ConnectPort"},
|
||||
DEFAULT_LISTEN_PORT};
|
||||
const ConfigInfo<u16> NETPLAY_LISTEN_PORT{{System::Main, "NetPlay", "ListenPort"},
|
||||
DEFAULT_LISTEN_PORT};
|
||||
|
||||
const ConfigInfo<std::string> NETPLAY_NICKNAME{{System::Main, "NetPlay", "Nickname"}, "Player"};
|
||||
const ConfigInfo<std::string> NETPLAY_SELECTED_HOST_GAME{
|
||||
{System::Main, "NetPlay", "SelectedHostGame"}, ""};
|
||||
const ConfigInfo<bool> NETPLAY_USE_UPNP{{System::Main, "NetPlay", "UseUPNP"}, false};
|
||||
|
||||
} // namespace Config
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Config/Config.h"
|
||||
|
||||
namespace Config
|
||||
{
|
||||
// Configuration Information
|
||||
|
||||
// Main.NetPlay
|
||||
|
||||
extern const ConfigInfo<std::string> NETPLAY_TRAVERSAL_SERVER;
|
||||
extern const ConfigInfo<u16> NETPLAY_TRAVERSAL_PORT;
|
||||
extern const ConfigInfo<std::string> NETPLAY_TRAVERSAL_CHOICE;
|
||||
extern const ConfigInfo<std::string> NETPLAY_HOST_CODE;
|
||||
|
||||
extern const ConfigInfo<u16> NETPLAY_HOST_PORT;
|
||||
extern const ConfigInfo<std::string> NETPLAY_ADDRESS;
|
||||
extern const ConfigInfo<u16> NETPLAY_CONNECT_PORT;
|
||||
extern const ConfigInfo<u16> NETPLAY_LISTEN_PORT;
|
||||
|
||||
extern const ConfigInfo<std::string> NETPLAY_NICKNAME;
|
||||
extern const ConfigInfo<std::string> NETPLAY_SELECTED_HOST_GAME;
|
||||
extern const ConfigInfo<bool> NETPLAY_USE_UPNP;
|
||||
|
||||
} // namespace Config
|
|
@ -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<Config::ConfigLocation> s_setting_saveable{
|
||||
// Graphics.Hardware
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<ClCompile Include="Boot\DolReader.cpp" />
|
||||
<ClCompile Include="Boot\ElfReader.cpp" />
|
||||
<ClCompile Include="Config\GraphicsSettings.cpp" />
|
||||
<ClCompile Include="Config\NetplaySettings.cpp" />
|
||||
<ClCompile Include="ConfigLoaders\BaseConfigLoader.cpp" />
|
||||
<ClCompile Include="ConfigLoaders\GameConfigLoader.cpp" />
|
||||
<ClCompile Include="ConfigLoaders\IsSettingSaveable.cpp" />
|
||||
|
@ -301,6 +302,7 @@
|
|||
<ClInclude Include="Boot\ElfReader.h" />
|
||||
<ClInclude Include="Boot\ElfTypes.h" />
|
||||
<ClInclude Include="Config\GraphicsSettings.h" />
|
||||
<ClInclude Include="Config\NetplaySettings.h" />
|
||||
<ClInclude Include="ConfigLoaders\BaseConfigLoader.h" />
|
||||
<ClInclude Include="ConfigLoaders\GameConfigLoader.h" />
|
||||
<ClInclude Include="ConfigLoaders\IsSettingSaveable.h" />
|
||||
|
|
|
@ -874,6 +874,9 @@
|
|||
<ClCompile Include="Config\GraphicsSettings.cpp">
|
||||
<Filter>Config</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\NetplaySettings.cpp">
|
||||
<Filter>Config</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IOS\Network\NCD\WiiNetConfig.cpp">
|
||||
<Filter>IOS\Network\NCD</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1523,6 +1526,9 @@
|
|||
<ClInclude Include="Config\GraphicsSettings.h">
|
||||
<Filter>Config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config\NetplaySettings.h">
|
||||
<Filter>Config</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="IOS\Network\NCD\WiiNetConfig.h">
|
||||
<Filter>IOS\Network\NCD</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include <wx/gdicmn.h>
|
||||
|
||||
#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<u16>(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<u16>(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);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <string>
|
||||
#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;
|
||||
|
|
|
@ -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() ?
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_CONNECT_PORT,
|
||||
static_cast<u16>(WxStrToUL(m_connect_port_text->GetValue())));
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_HOST_PORT,
|
||||
static_cast<u16>(WxStrToUL(m_host_port_text->GetValue())));
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_LISTEN_PORT,
|
||||
static_cast<u16>(m_traversal_listen_port_enabled->IsChecked() ?
|
||||
m_traversal_listen_port->GetValue() :
|
||||
0);
|
||||
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<u16>(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();
|
||||
|
|
Loading…
Reference in New Issue