mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Inherit Container and fade the key flow instead of individual children
This commit is contained in:
parent
6103674b54
commit
28e340c486
@ -2,11 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -31,7 +30,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
|
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
|
||||||
|
|
||||||
AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
|
AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
|
||||||
AddAssert("key counters are visible", () => hudOverlay.KeyCounter.All(k => k.IsPresent));
|
AddAssert("key counter flow is visible", () => hudOverlay.KeyCounter.KeyFlow.IsPresent);
|
||||||
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
|
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +54,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
|
||||||
|
|
||||||
// Key counters should not be affected by this, only the key counter container will be hidden as checked above.
|
// Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above.
|
||||||
AddAssert("key counters not affected", () => hudOverlay.KeyCounter.All(k => k.IsPresent));
|
AddAssert("key counter flow not affected", () => hudOverlay.KeyCounter.KeyFlow.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -88,11 +87,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
|
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
|
||||||
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
|
||||||
AddAssert("key counters hidden", () => hudOverlay.KeyCounter.All(k => !k.IsPresent));
|
AddAssert("key counters hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent);
|
||||||
|
|
||||||
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
|
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
|
||||||
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
|
AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
|
||||||
AddAssert("key counters still hidden", () => hudOverlay.KeyCounter.All(k => !k.IsPresent));
|
AddAssert("key counters still hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNew(Action<TestHUDOverlay> action = null)
|
private void createNew(Action<TestHUDOverlay> action = null)
|
||||||
@ -126,7 +125,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private class TestKeyCounterDisplay : KeyCounterDisplay
|
private class TestKeyCounterDisplay : KeyCounterDisplay
|
||||||
{
|
{
|
||||||
public new Bindable<bool> ConfigVisibility => base.ConfigVisibility;
|
public new Container<KeyCounter> KeyFlow => base.KeyFlow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -15,7 +14,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class KeyCounterDisplay : FillFlowContainer<KeyCounter>
|
public class KeyCounterDisplay : Container<KeyCounter>
|
||||||
{
|
{
|
||||||
private const int duration = 100;
|
private const int duration = 100;
|
||||||
private const double key_fade_time = 80;
|
private const double key_fade_time = 80;
|
||||||
@ -23,10 +22,19 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
||||||
protected readonly Bindable<bool> ConfigVisibility = new Bindable<bool>();
|
protected readonly Bindable<bool> ConfigVisibility = new Bindable<bool>();
|
||||||
|
|
||||||
|
protected readonly FillFlowContainer<KeyCounter> KeyFlow;
|
||||||
|
|
||||||
|
protected override Container<KeyCounter> Content => KeyFlow;
|
||||||
|
|
||||||
public KeyCounterDisplay()
|
public KeyCounterDisplay()
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Horizontal;
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = KeyFlow = new FillFlowContainer<KeyCounter>
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(KeyCounter key)
|
public override void Add(KeyCounter key)
|
||||||
@ -102,8 +110,8 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateVisibility() =>
|
private void updateVisibility() =>
|
||||||
// Change visibility of all key counters internally to isolate from showing them by fading in this container.
|
// Isolate changing visibility of the key counters from fading this component.
|
||||||
Children.ForEach(k => k.FadeTo(Visible.Value || ConfigVisibility.Value ? 1 : 0, duration));
|
KeyFlow.FadeTo(Visible.Value || alwaysShow.Value ? 1 : 0, duration);
|
||||||
|
|
||||||
public override bool HandleNonPositionalInput => receptor == null;
|
public override bool HandleNonPositionalInput => receptor == null;
|
||||||
public override bool HandlePositionalInput => receptor == null;
|
public override bool HandlePositionalInput => receptor == null;
|
||||||
|
Loading…
Reference in New Issue
Block a user