Layer effects - WIP commit

Profile editor - Show brush icons at different parts in the editor
This commit is contained in:
SpoinkyNL committed 2020-06-10 00:20:43 +02:00
1 parent c99a3aaf3b
commit 2493c2cbf1
28 files changed
+618 -63

No files matched your search

@@ -1,4 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerEffect;
using Artemis.Core.Plugins.LayerEffect.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
@@ -6,16 +10,37 @@ namespace Artemis.Core.Plugins.Abstract
/// <summary>
/// Allows you to create one or more <see cref="LayerEffect" />s usable by profile layers.
/// </summary>
public class LayerEffectProvider : Plugin
public abstract class LayerEffectProvider : Plugin
{
public override void EnablePlugin()
private readonly List<LayerEffectDescriptor> _layerEffectDescriptors;
protected LayerEffectProvider()
{
throw new NotImplementedException();
_layerEffectDescriptors = new List<LayerEffectDescriptor>();
}
public override void DisablePlugin()
/// <summary>
/// A read-only collection of all layer effects added with <see cref="AddLayerEffectDescriptor{T}" />
/// </summary>
public ReadOnlyCollection<LayerEffectDescriptor> LayerEffectDescriptors => _layerEffectDescriptors.AsReadOnly();
/// <summary>
/// Adds a layer effect descriptor for a given layer effect, so that it appears in the UI.
/// <para>Note: You do not need to manually remove these on disable</para>
/// </summary>
/// <typeparam name="T">The type of the layer effect you wish to register</typeparam>
/// <param name="displayName">The name to display in the UI</param>
/// <param name="description">The description to display in the UI</param>
/// <param name="icon">
/// The Material icon to display in the UI, a full reference can be found
/// <see href="https://materialdesignicons.com">here</see>
/// </param>
protected void AddLayerEffectDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerEffect
{
throw new NotImplementedException();
if (!Enabled)
throw new ArtemisPluginException(PluginInfo, "Can only add a layer effect descriptor when the plugin is enabled");
_layerEffectDescriptors.Add(new LayerEffectDescriptor(displayName, description, icon, typeof(T), this));
}
}
}
@@ -36,6 +36,11 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
/// </summary>
public virtual LayerPropertyGroup BaseProperties => null;
/// <summary>
/// Gets whether the brush supports transformations, RGB.NET brushes never support transformation
/// </summary>
public bool SupportsTransformation { get; protected set; }
public void Dispose()
{
DisableLayerBrush();
@@ -38,6 +38,7 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
internal void InitializeProperties(ILayerService layerService)
{
Properties = Activator.CreateInstance<T>();
Properties.LayerBrush = this;
Properties.InitializeProperties(layerService, Layer, "LayerBrush.");
PropertiesInitialized = true;
@@ -35,19 +35,14 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
internal set => _properties = value;
}
/// <summary>
/// Called when all layer properties in this effect have been initialized
/// </summary>
protected virtual void OnPropertiesInitialized()
{
}
internal void InitializeProperties(ILayerService layerService)
{
Properties = Activator.CreateInstance<T>();
Properties.LayerEffect = this;
Properties.InitializeProperties(layerService, Layer, "LayerEffect.");
OnPropertiesInitialized();
PropertiesInitialized = true;
EnableLayerEffect();
}
internal override void Initialize(ILayerService layerService)