mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
Re-add saving position of netplay window.
This commit is contained in:
parent
41e7c43d0d
commit
2b0f7d2669
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="GUI">
|
||||
@ -205,6 +205,9 @@
|
||||
<ClCompile Include="Cheats\ARCodeAddEdit.cpp">
|
||||
<Filter>GUI\Cheats</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlay\NetPlayLauncher.cpp">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Main.h" />
|
||||
@ -375,6 +378,9 @@
|
||||
<ClInclude Include="Cheats\ARCodeAddEdit.h">
|
||||
<Filter>GUI\Cheats</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlay\NetPlayLauncher.h">
|
||||
<Filter>GUI\NetPlay</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
|
@ -1138,7 +1138,7 @@ void CGameListCtrl::OnNetPlayHost(wxCommandEvent& WXUNUSED(event))
|
||||
config.FromIniConfig(netplay_section);
|
||||
config.game_name = iso->GetUniqueIdentifier();
|
||||
config.game_list_ctrl = this;
|
||||
config.parent_window = m_parent;
|
||||
config.SetDialogInfo(netplay_section, m_parent);
|
||||
|
||||
netplay_section.Set("SelectedHostGame", config.game_name);
|
||||
ini_file.Save(dolphin_ini);
|
||||
|
@ -2,13 +2,15 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "NetPlayLauncher.h"
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DolphinWX/NetPlay/NetPlayLauncher.h"
|
||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
#include "NetWindow.h"
|
||||
|
||||
bool NetPlayLauncher::Host(const NetPlayHostConfig& config)
|
||||
{
|
||||
@ -49,6 +51,7 @@ bool NetPlayLauncher::Host(const NetPlayHostConfig& config)
|
||||
|
||||
if (netplay_client->IsConnected())
|
||||
{
|
||||
npd->SetSize(config.window_pos);
|
||||
npd->Show();
|
||||
netplay_server->SetNetPlayUI(NetPlayDialog::GetInstance());
|
||||
return true;
|
||||
@ -78,6 +81,7 @@ bool NetPlayLauncher::Join(const NetPlayJoinConfig& config)
|
||||
config.traversal_host, config.traversal_port);
|
||||
if (netplay_client->IsConnected())
|
||||
{
|
||||
npd->SetSize(config.window_pos);
|
||||
npd->Show();
|
||||
return true;
|
||||
}
|
||||
@ -89,10 +93,9 @@ bool NetPlayLauncher::Join(const NetPlayJoinConfig& config)
|
||||
}
|
||||
|
||||
const std::string NetPlayLaunchConfig::DEFAULT_TRAVERSAL_HOST = "stun.dolphin-emu.org";
|
||||
const u16 NetPlayLaunchConfig::DEFAULT_TRAVERSAL_PORT = 6262;
|
||||
const u16 NetPlayHostConfig::DEFAULT_LISTEN_PORT = 2626;
|
||||
|
||||
std::string NetPlayLaunchConfig::GetTraversalHostFromIniConfig(IniFile::Section& netplay_section)
|
||||
std::string
|
||||
NetPlayLaunchConfig::GetTraversalHostFromIniConfig(const IniFile::Section& netplay_section)
|
||||
{
|
||||
std::string host;
|
||||
|
||||
@ -105,7 +108,7 @@ std::string NetPlayLaunchConfig::GetTraversalHostFromIniConfig(IniFile::Section&
|
||||
return host;
|
||||
}
|
||||
|
||||
u16 NetPlayLaunchConfig::GetTraversalPortFromIniConfig(IniFile::Section& netplay_section)
|
||||
u16 NetPlayLaunchConfig::GetTraversalPortFromIniConfig(const IniFile::Section& netplay_section)
|
||||
{
|
||||
std::string port_str;
|
||||
unsigned long port;
|
||||
@ -119,6 +122,22 @@ u16 NetPlayLaunchConfig::GetTraversalPortFromIniConfig(IniFile::Section& netplay
|
||||
return static_cast<u16>(port);
|
||||
}
|
||||
|
||||
void NetPlayLaunchConfig::SetDialogInfo(const IniFile::Section& section, 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());
|
||||
|
||||
if (window_pos.GetX() == window_defaults.GetX() || window_pos.GetY() == window_defaults.GetY())
|
||||
{
|
||||
// Center over toplevel dolphin window
|
||||
window_pos = window_defaults.CenterIn(parent_window->GetScreenRect());
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlayHostConfig::FromIniConfig(IniFile::Section& netplay_section)
|
||||
{
|
||||
std::string traversal_choice_setting;
|
||||
|
@ -7,16 +7,19 @@
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
class CGameListCtrl;
|
||||
class wxRect;
|
||||
class wxWindow;
|
||||
|
||||
class NetPlayLaunchConfig
|
||||
{
|
||||
public:
|
||||
static std::string GetTraversalHostFromIniConfig(IniFile::Section& netplay_section);
|
||||
static u16 GetTraversalPortFromIniConfig(IniFile::Section& netplay_section);
|
||||
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);
|
||||
|
||||
static const std::string DEFAULT_TRAVERSAL_HOST;
|
||||
static const u16 DEFAULT_TRAVERSAL_PORT;
|
||||
static constexpr u16 DEFAULT_TRAVERSAL_PORT = 6262;
|
||||
const wxRect window_defaults{wxDefaultCoord, wxDefaultCoord, 768, 768 - 128};
|
||||
|
||||
std::string player_name;
|
||||
const CGameListCtrl* game_list_ctrl;
|
||||
@ -24,6 +27,7 @@ public:
|
||||
bool use_traversal;
|
||||
std::string traversal_host;
|
||||
u16 traversal_port;
|
||||
wxRect window_pos{window_defaults};
|
||||
};
|
||||
|
||||
class NetPlayHostConfig : public NetPlayLaunchConfig
|
||||
@ -31,7 +35,7 @@ class NetPlayHostConfig : public NetPlayLaunchConfig
|
||||
public:
|
||||
void FromIniConfig(IniFile::Section& netplay_section);
|
||||
|
||||
static const u16 DEFAULT_LISTEN_PORT;
|
||||
static constexpr u16 DEFAULT_LISTEN_PORT = 2626;
|
||||
|
||||
std::string game_name;
|
||||
u16 listen_port = 0;
|
||||
|
@ -305,7 +305,7 @@ void NetPlaySetupFrame::DoHost()
|
||||
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.parent_window = m_parent;
|
||||
host_config.SetDialogInfo(netplay_section, m_parent);
|
||||
host_config.forward_port = m_upnp_chk->GetValue();
|
||||
|
||||
if (host_config.use_traversal)
|
||||
@ -347,7 +347,7 @@ void NetPlaySetupFrame::DoJoin()
|
||||
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.parent_window = m_parent;
|
||||
join_config.SetDialogInfo(netplay_section, m_parent);
|
||||
|
||||
unsigned long port = 0;
|
||||
m_connect_port_text->GetValue().ToULong(&port);
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
static constexpr int DIRECT_CHOICE = 0;
|
||||
static constexpr int TRAVERSAL_CHOICE = 1;
|
||||
|
||||
void GetWindowRect(const IniFile::Section& section, wxRect* rect) const;
|
||||
void OnJoin(wxCommandEvent& event);
|
||||
void OnHost(wxCommandEvent& event);
|
||||
void DoJoin();
|
||||
|
Loading…
x
Reference in New Issue
Block a user