mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 17:13:06 +08:00
Fix toolbar not respecting current overlay activation mode.
This commit is contained in:
parent
707912248a
commit
6aa31dffdb
@ -4,8 +4,10 @@
|
|||||||
using System.Linq;
|
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.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Toolbar;
|
using osu.Game.Overlays.Toolbar;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -15,7 +17,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneToolbar : OsuManualInputManagerTestScene
|
public class TestSceneToolbar : OsuManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private Toolbar toolbar;
|
private TestToolbar toolbar;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RulesetStore rulesets { get; set; }
|
private RulesetStore rulesets { get; set; }
|
||||||
@ -23,7 +25,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
Child = toolbar = new Toolbar { State = { Value = Visibility.Visible } };
|
Child = toolbar = new TestToolbar { State = { Value = Visibility.Visible } };
|
||||||
});
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -72,5 +74,26 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected));
|
AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(OverlayActivation.All)]
|
||||||
|
[TestCase(OverlayActivation.Disabled)]
|
||||||
|
public void TestRespectsOverlayActivation(OverlayActivation mode)
|
||||||
|
{
|
||||||
|
AddStep($"set activation mode to {mode}", () => toolbar.OverlayActivationMode.Value = mode);
|
||||||
|
AddStep("hide toolbar", () => toolbar.Hide());
|
||||||
|
AddStep("try to show toolbar", () => toolbar.Show());
|
||||||
|
|
||||||
|
if (mode == OverlayActivation.Disabled)
|
||||||
|
AddUntilStep("toolbar still hidden", () => toolbar.Visibility == Visibility.Hidden);
|
||||||
|
else
|
||||||
|
AddAssert("toolbar is visible", () => toolbar.Visibility == Visibility.Visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestToolbar : Toolbar
|
||||||
|
{
|
||||||
|
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode;
|
||||||
|
|
||||||
|
public Visibility Visibility => State.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
private const double transition_time = 500;
|
private const double transition_time = 500;
|
||||||
|
|
||||||
private readonly Bindable<OverlayActivation> overlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
|
||||||
|
|
||||||
// Toolbar components like RulesetSelector should receive keyboard input events even when the toolbar is hidden.
|
// Toolbar components like RulesetSelector should receive keyboard input events even when the toolbar is hidden.
|
||||||
public override bool PropagateNonPositionalInputSubTree => true;
|
public override bool PropagateNonPositionalInputSubTree => true;
|
||||||
@ -89,14 +89,8 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
// Bound after the selector is added to the hierarchy to give it a chance to load the available rulesets
|
// Bound after the selector is added to the hierarchy to give it a chance to load the available rulesets
|
||||||
rulesetSelector.Current.BindTo(parentRuleset);
|
rulesetSelector.Current.BindTo(parentRuleset);
|
||||||
|
|
||||||
State.ValueChanged += visibility =>
|
|
||||||
{
|
|
||||||
if (overlayActivationMode.Value == OverlayActivation.Disabled)
|
|
||||||
Hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (osuGame != null)
|
if (osuGame != null)
|
||||||
overlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ToolbarBackground : Container
|
public class ToolbarBackground : Container
|
||||||
@ -137,6 +131,17 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void UpdateState(ValueChangedEvent<Visibility> state)
|
||||||
|
{
|
||||||
|
if (state.NewValue == Visibility.Visible && OverlayActivationMode.Value == OverlayActivation.Disabled)
|
||||||
|
{
|
||||||
|
State.Value = Visibility.Hidden;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.UpdateState(state);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
this.MoveToY(0, transition_time, Easing.OutQuint);
|
this.MoveToY(0, transition_time, Easing.OutQuint);
|
||||||
|
Loading…
Reference in New Issue
Block a user