mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Core - Reworked brush/effect property storage
Profile editor - Added brush selection Profile editor - Added playback controls
This commit is contained in:
1 parent
022beb6a48
commit
1832a25426
64 files changed
+1168
-481
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.LayerBrushes
|
||||
@@ -24,6 +25,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
// Both are set right after construction to keep the constructor of inherited classes clean
|
||||
_layer = null!;
|
||||
_descriptor = null!;
|
||||
LayerBrushEntity = null!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,6 +37,11 @@ namespace Artemis.Core.LayerBrushes
|
||||
internal set => SetAndNotify(ref _layer, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the brush entity this brush uses for persistent storage
|
||||
/// </summary>
|
||||
public LayerBrushEntity LayerBrushEntity { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this brush
|
||||
/// </summary>
|
||||
@@ -185,6 +192,13 @@ namespace Artemis.Core.LayerBrushes
|
||||
public override string BrokenDisplayName => Descriptor.DisplayName;
|
||||
|
||||
#endregion
|
||||
|
||||
internal void Save()
|
||||
{
|
||||
// No need to update the type or provider ID, they're set once by the LayerBrushDescriptors CreateInstance and can't change
|
||||
BaseProperties?.ApplyToEntity();
|
||||
LayerBrushEntity.PropertyGroup = BaseProperties?.PropertyGroupEntity;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Core.LayerBrushes
|
||||
{
|
||||
@@ -32,12 +33,11 @@ namespace Artemis.Core.LayerBrushes
|
||||
internal set => _properties = value;
|
||||
}
|
||||
|
||||
internal void InitializeProperties()
|
||||
internal void InitializeProperties(PropertyGroupEntity? propertyGroupEntity)
|
||||
{
|
||||
Properties = Activator.CreateInstance<T>();
|
||||
Properties.GroupDescription = new PropertyGroupDescriptionAttribute {Name = Descriptor.DisplayName, Description = Descriptor.Description};
|
||||
Properties.LayerBrush = this;
|
||||
Properties.Initialize(Layer, "LayerBrush.", Descriptor.Provider);
|
||||
PropertyGroupDescriptionAttribute groupDescription = new() {Identifier = "Brush", Name = Descriptor.DisplayName, Description = Descriptor.Description};
|
||||
Properties.Initialize(Layer, null, groupDescription, propertyGroupEntity);
|
||||
PropertiesInitialized = true;
|
||||
|
||||
EnableLayerBrush();
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Core.LayerBrushes
|
||||
@@ -57,23 +58,20 @@ namespace Artemis.Core.LayerBrushes
|
||||
/// <summary>
|
||||
/// Creates an instance of the described brush and applies it to the layer
|
||||
/// </summary>
|
||||
internal void CreateInstance(Layer layer)
|
||||
public BaseLayerBrush CreateInstance(Layer layer, LayerBrushEntity? entity)
|
||||
{
|
||||
if (layer == null) throw new ArgumentNullException(nameof(layer));
|
||||
if (layer.LayerBrush != null)
|
||||
throw new ArtemisCoreException("Layer already has an instantiated layer brush");
|
||||
if (layer == null)
|
||||
throw new ArgumentNullException(nameof(layer));
|
||||
|
||||
BaseLayerBrush brush = (BaseLayerBrush) Provider.Plugin.Kernel!.Get(LayerBrushType);
|
||||
brush.Layer = layer;
|
||||
brush.Descriptor = this;
|
||||
brush.LayerBrushEntity = entity ?? new LayerBrushEntity { ProviderId = Provider.Id, BrushType = LayerBrushType.FullName };
|
||||
|
||||
brush.Initialize();
|
||||
brush.Update(0);
|
||||
|
||||
layer.LayerBrush = brush;
|
||||
layer.OnLayerBrushUpdated();
|
||||
|
||||
if (layer.ShouldBeEnabled)
|
||||
brush.InternalEnable();
|
||||
return brush;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
TryOrBreak(() => InitializeProperties(Layer.LayerEntity.LayerBrush?.PropertyGroup), "Failed to initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user