using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Artemis.Core.Plugins.Exceptions; namespace Artemis.Core.Plugins.LayerEffects { /// /// Allows you to register one or more s usable by profile layers. /// public abstract class LayerEffectProvider : Plugin { private readonly List _layerEffectDescriptors; /// /// Allows you to register one or more s usable by profile layers. /// protected LayerEffectProvider() { _layerEffectDescriptors = new List(); PluginDisabled += OnPluginDisabled; } /// /// A read-only collection of all layer effects added with /// public ReadOnlyCollection LayerEffectDescriptors => _layerEffectDescriptors.AsReadOnly(); /// /// Adds a layer effect descriptor for a given layer effect, so that it appears in the UI. /// Note: You do not need to manually remove these on disable /// /// The type of the layer effect you wish to register /// The name to display in the UI /// The description to display in the UI /// /// The Material icon to display in the UI, a full reference can be found /// here /// protected void RegisterLayerEffectDescriptor(string displayName, string description, string icon) where T : BaseLayerEffect { 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)); } private void OnPluginDisabled(object sender, EventArgs e) { _layerEffectDescriptors.Clear(); } } }