mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Apply NRT to ScorePanelList
This commit is contained in:
parent
1fd5d737da
commit
cb49147d1e
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
@ -329,6 +330,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
if (state.NewValue == Visibility.Visible)
|
||||
{
|
||||
Debug.Assert(SelectedScore.Value != null);
|
||||
// Detach the panel in its original location, and move into the desired location in the local container.
|
||||
var expandedPanel = ScorePanelList.GetPanelForScore(SelectedScore.Value);
|
||||
var screenSpacePos = expandedPanel.ScreenSpaceDrawQuad.TopLeft;
|
||||
|
@ -1,14 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -64,14 +61,14 @@ namespace osu.Game.Screens.Ranking
|
||||
/// <summary>
|
||||
/// An action to be invoked if a <see cref="ScorePanel"/> is clicked while in an expanded state.
|
||||
/// </summary>
|
||||
public Action PostExpandAction;
|
||||
public Action? PostExpandAction;
|
||||
|
||||
public readonly Bindable<ScoreInfo> SelectedScore = new Bindable<ScoreInfo>();
|
||||
public readonly Bindable<ScoreInfo?> SelectedScore = new Bindable<ScoreInfo?>();
|
||||
|
||||
private readonly CancellationTokenSource loadCancellationSource = new CancellationTokenSource();
|
||||
private readonly Flow flow;
|
||||
private readonly Scroll scroll;
|
||||
private ScorePanel expandedPanel;
|
||||
private ScorePanel? expandedPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ScorePanelList"/>.
|
||||
@ -174,7 +171,7 @@ namespace osu.Game.Screens.Ranking
|
||||
/// Brings a <see cref="ScoreInfo"/> to the centre of the screen and expands it.
|
||||
/// </summary>
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to present.</param>
|
||||
private void selectedScoreChanged(ValueChangedEvent<ScoreInfo> score)
|
||||
private void selectedScoreChanged(ValueChangedEvent<ScoreInfo?> score)
|
||||
{
|
||||
// avoid contracting panels unnecessarily when TriggerChange is fired manually.
|
||||
if (score.OldValue != null && !score.OldValue.Equals(score.NewValue))
|
||||
@ -317,7 +314,7 @@ namespace osu.Game.Screens.Ranking
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
loadCancellationSource?.Cancel();
|
||||
loadCancellationSource.Cancel();
|
||||
}
|
||||
|
||||
private partial class Flow : FillFlowContainer<ScorePanelTrackingContainer>
|
||||
@ -326,11 +323,9 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
public int GetPanelIndex(ScoreInfo score) => applySorting(Children).TakeWhile(s => !s.Panel.Score.Equals(score)).Count();
|
||||
|
||||
[CanBeNull]
|
||||
public ScoreInfo GetPreviousScore(ScoreInfo score) => applySorting(Children).TakeWhile(s => !s.Panel.Score.Equals(score)).LastOrDefault()?.Panel.Score;
|
||||
public ScoreInfo? GetPreviousScore(ScoreInfo score) => applySorting(Children).TakeWhile(s => !s.Panel.Score.Equals(score)).LastOrDefault()?.Panel.Score;
|
||||
|
||||
[CanBeNull]
|
||||
public ScoreInfo GetNextScore(ScoreInfo score) => applySorting(Children).SkipWhile(s => !s.Panel.Score.Equals(score)).ElementAtOrDefault(1)?.Panel.Score;
|
||||
public ScoreInfo? GetNextScore(ScoreInfo score) => applySorting(Children).SkipWhile(s => !s.Panel.Score.Equals(score)).ElementAtOrDefault(1)?.Panel.Score;
|
||||
|
||||
private IEnumerable<ScorePanelTrackingContainer> applySorting(IEnumerable<Drawable> drawables) => drawables.OfType<ScorePanelTrackingContainer>()
|
||||
.OrderByDescending(GetLayoutPosition)
|
||||
|
Loading…
Reference in New Issue
Block a user