Meta - Code cleanup

This commit is contained in:
SpoinkyNL committed 2020-06-13 22:27:51 +02:00
1 parent b2ab142dbd
commit 58a964b872
105 files changed
+3097 -2624

No files matched your search

@@ -10,15 +10,15 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
public abstract class BaseLayerProperty
{
private bool _keyframesEnabled;
private bool _isHidden;
private bool _keyframesEnabled;
internal BaseLayerProperty()
{
}
/// <summary>
/// The layer this property applies to
/// The layer this property applies to
/// </summary>
public Layer Layer { get; internal set; }
@@ -84,7 +84,9 @@ namespace Artemis.Core.Models.Profile.LayerProperties
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
public abstract void ApplyDefaultValue();
/// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@@ -113,12 +115,12 @@ namespace Artemis.Core.Models.Profile.LayerProperties
public event EventHandler BaseValueChanged;
/// <summary>
/// Occurs when the <see cref="IsHidden"/> value of the layer property was updated
/// Occurs when the <see cref="IsHidden" /> value of the layer property was updated
/// </summary>
public event EventHandler VisibilityChanged;
/// <summary>
/// Occurs when keyframes are enabled/disabled
/// Occurs when keyframes are enabled/disabled
/// </summary>
public event EventHandler KeyframesToggled;
@@ -163,9 +165,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}
#endregion
public abstract void ApplyDefaultValue();
}
}
@@ -56,7 +56,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}
/// <summary>
/// Gets or sets the default value of this layer property. If set, this value is automatically applied if the property has no
/// Gets or sets the default value of this layer property. If set, this value is automatically applied if the property
/// has no
/// value in storage
/// </summary>
public T DefaultValue { get; set; }
@@ -166,6 +167,12 @@ namespace Artemis.Core.Models.Profile.LayerProperties
RemoveKeyframe(layerPropertyKeyframe);
}
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
/// <summary>
/// Called every update (if keyframes are both supported and enabled) to determine the new <see cref="CurrentValue" />
/// based on the provided progress
@@ -284,11 +291,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
EasingFunction = (int) k.EasingFunction
}));
}
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
}
}
@@ -12,6 +12,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false;
}
public static implicit operator ColorGradient(ColorGradientLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new ArtemisCoreException("Color Gradients do not support keyframes.");
@@ -24,7 +29,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
// Don't allow color gradients to be null
BaseValue ??= DefaultValue ?? new ColorGradient();
}
public static implicit operator ColorGradient(ColorGradientLayerProperty p) => p.CurrentValue;
}
}
@@ -11,12 +11,19 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false;
}
public static implicit operator T(EnumLayerProperty<T> p)
{
return p.CurrentValue;
}
public static implicit operator int(EnumLayerProperty<T> p)
{
return Convert.ToInt32(p.CurrentValue);
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new ArtemisCoreException("Enum properties do not support keyframes.");
}
public static implicit operator T(EnumLayerProperty<T> p) => p.CurrentValue;
public static implicit operator int(EnumLayerProperty<T> p) => Convert.ToInt32(p.CurrentValue);
}
}
@@ -1,19 +1,26 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class FloatLayerProperty : LayerProperty<float>
{
internal FloatLayerProperty()
{
}
public static implicit operator float(FloatLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator double(FloatLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
CurrentValue = CurrentKeyframe.Value + diff * keyframeProgressEased;
}
public static implicit operator float(FloatLayerProperty p) => p.CurrentValue;
public static implicit operator double(FloatLayerProperty p) => p.CurrentValue;
}
}
@@ -2,21 +2,32 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class IntLayerProperty : LayerProperty<int>
{
internal IntLayerProperty()
{
}
public static implicit operator int(IntLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator float(IntLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator double(IntLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
CurrentValue = (int) Math.Round(CurrentKeyframe.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero);
}
public static implicit operator int(IntLayerProperty p) => p.CurrentValue;
public static implicit operator float(IntLayerProperty p) => p.CurrentValue;
public static implicit operator double(IntLayerProperty p) => p.CurrentValue;
}
}
@@ -3,7 +3,7 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <summary>
/// A special layer property used to configure the selected layer brush
/// A special layer property used to configure the selected layer brush
/// </summary>
public class LayerBrushReferenceLayerProperty : LayerProperty<LayerBrushReference>
{
@@ -12,11 +12,14 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false;
}
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new ArtemisCoreException("Layer brush references do not support keyframes.");
}
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p) => p.CurrentValue;
}
}
@@ -3,13 +3,18 @@ using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKColorLayerProperty : LayerProperty<SKColor>
{
internal SKColorLayerProperty()
{
}
public static implicit operator SKColor(SKColorLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var redDiff = NextKeyframe.Value.Red - CurrentKeyframe.Value.Red;
@@ -29,7 +34,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
return (byte) Math.Max(0, Math.Min(255, value));
}
public static implicit operator SKColor(SKColorLayerProperty p) => p.CurrentValue;
}
}
@@ -2,20 +2,23 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKPointLayerProperty : LayerProperty<SKPoint>
{
internal SKPointLayerProperty()
{
}
public static implicit operator SKPoint(SKPointLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X;
var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y;
CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased);
}
public static implicit operator SKPoint(SKPointLayerProperty p) => p.CurrentValue;
}
}
@@ -2,20 +2,23 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKSizeLayerProperty : LayerProperty<SKSize>
{
internal SKSizeLayerProperty()
{
}
public static implicit operator SKSize(SKSizeLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width;
var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height;
CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased);
}
public static implicit operator SKSize(SKSizeLayerProperty p) => p.CurrentValue;
}
}