mirror of
https://github.com/osukey/osukey.git
synced 2025-06-28 14:48:04 +09:00
Add ability to close statistics by clicking anywhere
This commit is contained in:
parent
6d19fd936e
commit
6bcc693c2f
@ -20,6 +20,7 @@ using osu.Game.Screens;
|
|||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Ranking
|
namespace osu.Game.Tests.Visual.Ranking
|
||||||
@ -87,6 +88,45 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
AddAssert("retry overlay present", () => screen.RetryOverlay != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestShowHideStatisticsViaOutsideClick()
|
||||||
|
{
|
||||||
|
TestResultsScreen screen = null;
|
||||||
|
|
||||||
|
AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen()));
|
||||||
|
AddUntilStep("wait for loaded", () => screen.IsLoaded);
|
||||||
|
|
||||||
|
AddStep("click expanded panel", () =>
|
||||||
|
{
|
||||||
|
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||||
|
InputManager.MoveMouseTo(expandedPanel);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("statistics shown", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Visible);
|
||||||
|
|
||||||
|
AddUntilStep("expanded panel at the left of the screen", () =>
|
||||||
|
{
|
||||||
|
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||||
|
return expandedPanel.ScreenSpaceDrawQuad.TopLeft.X - screen.ScreenSpaceDrawQuad.TopLeft.X < 150;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("click to right of panel", () =>
|
||||||
|
{
|
||||||
|
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||||
|
InputManager.MoveMouseTo(expandedPanel.ScreenSpaceDrawQuad.TopRight + new Vector2(100, 0));
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("statistics hidden", () => this.ChildrenOfType<StatisticsPanel>().Single().State.Value == Visibility.Hidden);
|
||||||
|
|
||||||
|
AddUntilStep("expanded panel in centre of screen", () =>
|
||||||
|
{
|
||||||
|
var expandedPanel = this.ChildrenOfType<ScorePanel>().Single(p => p.State == PanelState.Expanded);
|
||||||
|
return Precision.AlmostEquals(expandedPanel.ScreenSpaceDrawQuad.Centre.X, screen.ScreenSpaceDrawQuad.Centre.X, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestShowHideStatistics()
|
public void TestShowHideStatistics()
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
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.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.Placeholders;
|
using osu.Game.Online.Placeholders;
|
||||||
@ -129,6 +130,12 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
ToggleVisibility();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(150, Easing.OutQuint);
|
protected override void PopIn() => this.FadeIn(150, Easing.OutQuint);
|
||||||
|
|
||||||
protected override void PopOut() => this.FadeOut(150, Easing.OutQuint);
|
protected override void PopOut() => this.FadeOut(150, Easing.OutQuint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user