Files
tbd-station-14/Content.Client/UserInterface/Controls/ProgressTextureRect.cs
Nemanja f3f4616c49 Add a toggle for colorblind friendly progress bar colors (#25318)
* Add a toggle for progress bar colors

* yeah this thing

* PJB review

* optimization
2024-03-09 12:43:19 +01:00

24 lines
816 B
C#

using System.Numerics;
using Content.Client.UserInterface.Systems;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface.Controls
{
public sealed class ProgressTextureRect : TextureRect
{
public float Progress;
private readonly ProgressColorSystem _progressColor = IoCManager.Resolve<IEntityManager>().System<ProgressColorSystem>();
protected override void Draw(DrawingHandleScreen handle)
{
var dims = Texture != null ? GetDrawDimensions(Texture) : UIBox2.FromDimensions(Vector2.Zero, PixelSize);
dims.Top = Math.Max(dims.Bottom - dims.Bottom * Progress,0);
handle.DrawRect(dims, _progressColor.GetProgressColor(Progress));
base.Draw(handle);
}
}
}