Modules - Improved override behavior when activation reqs are met

Profile editor - Fixed error when pressing play without a selected element
This commit is contained in:
SpoinkyNL committed 2020-09-27 22:09:28 +02:00
1 parent fc91fd7225
commit e30e37e8e3
2 files changed
+24 -5

No files matched your search

+21 -5
View File
@@ -47,11 +47,6 @@ namespace Artemis.Core.Services
if (ActiveModuleOverride == overrideModule)
return;
// Always deactivate all modules whenever override is called
var modules = _pluginService.GetPluginsOfType<Module>().ToList();
foreach (var module in modules)
OverrideDeactivate(module);
if (overrideModule != null)
{
OverrideActivate(overrideModule);
@@ -60,6 +55,11 @@ namespace Artemis.Core.Services
else
_logger.Information("Clearing active module override");
// Always deactivate all other modules whenever override is called
var modules = _pluginService.GetPluginsOfType<Module>().ToList();
foreach (var module in modules.Where(m => m != overrideModule))
OverrideDeactivate(module);
ActiveModuleOverride = overrideModule;
}
finally
@@ -78,7 +78,23 @@ namespace Artemis.Core.Services
await ActiveModuleSemaphore.WaitAsync();
if (ActiveModuleOverride != null)
{
// The conditions of the active module override may be matched, in that case reactivate as a non-override
// the principle is different for this service but not for the module
var shouldBeActivated = ActiveModuleOverride.EvaluateActivationRequirements();
if (shouldBeActivated && ActiveModuleOverride.IsActivatedOverride)
{
ActiveModuleOverride.Deactivate(true);
ActiveModuleOverride.Activate(false);
}
else if (!shouldBeActivated && !ActiveModuleOverride.IsActivatedOverride)
{
ActiveModuleOverride.Deactivate(false);
ActiveModuleOverride.Activate(true);
}
return;
}
var stopwatch = new Stopwatch();
stopwatch.Start();
@@ -562,6 +562,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
Execute.PostToUIThread(() =>
{
var newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime));
if (SelectedProfileElement != null)
{
if (Repeating && RepeatTimeline)
{
if (newTime > SelectedProfileElement.TimelineLength)
@@ -577,6 +579,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
newTime = SelectedProfileElement.TimelineLength;
Pause();
}
}
ProfileEditorService.CurrentTime = newTime;
});