mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Core - Fixed when condition stops being true mid-fade
This commit is contained in:
parent
7c2bab0f89
commit
b39dd14526
@ -25,7 +25,7 @@ public sealed class Profile : ProfileElement
|
||||
_scriptConfigurations = new ObservableCollection<ScriptConfiguration>();
|
||||
|
||||
Opacity = 0d;
|
||||
ShouldBeEnabled = true;
|
||||
ShouldDisplay = true;
|
||||
Configuration = configuration;
|
||||
Profile = this;
|
||||
ProfileEntity = profileEntity;
|
||||
@ -83,7 +83,7 @@ public sealed class Profile : ProfileElement
|
||||
|
||||
internal List<Exception> Exceptions { get; }
|
||||
|
||||
internal bool ShouldBeEnabled { get; private set; }
|
||||
internal bool ShouldDisplay { get; set; }
|
||||
|
||||
internal double Opacity { get; private set; }
|
||||
|
||||
@ -106,9 +106,9 @@ public sealed class Profile : ProfileElement
|
||||
|
||||
const double OPACITY_PER_SECOND = 1;
|
||||
|
||||
if (ShouldBeEnabled && Opacity < 1)
|
||||
if (ShouldDisplay && Opacity < 1)
|
||||
Opacity = Math.Clamp(Opacity + OPACITY_PER_SECOND * deltaTime, 0d, 1d);
|
||||
if (!ShouldBeEnabled && Opacity > 0)
|
||||
if (!ShouldDisplay && Opacity > 0)
|
||||
Opacity = Math.Clamp(Opacity - OPACITY_PER_SECOND * deltaTime, 0d, 1d);
|
||||
}
|
||||
}
|
||||
@ -186,17 +186,6 @@ public sealed class Profile : ProfileElement
|
||||
layer.PopulateLeds(devices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the fade out process.
|
||||
/// </summary>
|
||||
public void FadeOut()
|
||||
{
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Profile");
|
||||
|
||||
ShouldBeEnabled = false;
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
@ -213,13 +213,15 @@ internal class ProfileService : IProfileService
|
||||
// Make sure the profile is active or inactive according to the parameters above
|
||||
if (shouldBeActive && profileConfiguration.Profile == null && profileConfiguration.BrokenState != "Failed to activate profile")
|
||||
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
|
||||
if (shouldBeActive && profileConfiguration.Profile != null && !profileConfiguration.Profile.ShouldDisplay)
|
||||
profileConfiguration.Profile.ShouldDisplay = true;
|
||||
else if (!shouldBeActive && profileConfiguration.Profile != null)
|
||||
{
|
||||
if (!profileConfiguration.FadeInAndOut)
|
||||
DeactivateProfile(profileConfiguration);
|
||||
else if (!profileConfiguration.Profile.ShouldBeEnabled && profileConfiguration.Profile.Opacity <= 0)
|
||||
else if (!profileConfiguration.Profile.ShouldDisplay && profileConfiguration.Profile.Opacity <= 0)
|
||||
DeactivateProfile(profileConfiguration);
|
||||
else if (profileConfiguration.Profile.ShouldBeEnabled && profileConfiguration.Profile.Opacity >= 1)
|
||||
else if (profileConfiguration.Profile.Opacity > 0)
|
||||
RequestDeactivation(profileConfiguration);
|
||||
}
|
||||
|
||||
@ -261,7 +263,7 @@ internal class ProfileService : IProfileService
|
||||
{
|
||||
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
|
||||
// Ensure all criteria are met before rendering
|
||||
if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || (profileConfiguration.Profile?.ShouldBeEnabled == false && profileConfiguration.Profile?.Opacity >= 0)))
|
||||
if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || (profileConfiguration.Profile?.ShouldDisplay == false && profileConfiguration.Profile?.Opacity >= 0)))
|
||||
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -323,7 +325,10 @@ internal class ProfileService : IProfileService
|
||||
public Profile ActivateProfile(ProfileConfiguration profileConfiguration)
|
||||
{
|
||||
if (profileConfiguration.Profile != null)
|
||||
{
|
||||
profileConfiguration.Profile.ShouldDisplay = true;
|
||||
return profileConfiguration.Profile;
|
||||
}
|
||||
|
||||
ProfileEntity profileEntity;
|
||||
try
|
||||
@ -375,7 +380,7 @@ internal class ProfileService : IProfileService
|
||||
if (profileConfiguration.Profile == null)
|
||||
return;
|
||||
|
||||
profileConfiguration.Profile.FadeOut();
|
||||
profileConfiguration.Profile.ShouldDisplay = false;
|
||||
}
|
||||
|
||||
public void DeleteProfile(ProfileConfiguration profileConfiguration)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user