mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Remove ctor params from DrawableRoomPlaylist/DrawablePlaylistItem
This commit is contained in:
parent
beb5d61a42
commit
3be4d8b68d
@ -329,10 +329,26 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
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)
|
||||
: base(allowEdit, allowSelection, showItemOwner)
|
||||
{
|
||||
}
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
PlaylistItem selectedItem = null;
|
||||
|
||||
createPlaylist(true, true);
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestNextItemSelectedAfterDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestLastItemSelectedAfterLastItemDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
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));
|
||||
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestSelectionResetWhenAllItemsDeleted()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist();
|
||||
|
||||
AddStep("remove all but one item", () =>
|
||||
{
|
||||
@ -101,7 +101,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
// [Test]
|
||||
public void TestNextItemSelectedAfterExternalDeletion()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist();
|
||||
|
||||
moveToItem(0);
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestChangeBeatmapAndRemove()
|
||||
{
|
||||
createPlaylist(true, true);
|
||||
createPlaylist();
|
||||
|
||||
AddStep("change beatmap of first item", () => playlist.Items[0].BeatmapID = 30);
|
||||
moveToDeleteButton(0);
|
||||
@ -129,11 +129,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
|
||||
});
|
||||
|
||||
private void createPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
private void createPlaylist()
|
||||
{
|
||||
AddStep("create playlist", () =>
|
||||
{
|
||||
Child = playlist = new TestPlaylist(allowEdit, allowSelection, showItemOwner)
|
||||
Child = playlist = new TestPlaylist
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -179,8 +179,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public new IReadOnlyDictionary<PlaylistItem, RearrangeableListItem<PlaylistItem>> ItemMap => base.ItemMap;
|
||||
|
||||
public TestPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
: base(allowEdit, allowSelection, showItemOwner)
|
||||
public TestPlaylist()
|
||||
: base(true, true, true)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Bottom = 10 },
|
||||
Child = playlist = new PlaylistsRoomPlaylist(true, false)
|
||||
Child = playlist = new PlaylistsRoomPlaylist(true, true, true)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
|
@ -20,16 +20,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> DeletionRequested;
|
||||
|
||||
private readonly bool allowEdit;
|
||||
private readonly bool allowSelection;
|
||||
private readonly bool showItemOwner;
|
||||
|
||||
public DrawableRoomPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
this.allowSelection = allowSelection;
|
||||
this.showItemOwner = showItemOwner;
|
||||
}
|
||||
|
||||
protected override ScrollContainer<Drawable> CreateScrollContainer() => base.CreateScrollContainer().With(d =>
|
||||
{
|
||||
@ -41,10 +31,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Spacing = new Vector2(0, 2)
|
||||
};
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item, allowEdit, allowSelection, showItemOwner)
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item)
|
||||
{
|
||||
SelectedItem = { BindTarget = SelectedItem },
|
||||
RequestDeletion = i => DeletionRequested?.Invoke(i)
|
||||
RequestDeletion = i => DeletionRequested?.Invoke(i),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -53,6 +52,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private ModDisplay modDisplay;
|
||||
private FillFlowContainer buttonsFlow;
|
||||
private UpdateableAvatar ownerAvatar;
|
||||
private Drawable removeButton;
|
||||
|
||||
private readonly IBindable<bool> valid = new Bindable<bool>();
|
||||
|
||||
@ -75,31 +75,20 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
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;
|
||||
protected override bool ShouldBeConsideredForInput(Drawable child) => AllowReordering || AllowDeletion || !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 +96,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (!allowEdit)
|
||||
HandleColour = HandleColour.Opacity(0);
|
||||
|
||||
maskingContainer.BorderColour = colours.Yellow;
|
||||
}
|
||||
|
||||
@ -169,6 +155,42 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
refresh();
|
||||
}
|
||||
|
||||
public bool AllowSelection { get; set; }
|
||||
|
||||
public bool AllowReordering
|
||||
{
|
||||
get => ShowDragHandle.Value;
|
||||
set => ShowDragHandle.Value = value;
|
||||
}
|
||||
|
||||
private bool allowDeletion;
|
||||
|
||||
public bool AllowDeletion
|
||||
{
|
||||
get => allowDeletion;
|
||||
set
|
||||
{
|
||||
allowDeletion = value;
|
||||
|
||||
if (removeButton != null)
|
||||
removeButton.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwner;
|
||||
|
||||
public bool ShowItemOwner
|
||||
{
|
||||
get => showItemOwner;
|
||||
set
|
||||
{
|
||||
showItemOwner = value;
|
||||
|
||||
if (ownerAvatar != null)
|
||||
ownerAvatar.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
if (!valid.Value)
|
||||
@ -336,7 +358,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
Margin = new MarginPadding { Right = 8 },
|
||||
Masking = true,
|
||||
CornerRadius = 4,
|
||||
Alpha = showItemOwner ? 1 : 0
|
||||
Alpha = ShowItemOwner ? 1 : 0
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -349,11 +371,11 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
new[]
|
||||
{
|
||||
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
|
||||
new PlaylistRemoveButton
|
||||
removeButton = new PlaylistRemoveButton
|
||||
{
|
||||
Size = new Vector2(30, 30),
|
||||
Alpha = allowEdit ? 1 : 0,
|
||||
Action = () => RequestDeletion?.Invoke(Model),
|
||||
Alpha = AllowDeletion ? 1 : 0,
|
||||
Action = () => RequestDeletion?.Invoke(Item),
|
||||
},
|
||||
};
|
||||
|
||||
@ -374,7 +396,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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osuTK;
|
||||
|
||||
@ -15,16 +16,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
/// </summary>
|
||||
public class MultiplayerHistoryList : DrawableRoomPlaylist
|
||||
{
|
||||
public MultiplayerHistoryList()
|
||||
: base(false, false, true)
|
||||
{
|
||||
}
|
||||
|
||||
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new HistoryFillFlowContainer
|
||||
{
|
||||
Spacing = new Vector2(0, 2)
|
||||
};
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item)
|
||||
=> base.CreateOsuDrawable(item).With(d => ((DrawableRoomPlaylistItem)d).ShowItemOwner = true);
|
||||
|
||||
private class HistoryFillFlowContainer : FillFlowContainer<RearrangeableListItem<PlaylistItem>>
|
||||
{
|
||||
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.OfType<RearrangeableListItem<PlaylistItem>>().OrderByDescending(item => item.Model.PlayedAt);
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osuTK;
|
||||
|
||||
@ -17,16 +18,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
/// </summary>
|
||||
public class MultiplayerQueueList : DrawableRoomPlaylist
|
||||
{
|
||||
public MultiplayerQueueList()
|
||||
: base(false, false, true)
|
||||
{
|
||||
}
|
||||
|
||||
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new QueueFillFlowContainer
|
||||
{
|
||||
Spacing = new Vector2(0, 2)
|
||||
};
|
||||
|
||||
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item)
|
||||
=> base.CreateOsuDrawable(item).With(d => ((DrawableRoomPlaylistItem)d).ShowItemOwner = true);
|
||||
|
||||
private class QueueFillFlowContainer : FillFlowContainer<RearrangeableListItem<PlaylistItem>>
|
||||
{
|
||||
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
||||
|
@ -3,14 +3,24 @@
|
||||
|
||||
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
|
||||
{
|
||||
public PlaylistsRoomPlaylist(bool allowEdit, bool allowSelection, bool showItemOwner = false)
|
||||
: base(allowEdit, allowSelection, showItemOwner)
|
||||
private readonly bool allowReordering;
|
||||
private readonly bool allowDeletion;
|
||||
private readonly bool allowSelection;
|
||||
|
||||
public PlaylistsRoomPlaylist(bool allowReordering, bool allowDeletion, bool allowSelection)
|
||||
{
|
||||
this.allowReordering = allowReordering;
|
||||
this.allowDeletion = allowDeletion;
|
||||
this.allowSelection = allowSelection;
|
||||
|
||||
DeletionRequested = item =>
|
||||
{
|
||||
var nextItem = Items.GetNext(item);
|
||||
@ -20,5 +30,14 @@ 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,7 +205,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
playlist = new PlaylistsRoomPlaylist(true, false)
|
||||
playlist = new PlaylistsRoomPlaylist(true, true, false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user