diff --git a/src/Artemis.Core/Models/Profile/Profile.cs b/src/Artemis.Core/Models/Profile/Profile.cs
index 7bbde4bd3..213ca0553 100644
--- a/src/Artemis.Core/Models/Profile/Profile.cs
+++ b/src/Artemis.Core/Models/Profile/Profile.cs
@@ -8,15 +8,6 @@ using SkiaSharp;
namespace Artemis.Core;
-
-internal enum FadingStatus
-{
- Enabled,
- FadingIn,
- FadingOut,
- Disabled
-}
-
///
/// Represents a profile containing folders and layers
///
@@ -27,15 +18,14 @@ public sealed class Profile : ProfileElement
private readonly ObservableCollection _scripts;
private bool _isFreshImport;
private ProfileElement? _lastSelectedProfileElement;
- private double _opacity;
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
{
_scripts = new ObservableCollection();
_scriptConfigurations = new ObservableCollection();
- _opacity = 0d;
- FadingStatus = FadingStatus.FadingIn;
+ Opacity = 0d;
+ ShouldBeEnabled = true;
Configuration = configuration;
Profile = this;
ProfileEntity = profileEntity;
@@ -93,7 +83,9 @@ public sealed class Profile : ProfileElement
internal List Exceptions { get; }
- internal FadingStatus FadingStatus { get; private set; }
+ internal bool ShouldBeEnabled { get; private set; }
+
+ internal double Opacity { get; private set; }
///
public override void Update(double deltaTime)
@@ -113,14 +105,11 @@ public sealed class Profile : ProfileElement
profileScript.OnProfileUpdated(deltaTime);
const double OPACITY_PER_SECOND = 1;
- if (FadingStatus == FadingStatus.FadingIn)
- _opacity = Math.Clamp(_opacity + OPACITY_PER_SECOND * deltaTime, 0d, 1d);
- if (FadingStatus == FadingStatus.FadingOut)
- _opacity = Math.Clamp(_opacity - OPACITY_PER_SECOND * deltaTime, 0d, 1d);
- if (_opacity == 0d)
- FadingStatus = FadingStatus.Disabled;
- if (_opacity == 1d)
- FadingStatus = FadingStatus.Enabled;
+
+ if (ShouldBeEnabled && Opacity < 1)
+ Opacity = Math.Clamp(Opacity + OPACITY_PER_SECOND * deltaTime, 0d, 1d);
+ if (!ShouldBeEnabled && Opacity > 0)
+ Opacity = Math.Clamp(Opacity - OPACITY_PER_SECOND * deltaTime, 0d, 1d);
}
}
@@ -136,8 +125,8 @@ public sealed class Profile : ProfileElement
profileScript.OnProfileRendering(canvas, canvas.LocalClipBounds);
using var opacityPaint = new SKPaint();
- if (Configuration.FadeInAndOut && FadingStatus != FadingStatus.Enabled)
- opacityPaint.Color = new SKColor(0, 0, 0, (byte)(255d * Easings.CubicEaseInOut(_opacity)));
+ if (Configuration.FadeInAndOut && Opacity != 1)
+ opacityPaint.Color = new SKColor(0, 0, 0, (byte)(255d * Easings.CubicEaseInOut(Opacity)));
canvas.SaveLayer(opacityPaint);
@@ -205,7 +194,7 @@ public sealed class Profile : ProfileElement
if (Disposed)
throw new ObjectDisposedException("Profile");
- FadingStatus = FadingStatus.FadingOut;
+ ShouldBeEnabled = false;
}
#region Overrides of BreakableModel
diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs
index 6a0c2ad52..ae403e05c 100644
--- a/src/Artemis.Core/Services/Storage/ProfileService.cs
+++ b/src/Artemis.Core/Services/Storage/ProfileService.cs
@@ -215,9 +215,11 @@ internal class ProfileService : IProfileService
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
else if (!shouldBeActive && profileConfiguration.Profile != null)
{
- if (!profileConfiguration.FadeInAndOut || profileConfiguration.Profile.FadingStatus == FadingStatus.Disabled)
+ if (!profileConfiguration.FadeInAndOut)
DeactivateProfile(profileConfiguration);
- else if (profileConfiguration.Profile.FadingStatus == FadingStatus.Enabled)
+ else if (!profileConfiguration.Profile.ShouldBeEnabled && profileConfiguration.Profile.Opacity <= 0)
+ DeactivateProfile(profileConfiguration);
+ else if (profileConfiguration.Profile.ShouldBeEnabled && profileConfiguration.Profile.Opacity >= 1)
RequestDeactivation(profileConfiguration);
}
@@ -259,7 +261,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?.FadingStatus == FadingStatus.FadingOut))
+ if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || (profileConfiguration.Profile?.ShouldBeEnabled == false && profileConfiguration.Profile?.Opacity >= 0)))
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
}
catch (Exception e)