UI - Restructured layer property VMs

This commit is contained in:
Robert committed 2020-05-01 23:07:21 +02:00
1 parent 41b3c77210
commit 54081b591b
11 files changed
+163 -234

No files matched your search

+5 -5
View File
@@ -125,7 +125,7 @@ namespace Artemis.Core.Models.Profile
General.ApplyToEntity();
Transform.ApplyToEntity();
LayerBrush.ApplyToEntity();
LayerBrush.BaseProperties.ApplyToEntity();
// LEDs
LayerEntity.Leds.Clear();
@@ -187,7 +187,7 @@ namespace Artemis.Core.Models.Profile
var properties = new List<BaseLayerProperty>(General.GetAllLayerProperties());
properties.AddRange(Transform.GetAllLayerProperties());
properties.AddRange(LayerBrush.GetAllLayerProperties());
properties.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties());
// For now, reset all keyframe engines after the last keyframe was hit
// This is a placeholder method of repeating the animation until repeat modes are implemented
@@ -196,13 +196,13 @@ namespace Artemis.Core.Models.Profile
{
General.Override(TimeSpan.Zero);
Transform.Override(TimeSpan.Zero);
LayerBrush.OverrideProperties(TimeSpan.Zero);
LayerBrush.BaseProperties.Override(TimeSpan.Zero);
}
else
{
General.Update(deltaTime);
Transform.Update(deltaTime);
LayerBrush.UpdateProperties(deltaTime);
LayerBrush.BaseProperties.Update(deltaTime);
}
LayerBrush.Update(deltaTime);
@@ -212,7 +212,7 @@ namespace Artemis.Core.Models.Profile
{
General.Override(timeOverride);
Transform.Override(timeOverride);
LayerBrush.OverrideProperties(timeOverride);
LayerBrush.BaseProperties.Override(timeOverride);
}
/// <inheritdoc />
@@ -5,7 +5,7 @@ using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties
{
/// <summary>
/// For internal use only, to implement your own layer property type, extend <see cref="LayerProperty{T}"/> instead.
/// For internal use only, to implement your own layer property type, extend <see cref="LayerProperty{T}" /> instead.
/// </summary>
public abstract class BaseLayerProperty
{
@@ -42,11 +42,15 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// <summary>
/// Used to declare that this property doesn't belong to a plugin and should use the core plugin GUID
/// </summary>
internal bool IsCoreProperty { get; set; }
public bool IsCoreProperty { get; internal set; }
/// <summary>
/// Gets a list of all the keyframes in their non-generic base form, without their values being available
/// </summary>
public abstract IReadOnlyList<BaseLayerPropertyKeyframe> BaseKeyframes { get; }
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
internal abstract IReadOnlyList<BaseLayerPropertyKeyframe> BaseKeyframes { get; }
/// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@@ -70,7 +70,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
public LayerPropertyKeyframe<T> NextKeyframe { get; protected set; }
internal override IReadOnlyList<BaseLayerPropertyKeyframe> BaseKeyframes => _keyframes.Cast<BaseLayerPropertyKeyframe>().ToList().AsReadOnly();
public override IReadOnlyList<BaseLayerPropertyKeyframe> BaseKeyframes => _keyframes.Cast<BaseLayerPropertyKeyframe>().ToList().AsReadOnly();
/// <summary>
/// Adds a keyframe to the layer property
@@ -14,29 +14,34 @@ namespace Artemis.Core.Models.Profile
public class LayerPropertyGroup
{
private ReadOnlyCollection<BaseLayerProperty> _allLayerProperties;
private readonly List<BaseLayerProperty> _layerProperties;
private readonly List<LayerPropertyGroup> _layerPropertyGroups;
protected LayerPropertyGroup()
{
LayerProperties = new List<BaseLayerProperty>();
LayerPropertyGroups = new List<LayerPropertyGroup>();
_layerProperties = new List<BaseLayerProperty>();
_layerPropertyGroups = new List<LayerPropertyGroup>();
}
/// <summary>
/// Gets whether this property group's properties are all initialized
/// </summary>
public bool PropertiesInitialized { get; private set; }
/// <summary>
/// Used to declare that this property group doesn't belong to a plugin and should use the core plugin GUID
/// </summary>
internal bool IsCorePropertyGroup { get; set; }
public bool IsCorePropertyGroup { get; internal set; }
/// <summary>
/// A list of all layer properties in this group
/// </summary>
internal List<BaseLayerProperty> LayerProperties { get; set; }
public ReadOnlyCollection<BaseLayerProperty> LayerProperties => _layerProperties.AsReadOnly();
/// <summary>
/// A list of al child groups in this group
/// </summary>
internal List<LayerPropertyGroup> LayerPropertyGroups { get; set; }
public ReadOnlyCollection<LayerPropertyGroup> LayerPropertyGroups => _layerPropertyGroups.AsReadOnly();
/// <summary>
/// Called when all layer properties in this property group have been initialized
@@ -63,7 +68,7 @@ namespace Artemis.Core.Models.Profile
var instance = (BaseLayerProperty) Activator.CreateInstance(propertyInfo.PropertyType);
InitializeProperty(layer, path, instance);
propertyInfo.SetValue(this, instance);
LayerProperties.Add(instance);
_layerProperties.Add(instance);
}
else
{
@@ -76,7 +81,7 @@ namespace Artemis.Core.Models.Profile
var instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType);
instance.InitializeProperties(layerService, layer, $"{path}{propertyInfo.Name}.");
propertyInfo.SetValue(this, instance);
LayerPropertyGroups.Add(instance);
_layerPropertyGroups.Add(instance);
}
}
}
@@ -121,7 +126,7 @@ namespace Artemis.Core.Models.Profile
/// Recursively gets all layer properties on this group and any subgroups
/// </summary>
/// <returns></returns>
internal IReadOnlyCollection<BaseLayerProperty> GetAllLayerProperties()
public IReadOnlyCollection<BaseLayerProperty> GetAllLayerProperties()
{
if (!PropertiesInitialized)
return new List<BaseLayerProperty>();