Scripting - Enabled scripting (#638)

* Scripting - Simplified view model structure
* Scripting - Removed Layer and LayerProperty scripts
This commit is contained in:
Robert Beekman authored and GitHub committed 2021-07-04 11:45:32 +02:00
1 parent ee16d69fb3
commit 631d8de2c3
26 files changed
+278 -578

No files matched your search

+3 -44
View File
@@ -38,8 +38,6 @@ namespace Artemis.Core
Profile = Parent.Profile;
Name = name;
Suspended = false;
Scripts = new List<LayerScript>();
ScriptConfigurations = new List<ScriptConfiguration>();
_general = new LayerGeneralProperties();
_transform = new LayerTransformProperties();
@@ -64,8 +62,6 @@ namespace Artemis.Core
Profile = profile;
Parent = parent;
Scripts = new List<LayerScript>();
ScriptConfigurations = new List<ScriptConfiguration>();
_general = new LayerGeneralProperties();
_transform = new LayerTransformProperties();
@@ -82,16 +78,6 @@ namespace Artemis.Core
/// </summary>
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
/// <summary>
/// Gets a collection of all active scripts assigned to this layer
/// </summary>
public List<LayerScript> Scripts { get; }
/// <summary>
/// Gets a collection of all script configurations assigned to this layer
/// </summary>
public List<ScriptConfiguration> ScriptConfigurations { get; }
/// <summary>
/// Defines the shape that is rendered by the <see cref="LayerBrush" />.
/// </summary>
@@ -190,9 +176,6 @@ namespace Artemis.Core
Disposed = true;
while (Scripts.Count > 1)
Scripts[0].Dispose();
LayerBrushStore.LayerBrushAdded -= LayerBrushStoreOnLayerBrushAdded;
LayerBrushStore.LayerBrushRemoved -= LayerBrushStoreOnLayerBrushRemoved;
@@ -269,11 +252,6 @@ namespace Artemis.Core
ExpandedPropertyGroups.AddRange(LayerEntity.ExpandedPropertyGroups);
LoadRenderElement();
Adapter.Load();
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
scriptConfiguration.Script?.Dispose();
ScriptConfigurations.Clear();
ScriptConfigurations.AddRange(LayerEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
}
internal override void Save()
@@ -310,14 +288,7 @@ namespace Artemis.Core
// Adaption hints
Adapter.Save();
LayerEntity.ScriptConfigurations.Clear();
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
{
scriptConfiguration.Save();
LayerEntity.ScriptConfigurations.Add(scriptConfiguration.Entity);
}
SaveRenderElement();
}
@@ -349,10 +320,7 @@ namespace Artemis.Core
{
if (Disposed)
throw new ObjectDisposedException("Layer");
foreach (LayerScript layerScript in Scripts)
layerScript.OnLayerUpdating(deltaTime);
UpdateDisplayCondition();
UpdateTimeline(deltaTime);
@@ -360,9 +328,6 @@ namespace Artemis.Core
Enable();
else if (Timeline.IsFinished)
Disable();
foreach (LayerScript layerScript in Scripts)
layerScript.OnLayerUpdated(deltaTime);
}
/// <inheritdoc />
@@ -512,10 +477,7 @@ namespace Artemis.Core
{
if (LayerBrush == null)
throw new ArtemisCoreException("The layer is not yet ready for rendering");
foreach (LayerScript layerScript in Scripts)
layerScript.OnLayerRendering(canvas, bounds, layerPaint);
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
baseLayerEffect.PreProcess(canvas, bounds, layerPaint);
@@ -531,9 +493,6 @@ namespace Artemis.Core
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
baseLayerEffect.PostProcess(canvas, bounds, layerPaint);
foreach (LayerScript layerScript in Scripts)
layerScript.OnLayerRendered(canvas, bounds, layerPaint);
}
finally
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Core.ScriptingProviders;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core
@@ -24,16 +23,6 @@ namespace Artemis.Core
/// </summary>
LayerPropertyGroup LayerPropertyGroup { get; }
/// <summary>
/// Gets a collection of all active scripts assigned to this layer property
/// </summary>
List<PropertyScript> Scripts { get; }
/// <summary>
/// Gets a collection of all script configurations assigned to this layer property
/// </summary>
public List<ScriptConfiguration> ScriptConfigurations { get; }
/// <summary>
/// Gets the unique path of the property on the layer
/// </summary>
@@ -81,8 +70,6 @@ namespace Artemis.Core
/// <param name="timeline">The timeline to apply to the property</param>
void Update(Timeline timeline);
#region Events
/// <summary>
/// Occurs when the layer property is disposed
/// </summary>
@@ -137,7 +124,5 @@ namespace Artemis.Core
/// Occurs when a data binding has been disabled
/// </summary>
public event EventHandler<LayerPropertyEventArgs>? DataBindingDisabled;
#endregion
}
}
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core.ScriptingProviders;
using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json;
@@ -31,8 +30,6 @@ namespace Artemis.Core
Path = null!;
Entity = null!;
PropertyDescription = null!;
Scripts = new List<PropertyScript>();
ScriptConfigurations = new List<ScriptConfiguration>();
CurrentValue = default!;
DefaultValue = default!;
@@ -60,9 +57,6 @@ namespace Artemis.Core
{
_disposed = true;
while (Scripts.Count > 1)
Scripts[0].Dispose();
foreach (IDataBinding dataBinding in _dataBindings)
dataBinding.Dispose();
@@ -153,12 +147,6 @@ namespace Artemis.Core
/// <inheritdoc />
public PropertyDescriptionAttribute PropertyDescription { get; internal set; }
/// <inheritdoc />
public List<PropertyScript> Scripts { get; }
/// <inheritdoc />
public List<ScriptConfiguration> ScriptConfigurations { get; }
/// <inheritdoc />
public string Path { get; private set; }
@@ -171,18 +159,12 @@ namespace Artemis.Core
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
foreach (PropertyScript propertyScript in Scripts)
propertyScript.OnPropertyUpdating(timeline.Delta.TotalSeconds);
CurrentValue = BaseValue;
UpdateKeyframes(timeline);
UpdateDataBindings(timeline);
OnUpdated();
foreach (PropertyScript propertyScript in Scripts)
propertyScript.OnPropertyUpdated(timeline.Delta.TotalSeconds);
}
/// <inheritdoc />
@@ -762,11 +744,6 @@ namespace Artemis.Core
if (dataBinding != null)
_dataBindings.Add(dataBinding);
}
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
scriptConfiguration.Script?.Dispose();
ScriptConfigurations.Clear();
ScriptConfigurations.AddRange(Entity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
}
/// <summary>
@@ -788,13 +765,6 @@ namespace Artemis.Core
Entity.DataBindingEntities.Clear();
foreach (IDataBinding dataBinding in _dataBindings)
dataBinding.Save();
Entity.ScriptConfigurations.Clear();
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
{
scriptConfiguration.Save();
Entity.ScriptConfigurations.Add(scriptConfiguration.Entity);
}
}
/// <summary>