Add Reduced Motion for Notifications (#1732)

When Reduced Motion configuration is on, the expiry progressbar is
removed, and instead a pie on top right is shown, and relative time
update interval increases to 15 seconds. Progress wave animation also is
suppressed.
This commit is contained in:
srkizer 2024-03-21 05:53:20 +09:00 committed by GitHub
parent fb60ac5b4b
commit 95defa200f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 185 additions and 49 deletions

View file

@ -2,6 +2,7 @@ using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Animation;
using Dalamud.Interface.Animation.EasingFunctions;
using Dalamud.Interface.Internal;
@ -187,16 +188,18 @@ internal sealed partial class ActiveNotification : IActiveNotification
set => this.newProgress = value;
}
private static bool ReducedMotions => Service<DalamudConfiguration>.Get().ReduceMotions;
/// <summary>Gets the eased progress.</summary>
private float ProgressEased
{
get
{
var underlyingProgress = this.underlyingNotification.Progress;
if (Math.Abs(underlyingProgress - this.progressBefore) < 0.000001f || this.progressEasing.IsDone)
if (Math.Abs(underlyingProgress - this.progressBefore) < 0.000001f || this.progressEasing.IsDone || ReducedMotions)
return underlyingProgress;
var state = Math.Clamp((float)this.progressEasing.Value, 0f, 1f);
var state = ReducedMotions ? 1f : Math.Clamp((float)this.progressEasing.Value, 0f, 1f);
return this.progressBefore + (state * (underlyingProgress - this.progressBefore));
}
}