mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 06:53:03 +08:00
Remove ctor params from PlaylistsRoomPlaylist
This commit is contained in:
parent
3be4d8b68d
commit
26f6c5e5a5
@ -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,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditable()
|
||||
{
|
||||
createPlaylist(true, false);
|
||||
createPlaylist(p => p.AllowReordering = p.AllowDeletion = true);
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -74,7 +75,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestMarkInvalid()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p => p.AllowReordering = p.AllowDeletion = p.AllowSelection = true);
|
||||
|
||||
AddStep("mark item 0 as invalid", () => playlist.Items[0].MarkInvalid());
|
||||
|
||||
@ -87,7 +88,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 +102,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestEditableSelectable()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p => p.AllowReordering = p.AllowDeletion = p.AllowSelection = true);
|
||||
|
||||
moveToItem(0);
|
||||
assertHandleVisibility(0, true);
|
||||
@ -115,7 +116,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectionNotLostAfterRearrangement()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist(p => p.AllowReordering = p.AllowDeletion = p.AllowSelection = true);
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -180,7 +181,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,
|
||||
@ -223,7 +224,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));
|
||||
}
|
||||
@ -245,11 +246,11 @@ 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)
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(allowEdit, allowSelection, showItemOwner)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -295,7 +296,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,
|
||||
@ -328,27 +329,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private class TestPlaylist : DrawableRoomPlaylist
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
private readonly bool allowEdit;
|
||||
private readonly bool allowSelection;
|
||||
private readonly bool showItemOwner;
|
||||
|
||||
public TestPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
this.allowSelection = allowSelection;
|
||||
this.showItemOwner = showItemOwner;
|
||||
}
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => base.CreateOsuDrawable(item).With(d =>
|
||||
{
|
||||
var drawablePlaylistItem = (DrawableRoomPlaylistItem)d;
|
||||
|
||||
drawablePlaylistItem.AllowReordering = allowEdit;
|
||||
drawablePlaylistItem.AllowDeletion = allowEdit;
|
||||
drawablePlaylistItem.AllowSelection = allowSelection;
|
||||
drawablePlaylistItem.ShowItemOwner = showItemOwner;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,8 +180,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist()
|
||||
: base(true, true, true)
|
||||
{
|
||||
AllowSelection = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,9 +44,10 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
Child = playlist = new PlaylistsRoomPlaylist(true, true, true)
|
||||
Child = playlist = new PlaylistsRoomPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AllowSelection = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -20,6 +21,61 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> DeletionRequested;
|
||||
|
||||
private bool allowReordering;
|
||||
|
||||
public bool AllowReordering
|
||||
{
|
||||
get => allowReordering;
|
||||
set
|
||||
{
|
||||
allowReordering = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowReordering = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowDeletion;
|
||||
|
||||
public bool AllowDeletion
|
||||
{
|
||||
get => allowDeletion;
|
||||
set
|
||||
{
|
||||
allowDeletion = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowDeletion = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowSelection;
|
||||
|
||||
public bool AllowSelection
|
||||
{
|
||||
get => allowSelection;
|
||||
set
|
||||
{
|
||||
allowSelection = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwners;
|
||||
|
||||
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 =>
|
||||
{
|
||||
@ -35,6 +91,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
RequestDeletion = i => DeletionRequested?.Invoke(i),
|
||||
AllowReordering = AllowReordering,
|
||||
AllowDeletion = AllowDeletion,
|
||||
AllowSelection = AllowSelection,
|
||||
ShowItemOwner = ShowItemOwners,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,23 +3,15 @@
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
public class PlaylistsRoomPlaylist : DrawableRoomPlaylist
|
||||
{
|
||||
private readonly bool allowReordering;
|
||||
private readonly bool allowDeletion;
|
||||
private readonly bool allowSelection;
|
||||
|
||||
public PlaylistsRoomPlaylist(bool allowReordering, bool allowDeletion, bool allowSelection)
|
||||
public PlaylistsRoomPlaylist()
|
||||
{
|
||||
this.allowReordering = allowReordering;
|
||||
this.allowDeletion = allowDeletion;
|
||||
this.allowSelection = allowSelection;
|
||||
AllowReordering = true;
|
||||
AllowDeletion = true;
|
||||
|
||||
DeletionRequested = item =>
|
||||
{
|
||||
@ -30,14 +22,5 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
SelectedItem.Value = nextItem ?? Items.LastOrDefault();
|
||||
};
|
||||
}
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => base.CreateOsuDrawable(item).With(d =>
|
||||
{
|
||||
var drawablePlaylistItem = (DrawableRoomPlaylistItem)d;
|
||||
|
||||
drawablePlaylistItem.AllowReordering = allowReordering;
|
||||
drawablePlaylistItem.AllowDeletion = allowDeletion;
|
||||
drawablePlaylistItem.AllowSelection = allowSelection;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
playlist = new PlaylistsRoomPlaylist(true, true, false)
|
||||
playlist = new PlaylistsRoomPlaylist
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
|
Loading…
Reference in New Issue
Block a user