From 0298759d1fbf7cf50442d9f6e52066669413ab0d Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sun, 21 Dec 2025 08:49:47 +0000 Subject: [PATCH] Panel animation uses double time --- .../Systems/UI/Panel/Panel.Event.cs | 2 +- .../Systems/UI/Panel/Panel.Util.cs | 8 ++++---- .../Systems/UI/Styles/Styles.Animation.cs | 6 +++--- .../Systems/UI/Styles/Transitions.cs | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Event.cs b/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Event.cs index 0b21c423..702334f1 100644 --- a/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Event.cs +++ b/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Event.cs @@ -187,7 +187,7 @@ public partial class Panel if ( debounce.HasValue ) { - e.Time = TimeNow + debounce.Value; + e.Time = (float)(TimeNow + debounce.Value); } } diff --git a/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Util.cs b/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Util.cs index a7eff98c..575a60b4 100644 --- a/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Util.cs +++ b/engine/Sandbox.Engine/Systems/UI/Panel/Panel.Util.cs @@ -5,8 +5,8 @@ namespace Sandbox.UI; public partial class Panel { - internal float TimeNow => PanelRealTime.TimeNow; - internal float TimeDelta => PanelRealTime.TimeDelta; + internal double TimeNow => PanelRealTime.TimeNow; + internal double TimeDelta => PanelRealTime.TimeDelta; /// /// Can be used to store random data without sub-classing the panel. @@ -36,8 +36,8 @@ public partial class Panel static class PanelRealTime { - public static float TimeNow; - public static float TimeDelta; + public static double TimeNow; + public static double TimeDelta; public static void Update() { diff --git a/engine/Sandbox.Engine/Systems/UI/Styles/Styles.Animation.cs b/engine/Sandbox.Engine/Systems/UI/Styles/Styles.Animation.cs index 459053cd..f73197a2 100644 --- a/engine/Sandbox.Engine/Systems/UI/Styles/Styles.Animation.cs +++ b/engine/Sandbox.Engine/Systems/UI/Styles/Styles.Animation.cs @@ -3,7 +3,7 @@ public partial class Styles { KeyFrames currentFrames; - float animationStart; + double animationStart; Styles animStyle; /// @@ -109,7 +109,7 @@ public partial class Styles } var f = Utility.Easing.GetFunction( AnimationTimingFunction ?? "linear" ); - delta = f( delta ); + delta = f( (float)delta ); if ( playLength >= totalDuration ) { @@ -120,7 +120,7 @@ public partial class Styles return false; } - keyframes.FillStyle( delta, animStyle ); + keyframes.FillStyle( (float)delta, animStyle ); Add( animStyle ); diff --git a/engine/Sandbox.Engine/Systems/UI/Styles/Transitions.cs b/engine/Sandbox.Engine/Systems/UI/Styles/Transitions.cs index 727c40f6..25aa897e 100644 --- a/engine/Sandbox.Engine/Systems/UI/Styles/Transitions.cs +++ b/engine/Sandbox.Engine/Systems/UI/Styles/Transitions.cs @@ -12,15 +12,15 @@ public sealed class Transitions public struct Entry { public string Property { get; init; } - public float StartTime { get; init; } - public float Length { get; init; } + public double StartTime { get; init; } + public double Length { get; init; } public int Target { get; init; } public Utility.Easing.Function EasingFunction { get; init; } public bool IsKilled { get; private set; } public TransitionFunction Action { get; init; } - public Entry( string property, float startTime, float length, int target, TransitionFunction action, Easing.Function easingFunction ) : this() + public Entry( string property, double startTime, double length, int target, TransitionFunction action, Easing.Function easingFunction ) : this() { Property = property; StartTime = startTime; @@ -107,7 +107,7 @@ public sealed class Transitions } } - internal void Add( Styles from, Styles to, float startTime ) + internal void Add( Styles from, Styles to, double startTime ) { if ( !to.HasTransitions ) return; @@ -124,7 +124,7 @@ public sealed class Transitions } } - void Transition( in TransitionDesc desc, BaseStyles from, BaseStyles to, TransitionFunction action, float startTime ) + void Transition( in TransitionDesc desc, BaseStyles from, BaseStyles to, TransitionFunction action, double startTime ) { if ( from == to ) return; @@ -134,7 +134,7 @@ public sealed class Transitions Add( desc, target, action, startTime ); } - void Add( in TransitionDesc desc, int target, TransitionFunction action, float startTime ) + void Add( in TransitionDesc desc, int target, TransitionFunction action, double startTime ) { var length = 1.0f; var property = desc.Property; @@ -157,7 +157,7 @@ public sealed class Transitions Entries.Add( entry ); } - internal bool Run( Styles style, float now ) + internal bool Run( Styles style, double now ) { if ( !HasAny ) return false; @@ -183,7 +183,7 @@ public sealed class Transitions var t = entry.IsKilled ? 1f : (now - entry.StartTime) / entry.Length; - entry.Invoke( style, entry.Ease( t ) ); + entry.Invoke( style, entry.Ease( (float)t ) ); } if ( Entries.RemoveAll( x => x.IsKilled ) > 0 )