mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Merge pull request #22022 from Joehuu/fix-playlist-item-regressions
Fix playlist items having a random selected state after deleting and not animating when rearranging
This commit is contained in:
commit
ee0bc55356
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -46,10 +47,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void TestNextItemSelectedAfterDeletion(bool allowSelection)
|
||||
{
|
||||
createPlaylist();
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowSelection = allowSelection;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -57,7 +62,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
AddAssert("item 0 is " + (allowSelection ? "selected" : "not selected"), () => playlist.SelectedItem.Value == (allowSelection ? playlist.Items[0] : null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -117,7 +122,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void createPlaylist()
|
||||
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
@ -154,6 +159,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setupPlaylist?.Invoke(playlist);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
|
||||
|
@ -156,6 +156,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new FillFlowContainer<RearrangeableListItem<PlaylistItem>>
|
||||
{
|
||||
LayoutDuration = 200,
|
||||
LayoutEasing = Easing.OutQuint,
|
||||
Spacing = new Vector2(0, 2)
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
Items.Remove(item);
|
||||
|
||||
SelectedItem.Value = nextItem ?? Items.LastOrDefault();
|
||||
if (AllowSelection && SelectedItem.Value == item)
|
||||
SelectedItem.Value = nextItem ?? Items.LastOrDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user