From b506227b5962205c1060e5133d00a37cbe3d35dd Mon Sep 17 00:00:00 2001 From: Rick van Dam Date: Mon, 13 Jul 2020 19:47:27 +0200 Subject: [PATCH 1/4] update sceneViewsettings --- .../SceneView/Modules/SceneView.cs | 14 +++-------- .../SceneView/SceneViewPlugin.cs | 25 +++++-------------- .../SceneView/SceneViewSettings.cs | 13 ++++++++++ 3 files changed, 23 insertions(+), 29 deletions(-) create mode 100644 Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs diff --git a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs index 56bbb0f21..74f64eeb1 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; @@ -172,16 +169,13 @@ protected override void OnClosed(EventArgs e) Scene.ComponentRemoving -= this.Scene_ComponentRemoving; } - internal void SaveUserData(XElement node) + internal void SaveUserData(SceneViewSettings sceneViewSettings) { - node.SetElementValue("ShowComponents", this.buttonShowComponents.Checked); + sceneViewSettings.ShowComponents = this.buttonShowComponents.Checked; } - internal void LoadUserData(XElement node) + internal void LoadUserData(SceneViewSettings sceneViewSettings) { - bool tryParseBool; - - if (node.GetElementValue("ShowComponents", out tryParseBool)) - this.buttonShowComponents.Checked = tryParseBool; + this.buttonShowComponents.Checked = sceneViewSettings.ShowComponents; } public void FlashNode(NodeBase node) diff --git a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs index 366504d48..2a3e4ea9e 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) { + SceneViewSettings sceneViewSettings = settings.GetSettings(); if (this.sceneView != null) { - XElement sceneViewElem = new XElement("SceneView"); - this.sceneView.SaveUserData(sceneViewElem); - if (!sceneViewElem.IsEmpty) - node.Add(sceneViewElem); + this.sceneView.SaveUserData(sceneViewSettings); } } - protected override void LoadUserData(XElement node) + protected override void LoadUserData(PluginSettings settings) { + SceneViewSettings sceneViewSettings = settings.GetSettings(); 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.LoadUserData(sceneViewSettings); } 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..f3987669f --- /dev/null +++ b/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs @@ -0,0 +1,13 @@ +namespace Duality.Editor.Plugins.SceneView +{ + public class SceneViewSettings + { + private bool showComponents = true; + + public bool ShowComponents + { + get { return this.showComponents; } + set { this.showComponents = value; } + } + } +} \ No newline at end of file From 5263981f7cf0c9ee278be4fb0b2fc60689f57158 Mon Sep 17 00:00:00 2001 From: Rick van Dam Date: Mon, 27 Jul 2020 20:41:00 +0200 Subject: [PATCH 2/4] fix build error --- Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs index 2a3e4ea9e..d7aa984db 100644 --- a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs +++ b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs @@ -38,7 +38,7 @@ protected override IDockContent DeserializeDockContent(Type dockContentType) } protected override void SaveUserData(PluginSettings settings) { - SceneViewSettings sceneViewSettings = settings.GetSettings(); + SceneViewSettings sceneViewSettings = settings.Get(); if (this.sceneView != null) { this.sceneView.SaveUserData(sceneViewSettings); @@ -46,7 +46,7 @@ protected override void SaveUserData(PluginSettings settings) } protected override void LoadUserData(PluginSettings settings) { - SceneViewSettings sceneViewSettings = settings.GetSettings(); + SceneViewSettings sceneViewSettings = settings.Get(); this.isLoading = true; if (this.sceneView != null) { From 02867a17f54702229d207d5262ede15e7e74177f Mon Sep 17 00:00:00 2001 From: Rick van Dam Date: Mon, 27 Jul 2020 20:51:21 +0200 Subject: [PATCH 3/4] updated sceneview settings code --- .../SceneView/Modules/SceneView.cs | 19 ++++++++++++------- .../SceneView/SceneViewPlugin.cs | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs index 74f64eeb1..b510a6dce 100644 --- a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs +++ b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs @@ -74,6 +74,14 @@ 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 @@ -168,14 +176,10 @@ protected override void OnClosed(EventArgs e) Scene.ComponentAdded -= this.Scene_ComponentAdded; Scene.ComponentRemoving -= this.Scene_ComponentRemoving; } - - internal void SaveUserData(SceneViewSettings sceneViewSettings) - { - sceneViewSettings.ShowComponents = this.buttonShowComponents.Checked; - } - internal void LoadUserData(SceneViewSettings sceneViewSettings) + + internal void ApplyUserSettings() { - this.buttonShowComponents.Checked = sceneViewSettings.ShowComponents; + this.buttonShowComponents.Checked = this.userSettings.ShowComponents; } public void FlashNode(NodeBase node) @@ -1806,6 +1810,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 d7aa984db..dcb919675 100644 --- a/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs +++ b/Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs @@ -38,10 +38,9 @@ protected override IDockContent DeserializeDockContent(Type dockContentType) } protected override void SaveUserData(PluginSettings settings) { - SceneViewSettings sceneViewSettings = settings.Get(); if (this.sceneView != null) { - this.sceneView.SaveUserData(sceneViewSettings); + settings.Set(this.sceneView.UserSettings); } } protected override void LoadUserData(PluginSettings settings) @@ -50,7 +49,8 @@ protected override void LoadUserData(PluginSettings settings) this.isLoading = true; if (this.sceneView != null) { - this.sceneView.LoadUserData(sceneViewSettings); + this.sceneView.UserSettings = sceneViewSettings; + this.sceneView.ApplyUserSettings(); } this.isLoading = false; } From f36867874c2b538966bcf27b98c8794814119104 Mon Sep 17 00:00:00 2001 From: Rick van Dam Date: Wed, 5 Aug 2020 20:26:15 +0200 Subject: [PATCH 4/4] PR comments --- Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs | 5 +++-- Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs index b510a6dce..811613425 100644 --- a/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs +++ b/Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs @@ -74,6 +74,7 @@ private class CreateContextEntryTag private MenuModelItem nodeContextItemCopy = null; private MenuModelItem nodeContextItemPaste = null; + private SceneViewSettings userSettings = new SceneViewSettings(); public SceneViewSettings UserSettings @@ -111,8 +112,7 @@ where c.Tag is GameObjectNode select c.Tag as GameObjectNode; } } - - + public SceneView() { this.InitializeComponent(); @@ -177,6 +177,7 @@ protected override void OnClosed(EventArgs e) Scene.ComponentRemoving -= this.Scene_ComponentRemoving; } + internal void ApplyUserSettings() { this.buttonShowComponents.Checked = this.userSettings.ShowComponents; diff --git a/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs b/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs index f3987669f..56e9a3376 100644 --- a/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs +++ b/Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs @@ -4,6 +4,9 @@ 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; }