mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Setup wizard - Added and auto-show on home open
UI - Slightly darkened W11 effect
This commit is contained in:
1 parent
5c1da6d2c4
commit
1210dc3f63
37 files changed
+1177
-487
No files matched your search
@@ -38,7 +38,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// The full path to the Artemis data folder
|
||||
/// </summary>
|
||||
public static readonly string DataFolder = Path.Combine(BaseFolder, "Artemis");
|
||||
public static readonly string DataFolder = Path.Combine(BaseFolder, "Artemis.Avalonia");
|
||||
|
||||
/// <summary>
|
||||
/// The full path to the Artemis logs folder
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.DeviceProviders;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using McMaster.NETCore.Plugins;
|
||||
using Ninject;
|
||||
@@ -16,6 +17,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class Plugin : CorePropertyChanged, IDisposable
|
||||
{
|
||||
private readonly bool _loadedFromStorage;
|
||||
private readonly List<PluginFeatureInfo> _features;
|
||||
private readonly List<Profiler> _profilers;
|
||||
|
||||
@@ -25,9 +27,10 @@ namespace Artemis.Core
|
||||
{
|
||||
Info = info;
|
||||
Directory = directory;
|
||||
Entity = pluginEntity ?? new PluginEntity {Id = Guid, IsEnabled = true};
|
||||
Entity = pluginEntity ?? new PluginEntity {Id = Guid};
|
||||
Info.Plugin = this;
|
||||
|
||||
_loadedFromStorage = pluginEntity != null;
|
||||
_features = new List<PluginFeatureInfo>();
|
||||
_profilers = new List<Profiler>();
|
||||
|
||||
@@ -309,6 +312,27 @@ namespace Artemis.Core
|
||||
{
|
||||
return Entity.Features.Any(f => f.IsEnabled) || Features.Any(f => f.AlwaysEnabled);
|
||||
}
|
||||
|
||||
internal void AutoEnableIfNew()
|
||||
{
|
||||
if (_loadedFromStorage)
|
||||
return;
|
||||
|
||||
// Enabled is preset to true if the plugin meets the following criteria
|
||||
// - Requires no admin rights
|
||||
// - No always-enabled device providers
|
||||
// - Either has no prerequisites or they are all met
|
||||
Entity.IsEnabled = !Info.RequiresAdmin &&
|
||||
Features.All(f => !f.AlwaysEnabled || !f.FeatureType.IsAssignableTo(typeof(DeviceProvider))) &&
|
||||
Info.ArePrerequisitesMet();
|
||||
|
||||
if (!Entity.IsEnabled)
|
||||
return;
|
||||
|
||||
// Also auto-enable any non-device provider feature
|
||||
foreach (PluginFeatureInfo pluginFeatureInfo in Features)
|
||||
pluginFeatureInfo.Entity.IsEnabled = !pluginFeatureInfo.FeatureType.IsAssignableTo(typeof(DeviceProvider));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
@@ -316,5 +340,7 @@ namespace Artemis.Core
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the plugin
|
||||
/// The name of the feature
|
||||
/// </summary>
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Name
|
||||
@@ -101,7 +101,7 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the plugin
|
||||
/// A short description of the feature
|
||||
/// </summary>
|
||||
[JsonProperty]
|
||||
public string? Description
|
||||
|
||||
@@ -362,23 +362,25 @@ namespace Artemis.Core.Services
|
||||
foreach (Type featureType in featureTypes)
|
||||
{
|
||||
// Load the enabled state and if not found, default to true
|
||||
PluginFeatureEntity featureEntity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ??
|
||||
new PluginFeatureEntity {IsEnabled = true, Type = featureType.FullName!};
|
||||
PluginFeatureEntity featureEntity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ?? new PluginFeatureEntity {Type = featureType.FullName!};
|
||||
PluginFeatureInfo feature = new(plugin, featureType, featureEntity, (PluginFeatureAttribute?) Attribute.GetCustomAttribute(featureType, typeof(PluginFeatureAttribute)));
|
||||
|
||||
|
||||
// If the plugin only has a single feature, it should always be enabled
|
||||
if (featureTypes.Count == 1)
|
||||
feature.AlwaysEnabled = true;
|
||||
|
||||
|
||||
plugin.AddFeature(feature);
|
||||
}
|
||||
|
||||
if (!featureTypes.Any())
|
||||
_logger.Warning("Plugin {plugin} contains no features", plugin);
|
||||
|
||||
// It is appropriate to call this now that we have the features of this plugin
|
||||
plugin.AutoEnableIfNew();
|
||||
|
||||
List<Type> bootstrappers = plugin.Assembly.GetTypes().Where(t => typeof(PluginBootstrapper).IsAssignableFrom(t)).ToList();
|
||||
if (bootstrappers.Count > 1)
|
||||
_logger.Warning($"{plugin} has more than one bootstrapper, only initializing {bootstrappers.First().FullName}");
|
||||
_logger.Warning("{Plugin} has more than one bootstrapper, only initializing {FullName}", plugin, bootstrappers.First().FullName);
|
||||
if (bootstrappers.Any())
|
||||
{
|
||||
plugin.Bootstrapper = (PluginBootstrapper?) Activator.CreateInstance(bootstrappers.First());
|
||||
@@ -398,7 +400,7 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
if (!plugin.Info.IsCompatible)
|
||||
throw new ArtemisPluginException(plugin, $"This plugin only supports the following operating system(s): {plugin.Info.Platforms}");
|
||||
|
||||
|
||||
if (plugin.Assembly == null)
|
||||
throw new ArtemisPluginException(plugin, "Cannot enable a plugin that hasn't successfully been loaded");
|
||||
|
||||
|
||||
Reference in new issue
Block a user