diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index 758e6214..034cca67 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -1149,7 +1149,7 @@ loot::PluginDirtyInfo EditorPanel::RowToPluginDirtyInfo(wxListView * list, long // Mini Editor Class /////////////////////////////////// -MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game) : wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { +MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game) : wxDialog(parent, wxID_ANY, title, pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { //Initialise content. editorPanel = new EditorPanel(this, basePlugins, editedPlugins, loot::Language::any, game); @@ -1203,7 +1203,7 @@ const std::list& MiniEditor::GetNewUserlist() const { // Full Editor Class /////////////////////////////////// -FullEditor::FullEditor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game) : wxFrame(parent, wxID_ANY, title), _userlistPath(userlistPath) { +FullEditor::FullEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game, YAML::Node &settings) : wxFrame(parent, wxID_ANY, title, pos, size), _userlistPath(userlistPath), _settings(settings) { //Set up content. editorPanel = new EditorPanel(this, basePlugins, editedPlugins, language, game); applyBtn = new wxButton(this, BUTTON_Apply, translate("Save Changes")); @@ -1212,6 +1212,7 @@ FullEditor::FullEditor(wxWindow *parent, const wxString& title, const std::strin //Set up event handling. Bind(wxEVT_BUTTON, &FullEditor::OnQuit, this, BUTTON_Apply); Bind(wxEVT_BUTTON, &FullEditor::OnQuit, this, BUTTON_Cancel); + Bind(wxEVT_CLOSE_WINDOW, &FullEditor::OnClose, this); //Set up layout. wxBoxSizer * bigBox = new wxBoxSizer(wxVERTICAL); @@ -1253,3 +1254,16 @@ void FullEditor::OnQuit(wxCommandEvent& event) { } Close(); } + +void FullEditor::OnClose(wxCloseEvent &event) { + //Record window settings. + YAML::Node node; + node["height"] = GetSize().GetHeight(); + node["width"] = GetSize().GetWidth(); + node["xPos"] = GetPosition().x; + node["yPos"] = GetPosition().y; + + _settings["windows"]["editor"] = node; + + Destroy(); +} \ No newline at end of file diff --git a/src/gui/editor.h b/src/gui/editor.h index 75edd682..21e1971a 100644 --- a/src/gui/editor.h +++ b/src/gui/editor.h @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -128,7 +129,7 @@ protected: class MiniEditor : public wxDialog { public: - MiniEditor(wxWindow *parent, const wxString& title, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game); + MiniEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::list& basePlugins, std::list& editedPlugins, const loot::Game& game); void OnApply(wxCommandEvent& event); void OnResize(wxSizeEvent& event); @@ -143,14 +144,16 @@ private: class FullEditor : public wxFrame { public: - FullEditor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game); + FullEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::string userlistPath, const std::list& basePlugins, std::list& editedPlugins, const unsigned int language, const loot::Game& game, YAML::Node &settings); void OnQuit(wxCommandEvent& event); + void OnClose(wxCloseEvent &event); private: EditorPanel * editorPanel; wxButton * applyBtn; wxButton * cancelBtn; const std::string _userlistPath; + YAML::Node& _settings; }; #endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 2a16c77f..4f00e96f 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -599,9 +599,19 @@ void Launcher::OnClose(wxCloseEvent& event) { } void Launcher::OnViewLastReport(wxCommandEvent& event) { + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["viewer"]) { + YAML::Node node = _settings["windows"]["viewer"]; + 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 viewer window. BOOST_LOG_TRIVIAL(debug) << "Opening viewer window..."; - Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _game->ReportDataPath().string()))); + Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _game->ReportDataPath().string())), pos, size, _settings); viewer->Show(); BOOST_LOG_TRIVIAL(debug) << "Report displayed."; } @@ -622,11 +632,7 @@ void Launcher::OnOpenSettings(wxCommandEvent& event) { 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) { - - } + settings.ShowModal(); //Record window settings. YAML::Node node; @@ -938,11 +944,32 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { progDia = nullptr; BOOST_LOG_TRIVIAL(info) << "Displaying load order preview."; - MiniEditor editor(this, translate("LOOT: Calculated Load Order"), plugins, ulist_plugins, *_game); + + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["editor"]) { + YAML::Node node = _settings["windows"]["editor"]; + 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()); + } + } + + MiniEditor editor(this, translate("LOOT: Calculated Load Order"), pos, size, plugins, ulist_plugins, *_game); long ret = editor.ShowModal(); const std::list& newUserlist = editor.GetNewUserlist(); + //Record window settings. + YAML::Node node; + node["height"] = editor.GetSize().GetHeight(); + node["width"] = editor.GetSize().GetWidth(); + node["xPos"] = editor.GetPosition().x; + node["yPos"] = editor.GetPosition().y; + + _settings["windows"]["editor"] = node; + //Need to determine if any new edits have been made. bool haveNewEdits = false; if (newUserlist.size() != ulist_plugins.size()) @@ -1049,8 +1076,19 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { ViewButton->Enable(true); BOOST_LOG_TRIVIAL(debug) << "Displaying report..."; + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["viewer"]) { + YAML::Node node = _settings["windows"]["viewer"]; + 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 viewer window. - Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _game->ReportDataPath().string()))); + Viewer *viewer = new Viewer(this, translate("LOOT: Report Viewer"), FromUTF8(ToFileURL(g_path_report.string() + "?data=" + _game->ReportDataPath().string())), pos, size, _settings); viewer->Show(); BOOST_LOG_TRIVIAL(debug) << "Report display successful. Sorting process complete."; @@ -1147,9 +1185,20 @@ void Launcher::OnEditMetadata(wxCommandEvent& event) { else lang = loot::Language::any; + //Load window size/pos settings. + wxSize size = wxDefaultSize; + wxPoint pos = wxDefaultPosition; + if (_settings["windows"] && _settings["windows"]["editor"]) { + YAML::Node node = _settings["windows"]["editor"]; + 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 editor window. BOOST_LOG_TRIVIAL(debug) << "Opening editor window."; - FullEditor *editor = new FullEditor(this, translate("LOOT: Metadata Editor"), _game->UserlistPath().string(), installed, ulist_plugins, lang, *_game); + FullEditor *editor = new FullEditor(this, translate("LOOT: Metadata Editor"), pos, size, _game->UserlistPath().string(), installed, ulist_plugins, lang, *_game, _settings); progDia->Destroy(); diff --git a/src/gui/viewer.cpp b/src/gui/viewer.cpp index f92c9b26..1ad37f5e 100644 --- a/src/gui/viewer.cpp +++ b/src/gui/viewer.cpp @@ -25,11 +25,12 @@ #include "viewer.h" #include "../backend/helpers.h" -Viewer::Viewer(wxWindow *parent, const wxString& title, const wxString& url) : wxFrame(parent, wxID_ANY, title) { +Viewer::Viewer(wxWindow *parent, const wxString& title, const wxString& url, wxPoint pos, wxSize size, YAML::Node& settings) : wxFrame(parent, wxID_ANY, title, pos, size), _settings(settings) { web = wxWebView::New(this, wxID_ANY, url); web->Bind(wxEVT_WEBVIEW_NAVIGATING, &Viewer::OnNavigationStart, this); web->Bind(wxEVT_CHAR_HOOK, &Viewer::OnKeyUp, this); + Bind(wxEVT_CLOSE_WINDOW, &Viewer::OnClose, this); wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); @@ -70,4 +71,17 @@ void Viewer::OnFind(wxFindDialogEvent &event) { web->Find(event.GetFindString(), findFlags); +} + +void Viewer::OnClose(wxCloseEvent &event) { + //Record window settings. + YAML::Node node; + node["height"] = GetSize().GetHeight(); + node["width"] = GetSize().GetWidth(); + node["xPos"] = GetPosition().x; + node["yPos"] = GetPosition().y; + + _settings["windows"]["viewer"] = node; + + Destroy(); } \ No newline at end of file diff --git a/src/gui/viewer.h b/src/gui/viewer.h index cca7d6b8..90621fa2 100644 --- a/src/gui/viewer.h +++ b/src/gui/viewer.h @@ -27,19 +27,23 @@ #include "ids.h" +#include #include #include class Viewer : public wxFrame { public: - Viewer(wxWindow *parent, const wxString& title, const wxString& url); + Viewer(wxWindow *parent, const wxString& title, const wxString& url, wxPoint pos, wxSize size, YAML::Node& settings); void OnNavigationStart(wxWebViewEvent& event); void OnKeyUp(wxKeyEvent &event); void OnFind(wxFindDialogEvent &event); + void OnClose(wxCloseEvent &event); wxWebView * web; wxFindReplaceData data; + + YAML::Node& _settings; }; #endif