1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-03-24 10:18:47 +00:00

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 2020-09-27 22:09:28 +02:00
parent fc91fd7225
commit e30e37e8e3
2 changed files with 38 additions and 19 deletions

View File

@ -46,12 +46,7 @@ namespace Artemis.Core.Services
if (ActiveModuleOverride == overrideModule) if (ActiveModuleOverride == overrideModule)
return; 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) if (overrideModule != null)
{ {
OverrideActivate(overrideModule); OverrideActivate(overrideModule);
@ -60,6 +55,11 @@ namespace Artemis.Core.Services
else else
_logger.Information("Clearing active module override"); _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; ActiveModuleOverride = overrideModule;
} }
finally finally
@ -78,7 +78,23 @@ namespace Artemis.Core.Services
await ActiveModuleSemaphore.WaitAsync(); await ActiveModuleSemaphore.WaitAsync();
if (ActiveModuleOverride != null) 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; return;
}
var stopwatch = new Stopwatch(); var stopwatch = new Stopwatch();
stopwatch.Start(); stopwatch.Start();

View File

@ -562,20 +562,23 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
Execute.PostToUIThread(() => Execute.PostToUIThread(() =>
{ {
var newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime)); var newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime));
if (Repeating && RepeatTimeline) if (SelectedProfileElement != null)
{ {
if (newTime > SelectedProfileElement.TimelineLength) if (Repeating && RepeatTimeline)
newTime = TimeSpan.Zero; {
} if (newTime > SelectedProfileElement.TimelineLength)
else if (Repeating && RepeatSegment) newTime = TimeSpan.Zero;
{ }
if (newTime > GetCurrentSegmentEnd()) else if (Repeating && RepeatSegment)
newTime = GetCurrentSegmentStart(); {
} if (newTime > GetCurrentSegmentEnd())
else if (newTime > SelectedProfileElement.TimelineLength) newTime = GetCurrentSegmentStart();
{ }
newTime = SelectedProfileElement.TimelineLength; else if (newTime > SelectedProfileElement.TimelineLength)
Pause(); {
newTime = SelectedProfileElement.TimelineLength;
Pause();
}
} }
ProfileEditorService.CurrentTime = newTime; ProfileEditorService.CurrentTime = newTime;