Nodes - Ensure models using scripts always have a script

This commit is contained in:
Robert committed 2021-08-19 16:13:37 +02:00
1 parent b8077ca589
commit 05d8222991
7 files changed
+78 -56

No files matched your search

@@ -17,9 +17,10 @@ namespace Artemis.Core
{
LayerProperty = dataBindingRegistration.LayerProperty;
Entity = new DataBindingEntity();
Script = new NodeScript<TProperty>(LayerProperty.PropertyDescription.Name ?? LayerProperty.Path, "");
ApplyRegistration(dataBindingRegistration);
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding");
Save();
}
@@ -27,7 +28,7 @@ namespace Artemis.Core
{
LayerProperty = layerProperty;
Entity = entity;
Script = new NodeScript<TProperty>(LayerProperty.PropertyDescription.Name ?? LayerProperty.Path, "");
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding");
// Load will add children so be initialized before that
Load();
@@ -116,8 +117,7 @@ namespace Artemis.Core
if (Registration != null)
Registration.DataBinding = null;
Script?.Dispose();
Script = null;
Script.Dispose();
}
}
@@ -213,6 +213,13 @@ namespace Artemis.Core
_reapplyValue = true;
}
private string GetScriptName()
{
if (LayerProperty.GetAllDataBindingRegistrations().Count == 1)
return LayerProperty.PropertyDescription.Name ?? LayerProperty.Path;
return $"{LayerProperty.PropertyDescription.Name ?? LayerProperty.Path} - {Registration?.DisplayName}";
}
/// <inheritdoc />
public void Dispose()
{
@@ -238,8 +245,8 @@ namespace Artemis.Core
Script.Dispose();
Script = Entity.NodeScript != null
? new NodeScript<TProperty>(Entity.NodeScript)
: new NodeScript<TProperty>(LayerProperty.PropertyDescription.Name ?? LayerProperty.Path, "");
? new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", Entity.NodeScript)
: new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding");
}
/// <inheritdoc />
@@ -18,13 +18,17 @@ namespace Artemis.Core
{
private SKRectI _bounds;
private SKPath? _path;
private readonly string _typeDisplayName;
internal RenderProfileElement(Profile profile) : base(profile)
{
_typeDisplayName = this is Layer ? "layer" : "folder";
_displayCondition = new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active");
Timeline = new Timeline();
ExpandedPropertyGroups = new List<string>();
LayerEffectsList = new List<BaseLayerEffect>();
LayerEffectStore.LayerEffectAdded += LayerEffectStoreOnLayerEffectAdded;
LayerEffectStore.LayerEffectRemoved += LayerEffectStoreOnLayerEffectRemoved;
}
@@ -59,15 +63,17 @@ namespace Artemis.Core
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
baseLayerEffect.Dispose();
DisplayCondition?.Dispose();
DisplayCondition.Dispose();
base.Dispose(disposing);
}
internal void LoadRenderElement()
{
DisplayCondition = RenderElementEntity.NodeScript != null ? new NodeScript<bool>(RenderElementEntity.NodeScript) : null;
DisplayCondition = RenderElementEntity.NodeScript != null
? new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", RenderElementEntity.NodeScript)
: new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active");
Timeline = RenderElementEntity.Timeline != null
? new Timeline(RenderElementEntity.Timeline)
: new Timeline();
@@ -354,14 +360,15 @@ namespace Artemis.Core
protected set => SetAndNotify(ref _displayConditionMet, value);
}
private NodeScript<bool>? _displayCondition;
private NodeScript<bool> _displayCondition;
private bool _displayConditionMet;
private bool _toggledOnByEvent = false;
/// <summary>
/// Gets or sets the root display condition group
/// </summary>
public NodeScript<bool>? DisplayCondition
public NodeScript<bool> DisplayCondition
{
get => _displayCondition;
set => SetAndNotify(ref _displayCondition, value);
@@ -378,7 +385,7 @@ namespace Artemis.Core
return;
}
if (DisplayCondition == null)
if (!DisplayCondition.HasNodes)
{
DisplayConditionMet = true;
return;