From c119bba7855ed8fadae0510ab304b32850d895c8 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sat, 9 Mar 2024 12:43:19 +0100 Subject: [PATCH] Cherry-picked commit f3f4616c49317898aeeff304160b0b50df9ee851 from space-wizards/space-station-14/master --- Content.Client/DoAfter/DoAfterOverlay.cs | 16 ++- Content.Client/Options/UI/Tabs/MiscTab.xaml | 102 +++++++++--------- .../Options/UI/Tabs/MiscTab.xaml.cs | 5 + .../Overlays/EntityHealthBarOverlay.cs | 39 +++---- .../Controls/ProgressTextureRect.cs | 6 +- .../Systems/ProgressColorSystem.cs | 77 +++++++++++++ Content.Shared/CCVar/CCVars.cs | 7 ++ .../en-US/escape-menu/ui/options-menu.ftl | 1 + 8 files changed, 169 insertions(+), 84 deletions(-) create mode 100644 Content.Client/UserInterface/Systems/ProgressColorSystem.cs diff --git a/Content.Client/DoAfter/DoAfterOverlay.cs b/Content.Client/DoAfter/DoAfterOverlay.cs index 2957dafdb7a..2e23dd44cac 100644 --- a/Content.Client/DoAfter/DoAfterOverlay.cs +++ b/Content.Client/DoAfter/DoAfterOverlay.cs @@ -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 DoAfterOverlay(IEntityManager entManager, IPrototypeManager protoManager, _player = player; _transform = _entManager.EntitySysManager.GetEntitySystem(); _meta = _entManager.EntitySysManager.GetEntitySystem(); + _progressColor = _entManager.System(); var sprite = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/progress_bar.rsi"), "icon"); _barTexture = _entManager.EntitySysManager.GetEntitySystem().Frame0(sprite); @@ -125,7 +127,7 @@ protected override void Draw(in OverlayDrawArgs args) 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 @@ protected override void Draw(in OverlayDrawArgs args) 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); } } diff --git a/Content.Client/Options/UI/Tabs/MiscTab.xaml b/Content.Client/Options/UI/Tabs/MiscTab.xaml index fc94ab7b0a6..2ee59910f70 100644 --- a/Content.Client/Options/UI/Tabs/MiscTab.xaml +++ b/Content.Client/Options/UI/Tabs/MiscTab.xaml @@ -4,57 +4,59 @@ xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:Content.Client.Stylesheets"> - -