From 71714f8f6e6bd7d2caf9214ff267c05e550352e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 15 Nov 2023 13:33:03 +0900 Subject: [PATCH 1/3] Add back test step for testing out argon health bar width --- .../Visual/Gameplay/TestSceneArgonHealthDisplay.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs index f51577bc84..6c364e41c7 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonHealthDisplay.cs @@ -52,6 +52,12 @@ namespace osu.Game.Tests.Visual.Gameplay if (healthDisplay.IsNotNull()) healthDisplay.BarHeight.Value = val; }); + + AddSliderStep("Width", 0, 1f, 0.98f, val => + { + if (healthDisplay.IsNotNull()) + healthDisplay.Width = val; + }); } [Test] From 8cd1f08a923b1b38e7b096e59211c0714089d1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 15 Nov 2023 13:33:12 +0900 Subject: [PATCH 2/3] Fix argon health bar folding in on itself --- .../Screens/Play/HUD/ArgonHealthDisplay.cs | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs index 82203d7891..372d2bab85 100644 --- a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs @@ -89,6 +89,11 @@ namespace osu.Game.Screens.Play.HUD public const float MAIN_PATH_RADIUS = 10f; + private const float curve_start_offset = 70; + private const float curve_end_offset = 40; + private const float padding = MAIN_PATH_RADIUS * 2; + private const float curve_smoothness = 10; + private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize); public ArgonHealthDisplay() @@ -248,11 +253,17 @@ namespace osu.Game.Screens.Play.HUD private void updatePath() { - float barLength = DrawWidth - MAIN_PATH_RADIUS * 2; - float curveStart = barLength - 70; - float curveEnd = barLength - 40; + float usableWidth = DrawWidth - padding; - const float curve_smoothness = 10; + if (usableWidth < 0) enforceMinimumWidth(); + + // the display starts curving at `curve_start_offset` units from the right and ends curving at `curve_end_offset`. + // to ensure that the curve is symmetric when it starts being narrow enough, add a `curve_end_offset` to the left side too. + const float rescale_cutoff = curve_start_offset + curve_end_offset; + + float barLength = Math.Max(DrawWidth - padding, rescale_cutoff); + float curveStart = barLength - curve_start_offset; + float curveEnd = barLength - curve_end_offset; Vector2 diagonalDir = (new Vector2(curveEnd, BarHeight.Value) - new Vector2(curveStart, 0)).Normalized(); @@ -268,6 +279,9 @@ namespace osu.Game.Screens.Play.HUD new PathControlPoint(new Vector2(barLength, BarHeight.Value)), }); + if (DrawWidth - padding < rescale_cutoff) + rescalePathProportionally(); + List vertices = new List(); barPath.GetPathToProgress(vertices, 0.0, 1.0); @@ -276,6 +290,20 @@ namespace osu.Game.Screens.Play.HUD glowBar.Vertices = vertices; updatePathVertices(); + + void enforceMinimumWidth() + { + var relativeAxes = RelativeSizeAxes; + RelativeSizeAxes = Axes.None; + Width = padding; + RelativeSizeAxes = relativeAxes; + } + + void rescalePathProportionally() + { + foreach (var point in barPath.ControlPoints) + point.Position = new Vector2(point.Position.X / barLength * (DrawWidth - padding), point.Position.Y); + } } private void updatePathVertices() From 2987c0e802ec597ab7480c9d3623b423592669bc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 Nov 2023 19:01:52 +0900 Subject: [PATCH 3/3] Add note about enfocing size methodology --- osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs index 372d2bab85..5e6130d3f8 100644 --- a/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/ArgonHealthDisplay.cs @@ -293,9 +293,13 @@ namespace osu.Game.Screens.Play.HUD void enforceMinimumWidth() { - var relativeAxes = RelativeSizeAxes; + // Switch to absolute in order to be able to define a minimum width. + // Then switch back is required. Framework will handle the conversion for us. + Axes relativeAxes = RelativeSizeAxes; RelativeSizeAxes = Axes.None; + Width = padding; + RelativeSizeAxes = relativeAxes; }