diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 7ca1cd3c..2a16c77f 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -442,9 +442,20 @@ bool LOOT::OnInit() { return false; } + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["main"]) { + YAML::Node node = _settings["windows"]["main"]; + if (node["width"] && node["height"] && node["xPos"] && node["yPos"]) { + size = wxSize(node["width"].as(), node["height"].as()); + pos = wxPoint(node["xPos"].as(), node["yPos"].as()); + } + } + //Create launcher window. BOOST_LOG_TRIVIAL(debug) << "Opening the main LOOT window."; - Launcher * launcher = new Launcher(wxT("LOOT"), _settings, &_game, _games); + Launcher * launcher = new Launcher(wxT("LOOT"), _settings, &_game, _games, pos, size); launcher->SetIcon(wxIconLocation("LOOT.exe")); launcher->Show(); @@ -453,7 +464,7 @@ bool LOOT::OnInit() { return true; } -Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game * game, vector& games) : wxFrame(nullptr, wxID_ANY, title), _game(game), _settings(settings), _games(games) { +Launcher::Launcher(const wxChar *title, YAML::Node& settings, Game * game, vector& games, wxPoint pos, wxSize size) : wxFrame(nullptr, wxID_ANY, title, pos, size), _game(game), _settings(settings), _games(games) { //Initialise menu items. wxMenuBar * MenuBar = new wxMenuBar(); @@ -556,8 +567,17 @@ void Launcher::OnQuit(wxCommandEvent& event) { void Launcher::OnClose(wxCloseEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Quiting LOOT."; - _settings["Last Game"] = _game->FolderName(); + //Record window settings. + YAML::Node main; + main["height"] = GetSize().GetHeight(); + main["width"] = GetSize().GetWidth(); + main["xPos"] = GetPosition().x; + main["yPos"] = GetPosition().y; + _settings["windows"]["main"] = main; + + //Record game settings. + _settings["Last Game"] = _game->FolderName(); _settings["Games"] = _games; //Save settings. @@ -588,9 +608,34 @@ void Launcher::OnViewLastReport(wxCommandEvent& event) { void Launcher::OnOpenSettings(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(debug) << "Opening settings window..."; - SettingsFrame *settings = new SettingsFrame(this, translate("LOOT: Settings"), _settings, _games); - settings->ShowModal(); + + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["settings"]) { + YAML::Node node = _settings["windows"]["settings"]; + if (node["width"] && node["height"] && node["xPos"] && node["yPos"]) { + size = wxSize(node["width"].as(), node["height"].as()); + pos = wxPoint(node["xPos"].as(), node["yPos"].as()); + } + } + + SettingsFrame settings = SettingsFrame(this, translate("LOOT: Settings"), _settings, _games, pos, size); BOOST_LOG_TRIVIAL(debug) << "Settings window opened."; + int ret = settings.ShowModal(); + + if (ret == wxID_OK) { + + } + + //Record window settings. + YAML::Node node; + node["height"] = settings.GetSize().GetHeight(); + node["width"] = settings.GetSize().GetWidth(); + node["xPos"] = settings.GetPosition().x; + node["yPos"] = settings.GetPosition().y; + + _settings["windows"]["settings"] = node; } void Launcher::OnGameChange(wxCommandEvent& event) { diff --git a/src/gui/main.h b/src/gui/main.h index 19a4b428..8d902b15 100644 --- a/src/gui/main.h +++ b/src/gui/main.h @@ -45,7 +45,7 @@ private: class Launcher : public wxFrame { public: - Launcher(const wxChar *title, YAML::Node& settings, loot::Game * inGame, std::vector& games); + Launcher(const wxChar *title, YAML::Node& settings, loot::Game * inGame, std::vector& games, wxPoint pos, wxSize size); void OnSortPlugins(wxCommandEvent& event); void OnEditMetadata(wxCommandEvent& event); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index f8378f82..d8c1e6df 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -34,7 +34,7 @@ using namespace std; -SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER), _settings(settings), _games(games) { +SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games, wxPoint pos, wxSize size) : wxDialog(parent, wxID_ANY, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _settings(settings), _games(games) { //Initialise drop-down list contents. wxString DebugVerbosity[] = { diff --git a/src/gui/settings.h b/src/gui/settings.h index 4c8317e1..bc67d870 100644 --- a/src/gui/settings.h +++ b/src/gui/settings.h @@ -33,7 +33,7 @@ class SettingsFrame : public wxDialog { public: - SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games); + SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node& settings, std::vector& games, wxPoint pos, wxSize size); void OnQuit(wxCommandEvent& event); void OnGameSelect(wxListEvent& event);