mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge pull request #20518 from peppy/fix-leaderboard-wobble
Fix leaderboard wobble when in first place
This commit is contained in:
@ -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;
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
scroll = new InputDisabledScrollContainer
|
scroll = new InputDisabledScrollContainer
|
||||||
{
|
{
|
||||||
|
ClampExtension = 0,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = Flow = new FillFlowContainer<GameplayLeaderboardScore>
|
Child = Flow = new FillFlowContainer<GameplayLeaderboardScore>
|
||||||
{
|
{
|
||||||
@ -78,10 +79,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);
|
||||||
@ -92,14 +93,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
int displayCount = Math.Min(Flow.Count, max_panels);
|
int displayCount = Math.Min(Flow.Count, max_panels);
|
||||||
Height = displayCount * (GameplayLeaderboardScore.PANEL_HEIGHT + Flow.Spacing.Y);
|
Height = displayCount * (GameplayLeaderboardScore.PANEL_HEIGHT + Flow.Spacing.Y);
|
||||||
// Add extra margin space to flow equal to height of leaderboard.
|
|
||||||
// This ensures the content is always on screen, but also accounts for the fact that scroll operations
|
|
||||||
// without animation were actually forcing the local score to a location it can't usually reside at.
|
|
||||||
//
|
|
||||||
// Basically, the local score was in the scroll extension region (due to always trying to scroll the
|
|
||||||
// local player to the middle of the display, but there being no other content below the local player
|
|
||||||
// to scroll up by).
|
|
||||||
Flow.Margin = new MarginPadding { Bottom = Height };
|
|
||||||
requiresScroll = displayCount != Flow.Count;
|
requiresScroll = displayCount != Flow.Count;
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
@ -108,7 +101,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 +112,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user