Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeekman committed Mar 3, 2024
2 parents 554f3e1 + 9132301 commit 9fcd20d
Show file tree
Hide file tree
Showing 60 changed files with 525 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Build DocFX
run: docfx docfx/docfx_project/docfx.json
- name: Upload to FTP
uses: SamKirkland/FTP-Deploy-Action@4.3.4
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: www360.your-server.de
protocol: ftps
Expand Down
3 changes: 3 additions & 0 deletions src/Artemis.Core/Models/BreakableModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public bool TryOrBreak(Action action, string breakMessage)
/// <inheritdoc />
public void SetBrokenState(string state, Exception? exception = null)
{
if (state == BrokenState && BrokenStateException?.StackTrace == exception?.StackTrace)
return;

BrokenState = state ?? throw new ArgumentNullException(nameof(state));
BrokenStateException = exception;
OnBrokenStateChanged();
Expand Down
15 changes: 15 additions & 0 deletions src/Artemis.Core/Models/IPluginFeatureDependent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;

namespace Artemis.Core;

/// <summary>
/// Represents a class that depends on plugin features
/// </summary>
public interface IPluginFeatureDependent
{
/// <summary>
/// Gets the plugin features this class depends on, may contain the same plugin feature twice if depending on it in multiple ways.
/// </summary>
/// <returns>A <see cref="List{T}"/> of <see cref="PluginFeature"/> this class depends on.</returns>
public IEnumerable<PluginFeature> GetFeatureDependencies();
}
11 changes: 11 additions & 0 deletions src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;

Expand Down Expand Up @@ -82,4 +83,14 @@ public void OverrideTimeline(TimeSpan position)
}

#endregion

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return [];
}

#endregion
}
10 changes: 10 additions & 0 deletions src/Artemis.Core/Models/Profile/Conditions/EventCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,14 @@ public void LoadNodeScript()
}

#endregion

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return Script.GetFeatureDependencies().Concat(EventPath?.GetFeatureDependencies() ?? []);
}

#endregion
}
2 changes: 1 addition & 1 deletion src/Artemis.Core/Models/Profile/Conditions/ICondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Artemis.Core;
/// <summary>
/// Represents a condition applied to a <see cref="ProfileElement" />
/// </summary>
public interface ICondition : IDisposable, IStorageModel
public interface ICondition : IDisposable, IStorageModel, IPluginFeatureDependent
{
/// <summary>
/// Gets the entity used to store this condition
Expand Down
11 changes: 11 additions & 0 deletions src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;

Expand Down Expand Up @@ -82,4 +83,14 @@ public void OverrideTimeline(TimeSpan position)
}

#endregion

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return [];
}

#endregion
}
11 changes: 11 additions & 0 deletions src/Artemis.Core/Models/Profile/Conditions/StaticCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
Expand Down Expand Up @@ -159,6 +160,16 @@ public void LoadNodeScript()
}

#endregion

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return Script.GetFeatureDependencies();
}

#endregion
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,14 @@ public void Save()
}

#endregion

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return Script.GetFeatureDependencies();
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Artemis.Core;
/// Represents a data binding that binds a certain <see cref="LayerProperty{T}" /> to a value inside a
/// <see cref="DataModel" />
/// </summary>
public interface IDataBinding : IStorageModel, IDisposable
public interface IDataBinding : IStorageModel, IDisposable, IPluginFeatureDependent
{
/// <summary>
/// Gets the layer property the data binding is applied to
Expand Down
10 changes: 9 additions & 1 deletion src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Artemis.Core;
/// <summary>
/// Represents a path that points to a property in data model
/// </summary>
public class DataModelPath : IStorageModel, IDisposable
public class DataModelPath : IStorageModel, IDisposable, IPluginFeatureDependent
{
private readonly LinkedList<DataModelPathSegment> _segments;
private Expression<Func<object, object>>? _accessorLambda;
Expand Down Expand Up @@ -188,6 +188,14 @@ public override string ToString()
return string.IsNullOrWhiteSpace(Path) ? "this" : Path;
}

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
if (Target == null)
return [];
return [Target.Module];
}

/// <summary>
/// Occurs whenever the path becomes invalid
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions src/Artemis.Core/Models/Profile/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ public override string ToString()
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
}

/// <inheritdoc />
public override IEnumerable<PluginFeature> GetFeatureDependencies()
{
return LayerEffects.SelectMany(e => e.GetFeatureDependencies())
.Concat(Children.SelectMany(c => c.GetFeatureDependencies()))
.Concat(DisplayCondition.GetFeatureDependencies());
}

#region Rendering

/// <inheritdoc />
Expand Down
18 changes: 15 additions & 3 deletions src/Artemis.Core/Models/Profile/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ public BaseLayerBrush? LayerBrush
public LayerAdapter Adapter { get; }

/// <inheritdoc />
public override bool ShouldBeEnabled => !Suspended && DisplayConditionMet;
public override bool ShouldBeEnabled => !Suspended && DisplayConditionMet && HasBounds;

internal override RenderElementEntity RenderElementEntity => LayerEntity;

private bool HasBounds => Bounds.Width > 0 && Bounds.Height > 0;

/// <inheritdoc />
public override List<ILayerProperty> GetAllLayerProperties()
{
Expand All @@ -187,6 +189,16 @@ public override string ToString()
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
}

/// <inheritdoc />
public override IEnumerable<PluginFeature> GetFeatureDependencies()
{
return LayerEffects.SelectMany(e => e.GetFeatureDependencies())
.Concat(LayerBrush?.GetFeatureDependencies() ?? [])
.Concat(General.GetFeatureDependencies())
.Concat(Transform.GetFeatureDependencies())
.Concat(DisplayCondition.GetFeatureDependencies());
}

/// <summary>
/// Occurs when a property affecting the rendering properties of this layer has been updated
/// </summary>
Expand Down Expand Up @@ -383,7 +395,7 @@ public override void Update(double deltaTime)

if (ShouldBeEnabled)
Enable();
else if (Suspended || (Timeline.IsFinished && !_renderCopies.Any()))
else if (Suspended || !HasBounds || (Timeline.IsFinished && !_renderCopies.Any()))
Disable();

if (!Enabled || Timeline.Delta == TimeSpan.Zero)
Expand Down Expand Up @@ -766,7 +778,7 @@ public void RemoveLed(ArtemisLed led)

if (!_leds.Remove(led))
return;

CalculateRenderProperties();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.Json.Serialization;

namespace Artemis.Core;

Expand All @@ -14,12 +15,13 @@ public readonly struct FloatRange
/// </summary>
/// <param name="start">The start value of the range</param>
/// <param name="end">The end value of the range</param>
[JsonConstructor]
public FloatRange(float start, float end)
{
Start = start;
End = end;

_rand = new Random();
_rand = Random.Shared;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Artemis.Core;
/// initialize these for you.
/// </para>
/// </summary>
public interface ILayerProperty : IStorageModel, IDisposable
public interface ILayerProperty : IStorageModel, IDisposable, IPluginFeatureDependent
{
/// <summary>
/// Gets the description attribute applied to this property
Expand Down
4 changes: 3 additions & 1 deletion src/Artemis.Core/Models/Profile/LayerProperties/IntRange.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.Json.Serialization;

namespace Artemis.Core;

Expand All @@ -14,12 +15,13 @@ public readonly struct IntRange
/// </summary>
/// <param name="start">The start value of the range</param>
/// <param name="end">The end value of the range</param>
[JsonConstructor]
public IntRange(int start, int end)
{
Start = start;
End = end;

_rand = new Random();
_rand = Random.Shared;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public override string ToString()
return $"{Path} - {CurrentValue} ({PropertyType})";
}

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return DataBinding.GetFeatureDependencies();
}

/// <summary>
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Artemis.Core;
/// initialize these for you.
/// </para>
/// </summary>
public abstract class LayerPropertyGroup : IDisposable
public abstract class LayerPropertyGroup : IDisposable, IPluginFeatureDependent
{
private readonly List<ILayerProperty> _layerProperties;
private readonly List<LayerPropertyGroup> _layerPropertyGroups;
Expand Down Expand Up @@ -343,4 +343,14 @@ public void Dispose()
Dispose(true);
GC.SuppressFinalize(this);
}

#region Implementation of IPluginFeatureDependent

/// <inheritdoc />
public IEnumerable<PluginFeature> GetFeatureDependencies()
{
return LayerProperties.SelectMany(p => p.GetFeatureDependencies()).Concat(LayerPropertyGroups.SelectMany(g => g.GetFeatureDependencies()));
}

#endregion
}
6 changes: 6 additions & 0 deletions src/Artemis.Core/Models/Profile/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public override string ToString()
return $"[Profile] {nameof(Name)}: {Name}";
}

/// <inheritdoc />
public override IEnumerable<PluginFeature> GetFeatureDependencies()
{
return GetRootFolder().GetFeatureDependencies().Concat(Scripts.Select(c => c.ScriptingProvider));
}

/// <summary>
/// Populates all the LEDs on the elements in this profile
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Artemis.Core/Models/Profile/ProfileElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Artemis.Core;
/// <summary>
/// Represents an element of a <see cref="Profile" />
/// </summary>
public abstract class ProfileElement : BreakableModel, IDisposable
public abstract class ProfileElement : BreakableModel, IDisposable, IPluginFeatureDependent
{
internal readonly List<ProfileElement> ChildrenList;
private Guid _entityId;
Expand Down Expand Up @@ -122,6 +122,9 @@ public override string ToString()
return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}";
}

/// <inheritdoc />
public abstract IEnumerable<PluginFeature> GetFeatureDependencies();

/// <summary>
/// Occurs when a child was added to the <see cref="Children" /> list
/// </summary>
Expand Down
Loading

0 comments on commit 9fcd20d

Please sign in to comment.