Add a toggle for colorblind friendly progress bar colors (#25318)
* Add a toggle for progress bar colors * yeah this thing * PJB review * optimization
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Client.UserInterface.Systems;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -18,6 +18,7 @@ public sealed class DoAfterOverlay : Overlay
|
||||
private readonly IPlayerManager _player;
|
||||
private readonly SharedTransformSystem _transform;
|
||||
private readonly MetaDataSystem _meta;
|
||||
private readonly ProgressColorSystem _progressColor;
|
||||
|
||||
private readonly Texture _barTexture;
|
||||
private readonly ShaderInstance _shader;
|
||||
@@ -40,6 +41,7 @@ public sealed class DoAfterOverlay : Overlay
|
||||
_player = player;
|
||||
_transform = _entManager.EntitySysManager.GetEntitySystem<SharedTransformSystem>();
|
||||
_meta = _entManager.EntitySysManager.GetEntitySystem<MetaDataSystem>();
|
||||
_progressColor = _entManager.System<ProgressColorSystem>();
|
||||
var sprite = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/progress_bar.rsi"), "icon");
|
||||
_barTexture = _entManager.EntitySysManager.GetEntitySystem<SpriteSystem>().Frame0(sprite);
|
||||
|
||||
@@ -125,7 +127,7 @@ public sealed class DoAfterOverlay : Overlay
|
||||
elapsedRatio = (float) Math.Min(1, elapsed.TotalSeconds / doAfter.Args.Delay.TotalSeconds);
|
||||
var cancelElapsed = (time - doAfter.CancelledTime.Value).TotalSeconds;
|
||||
var flash = Math.Floor(cancelElapsed / FlashTime) % 2 == 0;
|
||||
color = new Color(1f, 0f, 0f, flash ? alpha : 0f);
|
||||
color = GetProgressColor(0, flash ? alpha : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,14 +148,8 @@ public sealed class DoAfterOverlay : Overlay
|
||||
handle.SetTransform(Matrix3.Identity);
|
||||
}
|
||||
|
||||
public static Color GetProgressColor(float progress, float alpha = 1f)
|
||||
public Color GetProgressColor(float progress, float alpha = 1f)
|
||||
{
|
||||
if (progress >= 1.0f)
|
||||
{
|
||||
return new Color(0f, 1f, 0f, alpha);
|
||||
}
|
||||
// lerp
|
||||
var hue = (5f / 18f) * progress;
|
||||
return Color.FromHsv((hue, 1f, 0.75f, alpha));
|
||||
return _progressColor.GetProgressColor(progress).WithAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user