Plugins - Removed plugin info from constructor

This commit is contained in:
SpoinkyNL committed 2020-06-07 21:51:56 +02:00
1 parent 33bb3ffa6c
commit 1d35a02d5b
49 files changed
+305 -390

No files matched your search

@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
@@ -13,15 +14,32 @@ namespace Artemis.Core.Plugins.Abstract
{
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
protected LayerBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
protected LayerBrushProvider()
{
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
}
/// <summary>
/// A read-only collection of all layer brushes added with <see cref="AddLayerBrushDescriptor{T}" />
/// </summary>
public ReadOnlyCollection<LayerBrushDescriptor> LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
/// <summary>
/// Adds a layer brush descriptor for a given layer brush, 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 brush 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 AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
{
if (!Enabled)
throw new ArtemisPluginException(PluginInfo, "Can only add a layer brush descriptor when the plugin is enabled");
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
}
}