|
@@ -1,7 +1,6 @@
|
|
|
#include "CmEditorPrefs.h"
|
|
#include "CmEditorPrefs.h"
|
|
|
#include "CmFileSystem.h"
|
|
#include "CmFileSystem.h"
|
|
|
#include <QtCore/QDir>
|
|
#include <QtCore/QDir>
|
|
|
-#include "3rdParty/pugixml/pugixml.hpp"
|
|
|
|
|
|
|
|
|
|
using namespace pugi;
|
|
using namespace pugi;
|
|
|
|
|
|
|
@@ -45,6 +44,17 @@ namespace CamelotEditor
|
|
|
return mLastUsedProjectDirectory;
|
|
return mLastUsedProjectDirectory;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void EditorPrefs::setMainWindowLayout(const WindowLayoutDesc& desc)
|
|
|
|
|
+ {
|
|
|
|
|
+ mMainWindowLayout = desc;
|
|
|
|
|
+ mMainWindowLayout.name = "MainWindow";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const WindowLayoutDesc& EditorPrefs::getMainWindowLayout() const
|
|
|
|
|
+ {
|
|
|
|
|
+ return mMainWindowLayout;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void EditorPrefs::save(const QString& path, bool overwrite) const
|
|
void EditorPrefs::save(const QString& path, bool overwrite) const
|
|
|
{
|
|
{
|
|
|
String stdPath = path.toStdString();
|
|
String stdPath = path.toStdString();
|
|
@@ -74,9 +84,52 @@ namespace CamelotEditor
|
|
|
xml_attribute pathAttrib = lastUsedProjectDirectory.append_attribute("path");
|
|
xml_attribute pathAttrib = lastUsedProjectDirectory.append_attribute("path");
|
|
|
pathAttrib.set_value(mLastUsedProjectDirectory.toStdString().c_str());
|
|
pathAttrib.set_value(mLastUsedProjectDirectory.toStdString().c_str());
|
|
|
|
|
|
|
|
|
|
+ xml_node openWindows = camelotEditor.append_child("OpenWindows");
|
|
|
|
|
+ saveWindowLayout(openWindows, mMainWindowLayout);
|
|
|
|
|
+
|
|
|
|
|
+ // TODO - Add non-main windows
|
|
|
|
|
+
|
|
|
xmldoc.save_file(stdPath.c_str());
|
|
xmldoc.save_file(stdPath.c_str());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ void EditorPrefs::saveWindowLayout(xml_node parentNode, const WindowLayoutDesc& desc) const
|
|
|
|
|
+ {
|
|
|
|
|
+ xml_node windowLayout = parentNode.append_child("WindowLayout");
|
|
|
|
|
+ windowLayout.append_attribute("name").set_value(desc.name.toStdString().c_str());
|
|
|
|
|
+
|
|
|
|
|
+ xml_node windowGeometry = windowLayout.append_child("Geometry");
|
|
|
|
|
+ windowGeometry.append_attribute("left").set_value(desc.left);
|
|
|
|
|
+ windowGeometry.append_attribute("top").set_value(desc.top);
|
|
|
|
|
+ windowGeometry.append_attribute("width").set_value(desc.width);
|
|
|
|
|
+ windowGeometry.append_attribute("height").set_value(desc.height);
|
|
|
|
|
+
|
|
|
|
|
+ xml_node windowScreen = windowLayout.append_child("Screen");
|
|
|
|
|
+ windowScreen.append_attribute("fullscreen").set_value(desc.maximized);
|
|
|
|
|
+ windowScreen.append_attribute("screenIdx").set_value(desc.screenIdx);
|
|
|
|
|
+
|
|
|
|
|
+ xml_node dockInfo = windowLayout.append_child("DockInfo");
|
|
|
|
|
+ dockInfo.append_attribute("docked").set_value(desc.docked);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ WindowLayoutDesc EditorPrefs::loadWindowLayout(xml_node node) const
|
|
|
|
|
+ {
|
|
|
|
|
+ WindowLayoutDesc desc;
|
|
|
|
|
+
|
|
|
|
|
+ desc.name = node.attribute("name").value();
|
|
|
|
|
+
|
|
|
|
|
+ desc.left = node.child("Geometry").attribute("left").as_uint();
|
|
|
|
|
+ desc.top = node.child("Geometry").attribute("top").as_uint();
|
|
|
|
|
+ desc.width = node.child("Geometry").attribute("width").as_uint();
|
|
|
|
|
+ desc.height = node.child("Geometry").attribute("height").as_uint();
|
|
|
|
|
+
|
|
|
|
|
+ desc.maximized = node.child("Screen").attribute("fullscreen").as_bool();
|
|
|
|
|
+ desc.screenIdx = node.child("Screen").attribute("screenIdx").as_uint();
|
|
|
|
|
+
|
|
|
|
|
+ desc.docked = node.child("DockInfo").attribute("docked").as_bool();
|
|
|
|
|
+
|
|
|
|
|
+ return desc;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void EditorPrefs::load(const QString& path)
|
|
void EditorPrefs::load(const QString& path)
|
|
|
{
|
|
{
|
|
|
clear();
|
|
clear();
|
|
@@ -104,12 +157,27 @@ namespace CamelotEditor
|
|
|
xml_node lastUsedProjectDirectory = camelotEditor.child("LastUsedProjectDir");
|
|
xml_node lastUsedProjectDirectory = camelotEditor.child("LastUsedProjectDir");
|
|
|
xml_attribute pathAttrib = lastUsedProjectDirectory.attribute("path");
|
|
xml_attribute pathAttrib = lastUsedProjectDirectory.attribute("path");
|
|
|
mLastUsedProjectDirectory = pathAttrib.value();
|
|
mLastUsedProjectDirectory = pathAttrib.value();
|
|
|
|
|
+
|
|
|
|
|
+ xml_node openWindows = camelotEditor.child("OpenWindows");
|
|
|
|
|
+
|
|
|
|
|
+ bool foundMainWindowLayoutDesc = false;
|
|
|
|
|
+ for (xml_node windowLayout = openWindows.child("WindowLayout"); windowLayout; windowLayout = windowLayout.next_sibling("WindowLayout"))
|
|
|
|
|
+ {
|
|
|
|
|
+ WindowLayoutDesc desc = loadWindowLayout(windowLayout);
|
|
|
|
|
+
|
|
|
|
|
+ if(!foundMainWindowLayoutDesc)
|
|
|
|
|
+ {
|
|
|
|
|
+ mMainWindowLayout = desc;
|
|
|
|
|
+ foundMainWindowLayoutDesc = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void EditorPrefs::clear()
|
|
void EditorPrefs::clear()
|
|
|
{
|
|
{
|
|
|
mRecentlyUsedProjects.clear();
|
|
mRecentlyUsedProjects.clear();
|
|
|
mLastUsedProjectDirectory = "";
|
|
mLastUsedProjectDirectory = "";
|
|
|
|
|
+ mMainWindowLayout = WindowLayoutDesc();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
EditorPrefs& gEditorPrefs()
|
|
EditorPrefs& gEditorPrefs()
|