mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:07:52 +08:00
Add test coverage of current score staying on screen
This commit is contained in:
parent
8642ed7631
commit
8edb1cb98a
@ -58,6 +58,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddUntilStep("wait for some scores not masked away",
|
AddUntilStep("wait for some scores not masked away",
|
||||||
() => leaderboard.ChildrenOfType<GameplayLeaderboardScore>().Any(s => leaderboard.ScreenSpaceDrawQuad.Contains(s.ScreenSpaceDrawQuad.Centre)));
|
() => leaderboard.ChildrenOfType<GameplayLeaderboardScore>().Any(s => leaderboard.ScreenSpaceDrawQuad.Contains(s.ScreenSpaceDrawQuad.Centre)));
|
||||||
|
|
||||||
|
AddUntilStep("wait for tracked score fully visible", () => leaderboard.ScreenSpaceDrawQuad.Intersects(leaderboard.TrackedScore!.ScreenSpaceDrawQuad));
|
||||||
|
|
||||||
|
AddStep("change score to middle", () => playerScore.Value = 1000000);
|
||||||
|
AddWaitStep("wait for movement", 5);
|
||||||
|
AddUntilStep("wait for tracked score fully visible", () => leaderboard.ScreenSpaceDrawQuad.Intersects(leaderboard.TrackedScore!.ScreenSpaceDrawQuad));
|
||||||
|
|
||||||
|
AddStep("change score to first", () => playerScore.Value = 5000000);
|
||||||
|
AddWaitStep("wait for movement", 5);
|
||||||
|
AddUntilStep("wait for tracked score fully visible", () => leaderboard.ScreenSpaceDrawQuad.Intersects(leaderboard.TrackedScore!.ScreenSpaceDrawQuad));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private bool requiresScroll;
|
private bool requiresScroll;
|
||||||
private readonly OsuScrollContainer scroll;
|
private readonly OsuScrollContainer scroll;
|
||||||
|
|
||||||
private GameplayLeaderboardScore? trackedScore;
|
public GameplayLeaderboardScore? TrackedScore { get; private set; }
|
||||||
|
|
||||||
private const int max_panels = 8;
|
private const int max_panels = 8;
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (isTracked)
|
if (isTracked)
|
||||||
{
|
{
|
||||||
if (trackedScore != null)
|
if (TrackedScore != null)
|
||||||
throw new InvalidOperationException("Cannot track more than one score.");
|
throw new InvalidOperationException("Cannot track more than one score.");
|
||||||
|
|
||||||
trackedScore = drawable;
|
TrackedScore = drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawable.Expanded.BindTo(Expanded);
|
drawable.Expanded.BindTo(Expanded);
|
||||||
@ -108,7 +108,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
Flow.Clear();
|
Flow.Clear();
|
||||||
trackedScore = null;
|
TrackedScore = null;
|
||||||
scroll.ScrollToStart(false);
|
scroll.ScrollToStart(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +119,10 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (requiresScroll && trackedScore != null)
|
if (requiresScroll && TrackedScore != null)
|
||||||
{
|
{
|
||||||
float scrollTarget = scroll.GetChildPosInContent(trackedScore) + trackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
|
float scrollTarget = scroll.GetChildPosInContent(TrackedScore) + TrackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
|
||||||
|
|
||||||
scroll.ScrollTo(scrollTarget);
|
scroll.ScrollTo(scrollTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user