diff --git a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs index 56bbb0f21..811613425 100644 --- a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs +++ b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Windows.Forms; using System.Reflection; -using System.Xml.Linq; using CancelEventHandler = System.ComponentModel.CancelEventHandler; using CancelEventArgs = System.ComponentModel.CancelEventArgs; @@ -13,11 +12,9 @@ using AdamsLair.WinForms.ItemModels; using AdamsLair.WinForms.ItemViews; -using Duality; using Duality.Cloning; using Duality.Resources; using Duality.IO; -using Duality.Editor; using Duality.Editor.Forms; using Duality.Editor.UndoRedoActions; @@ -77,6 +74,15 @@ private class CreateContextEntryTag private MenuModelItem nodeContextItemCopy = null; private MenuModelItem nodeContextItemPaste = null; + + private SceneViewSettings userSettings = new SceneViewSettings(); + + public SceneViewSettings UserSettings + { + get { return this.userSettings; } + set { this.userSettings = value; } + } + public IEnumerable SelectedNodes { get @@ -106,8 +112,7 @@ where c.Tag is GameObjectNode select c.Tag as GameObjectNode; } } - - + public SceneView() { this.InitializeComponent(); @@ -171,17 +176,11 @@ protected override void OnClosed(EventArgs e) Scene.ComponentAdded -= this.Scene_ComponentAdded; Scene.ComponentRemoving -= this.Scene_ComponentRemoving; } - - internal void SaveUserData(XElement node) - { - node.SetElementValue("ShowComponents", this.buttonShowComponents.Checked); - } - internal void LoadUserData(XElement node) + + + internal void ApplyUserSettings() { - bool tryParseBool; - - if (node.GetElementValue("ShowComponents", out tryParseBool)) - this.buttonShowComponents.Checked = tryParseBool; + this.buttonShowComponents.Checked = this.userSettings.ShowComponents; } public void FlashNode(NodeBase node) @@ -1812,6 +1811,7 @@ private void buttonSaveScene_Click(object sender, EventArgs e) } private void buttonShowComponents_CheckedChanged(object sender, EventArgs e) { + this.userSettings.ShowComponents = this.buttonShowComponents.Checked; // Save expand data HashSet expandedMap = new HashSet(); this.objectView.SaveNodesExpanded(this.objectView.Root, expandedMap, this.NodeIdFuncCoreObject); diff --git a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs index 366504d48..dcb919675 100644 --- a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs +++ b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs @@ -1,15 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Windows.Forms; -using System.IO; -using System.Xml.Linq; -using Duality; -using Duality.Editor; using Duality.Editor.Forms; using Duality.Editor.Properties; -using Duality.Editor.UndoRedoActions; using Duality.Editor.Plugins.SceneView.Properties; using WeifenLuo.WinFormsUI.Docking; @@ -42,28 +36,21 @@ protected override IDockContent DeserializeDockContent(Type dockContentType) this.isLoading = false; return result; } - protected override void SaveUserData(XElement node) + protected override void SaveUserData(PluginSettings settings) { if (this.sceneView != null) { - XElement sceneViewElem = new XElement("SceneView"); - this.sceneView.SaveUserData(sceneViewElem); - if (!sceneViewElem.IsEmpty) - node.Add(sceneViewElem); + settings.Set(this.sceneView.UserSettings); } } - protected override void LoadUserData(XElement node) + protected override void LoadUserData(PluginSettings settings) { + SceneViewSettings sceneViewSettings = settings.Get(); this.isLoading = true; if (this.sceneView != null) { - foreach (XElement sceneViewElem in node.Elements("SceneView")) - { - int i = sceneViewElem.GetAttributeValue("id", 0); - if (i < 0 || i >= 1) continue; - - this.sceneView.LoadUserData(sceneViewElem); - } + this.sceneView.UserSettings = sceneViewSettings; + this.sceneView.ApplyUserSettings(); } this.isLoading = false; } diff --git a/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs b/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs new file mode 100644 index 000000000..56e9a3376 --- /dev/null +++ b/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs @@ -0,0 +1,16 @@ +namespace Duality.Editor.Plugins.SceneView +{ + public class SceneViewSettings + { + private bool showComponents = true; + + /// + /// Controls whether components are shown as individual nodes in the scene tree + /// + public bool ShowComponents + { + get { return this.showComponents; } + set { this.showComponents = value; } + } + } +} \ No newline at end of file