Nodes - Provide scripts with a context

Nodes - Inform nodes about the script they're being initialized for
Nodes - Added float nodes matching the existing other number types
Core - Add API for retrieving data binding values via the interface
This commit is contained in:
Robert committed 2021-08-21 12:15:01 +02:00
1 parent 3ed3cd1b1e
commit 836e979991
26 files changed
+305 -122

No files matched your search

@@ -19,7 +19,7 @@ namespace Artemis.Core
Entity = new DataBindingEntity();
ApplyRegistration(dataBindingRegistration);
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding");
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", LayerProperty.ProfileElement.Profile);
Save();
}
@@ -28,7 +28,7 @@ namespace Artemis.Core
{
LayerProperty = layerProperty;
Entity = entity;
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding");
Script = new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", LayerProperty.ProfileElement.Profile);
// Load will add children so be initialized before that
Load();
@@ -245,8 +245,8 @@ namespace Artemis.Core
Script.Dispose();
Script = Entity.NodeScript != null
? 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");
? new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", Entity.NodeScript, LayerProperty.ProfileElement.Profile)
: new NodeScript<TProperty>(GetScriptName(), "The value to put into the data binding", LayerProperty.ProfileElement.Profile);
}
/// <inheritdoc />
@@ -40,6 +40,9 @@ namespace Artemis.Core
/// <inheritdoc />
public string DisplayName { get; }
/// <inheritdoc />
public Type ValueType => typeof(TProperty);
/// <summary>
/// Gets the data binding created using this registration
/// </summary>
@@ -74,5 +77,11 @@ namespace Artemis.Core
// The related entity is left behind, just in case the data binding is added back later
LayerProperty.DisableDataBinding(DataBinding);
}
/// <inheritdoc />
public object? GetValue()
{
return Getter();
}
}
}
@@ -1,4 +1,6 @@
namespace Artemis.Core
using System;
namespace Artemis.Core
{
/// <summary>
/// Represents a data binding registration
@@ -10,6 +12,11 @@
/// </summary>
string DisplayName { get; }
/// <summary>
/// Gets the type of the value this data binding registration points to
/// </summary>
Type ValueType { get; }
/// <summary>
/// Returns the data binding applied using this registration
/// </summary>
@@ -25,5 +32,11 @@
/// If present, removes the current data binding
/// </summary>
void ClearDataBinding();
/// <summary>
/// Gets the value of the data binding
/// </summary>
/// <returns>A value matching the type of <see cref="ValueType" /></returns>
object? GetValue();
}
}
@@ -23,7 +23,7 @@ namespace Artemis.Core
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");
_displayCondition = new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", Profile);
Timeline = new Timeline();
ExpandedPropertyGroups = new List<string>();
@@ -71,8 +71,8 @@ namespace Artemis.Core
internal void LoadRenderElement()
{
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");
? new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", RenderElementEntity.NodeScript, Profile)
: new NodeScript<bool>($"Activate {_typeDisplayName}", $"Whether or not this {_typeDisplayName} should be active", Profile);
Timeline = RenderElementEntity.Timeline != null
? new Timeline(RenderElementEntity.Timeline)