mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Plugins - Implemented features
Core - Removed Stylet dependency for #500
This commit is contained in:
1 parent
b56966c585
commit
e812929215
139 files changed
+1635
-1106
No files matched your search
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Artemis.Core.Properties;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
@@ -19,13 +18,13 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public ColorGradient()
|
||||
{
|
||||
Stops = new BindableCollection<ColorGradientStop>();
|
||||
Stops = new List<ColorGradientStop>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all the <see cref="ColorGradientStop" />s in the gradient
|
||||
/// </summary>
|
||||
public BindableCollection<ColorGradientStop> Stops { get; }
|
||||
public List<ColorGradientStop> Stops { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the colors in the color gradient
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace Artemis.Core
|
||||
public abstract string Icon { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info this condition operator belongs to
|
||||
/// Gets the plugin this condition operator belongs to
|
||||
/// <para>Note: Not set until after registering</para>
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
public Plugin Plugin { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the left side type of this condition operator
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace Artemis.Core
|
||||
|
||||
if (Operator != null)
|
||||
{
|
||||
Entity.OperatorPluginGuid = Operator.PluginInfo.Guid;
|
||||
Entity.OperatorPluginGuid = Operator.Plugin.Guid;
|
||||
Entity.OperatorType = Operator.GetType().Name;
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ namespace Artemis.Core
|
||||
private void ConditionOperatorStoreOnConditionOperatorAdded(object? sender, ConditionOperatorStoreEvent e)
|
||||
{
|
||||
BaseConditionOperator conditionOperator = e.Registration.ConditionOperator;
|
||||
if (Entity.OperatorPluginGuid == conditionOperator.PluginInfo.Guid && Entity.OperatorType == conditionOperator.GetType().Name)
|
||||
if (Entity.OperatorPluginGuid == conditionOperator.Plugin.Guid && Entity.OperatorType == conditionOperator.GetType().Name)
|
||||
UpdateOperator(conditionOperator);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Artemis.Core
|
||||
{
|
||||
internal EventPredicateWrapperDataModel()
|
||||
{
|
||||
Implementation = Constants.CorePluginInfo;
|
||||
Feature = Constants.CorePluginFeature;
|
||||
}
|
||||
|
||||
[DataModelIgnore]
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Artemis.Core
|
||||
{
|
||||
internal ListPredicateWrapperDataModel()
|
||||
{
|
||||
Implementation = Constants.CorePluginInfo;
|
||||
Feature = Constants.CorePluginFeature;
|
||||
}
|
||||
|
||||
[DataModelIgnore]
|
||||
|
||||
+2
-2
@@ -12,10 +12,10 @@ namespace Artemis.Core
|
||||
public abstract class BaseDataBindingModifierType
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the plugin info this data binding modifier belongs to
|
||||
/// Gets the plugin this data binding modifier belongs to
|
||||
/// <para>Note: Not set until after registering</para>
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
public Plugin Plugin { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value type of this modifier type
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Artemis.Core
|
||||
if (ModifierType != null)
|
||||
{
|
||||
Entity.ModifierType = ModifierType.GetType().Name;
|
||||
Entity.ModifierTypePluginGuid = ModifierType.PluginInfo.Guid;
|
||||
Entity.ModifierTypePluginGuid = ModifierType.Plugin.Guid;
|
||||
}
|
||||
|
||||
// General
|
||||
@@ -286,7 +286,7 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
BaseDataBindingModifierType modifierType = e.TypeRegistration.DataBindingModifierType;
|
||||
if (modifierType.PluginInfo.Guid == Entity.ModifierTypePluginGuid && modifierType.GetType().Name == Entity.ModifierType)
|
||||
if (modifierType.Plugin.Guid == Entity.ModifierTypePluginGuid && modifierType.GetType().Name == Entity.ModifierType)
|
||||
UpdateModifierType(modifierType);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ namespace Artemis.Core
|
||||
public DataModel? Target { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data model GUID of the <see cref="Target" /> if it is a <see cref="DataModel" />
|
||||
/// Gets the data model ID of the <see cref="Target" /> if it is a <see cref="DataModel" />
|
||||
/// </summary>
|
||||
public Guid? DataModelGuid => Target?.Implementation.Guid;
|
||||
public string? DataModelId => Target?.Feature.Id;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point-separated path associated with this <see cref="DataModelPath" />
|
||||
@@ -267,8 +267,8 @@ namespace Artemis.Core
|
||||
{
|
||||
Path = Entity.Path;
|
||||
|
||||
if (Target == null && Entity.DataModelGuid != null)
|
||||
Target = DataModelStore.Get(Entity.DataModelGuid.Value)?.DataModel;
|
||||
if (Target == null && Entity.DataModelId != null)
|
||||
Target = DataModelStore.Get(Entity.DataModelId)?.DataModel;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -279,7 +279,7 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
Entity.Path = Path;
|
||||
Entity.DataModelGuid = DataModelGuid;
|
||||
Entity.DataModelId = DataModelId;
|
||||
|
||||
Entity.WrapperType = Target switch
|
||||
{
|
||||
@@ -295,7 +295,7 @@ namespace Artemis.Core
|
||||
|
||||
private void DataModelStoreOnDataModelAdded(object? sender, DataModelStoreEvent e)
|
||||
{
|
||||
if (e.Registration.DataModel.Implementation.Guid != Entity.DataModelGuid)
|
||||
if (e.Registration.DataModel.Feature.Id != Entity.DataModelId)
|
||||
return;
|
||||
|
||||
Target = e.Registration.DataModel;
|
||||
@@ -304,7 +304,7 @@ namespace Artemis.Core
|
||||
|
||||
private void DataModelStoreOnDataModelRemoved(object? sender, DataModelStoreEvent e)
|
||||
{
|
||||
if (e.Registration.DataModel.Implementation.Guid != Entity.DataModelGuid)
|
||||
if (e.Registration.DataModel.Feature.Id != Entity.DataModelId)
|
||||
return;
|
||||
|
||||
Target = null;
|
||||
|
||||
@@ -190,9 +190,9 @@ namespace Artemis.Core
|
||||
typeof(PropertyGroupDescriptionAttribute)
|
||||
);
|
||||
General.GroupDescription = (PropertyGroupDescriptionAttribute) generalAttribute;
|
||||
General.Initialize(this, "General.", Constants.CorePluginInfo);
|
||||
General.Initialize(this, "General.", Constants.CorePluginFeature);
|
||||
Transform.GroupDescription = (PropertyGroupDescriptionAttribute) transformAttribute;
|
||||
Transform.Initialize(this, "Transform.", Constants.CorePluginInfo);
|
||||
Transform.Initialize(this, "Transform.", Constants.CorePluginFeature);
|
||||
|
||||
General.ShapeType.CurrentValueSet += ShapeTypeOnCurrentValueSet;
|
||||
ApplyShapeType();
|
||||
@@ -619,7 +619,7 @@ namespace Artemis.Core
|
||||
|
||||
BaseLayerBrush brush = LayerBrush;
|
||||
DeactivateLayerBrush();
|
||||
LayerEntity.PropertyEntities.RemoveAll(p => p.PluginGuid == brush.PluginInfo.Guid && p.Path.StartsWith("LayerBrush."));
|
||||
LayerEntity.PropertyEntities.RemoveAll(p => p.FeatureId == brush.ProviderId && p.Path.StartsWith("LayerBrush."));
|
||||
}
|
||||
|
||||
internal void ActivateLayerBrush()
|
||||
@@ -628,7 +628,7 @@ namespace Artemis.Core
|
||||
if (current == null)
|
||||
return;
|
||||
|
||||
LayerBrushDescriptor descriptor = LayerBrushStore.Get(current.BrushPluginGuid, current.BrushType)?.LayerBrushDescriptor;
|
||||
LayerBrushDescriptor? descriptor = LayerBrushStore.Get(current.LayerBrushProviderId, current.BrushType)?.LayerBrushDescriptor;
|
||||
descriptor?.CreateInstance(this);
|
||||
|
||||
OnLayerBrushUpdated();
|
||||
@@ -662,7 +662,7 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
LayerBrushReference current = General.BrushReference.CurrentValue;
|
||||
if (e.Registration.PluginImplementation.PluginInfo.Guid == current.BrushPluginGuid &&
|
||||
if (e.Registration.PluginFeature.Id == current.LayerBrushProviderId &&
|
||||
e.Registration.LayerBrushDescriptor.LayerBrushType.Name == current.BrushType)
|
||||
ActivateLayerBrush();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
@@ -8,24 +7,24 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class LayerBrushReference
|
||||
{
|
||||
/// <summary>
|
||||
/// The GUID of the plugin the brush descriptor resides in
|
||||
/// </summary>
|
||||
public Guid BrushPluginGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full type name of the brush descriptor
|
||||
/// </summary>
|
||||
public string BrushType { get; set; }
|
||||
|
||||
public LayerBrushReference()
|
||||
{
|
||||
}
|
||||
|
||||
public LayerBrushReference(LayerBrushDescriptor descriptor)
|
||||
{
|
||||
BrushPluginGuid = descriptor.LayerBrushProvider.PluginInfo.Guid;
|
||||
LayerBrushProviderId = descriptor.Provider.Id;
|
||||
BrushType = descriptor.LayerBrushType.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the layer brush provided the brush was provided by
|
||||
/// </summary>
|
||||
public string LayerBrushProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full type name of the brush descriptor
|
||||
/// </summary>
|
||||
public string BrushType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a keyframe on a <see cref="LayerProperty{T}" /> containing a value and a timestamp
|
||||
/// </summary>
|
||||
public class LayerPropertyKeyframe<T> : PropertyChangedBase
|
||||
public class LayerPropertyKeyframe<T> : CorePropertyChanged
|
||||
{
|
||||
private LayerProperty<T> _layerProperty;
|
||||
private TimeSpan _position;
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace Artemis.Core
|
||||
/// Gets the description of this group
|
||||
/// </summary>
|
||||
public PropertyGroupDescriptionAttribute GroupDescription { get; internal set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the info of the plugin this group is associated with
|
||||
/// Gets the plugin feature this group is associated with
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
public PluginFeature Feature { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile element (such as layer or folder) this group is associated with
|
||||
@@ -145,18 +145,18 @@ namespace Artemis.Core
|
||||
PropertyGroupInitialized?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
internal void Initialize(RenderProfileElement profileElement, [NotNull] string path, PluginInfo pluginInfo)
|
||||
internal void Initialize(RenderProfileElement profileElement, [NotNull] string path, PluginFeature feature)
|
||||
{
|
||||
if (path == null)
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
if (pluginInfo == null)
|
||||
throw new ArgumentNullException(nameof(pluginInfo));
|
||||
if (feature == null)
|
||||
throw new ArgumentNullException(nameof(feature));
|
||||
|
||||
// Doubt this will happen but let's make sure
|
||||
if (PropertiesInitialized)
|
||||
throw new ArtemisCoreException("Layer property group already initialized, wut");
|
||||
|
||||
PluginInfo = pluginInfo;
|
||||
Feature = feature;
|
||||
ProfileElement = profileElement;
|
||||
Path = path.TrimEnd('.');
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Artemis.Core
|
||||
instance.GroupDescription = propertyGroupDescription;
|
||||
instance.LayerBrush = LayerBrush;
|
||||
instance.LayerEffect = LayerEffect;
|
||||
instance.Initialize(ProfileElement, $"{path}{propertyInfo.Name}.", PluginInfo);
|
||||
instance.Initialize(ProfileElement, $"{path}{propertyInfo.Name}.", Feature);
|
||||
|
||||
propertyInfo.SetValue(this, instance);
|
||||
_layerPropertyGroups.Add(instance);
|
||||
@@ -254,11 +254,11 @@ namespace Artemis.Core
|
||||
|
||||
private PropertyEntity GetPropertyEntity(RenderProfileElement profileElement, string path, out bool fromStorage)
|
||||
{
|
||||
PropertyEntity entity = profileElement.RenderElementEntity.PropertyEntities.FirstOrDefault(p => p.PluginGuid == PluginInfo.Guid && p.Path == path);
|
||||
PropertyEntity entity = profileElement.RenderElementEntity.PropertyEntities.FirstOrDefault(p => p.FeatureId == Feature.Id && p.Path == path);
|
||||
fromStorage = entity != null;
|
||||
if (entity == null)
|
||||
{
|
||||
entity = new PropertyEntity {PluginGuid = PluginInfo.Guid, Path = path};
|
||||
entity = new PropertyEntity {FeatureId = Feature.Id, Path = path};
|
||||
profileElement.RenderElementEntity.PropertyEntities.Add(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Newtonsoft.Json;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core
|
||||
@@ -147,7 +146,7 @@ namespace Artemis.Core
|
||||
throw new ObjectDisposedException("Profile");
|
||||
|
||||
ProfileEntity.Id = EntityId;
|
||||
ProfileEntity.PluginGuid = Module.PluginInfo.Guid;
|
||||
ProfileEntity.ModuleId = Module.Id;
|
||||
ProfileEntity.Name = Name;
|
||||
ProfileEntity.IsActive = IsActivated;
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
public abstract class ProfileElement : PropertyChangedBase, IDisposable
|
||||
public abstract class ProfileElement : CorePropertyChanged, IDisposable
|
||||
{
|
||||
private bool _enabled;
|
||||
private Guid _entityId;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Artemis.Core
|
||||
LayerEffectEntity layerEffectEntity = new LayerEffectEntity
|
||||
{
|
||||
Id = layerEffect.EntityId,
|
||||
PluginGuid = layerEffect.Descriptor.PlaceholderFor ?? layerEffect.PluginInfo.Guid,
|
||||
ProviderId = layerEffect.Descriptor.PlaceholderFor ?? layerEffect.ProviderId,
|
||||
EffectType = layerEffect.GetEffectTypeName(),
|
||||
Name = layerEffect.Name,
|
||||
Enabled = layerEffect.Enabled,
|
||||
@@ -215,11 +215,11 @@ namespace Artemis.Core
|
||||
foreach (LayerEffectEntity layerEffectEntity in RenderElementEntity.LayerEffects)
|
||||
{
|
||||
// If there is a non-placeholder existing effect, skip this entity
|
||||
BaseLayerEffect existing = _layerEffects.FirstOrDefault(e => e.EntityId == layerEffectEntity.Id);
|
||||
BaseLayerEffect? existing = _layerEffects.FirstOrDefault(e => e.EntityId == layerEffectEntity.Id);
|
||||
if (existing != null && existing.Descriptor.PlaceholderFor == null)
|
||||
continue;
|
||||
|
||||
LayerEffectDescriptor descriptor = LayerEffectStore.Get(layerEffectEntity.PluginGuid, layerEffectEntity.EffectType)?.LayerEffectDescriptor;
|
||||
LayerEffectDescriptor? descriptor = LayerEffectStore.Get(layerEffectEntity.ProviderId, layerEffectEntity.EffectType)?.LayerEffectDescriptor;
|
||||
if (descriptor != null)
|
||||
{
|
||||
// If a descriptor is found but there is an existing placeholder, remove the placeholder
|
||||
@@ -235,7 +235,7 @@ namespace Artemis.Core
|
||||
else if (existing == null)
|
||||
{
|
||||
// If no descriptor was found and there was no existing placeholder, create a placeholder
|
||||
descriptor = PlaceholderLayerEffectDescriptor.Create(layerEffectEntity.PluginGuid);
|
||||
descriptor = PlaceholderLayerEffectDescriptor.Create(layerEffectEntity.ProviderId);
|
||||
descriptor.CreateInstance(this, layerEffectEntity);
|
||||
}
|
||||
}
|
||||
@@ -253,22 +253,22 @@ namespace Artemis.Core
|
||||
private void LayerEffectStoreOnLayerEffectRemoved(object sender, LayerEffectStoreEvent e)
|
||||
{
|
||||
// If effects provided by the plugin are on the element, replace them with placeholders
|
||||
List<BaseLayerEffect> pluginEffects = _layerEffects.Where(ef => ef.Descriptor.LayerEffectProvider != null &&
|
||||
ef.PluginInfo.Guid == e.Registration.PluginImplementation.PluginInfo.Guid).ToList();
|
||||
List<BaseLayerEffect> pluginEffects = _layerEffects.Where(ef => ef.Descriptor.Provider != null &&
|
||||
ef.ProviderId == e.Registration.PluginFeature.Id).ToList();
|
||||
foreach (BaseLayerEffect pluginEffect in pluginEffects)
|
||||
{
|
||||
LayerEffectEntity entity = RenderElementEntity.LayerEffects.First(en => en.Id == pluginEffect.EntityId);
|
||||
_layerEffects.Remove(pluginEffect);
|
||||
pluginEffect.Dispose();
|
||||
|
||||
LayerEffectDescriptor descriptor = PlaceholderLayerEffectDescriptor.Create(pluginEffect.PluginInfo.Guid);
|
||||
LayerEffectDescriptor descriptor = PlaceholderLayerEffectDescriptor.Create(pluginEffect.ProviderId);
|
||||
descriptor.CreateInstance(this, entity);
|
||||
}
|
||||
}
|
||||
|
||||
private void LayerEffectStoreOnLayerEffectAdded(object sender, LayerEffectStoreEvent e)
|
||||
{
|
||||
if (RenderElementEntity.LayerEffects.Any(ef => ef.PluginGuid == e.Registration.PluginImplementation.PluginInfo.Guid))
|
||||
if (RenderElementEntity.LayerEffects.Any(ef => ef.ProviderId == e.Registration.PluginFeature.Id))
|
||||
ActivateEffects();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,13 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a timeline used by profile elements
|
||||
/// </summary>
|
||||
public class Timeline : PropertyChangedBase, IStorageModel
|
||||
public class Timeline : CorePropertyChanged, IStorageModel
|
||||
{
|
||||
private const int MaxExtraTimelines = 15;
|
||||
|
||||
@@ -275,20 +274,20 @@ namespace Artemis.Core
|
||||
if (segment <= TimelineSegment.End)
|
||||
{
|
||||
if (startUpdated || segment < TimelineSegment.End)
|
||||
NotifyOfPropertyChange(nameof(EndSegmentStartPosition));
|
||||
NotifyOfPropertyChange(nameof(EndSegmentEndPosition));
|
||||
OnPropertyChanged(nameof(EndSegmentStartPosition));
|
||||
OnPropertyChanged(nameof(EndSegmentEndPosition));
|
||||
}
|
||||
|
||||
if (segment <= TimelineSegment.Main)
|
||||
{
|
||||
if (startUpdated || segment < TimelineSegment.Main)
|
||||
NotifyOfPropertyChange(nameof(MainSegmentStartPosition));
|
||||
NotifyOfPropertyChange(nameof(MainSegmentEndPosition));
|
||||
OnPropertyChanged(nameof(MainSegmentStartPosition));
|
||||
OnPropertyChanged(nameof(MainSegmentEndPosition));
|
||||
}
|
||||
|
||||
if (segment <= TimelineSegment.Start) NotifyOfPropertyChange(nameof(StartSegmentEndPosition));
|
||||
if (segment <= TimelineSegment.Start) OnPropertyChanged(nameof(StartSegmentEndPosition));
|
||||
|
||||
NotifyOfPropertyChange(nameof(Length));
|
||||
OnPropertyChanged(nameof(Length));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user