mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Merge pull request #16009 from smoogipoo/cleanup-drawable-playlist
Cleanup DrawableRoomPlaylist and DrawableRoomPlaylistItem
This commit is contained in:
commit
b393f83028
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
@ -48,7 +49,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestNonEditableNonSelectable()
|
||||
{
|
||||
createPlaylist(false, false);
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, false);
|
||||
@ -61,7 +62,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditable()
|
||||
{
|
||||
createPlaylist(true, false);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -74,7 +79,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestMarkInvalid()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
AddStep("mark item 0 as invalid", () => playlist.Items[0].MarkInvalid());
|
||||
|
||||
@ -87,7 +97,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectable()
|
||||
{
|
||||
createPlaylist(false, true);
|
||||
createPlaylist(p => p.AllowSelection = true);
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, false);
|
||||
@ -101,7 +111,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditableSelectable()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -115,7 +130,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectionNotLostAfterRearrangement()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p =>
|
||||
{
|
||||
p.AllowReordering = true;
|
||||
p.AllowDeletion = true;
|
||||
p.AllowSelection = true;
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -128,95 +148,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("item 1 is selected", () => playlist.SelectedItem.Value == playlist.Items[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemRemovedOnDeletion()
|
||||
{
|
||||
PlaylistItem selectedItem = null;
|
||||
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value);
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastItemSelectedAfterLastItemDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddWaitStep("wait for flow", 5); // Items may take 1 update frame to flow. A wait count of 5 is guaranteed to result in the flow being updated as desired.
|
||||
AddStep("scroll to bottom", () => playlist.ChildrenOfType<ScrollContainer<Drawable>>().First().ScrollToEnd(false));
|
||||
|
||||
moveToItem(19);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(19);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 18 is selected", () => playlist.SelectedItem.Value == playlist.Items[18]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectionResetWhenAllItemsDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddStep("remove all but one item", () =>
|
||||
{
|
||||
playlist.Items.RemoveRange(1, playlist.Items.Count - 1);
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("no item selected", () => playlist.SelectedItem.Value == null);
|
||||
}
|
||||
|
||||
// Todo: currently not possible due to bindable list shortcomings (https://github.com/ppy/osu-framework/issues/3081)
|
||||
// [Test]
|
||||
public void TestNextItemSelectedAfterExternalDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("remove item 0", () => playlist.Items.RemoveAt(0));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeBeatmapAndRemove()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
|
||||
AddStep("change beatmap of first item", () => playlist.Items[0].BeatmapID = 30);
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
||||
{
|
||||
@ -224,7 +155,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("import beatmap", () => manager.Import(beatmap.BeatmapSet).Wait());
|
||||
|
||||
createPlaylist(beatmap);
|
||||
createPlaylistWithBeatmaps(beatmap);
|
||||
|
||||
assertDownloadButtonVisible(false);
|
||||
|
||||
@ -247,7 +178,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
var byChecksum = CreateAPIBeatmap();
|
||||
byChecksum.Checksum = "1337"; // Some random checksum that does not exist locally.
|
||||
|
||||
createPlaylist(byOnlineId, byChecksum);
|
||||
createPlaylistWithBeatmaps(byOnlineId, byChecksum);
|
||||
|
||||
AddAssert("download buttons shown", () => playlist.ChildrenOfType<BeatmapDownloadButton>().All(d => d.IsPresent));
|
||||
}
|
||||
@ -261,7 +192,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
beatmap.BeatmapSet.HasExplicitContent = true;
|
||||
|
||||
createPlaylist(beatmap);
|
||||
createPlaylistWithBeatmaps(beatmap);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -269,7 +200,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(false, false)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -312,7 +243,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[TestCase(true)]
|
||||
public void TestWithOwner(bool withOwner)
|
||||
{
|
||||
createPlaylist(false, false, withOwner);
|
||||
createPlaylist(p => p.ShowItemOwners = withOwner);
|
||||
|
||||
AddAssert("owner visible", () => playlist.ChildrenOfType<UpdateableAvatar>().All(a => a.IsPresent == withOwner));
|
||||
}
|
||||
@ -326,12 +257,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().Single(), offset);
|
||||
});
|
||||
|
||||
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void assertHandleVisibility(int index, bool visible)
|
||||
=> AddAssert($"handle {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>.PlaylistItemHandle>().ElementAt(index).Alpha > 0) == visible);
|
||||
@ -340,17 +265,19 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
|
||||
|
||||
private void createPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(allowEdit, allowSelection, showItemOwner)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500, 300)
|
||||
};
|
||||
|
||||
setupPlaylist?.Invoke(playlist);
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
playlist.Items.Add(new PlaylistItem
|
||||
@ -386,11 +313,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
|
||||
}
|
||||
|
||||
private void createPlaylist(params IBeatmapInfo[] beatmaps)
|
||||
private void createPlaylistWithBeatmaps(params IBeatmapInfo[] beatmaps)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(false, false)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -423,11 +350,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private class TestPlaylist : DrawableRoomPlaylist
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
: base(allowEdit, allowSelection, showItemOwner: showItemOwner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,188 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestScenePlaylistsRoomSettingsPlaylist : OsuManualInputManagerTestScene
|
||||
{
|
||||
private TestPlaylist playlist;
|
||||
|
||||
[Cached(typeof(UserLookupCache))]
|
||||
private readonly TestUserLookupCache userLookupCache = new TestUserLookupCache();
|
||||
|
||||
[Test]
|
||||
public void TestItemRemovedOnDeletion()
|
||||
{
|
||||
PlaylistItem selectedItem = null;
|
||||
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("retrieve selection", () => selectedItem = playlist.SelectedItem.Value);
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastItemSelectedAfterLastItemDeleted()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddWaitStep("wait for flow", 5); // Items may take 1 update frame to flow. A wait count of 5 is guaranteed to result in the flow being updated as desired.
|
||||
AddStep("scroll to bottom", () => playlist.ChildrenOfType<ScrollContainer<Drawable>>().First().ScrollToEnd(false));
|
||||
|
||||
moveToItem(19);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
moveToDeleteButton(19);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("item 18 is selected", () => playlist.SelectedItem.Value == playlist.Items[18]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectionResetWhenAllItemsDeleted()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddStep("remove all but one item", () =>
|
||||
{
|
||||
playlist.Items.RemoveRange(1, playlist.Items.Count - 1);
|
||||
});
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
|
||||
AddAssert("no item selected", () => playlist.SelectedItem.Value == null);
|
||||
}
|
||||
|
||||
// Todo: currently not possible due to bindable list shortcomings (https://github.com/ppy/osu-framework/issues/3081)
|
||||
// [Test]
|
||||
public void TestNextItemSelectedAfterExternalDeletion()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
AddStep("remove item 0", () => playlist.Items.RemoveAt(0));
|
||||
|
||||
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChangeBeatmapAndRemove()
|
||||
{
|
||||
createPlaylist();
|
||||
|
||||
AddStep("change beatmap of first item", () => playlist.Items[0].BeatmapID = 30);
|
||||
moveToDeleteButton(0);
|
||||
AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
|
||||
}
|
||||
|
||||
private void moveToItem(int index, Vector2? offset = null)
|
||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DifficultyIcon>().ElementAt(index), offset));
|
||||
|
||||
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void createPlaylist()
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(500, 300)
|
||||
};
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
playlist.Items.Add(new PlaylistItem
|
||||
{
|
||||
ID = i,
|
||||
OwnerID = 2,
|
||||
Beatmap =
|
||||
{
|
||||
Value = i % 2 == 1
|
||||
? new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo
|
||||
: new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = "Artist",
|
||||
Author = new APIUser { Username = "Creator name here" },
|
||||
Title = "Long title used to check background colour",
|
||||
},
|
||||
BeatmapSet = new BeatmapSetInfo()
|
||||
}
|
||||
},
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
RequiredMods =
|
||||
{
|
||||
new OsuModHardRock(),
|
||||
new OsuModDoubleTime(),
|
||||
new OsuModAutoplay()
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));
|
||||
}
|
||||
|
||||
private class TestPlaylist : PlaylistsRoomSettingsPlaylist
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist()
|
||||
{
|
||||
AllowSelection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Screens.Select;
|
||||
using osuTK;
|
||||
|
||||
@ -43,9 +44,9 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
Child = playlist = new DrawableRoomPlaylist(true, false)
|
||||
Child = playlist = new PlaylistsRoomSettingsPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,9 +1,9 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -12,36 +12,113 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
/// <summary>
|
||||
/// A scrollable list which displays the <see cref="PlaylistItem"/>s in a <see cref="Room"/>.
|
||||
/// </summary>
|
||||
public class DrawableRoomPlaylist : OsuRearrangeableListContainer<PlaylistItem>
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently-selected item. Selection is visually represented with a border.
|
||||
/// May be updated by clicking playlist items if <see cref="AllowSelection"/> is <c>true</c>.
|
||||
/// </summary>
|
||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
private readonly bool allowEdit;
|
||||
private readonly bool allowSelection;
|
||||
private readonly bool showItemOwner;
|
||||
/// <summary>
|
||||
/// Invoked when an item is requested to be deleted.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestDeletion;
|
||||
|
||||
public DrawableRoomPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
/// <summary>
|
||||
/// Invoked when an item requests its results to be shown.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestResults;
|
||||
|
||||
private bool allowReordering;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to allow reordering items in the playlist.
|
||||
/// </summary>
|
||||
public bool AllowReordering
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
this.allowSelection = allowSelection;
|
||||
this.showItemOwner = showItemOwner;
|
||||
get => allowReordering;
|
||||
set
|
||||
{
|
||||
allowReordering = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowReordering = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
private bool allowDeletion;
|
||||
|
||||
// Scheduled since items are removed and re-added upon rearrangement
|
||||
Items.CollectionChanged += (_, args) => Schedule(() =>
|
||||
/// <summary>
|
||||
/// Whether to allow deleting items from the playlist.
|
||||
/// If <c>true</c>, requests to delete items may be satisfied via <see cref="RequestDeletion"/>.
|
||||
/// </summary>
|
||||
public bool AllowDeletion
|
||||
{
|
||||
get => allowDeletion;
|
||||
set
|
||||
{
|
||||
switch (args.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
if (allowSelection && args.OldItems.Contains(SelectedItem))
|
||||
SelectedItem.Value = null;
|
||||
break;
|
||||
}
|
||||
});
|
||||
allowDeletion = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowDeletion = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowSelection;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to allow selecting items from the playlist.
|
||||
/// If <c>true</c>, clicking on items in the playlist will change the value of <see cref="SelectedItem"/>.
|
||||
/// </summary>
|
||||
public bool AllowSelection
|
||||
{
|
||||
get => allowSelection;
|
||||
set
|
||||
{
|
||||
allowSelection = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowShowingResults;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to allow items to request their results to be shown.
|
||||
/// If <c>true</c>, requests to show the results may be satisfied via <see cref="RequestResults"/>.
|
||||
/// </summary>
|
||||
public bool AllowShowingResults
|
||||
{
|
||||
get => allowShowingResults;
|
||||
set
|
||||
{
|
||||
allowShowingResults = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowShowingResults = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwners;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the avatar of users which own each playlist item.
|
||||
/// </summary>
|
||||
public bool ShowItemOwners
|
||||
{
|
||||
get => showItemOwners;
|
||||
set
|
||||
{
|
||||
showItemOwners = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.ShowItemOwner = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override ScrollContainer<Drawable> CreateScrollContainer() => base.CreateScrollContainer().With(d =>
|
||||
@ -54,23 +131,18 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Spacing = new Vector2(0, 2)
|
||||
};
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item, allowEdit, allowSelection, showItemOwner)
|
||||
protected sealed override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => CreateDrawablePlaylistItem(item).With(d =>
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
RequestDeletion = requestDeletion
|
||||
};
|
||||
d.SelectedItem.BindTarget = SelectedItem;
|
||||
d.RequestDeletion = i => RequestDeletion?.Invoke(i);
|
||||
d.AllowReordering = AllowReordering;
|
||||
d.AllowDeletion = AllowDeletion;
|
||||
d.AllowSelection = AllowSelection;
|
||||
d.AllowShowingResults = AllowShowingResults;
|
||||
d.ShowItemOwner = ShowItemOwners;
|
||||
d.RequestResults = i => RequestResults?.Invoke(i);
|
||||
});
|
||||
|
||||
private void requestDeletion(PlaylistItem item)
|
||||
{
|
||||
if (allowSelection && SelectedItem.Value == item)
|
||||
{
|
||||
if (Items.Count == 1)
|
||||
SelectedItem.Value = null;
|
||||
else
|
||||
SelectedItem.Value = Items.GetNext(item) ?? Items[^2];
|
||||
}
|
||||
|
||||
Items.Remove(item);
|
||||
}
|
||||
protected virtual DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new DrawableRoomPlaylistItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -39,12 +38,33 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem>
|
||||
{
|
||||
public const float HEIGHT = 50;
|
||||
public const float ICON_HEIGHT = 34;
|
||||
|
||||
private const float icon_height = 34;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this item requests to be deleted.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestDeletion;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this item requests its results to be shown.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestResults;
|
||||
|
||||
/// <summary>
|
||||
/// The currently-selected item, used to show a border around this item.
|
||||
/// May be updated by this item if <see cref="AllowSelection"/> is <c>true</c>.
|
||||
/// </summary>
|
||||
public readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
|
||||
public readonly PlaylistItem Item;
|
||||
|
||||
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
|
||||
private readonly IBindable<bool> valid = new Bindable<bool>();
|
||||
private readonly Bindable<IBeatmapInfo> beatmap = new Bindable<IBeatmapInfo>();
|
||||
private readonly Bindable<IRulesetInfo> ruleset = new Bindable<IRulesetInfo>();
|
||||
private readonly BindableList<Mod> requiredMods = new BindableList<Mod>();
|
||||
|
||||
private Container maskingContainer;
|
||||
private Container difficultyIconContainer;
|
||||
private LinkFlowContainer beatmapText;
|
||||
@ -53,14 +73,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private ModDisplay modDisplay;
|
||||
private FillFlowContainer buttonsFlow;
|
||||
private UpdateableAvatar ownerAvatar;
|
||||
|
||||
private readonly IBindable<bool> valid = new Bindable<bool>();
|
||||
|
||||
private readonly Bindable<IBeatmapInfo> beatmap = new Bindable<IBeatmapInfo>();
|
||||
private readonly Bindable<IRulesetInfo> ruleset = new Bindable<IRulesetInfo>();
|
||||
private readonly BindableList<Mod> requiredMods = new BindableList<Mod>();
|
||||
|
||||
public readonly PlaylistItem Item;
|
||||
private Drawable removeButton;
|
||||
private Drawable showResultsButton;
|
||||
private PanelBackground panelBackground;
|
||||
private FillFlowContainer mainFillFlow;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
@ -71,35 +87,18 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Resolved]
|
||||
private BeatmapLookupCache beatmapLookupCache { get; set; }
|
||||
|
||||
private PanelBackground panelBackground;
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => AllowReordering || AllowDeletion || !AllowSelection || SelectedItem.Value == Model;
|
||||
|
||||
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
private readonly bool allowEdit;
|
||||
private readonly bool allowSelection;
|
||||
private readonly bool showItemOwner;
|
||||
|
||||
private FillFlowContainer mainFillFlow;
|
||||
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => allowEdit || !allowSelection || SelectedItem.Value == Model;
|
||||
|
||||
public DrawableRoomPlaylistItem(PlaylistItem item, bool allowEdit, bool allowSelection, bool showItemOwner)
|
||||
public DrawableRoomPlaylistItem(PlaylistItem item)
|
||||
: base(item)
|
||||
{
|
||||
Item = item;
|
||||
|
||||
// TODO: edit support should be moved out into a derived class
|
||||
this.allowEdit = allowEdit;
|
||||
this.allowSelection = allowSelection;
|
||||
this.showItemOwner = showItemOwner;
|
||||
|
||||
beatmap.BindTo(item.Beatmap);
|
||||
valid.BindTo(item.Valid);
|
||||
ruleset.BindTo(item.Ruleset);
|
||||
requiredMods.BindTo(item.RequiredMods);
|
||||
|
||||
ShowDragHandle.Value = allowEdit;
|
||||
|
||||
if (item.Expired)
|
||||
Colour = OsuColour.Gray(0.5f);
|
||||
}
|
||||
@ -107,9 +106,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (!allowEdit)
|
||||
HandleColour = HandleColour.Opacity(0);
|
||||
|
||||
maskingContainer.BorderColour = colours.Yellow;
|
||||
}
|
||||
|
||||
@ -169,6 +165,71 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can be selected.
|
||||
/// </summary>
|
||||
public bool AllowSelection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can be reordered in the playlist.
|
||||
/// </summary>
|
||||
public bool AllowReordering
|
||||
{
|
||||
get => ShowDragHandle.Value;
|
||||
set => ShowDragHandle.Value = value;
|
||||
}
|
||||
|
||||
private bool allowDeletion;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can be deleted.
|
||||
/// </summary>
|
||||
public bool AllowDeletion
|
||||
{
|
||||
get => allowDeletion;
|
||||
set
|
||||
{
|
||||
allowDeletion = value;
|
||||
|
||||
if (removeButton != null)
|
||||
removeButton.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowShowingResults;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can have results shown.
|
||||
/// </summary>
|
||||
public bool AllowShowingResults
|
||||
{
|
||||
get => allowShowingResults;
|
||||
set
|
||||
{
|
||||
allowShowingResults = value;
|
||||
|
||||
if (showResultsButton != null)
|
||||
showResultsButton.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwner;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to display the avatar of the user which owns this playlist item.
|
||||
/// </summary>
|
||||
public bool ShowItemOwner
|
||||
{
|
||||
get => showItemOwner;
|
||||
set
|
||||
{
|
||||
showItemOwner = value;
|
||||
|
||||
if (ownerAvatar != null)
|
||||
ownerAvatar.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
if (!valid.Value)
|
||||
@ -178,7 +239,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
|
||||
if (Item.Beatmap.Value != null)
|
||||
difficultyIconContainer.Child = new DifficultyIcon(Item.Beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(ICON_HEIGHT) };
|
||||
difficultyIconContainer.Child = new DifficultyIcon(Item.Beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(icon_height) };
|
||||
else
|
||||
difficultyIconContainer.Clear();
|
||||
|
||||
@ -208,7 +269,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
modDisplay.Current.Value = requiredMods.ToArray();
|
||||
|
||||
buttonsFlow.Clear();
|
||||
buttonsFlow.ChildrenEnumerable = CreateButtons();
|
||||
buttonsFlow.ChildrenEnumerable = createButtons();
|
||||
|
||||
difficultyIconContainer.FadeInFromZero(500, Easing.OutQuint);
|
||||
mainFillFlow.FadeInFromZero(500, Easing.OutQuint);
|
||||
@ -322,7 +383,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Margin = new MarginPadding { Horizontal = 8 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(5),
|
||||
ChildrenEnumerable = CreateButtons().Select(button => button.With(b =>
|
||||
ChildrenEnumerable = createButtons().Select(button => button.With(b =>
|
||||
{
|
||||
b.Anchor = Anchor.Centre;
|
||||
b.Origin = Anchor.Centre;
|
||||
@ -332,11 +393,11 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(ICON_HEIGHT),
|
||||
Size = new Vector2(icon_height),
|
||||
Margin = new MarginPadding { Right = 8 },
|
||||
Masking = true,
|
||||
CornerRadius = 4,
|
||||
Alpha = showItemOwner ? 1 : 0
|
||||
Alpha = ShowItemOwner ? 1 : 0
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -345,17 +406,21 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual IEnumerable<Drawable> CreateButtons() =>
|
||||
new[]
|
||||
private IEnumerable<Drawable> createButtons() => new[]
|
||||
{
|
||||
showResultsButton = new ShowResultsButton
|
||||
{
|
||||
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
|
||||
new PlaylistRemoveButton
|
||||
{
|
||||
Size = new Vector2(30, 30),
|
||||
Alpha = allowEdit ? 1 : 0,
|
||||
Action = () => RequestDeletion?.Invoke(Model),
|
||||
},
|
||||
};
|
||||
Action = () => RequestResults?.Invoke(Item),
|
||||
Alpha = AllowShowingResults ? 1 : 0,
|
||||
},
|
||||
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
|
||||
removeButton = new PlaylistRemoveButton
|
||||
{
|
||||
Size = new Vector2(30, 30),
|
||||
Alpha = AllowDeletion ? 1 : 0,
|
||||
Action = () => RequestDeletion?.Invoke(Item),
|
||||
},
|
||||
};
|
||||
|
||||
public class PlaylistRemoveButton : GrayButton
|
||||
{
|
||||
@ -374,7 +439,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (allowSelection && valid.Value)
|
||||
if (AllowSelection && valid.Value)
|
||||
SelectedItem.Value = Model;
|
||||
return true;
|
||||
}
|
||||
@ -432,6 +497,23 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowResultsButton : IconButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Icon = FontAwesome.Solid.ChartPie;
|
||||
TooltipText = "View results";
|
||||
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MaxValue,
|
||||
Colour = colours.Gray4,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// For now, this is the same implementation as in PanelBackground, but supports a beatmap info rather than a working beatmap
|
||||
private class PanelBackground : Container // todo: should be a buffered container (https://github.com/ppy/osu-framework/issues/3222)
|
||||
{
|
||||
|
@ -1,69 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
public class DrawableRoomPlaylistWithResults : DrawableRoomPlaylist
|
||||
{
|
||||
public Action<PlaylistItem> RequestShowResults;
|
||||
|
||||
private readonly bool showItemOwner;
|
||||
|
||||
public DrawableRoomPlaylistWithResults(bool showItemOwner = false)
|
||||
: base(false, true, showItemOwner: showItemOwner)
|
||||
{
|
||||
this.showItemOwner = showItemOwner;
|
||||
}
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) =>
|
||||
new DrawableRoomPlaylistItemWithResults(item, false, true, showItemOwner)
|
||||
{
|
||||
RequestShowResults = () => RequestShowResults(item),
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
};
|
||||
|
||||
private class DrawableRoomPlaylistItemWithResults : DrawableRoomPlaylistItem
|
||||
{
|
||||
public Action RequestShowResults;
|
||||
|
||||
public DrawableRoomPlaylistItemWithResults(PlaylistItem item, bool allowEdit, bool allowSelection, bool showItemOwner)
|
||||
: base(item, allowEdit, allowSelection, showItemOwner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IEnumerable<Drawable> CreateButtons() =>
|
||||
base.CreateButtons().Prepend(new FilledIconButton
|
||||
{
|
||||
Icon = FontAwesome.Solid.ChartPie,
|
||||
Action = () => RequestShowResults?.Invoke(),
|
||||
TooltipText = "View results"
|
||||
});
|
||||
|
||||
private class FilledIconButton : IconButton
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Add(new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = float.MaxValue,
|
||||
Colour = colours.Gray4,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -248,7 +248,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
Spacing = new Vector2(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
drawablePlaylist = new DrawableRoomPlaylist(false, false)
|
||||
drawablePlaylist = new DrawableRoomPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = DrawableRoomPlaylistItem.HEIGHT
|
||||
|
@ -16,8 +16,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
public class MultiplayerHistoryList : DrawableRoomPlaylist
|
||||
{
|
||||
public MultiplayerHistoryList()
|
||||
: base(false, false, true)
|
||||
{
|
||||
ShowItemOwners = true;
|
||||
}
|
||||
|
||||
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new HistoryFillFlowContainer
|
||||
|
@ -18,8 +18,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
public class MultiplayerQueueList : DrawableRoomPlaylist
|
||||
{
|
||||
public MultiplayerQueueList()
|
||||
: base(false, false, true)
|
||||
{
|
||||
ShowItemOwners = true;
|
||||
}
|
||||
|
||||
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new QueueFillFlowContainer
|
||||
|
@ -205,7 +205,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
playlist = new DrawableRoomPlaylist(true, false) { RelativeSizeAxes = Axes.Both }
|
||||
playlist = new PlaylistsRoomSettingsPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
|
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="DrawableRoomPlaylist"/> which is displayed during the setup stage of a playlists room.
|
||||
/// </summary>
|
||||
public class PlaylistsRoomSettingsPlaylist : DrawableRoomPlaylist
|
||||
{
|
||||
public PlaylistsRoomSettingsPlaylist()
|
||||
{
|
||||
AllowReordering = true;
|
||||
AllowDeletion = true;
|
||||
|
||||
RequestDeletion = item =>
|
||||
{
|
||||
var nextItem = Items.GetNext(item);
|
||||
|
||||
Items.Remove(item);
|
||||
|
||||
SelectedItem.Value = nextItem ?? Items.LastOrDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -88,12 +88,14 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
new Drawable[] { new OverlinedPlaylistHeader(), },
|
||||
new Drawable[]
|
||||
{
|
||||
new DrawableRoomPlaylistWithResults
|
||||
new DrawableRoomPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Items = { BindTarget = Room.Playlist },
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
RequestShowResults = item =>
|
||||
AllowSelection = true,
|
||||
AllowShowingResults = true,
|
||||
RequestResults = item =>
|
||||
{
|
||||
Debug.Assert(RoomId.Value != null);
|
||||
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false));
|
||||
|
Loading…
Reference in New Issue
Block a user