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

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