mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Plugin features - Added PluginFeature attribute
Plugin features -Added PluginFeatureInfo to plugin features Web server - Moved REST APIs to plugins
This commit is contained in:
1 parent
46958338b9
commit
c1b0027231
18 files changed
+297
-183
No files matched your search
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Modules;
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core.DataModelExpansions
|
||||
{
|
||||
@@ -28,12 +29,14 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// <summary>
|
||||
/// Gets the plugin feature this data model belongs to
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[DataModelIgnore]
|
||||
public DataModelPluginFeature Feature { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DataModelPropertyAttribute" /> describing this data model
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[DataModelIgnore]
|
||||
public DataModelPropertyAttribute DataModelDescription { get; internal set; }
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public DirectoryInfo Directory { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins
|
||||
/// </summary>
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace Artemis.Core
|
||||
private bool _isEnabled;
|
||||
private Exception? _loadException;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin feature info related to this feature
|
||||
/// </summary>
|
||||
public PluginFeatureInfo Info { get; internal set; } = null!; // Will be set right after construction
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin that provides this feature
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an attribute that describes a plugin feature
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class PluginFeatureAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user-friendly name for this property, shown in the UI.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user-friendly description for this property, shown in the UI.
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
|
||||
/// available icons
|
||||
/// </summary>
|
||||
public string? Icon { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.Core.DeviceProviders;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.LayerEffects;
|
||||
using Artemis.Core.Modules;
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents basic info about a plugin feature and contains a reference to the instance of said feature
|
||||
/// </summary>
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class PluginFeatureInfo : CorePropertyChanged
|
||||
{
|
||||
private string? _description;
|
||||
private string? _icon;
|
||||
private string _name = null!;
|
||||
private PluginFeature _pluginFeature = null!;
|
||||
|
||||
internal PluginFeatureInfo()
|
||||
{
|
||||
}
|
||||
|
||||
internal PluginFeatureInfo(PluginFeature instance, PluginFeatureAttribute? attribute)
|
||||
{
|
||||
Name = attribute?.Name ?? instance.GetType().Name.Humanize(LetterCasing.Title);
|
||||
Description = attribute?.Description;
|
||||
Icon = attribute?.Icon;
|
||||
PluginFeature = instance;
|
||||
|
||||
if (Icon != null) return;
|
||||
Icon = PluginFeature switch
|
||||
{
|
||||
BaseDataModelExpansion => "TableAdd",
|
||||
DeviceProvider => "Devices",
|
||||
ProfileModule => "VectorRectangle",
|
||||
Module => "GearBox",
|
||||
LayerBrushProvider => "Brush",
|
||||
LayerEffectProvider => "AutoAwesome",
|
||||
_ => "Plugin"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plugin
|
||||
/// </summary>
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
internal set => SetAndNotify(ref _name, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the plugin
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public string? Description
|
||||
{
|
||||
get => _description;
|
||||
set => SetAndNotify(ref _description, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
|
||||
/// available icons
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public string? Icon
|
||||
{
|
||||
get => _icon;
|
||||
set => SetAndNotify(ref _icon, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin this info is associated with
|
||||
/// </summary>
|
||||
public PluginFeature PluginFeature
|
||||
{
|
||||
get => _pluginFeature;
|
||||
internal set => SetAndNotify(ref _pluginFeature, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return PluginFeature.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user