mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Give flow container a type to avoid locally casting in every location
This commit is contained in:
parent
09c7ab3af6
commit
35ad66eef9
@ -103,10 +103,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
AddStep("Hide judgement names", () => counterDisplay.ShowJudgementNames.Value = false);
|
||||
AddWaitStep("wait some", 2);
|
||||
AddAssert("Assert hidden", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 0);
|
||||
AddAssert("Assert hidden", () => counterDisplay.JudgementContainer.Children.First().ResultName.Alpha == 0);
|
||||
AddStep("Hide judgement names", () => counterDisplay.ShowJudgementNames.Value = true);
|
||||
AddWaitStep("wait some", 2);
|
||||
AddAssert("Assert shown", () => counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 1);
|
||||
AddAssert("Assert shown", () => counterDisplay.JudgementContainer.Children.First().ResultName.Alpha == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -132,13 +132,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private int hiddenCount()
|
||||
{
|
||||
var num = counterDisplay.JudgementContainer.Children.OfType<JudgementCounter>().First(child => child.Result.Type == HitResult.LargeTickHit);
|
||||
var num = counterDisplay.JudgementContainer.Children.First(child => child.Result.Type == HitResult.LargeTickHit);
|
||||
return num.Result.ResultCount.Value;
|
||||
}
|
||||
|
||||
private partial class TestJudgementCounterDisplay : JudgementCounterDisplay
|
||||
{
|
||||
public new FillFlowContainer JudgementContainer => base.JudgementContainer;
|
||||
public new FillFlowContainer<JudgementCounter> JudgementContainer => base.JudgementContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
[Resolved]
|
||||
private JudgementTally tally { get; set; } = null!;
|
||||
|
||||
protected FillFlowContainer JudgementContainer = null!;
|
||||
protected FillFlowContainer<JudgementCounter> JudgementContainer = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = JudgementContainer = new FillFlowContainer
|
||||
InternalChild = JudgementContainer = new FillFlowContainer<JudgementCounter>
|
||||
{
|
||||
Direction = getFillDirection(FlowDirection.Value),
|
||||
Spacing = new Vector2(10),
|
||||
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
JudgementContainer.Direction = getFillDirection(direction.NewValue);
|
||||
|
||||
//Can't pass directly due to Enum conversion
|
||||
foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>())
|
||||
foreach (var counter in JudgementContainer.Children)
|
||||
counter.Direction.Value = getFillDirection(direction.NewValue);
|
||||
}, true);
|
||||
Mode.BindValueChanged(_ => updateMode(), true);
|
||||
@ -73,7 +73,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
|
||||
private void updateMode()
|
||||
{
|
||||
foreach (var counter in JudgementContainer.Children.OfType<JudgementCounter>().Where(counter => !counter.Result.Type.IsBasic()))
|
||||
foreach (var counter in JudgementContainer.Children.Where(counter => !counter.Result.Type.IsBasic()))
|
||||
{
|
||||
switch (Mode.Value)
|
||||
{
|
||||
@ -110,15 +110,12 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
}
|
||||
}
|
||||
|
||||
private JudgementCounter createCounter(JudgementTally.JudgementCount info)
|
||||
{
|
||||
JudgementCounter counter = new JudgementCounter(info)
|
||||
private JudgementCounter createCounter(JudgementTally.JudgementCount info) =>
|
||||
new JudgementCounter(info)
|
||||
{
|
||||
State = { Value = Visibility.Visible },
|
||||
ShowName = { BindTarget = ShowJudgementNames }
|
||||
};
|
||||
return counter;
|
||||
}
|
||||
|
||||
public enum DisplayMode
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user