Skip to content

Commit

Permalink
Better Progress Bar (#1648)
Browse files Browse the repository at this point in the history
# Description

DoAfter progress bar like in ss13 forks.

---


![2025-01-24_01-04_2](https://github.com/user-attachments/assets/df524426-cecd-4a32-a3b3-f588f11684b1)

![2025-01-24_01-03](https://github.com/user-attachments/assets/62dcb13a-4259-4980-8aa2-87de6e77a226)

![2025-01-24_01-04](https://github.com/user-attachments/assets/493c0c54-4225-40c9-8518-4da613bb2e12)

---

# Changelog

Fuck it, no need this, im not a contributor.

---------

Signed-off-by: sleepyyapril <[email protected]>
Co-authored-by: sleepyyapril <[email protected]>
  • Loading branch information
DocNITE and sleepyyapril authored Jan 24, 2025
1 parent 8e4fc9d commit 1ef0bd0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
44 changes: 40 additions & 4 deletions Content.Client/DoAfter/DoAfterOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.Configuration;
using Content.Shared.CCVar;

namespace Content.Client.DoAfter;

Expand All @@ -16,6 +18,7 @@ public sealed class DoAfterOverlay : Overlay
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;
private readonly IPlayerManager _player;
private readonly IConfigurationManager _cfg;
private readonly SharedTransformSystem _transform;
private readonly MetaDataSystem _meta;
private readonly ProgressColorSystem _progressColor;
Expand All @@ -32,20 +35,25 @@ public sealed class DoAfterOverlay : Overlay
private const float StartX = 2;
private const float EndX = 22f;

private bool _useModernHUD = false;

public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;

public DoAfterOverlay(IEntityManager entManager, IPrototypeManager protoManager, IGameTiming timing, IPlayerManager player)
{
_entManager = entManager;
_timing = timing;
_player = player;
_cfg = IoCManager.Resolve<IConfigurationManager>();
_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);

_unshadedShader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
_useModernHUD = _cfg.GetCVar(CCVars.ModernProgressBar);
_cfg.OnValueChanged(CCVars.ModernProgressBar, (newValue) => { _useModernHUD = newValue; } );
}

protected override void Draw(in OverlayDrawArgs args)
Expand Down Expand Up @@ -139,13 +147,41 @@ protected override void Draw(in OverlayDrawArgs args)
{
var elapsed = time - doAfter.StartTime;
elapsedRatio = (float) Math.Min(1, elapsed.TotalSeconds / doAfter.Args.Delay.TotalSeconds);
color = GetProgressColor(elapsedRatio, alpha);

if (_useModernHUD)
{
if (elapsedRatio < 1.0f)
color = GetProgressColor(elapsedRatio, alpha);
else
color = GetProgressColor(0.35f, alpha); // Make orange/yellow color
}
else
{
color = GetProgressColor(elapsedRatio, alpha);
}
}

var xProgress = (EndX - StartX) * elapsedRatio + StartX;
var box = new Box2(new Vector2(StartX, 3f) / EyeManager.PixelsPerMeter, new Vector2(xProgress, 4f) / EyeManager.PixelsPerMeter);
box = box.Translated(position);
handle.DrawRect(box, color);

if (_useModernHUD)
{
var box = new Box2(new Vector2(StartX, 2f) / EyeManager.PixelsPerMeter, new Vector2(xProgress, 5f) / EyeManager.PixelsPerMeter);
box = box.Translated(position);
// Brighter line, like /tg/station bar
var boxInner = new Box2(new Vector2(StartX, 3f) / EyeManager.PixelsPerMeter, new Vector2(xProgress, 4f) / EyeManager.PixelsPerMeter);
boxInner = boxInner.Translated(position);

handle.DrawRect(box, color);
handle.DrawRect(boxInner, Color.InterpolateBetween(color, Color.White, 0.5f));
}
else
{
var box = new Box2(new Vector2(StartX, 3f) / EyeManager.PixelsPerMeter, new Vector2(xProgress, 4f) / EyeManager.PixelsPerMeter);
box = box.Translated(position);

handle.DrawRect(box, color);
}

offset += _barTexture.Height / scale;
}
}
Expand Down
4 changes: 4 additions & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
StyleClasses="LabelKeyText"/>
<CheckBox Name="OpaqueStorageWindowCheckBox" Text="{Loc 'ui-options-opaque-storage-window'}" />
<CheckBox Name="StaticStorageUI" Text="{Loc 'ui-options-static-storage-ui'}" />
<Label Text="{Loc 'ui-options-general-other'}"
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
StyleClasses="LabelKeyText"/>
<CheckBox Name="ModernProgressBar" Text="{Loc 'ui-options-modern-progress-bar'}" />
<!-- <CheckBox Name="ToggleWalk" Text="{Loc 'ui-options-hotkey-toggle-walk'}" /> -->
</BoxContainer>
</ScrollContainer>
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public MiscTab()
ScreenShakeIntensitySlider.OnValueChanged += OnScreenShakeIntensitySliderChanged;
// ToggleWalk.OnToggled += OnCheckBoxToggled;
StaticStorageUI.OnToggled += OnCheckBoxToggled;
ModernProgressBar.OnToggled += OnCheckBoxToggled;
DisableFiltersCheckBox.OnToggled += OnCheckBoxToggled;

HudThemeOption.SelectId(_hudThemeIdToIndex.GetValueOrDefault(_cfg.GetCVar(CVars.InterfaceTheme), 0));
Expand All @@ -111,6 +112,7 @@ public MiscTab()
ScreenShakeIntensitySlider.Value = _cfg.GetCVar(CCVars.ScreenShakeIntensity) * 100f;
// ToggleWalk.Pressed = _cfg.GetCVar(CCVars.ToggleWalk);
StaticStorageUI.Pressed = _cfg.GetCVar(CCVars.StaticStorageUI);
ModernProgressBar.Pressed = _cfg.GetCVar(CCVars.ModernProgressBar);
DisableFiltersCheckBox.Pressed = _cfg.GetCVar(CCVars.NoVisionFilters);


Expand Down Expand Up @@ -168,6 +170,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.ScreenShakeIntensity, ScreenShakeIntensitySlider.Value / 100f);
// _cfg.SetCVar(CCVars.ToggleWalk, ToggleWalk.Pressed);
_cfg.SetCVar(CCVars.StaticStorageUI, StaticStorageUI.Pressed);
_cfg.SetCVar(CCVars.ModernProgressBar, ModernProgressBar.Pressed);
_cfg.SetCVar(CCVars.NoVisionFilters, DisableFiltersCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatStackLastLines, ChatStackOption.SelectedId);

Expand Down Expand Up @@ -200,6 +203,7 @@ private void UpdateApplyButton()
var isScreenShakeIntensitySame = Math.Abs(ScreenShakeIntensitySlider.Value / 100f - _cfg.GetCVar(CCVars.ScreenShakeIntensity)) < 0.01f;
// var isToggleWalkSame = ToggleWalk.Pressed == _cfg.GetCVar(CCVars.ToggleWalk);
var isStaticStorageUISame = StaticStorageUI.Pressed == _cfg.GetCVar(CCVars.StaticStorageUI);
var isModernProgressBarSame = ModernProgressBar.Pressed == _cfg.GetCVar(CCVars.ModernProgressBar);
var isNoVisionFiltersSame = DisableFiltersCheckBox.Pressed == _cfg.GetCVar(CCVars.NoVisionFilters);
var isChatStackTheSame = ChatStackOption.SelectedId == _cfg.GetCVar(CCVars.ChatStackLastLines);

Expand All @@ -221,6 +225,7 @@ private void UpdateApplyButton()
isScreenShakeIntensitySame &&
// isToggleWalkSame &&
isStaticStorageUISame &&
isModernProgressBarSame &&
isNoVisionFiltersSame &&
isChatStackTheSame;
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/CCVar/CCVars.Hud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public sealed partial class CCVars

public static readonly CVarDef<bool> HudFpsCounterVisible =
CVarDef.Create("hud.fps_counter_visible", false, CVar.CLIENTONLY | CVar.ARCHIVE);

public static readonly CVarDef<bool> ModernProgressBar =
CVarDef.Create("hud.modern_progress_bar", true, CVar.CLIENTONLY | CVar.ARCHIVE);
}
4 changes: 3 additions & 1 deletion Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ui-options-general-discord = Discord
ui-options-general-cursor = Cursor
ui-options-general-speech = Speech
ui-options-general-storage = Storage
ui-options-general-other = Other
ui-options-general-accessibility = Accessibility
ui-options-chatstack = Automatically merge identical chat messages
ui-options-chatstack-off = Off
Expand Down Expand Up @@ -159,6 +160,7 @@ ui-options-function-save-item-location = Save item location
ui-options-function-toggle-standing = Toggle standing
ui-options-function-toggle-crawling-under = Toggle crawling under furniture
ui-options-static-storage-ui = Lock storage window to hotbar
ui-options-modern-progress-bar = Modern progress bar
ui-options-function-smart-equip-backpack = Smart-equip to backpack
ui-options-function-smart-equip-belt = Smart-equip to belt
Expand Down Expand Up @@ -295,4 +297,4 @@ cmd-options-help = Usage: options [tab]
## Combat Options
ui-options-function-look-up = Look up/Take aim
ui-options-function-auto-get-up = Automatically get up after falling
ui-options-function-hold-look-up = Hold down the key to aim
ui-options-function-hold-look-up = Hold down the key to aim

0 comments on commit 1ef0bd0

Please sign in to comment.