Skip to content

Commit 98c3437

Browse files
committed
Always show the same number of placeholder digits in argon judgement counter when it is vertical
1 parent a56f81a commit 98c3437

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

osu.Game.Tests/Visual/Gameplay/TestSceneArgonJudgementCounter.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ public void TestChangeFlowDirection()
101101

102102
AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = Direction.Vertical);
103103
AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = Direction.Horizontal);
104+
105+
AddStep("add 100 ok judgements", () =>
106+
{
107+
for (int i = 0; i < 100; i++)
108+
applyOneJudgement(HitResult.Ok);
109+
});
110+
AddStep("add 1000 great judgements", () =>
111+
{
112+
for (int i = 0; i < 1000; i++)
113+
applyOneJudgement(HitResult.Great);
114+
});
115+
116+
AddToggleStep("toggle max judgement display", t => counterDisplay.ShowMaxJudgement.Value = t);
104117
}
105118

106119
[Test]

osu.Game/Skinning/Components/ArgonJudgementCounter.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public sealed partial class ArgonJudgementCounter : VisibilityContainer
2121
public readonly JudgementCount Result;
2222

2323
public IBindable<float> WireframeOpacity => textComponent.WireframeOpacity;
24+
25+
public IBindable<int?> WireframeDigits { get; } = new Bindable<int?>();
26+
2427
public IBindable<bool> ShowLabel => textComponent.ShowLabel;
2528

2629
private readonly ArgonCounterTextComponent textComponent;
@@ -39,13 +42,15 @@ public ArgonJudgementCounter(JudgementCount result)
3942

4043
private void updateWireframe()
4144
{
42-
int wireframeLength = Math.Max(2, textComponent.Text.ToString().Length);
43-
textComponent.WireframeTemplate = new string('#', wireframeLength);
45+
textComponent.WireframeTemplate = new string('#', WireframeDigits.Value ?? Math.Max(2, textComponent.Text.ToString().Length));
4446
}
4547

4648
protected override void LoadComplete()
4749
{
4850
base.LoadComplete();
51+
52+
WireframeDigits.BindValueChanged(_ => updateWireframe());
53+
4954
displayedValue.BindTo(Result.ResultCount);
5055
displayedValue.BindValueChanged(v =>
5156
{
@@ -64,6 +69,6 @@ private Color4 getJudgementColor(HitResult result)
6469
}
6570

6671
protected override void PopIn() => this.FadeIn(JudgementCounterDisplay.TRANSFORM_DURATION, Easing.OutQuint);
67-
protected override void PopOut() => this.FadeOut(100);
72+
protected override void PopOut() => this.FadeOut();
6873
}
6974
}

osu.Game/Skinning/Components/ArgonJudgementCounterDisplay.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public partial class ArgonJudgementCounterDisplay : CompositeDrawable, ISerialis
4444
[SettingSource(typeof(JudgementCounterDisplayStrings), nameof(JudgementCounterDisplayStrings.FlowDirection))]
4545
public Bindable<Direction> FlowDirection { get; } = new Bindable<Direction>();
4646

47+
private readonly Bindable<int?> wireframeDigits = new Bindable<int?>();
48+
4749
protected FillFlowContainer<ArgonJudgementCounter> CounterFlow = null!;
4850

4951
[BackgroundDependencyLoader]
@@ -59,9 +61,13 @@ private void load()
5961

6062
foreach (var counter in judgementCountController.Counters)
6163
{
62-
ArgonJudgementCounter counterComponent = new ArgonJudgementCounter(counter);
63-
counterComponent.WireframeOpacity.BindTo(WireframeOpacity);
64-
counterComponent.ShowLabel.BindTo(ShowLabel);
64+
counter.ResultCount.BindValueChanged(_ => updateWireframeDigits());
65+
ArgonJudgementCounter counterComponent = new ArgonJudgementCounter(counter)
66+
{
67+
WireframeOpacity = { BindTarget = WireframeOpacity },
68+
WireframeDigits = { BindTarget = wireframeDigits },
69+
ShowLabel = { BindTarget = ShowLabel },
70+
};
6571
CounterFlow.Add(counterComponent);
6672
}
6773
}
@@ -71,7 +77,7 @@ protected override void LoadComplete()
7177
base.LoadComplete();
7278
Mode.BindValueChanged(_ => updateVisibility());
7379
ShowMaxJudgement.BindValueChanged(_ => updateVisibility(), true);
74-
FlowDirection.BindValueChanged(d => CounterFlow.Direction = getFillDirection(d.NewValue), true);
80+
FlowDirection.BindValueChanged(_ => updateFlowDirection(), true);
7581
}
7682

7783
private void updateVisibility()
@@ -85,6 +91,21 @@ private void updateVisibility()
8591
else
8692
counter.Hide();
8793
}
94+
95+
updateWireframeDigits();
96+
}
97+
98+
private void updateFlowDirection()
99+
{
100+
CounterFlow.Direction = getFillDirection(FlowDirection.Value);
101+
updateWireframeDigits();
102+
}
103+
104+
private void updateWireframeDigits()
105+
{
106+
wireframeDigits.Value = FlowDirection.Value == Direction.Vertical
107+
? Math.Max(2, CounterFlow.Children.Where(counter => counter.State.Value == Visibility.Visible).Max(counter => counter.Result.ResultCount.Value).ToString().Length)
108+
: null;
88109
}
89110

90111
private bool shouldBeVisible(int index, ArgonJudgementCounter counter)

0 commit comments

Comments
 (0)