1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Fix JudgementCounterDisplay.cs max judgement always showing upon changing display mode

This commit is contained in:
mk56-spn 2023-01-19 10:31:02 +01:00
parent c6dfbab702
commit b22363ed8c
2 changed files with 27 additions and 7 deletions

View File

@ -136,6 +136,17 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("Check max hidden", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().First().Alpha == 0);
}
[Test]
public void TestMaxValueHiddenOnModeChange()
{
AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay());
AddStep("Set max judgement to hide itself", () => counterDisplay.ShowMaxJudgement.Value = false);
AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
AddWaitStep("wait some", 2);
AddAssert("Assert max judgement hidden", () => counterDisplay.CounterFlow.ChildrenOfType<JudgementCounter>().First().Alpha == 0);
}
[Test]
public void TestCycleDisplayModes()
{

View File

@ -66,15 +66,16 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
counter.Direction.Value = convertedDirection;
}, true);
Mode.BindValueChanged(_ => updateMode(), true);
Mode.BindValueChanged(_ =>
{
updateMode();
//Refreshing the counter causes the first child to become visible, so we want to make sure it isn't if it shouldn't be
updateFirstChildVisibility();
}, true);
ShowMaxJudgement.BindValueChanged(showMax =>
{
var firstChild = CounterFlow.Children.FirstOrDefault();
if (firstChild != null)
firstChild.State.Value = showMax.NewValue ? Visibility.Visible : Visibility.Hidden;
}, true);
updateFirstChildVisibility(), true);
}
private void updateMode()
@ -109,6 +110,14 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
}
}
private void updateFirstChildVisibility()
{
var firstChild = CounterFlow.Children.FirstOrDefault();
if (firstChild != null)
firstChild.State.Value = ShowMaxJudgement.Value ? Visibility.Visible : Visibility.Hidden;
}
private FillDirection getFillDirection(Direction flow)
{
switch (flow)