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