Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update sceneViewsettings #870

Merged
merged 4 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions Source/Plugins/EditorModules/SceneView/Modules/SceneView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -77,6 +74,14 @@ private class CreateContextEntryTag
private MenuModelItem nodeContextItemCopy = null;
private MenuModelItem nodeContextItemPaste = null;

private SceneViewSettings userSettings = new SceneViewSettings();
Barsonax marked this conversation as resolved.
Show resolved Hide resolved

public SceneViewSettings UserSettings
{
get { return this.userSettings; }
set { this.userSettings = value; }
}

Barsonax marked this conversation as resolved.
Show resolved Hide resolved
public IEnumerable<NodeBase> SelectedNodes
{
get
Expand Down Expand Up @@ -171,17 +176,10 @@ 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)

Barsonax marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down Expand Up @@ -1812,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<object> expandedMap = new HashSet<object>();
this.objectView.SaveNodesExpanded(this.objectView.Root, expandedMap, this.NodeIdFuncCoreObject);
Expand Down
25 changes: 6 additions & 19 deletions Source/Plugins/EditorModules/SceneView/SceneViewPlugin.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<SceneViewSettings>();
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;
}
Expand Down
13 changes: 13 additions & 0 deletions Source/Plugins/EditorModules/SceneView/SceneViewSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Duality.Editor.Plugins.SceneView
{
public class SceneViewSettings
{
private bool showComponents = true;

public bool ShowComponents
Barsonax marked this conversation as resolved.
Show resolved Hide resolved
{
get { return this.showComponents; }
set { this.showComponents = value; }
}
}
}