mirror of
https://github.com/ppy/osu.git
synced 2026-06-06 06:23:41 +08:00
Fix abysmal code quality
This commit is contained in:
@@ -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<ArgonJudgementCounter>().Count(),
|
||||
() => Is.EqualTo(counterDisplay.CounterFlow.ChildrenOfType<ArgonJudgementCounter>().Select(c => c.JudgementName).Distinct().Count()));
|
||||
() => Is.EqualTo(counterDisplay.CounterFlow.ChildrenOfType<ArgonJudgementCounter>().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
|
||||
|
||||
@@ -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<float> WireframeOpacity => textComponent.WireframeOpacity;
|
||||
public IBindable<bool> 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)
|
||||
|
||||
@@ -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<ArgonJudgementCounter> CounterFlow = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = CounterFlow = new FillFlowContainer<ArgonJudgementCounter>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user