1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 00:07:20 +08:00

Merge branch 'results-screen-animate-once' into results-screen-applause

This commit is contained in:
Dean Herbert 2020-10-29 18:52:54 +09:00
commit 404885af89
3 changed files with 27 additions and 20 deletions

View File

@ -2,6 +2,7 @@
// 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 osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;

View File

@ -6,6 +6,7 @@ using System.Linq;
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.Graphics.Performance;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI

View File

@ -118,22 +118,24 @@ namespace osu.Game.Screens.Ranking
d.Origin = Anchor.Centre; d.Origin = Anchor.Centre;
})); }));
if (SelectedScore.Value == score) if (IsLoaded)
{ {
if (IsLoaded) if (SelectedScore.Value == score)
SelectedScore.TriggerChange();
}
else
{
// We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
// But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
{ {
// A somewhat hacky property is used here because we need to: SelectedScore.TriggerChange();
// 1) Scroll after the scroll container's visible range is updated. }
// 2) Scroll before the scroll container's scroll position is updated. else
// Without this, we would have a 1-frame positioning error which looks very jarring. {
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing; // We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done.
// But when a panel is added before the expanded panel, we need to offset the scroll position by the width of the new panel.
if (expandedPanel != null && flow.GetPanelIndex(score) < flow.GetPanelIndex(expandedPanel.Score))
{
// A somewhat hacky property is used here because we need to:
// 1) Scroll after the scroll container's visible range is updated.
// 2) Scroll before the scroll container's scroll position is updated.
// Without this, we would have a 1-frame positioning error which looks very jarring.
scroll.InstantScrollTarget = (scroll.InstantScrollTarget ?? scroll.Target) + ScorePanel.CONTRACTED_WIDTH + panel_spacing;
}
} }
} }
@ -170,12 +172,15 @@ namespace osu.Game.Screens.Ranking
expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing }; expandedTrackingComponent.Margin = new MarginPadding { Horizontal = expanded_panel_spacing };
expandedPanel.State = PanelState.Expanded; expandedPanel.State = PanelState.Expanded;
// Scroll to the new panel. This is done manually since we need: SchedulerAfterChildren.Add(() =>
// 1) To scroll after the scroll container's visible range is updated. {
// 2) To account for the centre anchor/origins of panels. // Scroll to the new panel. This is done manually since we need:
// In the end, it's easier to compute the scroll position manually. // 1) To scroll after the scroll container's visible range is updated.
float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing); // 2) To account for the centre anchor/origins of panels.
scroll.ScrollTo(scrollOffset); // In the end, it's easier to compute the scroll position manually.
float scrollOffset = flow.GetPanelIndex(expandedPanel.Score) * (ScorePanel.CONTRACTED_WIDTH + panel_spacing);
scroll.ScrollTo(scrollOffset);
});
} }
protected override void Update() protected override void Update()