diff --git a/Content.Client/Popups/PopupOverlay.cs b/Content.Client/Popups/PopupOverlay.cs index 17af5ca38f..5adc2e1ff0 100644 --- a/Content.Client/Popups/PopupOverlay.cs +++ b/Content.Client/Popups/PopupOverlay.cs @@ -115,10 +115,12 @@ public sealed class PopupOverlay : Overlay private void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, Vector2 position, float scale) { - const float alphaMinimum = 0.5f; + var lifetime = PopupSystem.GetPopupLifetime(popup); - var alpha = MathF.Min(1f, 1f - (popup.TotalTime - alphaMinimum) / (PopupSystem.PopupLifetime - alphaMinimum)); - var updatedPosition = position - new Vector2(0f, 20f * (popup.TotalTime * popup.TotalTime + popup.TotalTime)); + // Keep alpha at 1 until TotalTime passes half its lifetime, then gradually decrease to 0. + var alpha = MathF.Min(1f, 1f - MathF.Max(0f, popup.TotalTime - lifetime / 2) * 2 / lifetime); + + var updatedPosition = position - new Vector2(0f, MathF.Min(8f, 12f * (popup.TotalTime * popup.TotalTime + popup.TotalTime))); var font = _smallFont; var color = Color.White.WithAlpha(alpha); diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index be0966674d..d8d3f079c5 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -35,7 +35,9 @@ namespace Content.Client.Popups private readonly List _aliveWorldLabels = new(); private readonly List _aliveCursorLabels = new(); - public const float PopupLifetime = 3f; + public const float MinimumPopupLifetime = 0.7f; + public const float MaximumPopupLifetime = 5f; + public const float PopupLifetimePerCharacter = 0.04f; public override void Initialize() { @@ -185,6 +187,13 @@ namespace Content.Client.Popups #endregion + public static float GetPopupLifetime(PopupLabel label) + { + return Math.Clamp(PopupLifetimePerCharacter * label.Text.Length, + MinimumPopupLifetime, + MaximumPopupLifetime); + } + public override void FrameUpdate(float frameTime) { if (_aliveWorldLabels.Count == 0 && _aliveCursorLabels.Count == 0) @@ -195,7 +204,7 @@ namespace Content.Client.Popups var label = _aliveWorldLabels[i]; label.TotalTime += frameTime; - if (label.TotalTime > PopupLifetime || Deleted(label.InitialPos.EntityId)) + if (label.TotalTime > GetPopupLifetime(label) || Deleted(label.InitialPos.EntityId)) { _aliveWorldLabels.RemoveSwap(i); i--; @@ -207,7 +216,7 @@ namespace Content.Client.Popups var label = _aliveCursorLabels[i]; label.TotalTime += frameTime; - if (label.TotalTime > PopupLifetime) + if (label.TotalTime > GetPopupLifetime(label)) { _aliveCursorLabels.RemoveSwap(i); i--;