diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonJudgementCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonJudgementCounter.cs index 64bb6497ad..925cc087c5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneArgonJudgementCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneArgonJudgementCounter.cs @@ -155,7 +155,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Show all judgements", () => counterDisplay.Mode.Value = ArgonJudgementCounterDisplay.DisplayMode.All); AddAssert("Check no duplicates", () => counterDisplay.CounterFlow.ChildrenOfType().Count(), - () => Is.EqualTo(counterDisplay.CounterFlow.ChildrenOfType().Select(c => c.JudgementName).Distinct().Count())); + () => Is.EqualTo(counterDisplay.CounterFlow.ChildrenOfType().Select(c => c.Result.DisplayName).Distinct().Count())); } [Test] @@ -174,8 +174,8 @@ namespace osu.Game.Tests.Visual.Gameplay private int hiddenCount() { - var num = counterDisplay.CounterFlow.Children.First(child => child.JudgementCounter.Types.Contains(HitResult.LargeTickHit)); - return num.JudgementCounter.ResultCount.Value; + var num = counterDisplay.CounterFlow.Children.First(child => child.Result.Types.Contains(HitResult.LargeTickHit)); + return num.Result.ResultCount.Value; } private partial class TestArgonJudgementCounterDisplay : ArgonJudgementCounterDisplay diff --git a/osu.Game/Skinning/Components/ArgonJudgementCounter.cs b/osu.Game/Skinning/Components/ArgonJudgementCounter.cs index a627a53c02..482908cef3 100644 --- a/osu.Game/Skinning/Components/ArgonJudgementCounter.cs +++ b/osu.Game/Skinning/Components/ArgonJudgementCounter.cs @@ -18,45 +18,44 @@ namespace osu.Game.Skinning.Components { public sealed partial class ArgonJudgementCounter : VisibilityContainer { - public ArgonCounterTextComponent TextComponent; - private OsuColour colours = null!; - public readonly JudgementCount JudgementCounter; - public BindableInt DisplayedValue = new BindableInt(); - public string JudgementName; + public readonly JudgementCount Result; - public ArgonJudgementCounter(JudgementCount judgementCounter) + public IBindable WireframeOpacity => textComponent.WireframeOpacity; + public IBindable ShowLabel => textComponent.ShowLabel; + + private readonly ArgonCounterTextComponent textComponent; + private readonly BindableInt displayedValue = new BindableInt(); + + [Resolved] + private OsuColour colours { get; set; } = null!; + + public ArgonJudgementCounter(JudgementCount result) { - JudgementCounter = judgementCounter; - JudgementName = judgementCounter.DisplayName.ToUpper().ToString(); + Result = result; AutoSizeAxes = Axes.Both; - AddInternal(TextComponent = new ArgonCounterTextComponent(Anchor.TopRight, judgementCounter.DisplayName.ToUpper())); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - this.colours = colours; + AddInternal(textComponent = new ArgonCounterTextComponent(Anchor.TopRight, result.DisplayName.ToUpper())); } private void updateWireframe() { - int wireframeLenght = Math.Max(2, TextComponent.Text.ToString().Length); - TextComponent.WireframeTemplate = new string('#', wireframeLenght); + int wireframeLength = Math.Max(2, textComponent.Text.ToString().Length); + textComponent.WireframeTemplate = new string('#', wireframeLength); } protected override void LoadComplete() { base.LoadComplete(); - DisplayedValue.BindValueChanged(v => + displayedValue.BindTo(Result.ResultCount); + displayedValue.BindValueChanged(v => { - TextComponent.Text = v.NewValue.ToString(); + textComponent.Text = v.NewValue.ToString(); updateWireframe(); }, true); - var result = JudgementCounter.Types.First(); - TextComponent.LabelColour.Value = getJudgementColor(result); - TextComponent.ShowLabel.BindValueChanged(v => TextComponent.TextColour.Value = !v.NewValue ? getJudgementColor(result) : Color4.White); + var result = Result.Types.First(); + textComponent.LabelColour.Value = getJudgementColor(result); + textComponent.ShowLabel.BindValueChanged(v => textComponent.TextColour.Value = !v.NewValue ? getJudgementColor(result) : Color4.White); } private Color4 getJudgementColor(HitResult result) diff --git a/osu.Game/Skinning/Components/ArgonJudgementCounterDisplay.cs b/osu.Game/Skinning/Components/ArgonJudgementCounterDisplay.cs index 5e3ca725c6..227b1fd65f 100644 --- a/osu.Game/Skinning/Components/ArgonJudgementCounterDisplay.cs +++ b/osu.Game/Skinning/Components/ArgonJudgementCounterDisplay.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Localisation; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Localisation.HUD; using osu.Game.Localisation.SkinComponents; using osu.Game.Rulesets.Scoring; @@ -48,7 +47,7 @@ namespace osu.Game.Skinning.Components protected FillFlowContainer CounterFlow = null!; [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { AutoSizeAxes = Axes.Both; InternalChild = CounterFlow = new FillFlowContainer @@ -61,9 +60,8 @@ namespace osu.Game.Skinning.Components foreach (var counter in judgementCountController.Counters) { ArgonJudgementCounter counterComponent = new ArgonJudgementCounter(counter); - counterComponent.TextComponent.WireframeOpacity.BindTo(WireframeOpacity); - counterComponent.TextComponent.ShowLabel.BindTo(ShowLabel); - counterComponent.DisplayedValue.BindTo(counter.ResultCount); + counterComponent.WireframeOpacity.BindTo(WireframeOpacity); + counterComponent.ShowLabel.BindTo(ShowLabel); CounterFlow.Add(counterComponent); } } @@ -71,9 +69,9 @@ namespace osu.Game.Skinning.Components protected override void LoadComplete() { base.LoadComplete(); - Mode.BindValueChanged(_ => updateVisibility(), true); + Mode.BindValueChanged(_ => updateVisibility()); ShowMaxJudgement.BindValueChanged(_ => updateVisibility(), true); - FlowDirection.BindValueChanged(d => CounterFlow.Direction = getFillDirection(d.NewValue)); + FlowDirection.BindValueChanged(d => CounterFlow.Direction = getFillDirection(d.NewValue), true); } private void updateVisibility() @@ -94,7 +92,7 @@ namespace osu.Game.Skinning.Components if (index == 0 && !ShowMaxJudgement.Value) return false; - var hitResult = counter.JudgementCounter.Types.First(); + var hitResult = counter.Result.Types.First(); if (hitResult.IsBasic()) return true; @@ -110,7 +108,7 @@ namespace osu.Game.Skinning.Components return true; default: - throw new ArgumentOutOfRangeException(); + throw new ArgumentOutOfRangeException(nameof(Mode), Mode.Value, null); } } @@ -125,7 +123,7 @@ namespace osu.Game.Skinning.Components return FillDirection.Vertical; default: - throw new ArgumentOutOfRangeException(nameof(flow), flow, @"Unsupported direction"); + throw new ArgumentOutOfRangeException(nameof(flow), flow, null); } }