mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Added editors and viewer window position memory.
Just realised that sizing isn't working because the windows are fitted to their content.
This commit is contained in:
+16
-2
@@ -1149,7 +1149,7 @@ loot::PluginDirtyInfo EditorPanel::RowToPluginDirtyInfo(wxListView * list, long
|
||||
// Mini Editor Class
|
||||
///////////////////////////////////
|
||||
|
||||
MiniEditor::MiniEditor(wxWindow *parent, const wxString& title, const std::list<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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<loot::Plugin>& MiniEditor::GetNewUserlist() const {
|
||||
// Full Editor Class
|
||||
///////////////////////////////////
|
||||
|
||||
FullEditor::FullEditor(wxWindow *parent, const wxString& title, const std::string userlistPath, const std::list<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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();
|
||||
}
|
||||
+5
-2
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <wx/spinctrl.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/listctrl.h>
|
||||
@@ -128,7 +129,7 @@ protected:
|
||||
|
||||
class MiniEditor : public wxDialog {
|
||||
public:
|
||||
MiniEditor(wxWindow *parent, const wxString& title, const std::list<loot::Plugin>& basePlugins, std::list<loot::Plugin>& editedPlugins, const loot::Game& game);
|
||||
MiniEditor(wxWindow *parent, const wxString& title, wxPoint pos, wxSize size, const std::list<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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<loot::Plugin>& basePlugins, std::list<loot::Plugin>& 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
|
||||
|
||||
+58
-9
@@ -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<int>(), node["height"].as<int>());
|
||||
pos = wxPoint(node["xPos"].as<int>(), node["yPos"].as<int>());
|
||||
}
|
||||
}
|
||||
//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<int>(), node["height"].as<int>());
|
||||
pos = wxPoint(node["xPos"].as<int>(), node["yPos"].as<int>());
|
||||
}
|
||||
}
|
||||
|
||||
MiniEditor editor(this, translate("LOOT: Calculated Load Order"), pos, size, plugins, ulist_plugins, *_game);
|
||||
|
||||
long ret = editor.ShowModal();
|
||||
const std::list<loot::Plugin>& 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<int>(), node["height"].as<int>());
|
||||
pos = wxPoint(node["xPos"].as<int>(), node["yPos"].as<int>());
|
||||
}
|
||||
}
|
||||
|
||||
//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<int>(), node["height"].as<int>());
|
||||
pos = wxPoint(node["xPos"].as<int>(), node["yPos"].as<int>());
|
||||
}
|
||||
}
|
||||
|
||||
//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();
|
||||
|
||||
|
||||
+15
-1
@@ -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();
|
||||
}
|
||||
+5
-1
@@ -27,19 +27,23 @@
|
||||
|
||||
#include "ids.h"
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include <wx/webview.h>
|
||||
#include <wx/fdrepdlg.h>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user