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:
SpoinkyNL committed 2020-12-12 10:57:09 +01:00
1 parent c6181ea823
commit 8e8258506b
8 files changed
+879 -83

No files matched your search

+1 -6
View File
@@ -97,7 +97,6 @@ namespace Artemis.Core.Services
ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface;
_logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId);
PlayIntroAnimation();
OnInitialized();
}
@@ -111,12 +110,8 @@ namespace Artemis.Core.Services
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);
// Draw a white overlay over the device
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Artemis.Core.Services
{
/// <summary>
/// A service that initializes the Core and manages the render loop
/// A service that initializes the Core and manages the render loop
/// </summary>
public interface ICoreService : IArtemisService, IDisposable
{
@@ -33,6 +33,11 @@ namespace Artemis.Core.Services
/// </summary>
void Initialize();
/// <summary>
/// Plays the into animation profile defined in <c>Resources/intro-profile.json</c>
/// </summary>
void PlayIntroAnimation();
/// <summary>
/// Occurs the core has finished initializing
/// </summary>
@@ -185,6 +185,7 @@ namespace Artemis.Core.Services
// Load the plugin assemblies into the plugin context
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins"));
foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories())
{
try
{
Plugin plugin = LoadPlugin(subDirectory);
@@ -195,6 +196,7 @@ namespace Artemis.Core.Services
{
_logger.Warning(new ArtemisPluginException("Failed to load plugin", e), "Plugin exception");
}
}
LoadingPlugins = false;
}
@@ -308,6 +310,7 @@ namespace Artemis.Core.Services
// 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
foreach (Type featureType in featureTypes)
{
try
{
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
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)
{
throw new ArtemisPluginException(plugin, "Failed to instantiate feature", e);
}
}
// Activate plugins after they are all loaded
foreach (PluginFeature pluginFeature in plugin.Features.Where(i => i.Entity.IsEnabled))
{
try
{
EnablePluginFeature(pluginFeature, false, !ignorePluginLock);
@@ -336,6 +341,7 @@ namespace Artemis.Core.Services
{
// ignored, logged in EnablePluginFeature
}
}
if (saveState)
{
@@ -477,8 +483,10 @@ namespace Artemis.Core.Services
private void SavePlugin(Plugin plugin)
{
foreach (PluginFeature pluginFeature in plugin.Features)
{
if (plugin.Entity.Features.All(i => i.Type != pluginFeature.GetType().FullName))
plugin.Entity.Features.Add(pluginFeature.Entity);
}
_pluginRepository.SavePlugin(plugin.Entity);
}
@@ -207,7 +207,9 @@ namespace Artemis.Core.Services
public void AutoArrange(ArtemisSurface? artemisSurface = null)
{
artemisSurface ??= ActiveSurface;
if (!artemisSurface.Devices.Any())
return;
SurfaceArrangement surfaceArrangement = SurfaceArrangement.GetDefaultArrangement();
surfaceArrangement.Arrange(artemisSurface);
UpdateSurfaceConfiguration(artemisSurface, true);