mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Merge pull request #5872 from ligfx/wxnetplayonionconfig
WX: make Netplay use new-style config
This commit is contained in:
@ -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(netplay_section, m_parent);
|
||||
|
||||
netplay_section.Set("SelectedHostGame", config.game_name);
|
||||
ini_file.Save(dolphin_ini);
|
||||
config.SetDialogInfo(m_parent);
|
||||
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_SELECTED_HOST_GAME, config.game_name);
|
||||
NetPlayLauncher::Host(config);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/config.h>
|
||||
#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"
|
||||
@ -91,44 +92,14 @@ 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(const IniFile::Section& section, wxWindow* parent)
|
||||
void NetPlayLaunchConfig::SetDialogInfo(wxWindow* parent)
|
||||
{
|
||||
parent_window = parent;
|
||||
|
||||
section.Get("NetWindowPosX", &window_pos.x, window_defaults.GetX());
|
||||
section.Get("NetWindowPosY", &window_pos.y, window_defaults.GetY());
|
||||
section.Get("NetWindowWidth", &window_pos.width, window_defaults.GetWidth());
|
||||
section.Get("NetWindowHeight", &window_pos.height, window_defaults.GetHeight());
|
||||
wxConfig::Get()->Read("NetWindowPosX", &window_pos.x, window_defaults.GetX());
|
||||
wxConfig::Get()->Read("NetWindowPosY", &window_pos.y, window_defaults.GetY());
|
||||
wxConfig::Get()->Read("NetWindowWidth", &window_pos.width, window_defaults.GetWidth());
|
||||
wxConfig::Get()->Read("NetWindowHeight", &window_pos.height, window_defaults.GetHeight());
|
||||
|
||||
if (window_pos.GetX() == window_defaults.GetX() || window_pos.GetY() == window_defaults.GetY())
|
||||
{
|
||||
@ -137,26 +108,20 @@ void NetPlayLaunchConfig::SetDialogInfo(const IniFile::Section& section, wxWindo
|
||||
}
|
||||
}
|
||||
|
||||
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(const IniFile::Section& section, wxWindow* parent);
|
||||
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() ?
|
||||
m_traversal_listen_port->GetValue() :
|
||||
0);
|
||||
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));
|
||||
|
||||
#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,17 +298,12 @@ 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;
|
||||
host_config.player_name = WxStrToStr(m_nickname_text->GetValue());
|
||||
host_config.game_list_ctrl = m_game_list;
|
||||
host_config.SetDialogInfo(netplay_section, m_parent);
|
||||
host_config.SetDialogInfo(m_parent);
|
||||
#ifdef USE_UPNP
|
||||
host_config.forward_port = m_upnp_chk->GetValue();
|
||||
#endif
|
||||
@ -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,15 +338,11 @@ 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());
|
||||
join_config.game_list_ctrl = m_game_list;
|
||||
join_config.SetDialogInfo(netplay_section, m_parent);
|
||||
join_config.SetDialogInfo(m_parent);
|
||||
|
||||
unsigned long port = 0;
|
||||
m_connect_port_text->GetValue().ToULong(&port);
|
||||
@ -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();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <wx/choice.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/config.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/listbox.h>
|
||||
@ -33,7 +34,6 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FifoQueue.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
@ -77,15 +77,11 @@ NetPlayDialog::NetPlayDialog(wxWindow* const parent, const GameListCtrl* const g
|
||||
|
||||
// Remember the window size and position for NetWindow
|
||||
{
|
||||
IniFile inifile;
|
||||
inifile.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
int winPosX, winPosY, winWidth, winHeight;
|
||||
netplay_section.Get("NetWindowPosX", &winPosX, std::numeric_limits<int>::min());
|
||||
netplay_section.Get("NetWindowPosY", &winPosY, std::numeric_limits<int>::min());
|
||||
netplay_section.Get("NetWindowWidth", &winWidth, -1);
|
||||
netplay_section.Get("NetWindowHeight", &winHeight, -1);
|
||||
wxConfig::Get()->Read("NetWindowPosX", &winPosX, std::numeric_limits<int>::min());
|
||||
wxConfig::Get()->Read("NetWindowPosY", &winPosY, std::numeric_limits<int>::min());
|
||||
wxConfig::Get()->Read("NetWindowWidth", &winWidth, -1);
|
||||
wxConfig::Get()->Read("NetWindowHeight", &winHeight, -1);
|
||||
|
||||
WxUtils::SetWindowSizeAndFitToScreen(this, wxPoint(winPosX, winPosY),
|
||||
wxSize(winWidth, winHeight), GetSize());
|
||||
@ -282,17 +278,10 @@ wxSizer* NetPlayDialog::CreateBottomGUI(wxWindow* parent)
|
||||
|
||||
NetPlayDialog::~NetPlayDialog()
|
||||
{
|
||||
IniFile inifile;
|
||||
const std::string dolphin_ini = File::GetUserPath(F_DOLPHINCONFIG_IDX);
|
||||
inifile.Load(dolphin_ini);
|
||||
IniFile::Section& netplay_config = *inifile.GetOrCreateSection("NetPlay");
|
||||
|
||||
netplay_config.Set("NetWindowPosX", GetPosition().x);
|
||||
netplay_config.Set("NetWindowPosY", GetPosition().y);
|
||||
netplay_config.Set("NetWindowWidth", GetSize().GetWidth());
|
||||
netplay_config.Set("NetWindowHeight", GetSize().GetHeight());
|
||||
|
||||
inifile.Save(dolphin_ini);
|
||||
wxConfig::Get()->Write("NetWindowPosX", GetPosition().x);
|
||||
wxConfig::Get()->Write("NetWindowPosY", GetPosition().y);
|
||||
wxConfig::Get()->Write("NetWindowWidth", GetSize().GetWidth());
|
||||
wxConfig::Get()->Write("NetWindowHeight", GetSize().GetHeight());
|
||||
|
||||
if (netplay_client)
|
||||
{
|
||||
|
@ -531,3 +531,10 @@ wxString StrToWxStr(const std::string& str)
|
||||
// return wxString::FromUTF8Unchecked(str.c_str());
|
||||
return wxString::FromUTF8(str.c_str());
|
||||
}
|
||||
|
||||
unsigned long WxStrToUL(const wxString& str)
|
||||
{
|
||||
unsigned long value = 0;
|
||||
str.ToULong(&value);
|
||||
return value;
|
||||
}
|
||||
|
@ -145,3 +145,4 @@ wxImage ScaleImage(wxImage image, double source_scale_factor = 1.0,
|
||||
|
||||
std::string WxStrToStr(const wxString& str);
|
||||
wxString StrToWxStr(const std::string& str);
|
||||
unsigned long WxStrToUL(const wxString& str);
|
||||
|
Reference in New Issue
Block a user