mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Plugins - Add JSON property to disable auto-enabling features
Setup wizard - Play intro animation at the end (and no where else)
This commit is contained in:
parent
c6181ea823
commit
8e8258506b
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Core
|
namespace Artemis.Core
|
||||||
@ -9,6 +10,7 @@ namespace Artemis.Core
|
|||||||
[JsonObject(MemberSerialization.OptIn)]
|
[JsonObject(MemberSerialization.OptIn)]
|
||||||
public class PluginInfo : CorePropertyChanged
|
public class PluginInfo : CorePropertyChanged
|
||||||
{
|
{
|
||||||
|
private bool _autoEnableFeatures = true;
|
||||||
private string? _description;
|
private string? _description;
|
||||||
private Guid _guid;
|
private Guid _guid;
|
||||||
private string? _icon;
|
private string? _icon;
|
||||||
@ -83,6 +85,17 @@ namespace Artemis.Core
|
|||||||
internal set => SetAndNotify(ref _main, value);
|
internal set => SetAndNotify(ref _main, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether this plugin should automatically enable all its features when it is first loaded
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||||
|
public bool AutoEnableFeatures
|
||||||
|
{
|
||||||
|
get => _autoEnableFeatures;
|
||||||
|
set => SetAndNotify(ref _autoEnableFeatures, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the plugin this info is associated with
|
/// Gets the plugin this info is associated with
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -97,7 +97,6 @@ namespace Artemis.Core.Services
|
|||||||
ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface;
|
ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface;
|
||||||
_logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId);
|
_logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId);
|
||||||
|
|
||||||
PlayIntroAnimation();
|
|
||||||
OnInitialized();
|
OnInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,12 +110,8 @@ namespace Artemis.Core.Services
|
|||||||
FrameRendered?.Invoke(this, e);
|
FrameRendered?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayIntroAnimation()
|
public void PlayIntroAnimation()
|
||||||
{
|
{
|
||||||
// The intro is cool and all, but sometimes you just wanna see what you're working on straight away ^^
|
|
||||||
if (Debugger.IsAttached)
|
|
||||||
return;
|
|
||||||
|
|
||||||
IntroAnimation intro = new IntroAnimation(_logger, _profileService, _surfaceService);
|
IntroAnimation intro = new IntroAnimation(_logger, _profileService, _surfaceService);
|
||||||
|
|
||||||
// Draw a white overlay over the device
|
// Draw a white overlay over the device
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A service that initializes the Core and manages the render loop
|
/// A service that initializes the Core and manages the render loop
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICoreService : IArtemisService, IDisposable
|
public interface ICoreService : IArtemisService, IDisposable
|
||||||
{
|
{
|
||||||
@ -33,6 +33,11 @@ namespace Artemis.Core.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Plays the into animation profile defined in <c>Resources/intro-profile.json</c>
|
||||||
|
/// </summary>
|
||||||
|
void PlayIntroAnimation();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs the core has finished initializing
|
/// Occurs the core has finished initializing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -185,6 +185,7 @@ namespace Artemis.Core.Services
|
|||||||
// Load the plugin assemblies into the plugin context
|
// Load the plugin assemblies into the plugin context
|
||||||
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins"));
|
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins"));
|
||||||
foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories())
|
foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories())
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Plugin plugin = LoadPlugin(subDirectory);
|
Plugin plugin = LoadPlugin(subDirectory);
|
||||||
@ -195,6 +196,7 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
_logger.Warning(new ArtemisPluginException("Failed to load plugin", e), "Plugin exception");
|
_logger.Warning(new ArtemisPluginException("Failed to load plugin", e), "Plugin exception");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LoadingPlugins = false;
|
LoadingPlugins = false;
|
||||||
}
|
}
|
||||||
@ -308,6 +310,7 @@ namespace Artemis.Core.Services
|
|||||||
// Create instances of each feature and add them to the plugin
|
// Create instances of each feature and add them to the plugin
|
||||||
// Construction should be simple and not contain any logic so failure at this point means the entire plugin fails
|
// Construction should be simple and not contain any logic so failure at this point means the entire plugin fails
|
||||||
foreach (Type featureType in featureTypes)
|
foreach (Type featureType in featureTypes)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.Kernel.Bind(featureType).ToSelf().InSingletonScope();
|
plugin.Kernel.Bind(featureType).ToSelf().InSingletonScope();
|
||||||
@ -319,15 +322,17 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
// Load the enabled state and if not found, default to true
|
// Load the enabled state and if not found, default to true
|
||||||
instance.Entity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ??
|
instance.Entity = plugin.Entity.Features.FirstOrDefault(i => i.Type == featureType.FullName) ??
|
||||||
new PluginFeatureEntity {IsEnabled = true, Type = featureType.FullName!};
|
new PluginFeatureEntity {IsEnabled = plugin.Info.AutoEnableFeatures, Type = featureType.FullName!};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new ArtemisPluginException(plugin, "Failed to instantiate feature", e);
|
throw new ArtemisPluginException(plugin, "Failed to instantiate feature", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Activate plugins after they are all loaded
|
// Activate plugins after they are all loaded
|
||||||
foreach (PluginFeature pluginFeature in plugin.Features.Where(i => i.Entity.IsEnabled))
|
foreach (PluginFeature pluginFeature in plugin.Features.Where(i => i.Entity.IsEnabled))
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EnablePluginFeature(pluginFeature, false, !ignorePluginLock);
|
EnablePluginFeature(pluginFeature, false, !ignorePluginLock);
|
||||||
@ -336,6 +341,7 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
// ignored, logged in EnablePluginFeature
|
// ignored, logged in EnablePluginFeature
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (saveState)
|
if (saveState)
|
||||||
{
|
{
|
||||||
@ -477,8 +483,10 @@ namespace Artemis.Core.Services
|
|||||||
private void SavePlugin(Plugin plugin)
|
private void SavePlugin(Plugin plugin)
|
||||||
{
|
{
|
||||||
foreach (PluginFeature pluginFeature in plugin.Features)
|
foreach (PluginFeature pluginFeature in plugin.Features)
|
||||||
|
{
|
||||||
if (plugin.Entity.Features.All(i => i.Type != pluginFeature.GetType().FullName))
|
if (plugin.Entity.Features.All(i => i.Type != pluginFeature.GetType().FullName))
|
||||||
plugin.Entity.Features.Add(pluginFeature.Entity);
|
plugin.Entity.Features.Add(pluginFeature.Entity);
|
||||||
|
}
|
||||||
|
|
||||||
_pluginRepository.SavePlugin(plugin.Entity);
|
_pluginRepository.SavePlugin(plugin.Entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,7 +207,9 @@ namespace Artemis.Core.Services
|
|||||||
public void AutoArrange(ArtemisSurface? artemisSurface = null)
|
public void AutoArrange(ArtemisSurface? artemisSurface = null)
|
||||||
{
|
{
|
||||||
artemisSurface ??= ActiveSurface;
|
artemisSurface ??= ActiveSurface;
|
||||||
|
if (!artemisSurface.Devices.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
SurfaceArrangement surfaceArrangement = SurfaceArrangement.GetDefaultArrangement();
|
SurfaceArrangement surfaceArrangement = SurfaceArrangement.GetDefaultArrangement();
|
||||||
surfaceArrangement.Arrange(artemisSurface);
|
surfaceArrangement.Arrange(artemisSurface);
|
||||||
UpdateSurfaceConfiguration(artemisSurface, true);
|
UpdateSurfaceConfiguration(artemisSurface, true);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Core.DeviceProviders;
|
using Artemis.Core.DeviceProviders;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
@ -24,7 +25,13 @@ namespace Artemis.UI.Screens.SetupWizard.Steps
|
|||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Items.Clear();
|
Items.Clear();
|
||||||
Items.AddRange(_pluginManagementService.GetFeaturesOfType<DeviceProvider>().Select(d => _settingsVmFactory.CreatePluginFeatureViewModel(d)));
|
|
||||||
|
// _pluginManagementService.GetFeaturesOfType<>() will only give us enabled features so lets get all of them this way
|
||||||
|
IEnumerable<DeviceProvider> features = _pluginManagementService.GetAllPlugins()
|
||||||
|
.SelectMany(p => p.Features.Where(f => f is DeviceProvider))
|
||||||
|
.Cast<DeviceProvider>()
|
||||||
|
.OrderBy(d => d.GetType().Name);
|
||||||
|
Items.AddRange(features.Select(d => _settingsVmFactory.CreatePluginFeatureViewModel(d)));
|
||||||
|
|
||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,18 @@
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.SetupWizard.Steps
|
namespace Artemis.UI.Screens.SetupWizard.Steps
|
||||||
{
|
{
|
||||||
public class FinishStepViewModel : Screen
|
public class FinishStepViewModel : Screen
|
||||||
{
|
{
|
||||||
|
private readonly ICoreService _coreService;
|
||||||
|
|
||||||
|
public FinishStepViewModel(ICoreService coreService)
|
||||||
|
{
|
||||||
|
_coreService = coreService;
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
|
public void OpenHyperlink(object sender, RequestNavigateEventArgs e)
|
||||||
{
|
{
|
||||||
Core.Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
Core.Utilities.OpenUrl(e.Uri.AbsoluteUri);
|
||||||
@ -14,5 +22,11 @@ namespace Artemis.UI.Screens.SetupWizard.Steps
|
|||||||
{
|
{
|
||||||
((SetupWizardViewModel) Parent).SkipOrFinishWizard();
|
((SetupWizardViewModel) Parent).SkipOrFinishWizard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivate()
|
||||||
|
{
|
||||||
|
_coreService.PlayIntroAnimation();
|
||||||
|
base.OnActivate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user