mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Removed FadingStatus enum
This commit is contained in:
parent
194780b25c
commit
7c2bab0f89
@ -8,15 +8,6 @@ using SkiaSharp;
|
|||||||
|
|
||||||
namespace Artemis.Core;
|
namespace Artemis.Core;
|
||||||
|
|
||||||
|
|
||||||
internal enum FadingStatus
|
|
||||||
{
|
|
||||||
Enabled,
|
|
||||||
FadingIn,
|
|
||||||
FadingOut,
|
|
||||||
Disabled
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a profile containing folders and layers
|
/// Represents a profile containing folders and layers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,15 +18,14 @@ public sealed class Profile : ProfileElement
|
|||||||
private readonly ObservableCollection<ProfileScript> _scripts;
|
private readonly ObservableCollection<ProfileScript> _scripts;
|
||||||
private bool _isFreshImport;
|
private bool _isFreshImport;
|
||||||
private ProfileElement? _lastSelectedProfileElement;
|
private ProfileElement? _lastSelectedProfileElement;
|
||||||
private double _opacity;
|
|
||||||
|
|
||||||
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
|
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
|
||||||
{
|
{
|
||||||
_scripts = new ObservableCollection<ProfileScript>();
|
_scripts = new ObservableCollection<ProfileScript>();
|
||||||
_scriptConfigurations = new ObservableCollection<ScriptConfiguration>();
|
_scriptConfigurations = new ObservableCollection<ScriptConfiguration>();
|
||||||
_opacity = 0d;
|
|
||||||
|
|
||||||
FadingStatus = FadingStatus.FadingIn;
|
Opacity = 0d;
|
||||||
|
ShouldBeEnabled = true;
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
Profile = this;
|
Profile = this;
|
||||||
ProfileEntity = profileEntity;
|
ProfileEntity = profileEntity;
|
||||||
@ -93,7 +83,9 @@ public sealed class Profile : ProfileElement
|
|||||||
|
|
||||||
internal List<Exception> Exceptions { get; }
|
internal List<Exception> Exceptions { get; }
|
||||||
|
|
||||||
internal FadingStatus FadingStatus { get; private set; }
|
internal bool ShouldBeEnabled { get; private set; }
|
||||||
|
|
||||||
|
internal double Opacity { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
@ -113,14 +105,11 @@ public sealed class Profile : ProfileElement
|
|||||||
profileScript.OnProfileUpdated(deltaTime);
|
profileScript.OnProfileUpdated(deltaTime);
|
||||||
|
|
||||||
const double OPACITY_PER_SECOND = 1;
|
const double OPACITY_PER_SECOND = 1;
|
||||||
if (FadingStatus == FadingStatus.FadingIn)
|
|
||||||
_opacity = Math.Clamp(_opacity + OPACITY_PER_SECOND * deltaTime, 0d, 1d);
|
if (ShouldBeEnabled && Opacity < 1)
|
||||||
if (FadingStatus == FadingStatus.FadingOut)
|
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 (_opacity == 0d)
|
Opacity = Math.Clamp(Opacity - OPACITY_PER_SECOND * deltaTime, 0d, 1d);
|
||||||
FadingStatus = FadingStatus.Disabled;
|
|
||||||
if (_opacity == 1d)
|
|
||||||
FadingStatus = FadingStatus.Enabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,8 +125,8 @@ public sealed class Profile : ProfileElement
|
|||||||
profileScript.OnProfileRendering(canvas, canvas.LocalClipBounds);
|
profileScript.OnProfileRendering(canvas, canvas.LocalClipBounds);
|
||||||
|
|
||||||
using var opacityPaint = new SKPaint();
|
using var opacityPaint = new SKPaint();
|
||||||
if (Configuration.FadeInAndOut && FadingStatus != FadingStatus.Enabled)
|
if (Configuration.FadeInAndOut && Opacity != 1)
|
||||||
opacityPaint.Color = new SKColor(0, 0, 0, (byte)(255d * Easings.CubicEaseInOut(_opacity)));
|
opacityPaint.Color = new SKColor(0, 0, 0, (byte)(255d * Easings.CubicEaseInOut(Opacity)));
|
||||||
|
|
||||||
canvas.SaveLayer(opacityPaint);
|
canvas.SaveLayer(opacityPaint);
|
||||||
|
|
||||||
@ -205,7 +194,7 @@ public sealed class Profile : ProfileElement
|
|||||||
if (Disposed)
|
if (Disposed)
|
||||||
throw new ObjectDisposedException("Profile");
|
throw new ObjectDisposedException("Profile");
|
||||||
|
|
||||||
FadingStatus = FadingStatus.FadingOut;
|
ShouldBeEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of BreakableModel
|
#region Overrides of BreakableModel
|
||||||
|
|||||||
@ -215,9 +215,11 @@ internal class ProfileService : IProfileService
|
|||||||
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
|
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
|
||||||
else if (!shouldBeActive && profileConfiguration.Profile != null)
|
else if (!shouldBeActive && profileConfiguration.Profile != null)
|
||||||
{
|
{
|
||||||
if (!profileConfiguration.FadeInAndOut || profileConfiguration.Profile.FadingStatus == FadingStatus.Disabled)
|
if (!profileConfiguration.FadeInAndOut)
|
||||||
DeactivateProfile(profileConfiguration);
|
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);
|
RequestDeactivation(profileConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +261,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?.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);
|
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user