NetPlayLauncher: store window geometry in native wxConfig

This commit is contained in:
Michael M 2017-08-02 16:51:05 -07:00
parent 9867677211
commit f8fea83e67
5 changed files with 19 additions and 29 deletions

View File

@ -1343,7 +1343,7 @@ void GameListCtrl::OnNetPlayHost(wxCommandEvent& WXUNUSED(event))
config.FromIniConfig(netplay_section);
config.game_name = iso->GetUniqueIdentifier();
config.game_list_ctrl = this;
config.SetDialogInfo(netplay_section, m_parent);
config.SetDialogInfo(m_parent);
netplay_section.Set("SelectedHostGame", config.game_name);
ini_file.Save(dolphin_ini);

View File

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <wx/config.h>
#include <wx/gdicmn.h>
#include "Common/CommonTypes.h"
@ -121,14 +122,14 @@ u16 NetPlayLaunchConfig::GetTraversalPortFromIniConfig(const IniFile::Section& n
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())
{

View File

@ -17,7 +17,7 @@ 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;

View File

@ -338,7 +338,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.SetDialogInfo(netplay_section, m_parent);
host_config.SetDialogInfo(m_parent);
#ifdef USE_UPNP
host_config.forward_port = m_upnp_chk->GetValue();
#endif
@ -382,7 +382,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.SetDialogInfo(netplay_section, m_parent);
join_config.SetDialogInfo(m_parent);
unsigned long port = 0;
m_connect_port_text->GetValue().ToULong(&port);

View File

@ -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)
{