mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Conditions - Refactor layer properties WIP
This commit is contained in:
1 parent
d9bba8cb54
commit
660324c980
33 files changed
+363
-492
No files matched your search
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// A basic layer brush that does not implement any layer property, to use properties with persistent storage,
|
||||
/// implement <see cref="LayerBrush{T}" /> instead
|
||||
/// </summary>
|
||||
public abstract class BaseLayerBrush : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the layer this brush is applied to
|
||||
/// </summary>
|
||||
public Layer Layer { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this brush
|
||||
/// </summary>
|
||||
public LayerBrushDescriptor Descriptor { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info that defined this brush
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo => Descriptor.LayerBrushProvider.PluginInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the brush is being removed from the layer
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before rendering every frame, write your update logic here
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
public virtual void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering anything to the layer. The provided <see cref="SKCanvas" /> is specific to the layer
|
||||
/// and matches it's width and height.
|
||||
/// <para>Called during rendering or layer preview, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
/// <param name="canvasInfo"></param>
|
||||
/// <param name="path">The path to be filled, represents the shape</param>
|
||||
/// <param name="paint">The paint to be used to fill the shape</param>
|
||||
public virtual void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
}
|
||||
|
||||
internal virtual void InitializeProperties(ILayerService layerService, string path)
|
||||
{
|
||||
}
|
||||
|
||||
internal virtual void ApplyToEntity()
|
||||
{
|
||||
}
|
||||
|
||||
internal virtual void UpdateProperties(double deltaTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public interface ILayerBrush : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the layer this brush is applied to
|
||||
/// </summary>
|
||||
Layer Layer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this brush
|
||||
/// </summary>
|
||||
LayerBrushDescriptor Descriptor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called before rendering every frame, write your update logic here
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
void Update(double deltaTime);
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering anything to the layer. The provided <see cref="SKCanvas" /> is specific to the layer
|
||||
/// and matches it's width and height.
|
||||
/// <para>Called during rendering or layer preview, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
/// <param name="canvasInfo"></param>
|
||||
/// <param name="path">The path to be filled, represents the shape</param>
|
||||
/// <param name="paint">The paint to be used to fill the shape</param>
|
||||
void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
|
||||
|
||||
public void InitializeProperties(ILayerService layerService, string path);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public abstract class LayerBrush<T> : ILayerBrush where T : LayerPropertyGroup
|
||||
public abstract class LayerBrush<T> : BaseLayerBrush where T : LayerPropertyGroup
|
||||
{
|
||||
private T _properties;
|
||||
|
||||
@@ -15,27 +14,6 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
Descriptor = descriptor;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Layer Layer { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public LayerBrushDescriptor Descriptor { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -52,12 +30,12 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
}
|
||||
internal set => _properties = value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether all properties on this brush are initialized
|
||||
/// </summary>
|
||||
public bool PropertiesInitialized { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when all layer properties in this brush have been initialized
|
||||
/// </summary>
|
||||
@@ -65,13 +43,23 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
}
|
||||
|
||||
public void InitializeProperties(ILayerService layerService, string path)
|
||||
internal override void InitializeProperties(ILayerService layerService, string path)
|
||||
{
|
||||
Properties.InitializeProperties(layerService, Descriptor.LayerBrushProvider.PluginInfo, path);
|
||||
Properties.InitializeProperties(layerService, Layer, path);
|
||||
OnPropertiesInitialized();
|
||||
PropertiesInitialized = true;
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
Properties.ApplyToEntity();
|
||||
}
|
||||
|
||||
internal override void UpdateProperties(double deltaTime)
|
||||
{
|
||||
Properties.Update(deltaTime);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
|
||||
public ReadOnlyCollection<LayerBrushDescriptor> LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
|
||||
|
||||
protected void AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : ILayerBrush
|
||||
protected void AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
|
||||
{
|
||||
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user