mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:43:01 +08:00
Merge pull request #22290 from mk56-spn/judgement_fix
Fix JudgementCounterDisplay.cs max judgement not hiding upon display mode change
This commit is contained in:
commit
5a1940facf
@ -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()
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -66,29 +65,27 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
counter.Direction.Value = convertedDirection;
|
||||
}, true);
|
||||
|
||||
Mode.BindValueChanged(_ => updateMode(), true);
|
||||
|
||||
ShowMaxJudgement.BindValueChanged(showMax =>
|
||||
{
|
||||
var firstChild = CounterFlow.Children.FirstOrDefault();
|
||||
|
||||
if (firstChild != null)
|
||||
firstChild.State.Value = showMax.NewValue ? Visibility.Visible : Visibility.Hidden;
|
||||
}, true);
|
||||
Mode.BindValueChanged(_ => updateDisplay());
|
||||
ShowMaxJudgement.BindValueChanged(_ => updateDisplay(), true);
|
||||
}
|
||||
|
||||
private void updateMode()
|
||||
private void updateDisplay()
|
||||
{
|
||||
foreach (var counter in CounterFlow.Children)
|
||||
for (int i = 0; i < CounterFlow.Children.Count; i++)
|
||||
{
|
||||
if (shouldShow(counter))
|
||||
JudgementCounter counter = CounterFlow.Children[i];
|
||||
|
||||
if (shouldShow(i, counter))
|
||||
counter.Show();
|
||||
else
|
||||
counter.Hide();
|
||||
}
|
||||
|
||||
bool shouldShow(JudgementCounter counter)
|
||||
bool shouldShow(int index, JudgementCounter counter)
|
||||
{
|
||||
if (index == 0 && !ShowMaxJudgement.Value)
|
||||
return false;
|
||||
|
||||
if (counter.Result.Type.IsBasic())
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user