mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 10:33:07 +08:00
Ensure selected playlist item is always scrolled into view
This commit is contained in:
parent
ec27fa8e85
commit
0405c1c34a
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -173,6 +174,21 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected virtual DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new DrawableRoomPlaylistItem(item);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
SelectedItem.BindValueChanged(_ => scrollToSelection(), true);
|
||||
}
|
||||
|
||||
private void scrollToSelection()
|
||||
{
|
||||
if (SelectedItem.Value == null) return;
|
||||
|
||||
Debug.Assert(ItemMap.TryGetValue(SelectedItem.Value, out var drawableItem));
|
||||
ScrollContainer.ScrollIntoView(drawableItem);
|
||||
}
|
||||
|
||||
#region Key selection logic (shared with BeatmapCarousel and RoomsContainer)
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
|
Loading…
Reference in New Issue
Block a user