Skip to content

Commit

Permalink
revert Gradient Percent to Bitmap Layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Dec 11, 2024
1 parent f00b151 commit 4c3e56d
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Controls;
using System.Globalization;
using System.Windows.Controls;
using AuroraRgb.EffectsEngine;
using AuroraRgb.Profiles;
using AuroraRgb.Settings.Layers.Controls;
Expand Down Expand Up @@ -29,28 +30,47 @@ public override void Default()
[LogicOverrideIgnoreProperty("_PrimaryColor")]
[LogicOverrideIgnoreProperty("SecondaryColor")]
[LayerHandlerMeta(Name = "Percent (Gradient)", IsDefault = true)]
public class PercentGradientLayerHandler : PercentLayerHandler<PercentGradientLayerHandlerProperties>
public sealed class PercentGradientLayerHandler() : LayerHandler<PercentGradientLayerHandlerProperties, BitmapEffectLayer>("PercentLayer")
{
protected override UserControl CreateControl()
{
return new Control_PercentGradientLayer(this);
}

public override EffectLayer Render(IGameState state)
public override EffectLayer Render(IGameState gameState)
{
if (Invalidated)
{
EffectLayer.Clear();
}
Invalidated = false;

var value = Properties.Logic?._Value ?? state.GetNumber(Properties.VariablePath);
var maxvalue = Properties.Logic?._MaxValue ?? state.GetNumber(Properties.MaxVariablePath);
var value = Properties.Logic?._Value ?? gameState.GetNumber(Properties.VariablePath);
var maxvalue = Properties.Logic?._MaxValue ?? gameState.GetNumber(Properties.MaxVariablePath);

EffectLayer.PercentEffect(Properties.Gradient.GetColorSpectrum(), Properties.Sequence, value, maxvalue, Properties.PercentType, Properties.BlinkThreshold, Properties.BlinkDirection);
// below is for no-render layer
//var percentDrawer = new ZoneKeyPercentDrawer(EffectLayer);
//percentDrawer.PercentEffect(Properties.Gradient.GetColorSpectrum(), Properties.Sequence, value, maxvalue, Properties.PercentType, Properties.BlinkThreshold, Properties.BlinkDirection);
return EffectLayer;
}

public override void SetApplication(Application profile)
{
if (!double.TryParse(Properties.VariablePath.GsiPath, CultureInfo.InvariantCulture, out _) &&
!string.IsNullOrWhiteSpace(Properties.VariablePath.GsiPath) &&
!profile.ParameterLookup.IsValidParameter(Properties.VariablePath.GsiPath)
)
Properties.VariablePath = VariablePath.Empty;

if (!double.TryParse(Properties.MaxVariablePath.GsiPath, CultureInfo.InvariantCulture, out _) &&
!string.IsNullOrWhiteSpace(Properties.MaxVariablePath.GsiPath) &&
!profile.ParameterLookup.IsValidParameter(Properties.MaxVariablePath.GsiPath)
)
Properties.MaxVariablePath = VariablePath.Empty;
base.SetApplication(profile);
}

public override void Dispose()
{
EffectLayer.Dispose();
Expand Down

0 comments on commit 4c3e56d

Please sign in to comment.