Modules - Remove Name and Icon in favor PluginFeature attribute

This commit is contained in:
Robert committed 2021-06-09 20:58:05 +02:00
1 parent 730207ccd0
commit 2179c889a3
14 files changed
+54 -90

No files matched your search

+9 -21
View File
@@ -61,7 +61,6 @@ namespace Artemis.Core.Modules
}
}
/// <summary>
/// For internal use only, please use <see cref="Module{T}" />.
/// </summary>
@@ -79,20 +78,15 @@ namespace Artemis.Core.Modules
/// Gets a read only collection of default profile paths
/// </summary>
public IReadOnlyCollection<(DefaultCategoryName, string)> DefaultProfilePaths => _defaultProfilePaths.AsReadOnly();
/// <summary>
/// The modules display name that's shown in the menu
/// </summary>
public string? DisplayName { get; protected set; }
/// <summary>
/// The modules display icon that's shown in the UI accepts:
/// A list of activation requirements
/// <para>
/// Either set to the name of a Material Icon see (<see href="https://materialdesignicons.com" /> for available
/// icons) or set to a path relative to the plugin folder pointing to a .svg file
/// If this list is not <see langword="null" /> and not empty <see cref="IsAlwaysAvailable" /> becomes
/// <see langword="false" /> and the data of this module is only available to profiles specifically targeting it.
/// </para>
/// </summary>
public string? DisplayIcon { get; set; }
public abstract List<IModuleActivationRequirement>? ActivationRequirements { get; }
/// <summary>
/// Gets whether this module is activated. A module can only be active while its <see cref="ActivationRequirements" />
@@ -114,12 +108,6 @@ namespace Artemis.Core.Modules
/// </summary>
public bool UpdateDuringActivationOverride { get; protected set; }
/// <summary>
/// A list of activation requirements
/// <para>Note: if empty the module is always activated</para>
/// </summary>
public List<IModuleActivationRequirement> ActivationRequirements { get; } = new();
/// <summary>
/// Gets or sets the activation requirement mode, defaults to <see cref="ActivationRequirementType.Any" />
/// </summary>
@@ -133,7 +121,7 @@ namespace Artemis.Core.Modules
/// <see langword="false" />
/// </para>
/// </summary>
public bool IsAlwaysAvailable => ActivationRequirements.Count == 0;
public bool IsAlwaysAvailable => ActivationRequirements == null || ActivationRequirements.Count == 0;
/// <summary>
/// Gets whether updating this module is currently allowed
@@ -181,12 +169,12 @@ namespace Artemis.Core.Modules
/// <returns>The evaluated result of the activation requirements</returns>
public bool EvaluateActivationRequirements()
{
if (!ActivationRequirements.Any())
if (IsAlwaysAvailable)
return true;
if (ActivationRequirementMode == ActivationRequirementType.All)
return ActivationRequirements.All(r => r.Evaluate());
return ActivationRequirements!.All(r => r.Evaluate());
if (ActivationRequirementMode == ActivationRequirementType.Any)
return ActivationRequirements.Any(r => r.Evaluate());
return ActivationRequirements!.Any(r => r.Evaluate());
return false;
}
+13 -1
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.DeviceProviders;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
@@ -132,6 +131,19 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _instance, value);
}
/// <summary>
/// Gets a string representing either a full path pointing to an svg or the markdown icon
/// </summary>
public string? ResolvedIcon
{
get
{
if (Icon == null)
return null;
return Icon.EndsWith(".svg") ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}
internal PluginFeatureEntity Entity { get; }
/// <inheritdoc />
+13
View File
@@ -152,6 +152,19 @@ namespace Artemis.Core
internal set => SetAndNotify(ref _plugin, value);
}
/// <summary>
/// Gets a string representing either a full path pointing to an svg or the markdown icon
/// </summary>
public string? ResolvedIcon
{
get
{
if (Icon == null)
return null;
return Icon.EndsWith(".svg") ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}
internal string PreferredPluginDirectory => $"{Main.Split(".dll")[0].Replace("/", "").Replace("\\", "")}-{Guid.ToString().Substring(0, 8)}";
/// <inheritdoc />
@@ -1,4 +1,5 @@
using Artemis.Core.LayerEffects;
using System.Collections.Generic;
using Artemis.Core.LayerEffects;
using Artemis.Core.Modules;
namespace Artemis.Core
@@ -14,6 +15,8 @@ namespace Artemis.Core
IsEnabled = true;
}
public override List<IModuleActivationRequirement>? ActivationRequirements => null;
public override void Enable()
{
}