mirror of
https://github.com/ppy/osu
synced 2025-01-02 20:32:10 +00:00
Add edit button to DrawableRoomPlaylistItem
This commit is contained in:
parent
4d1c06c061
commit
048a495115
@ -255,6 +255,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
p.AllowDeletion = true;
|
||||
p.AllowShowingResults = true;
|
||||
p.AllowEditing = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,11 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestResults;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when an item requests to be edited.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestEdit;
|
||||
|
||||
private bool allowReordering;
|
||||
|
||||
/// <summary>
|
||||
@ -104,6 +109,24 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowEditing;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to allow items to be edited.
|
||||
/// If <c>true</c>, requests to edit items may be satisfied via <see cref="RequestEdit"/>.
|
||||
/// </summary>
|
||||
public bool AllowEditing
|
||||
{
|
||||
get => allowEditing;
|
||||
set
|
||||
{
|
||||
allowEditing = value;
|
||||
|
||||
foreach (var item in ListContainer.OfType<DrawableRoomPlaylistItem>())
|
||||
item.AllowEditing = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwners;
|
||||
|
||||
/// <summary>
|
||||
@ -135,12 +158,14 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
d.SelectedItem.BindTarget = SelectedItem;
|
||||
d.RequestDeletion = i => RequestDeletion?.Invoke(i);
|
||||
d.RequestResults = i => RequestResults?.Invoke(i);
|
||||
d.RequestEdit = i => RequestEdit?.Invoke(i);
|
||||
d.AllowReordering = AllowReordering;
|
||||
d.AllowDeletion = AllowDeletion;
|
||||
d.AllowSelection = AllowSelection;
|
||||
d.AllowShowingResults = AllowShowingResults;
|
||||
d.AllowEditing = AllowEditing;
|
||||
d.ShowItemOwner = ShowItemOwners;
|
||||
d.RequestResults = i => RequestResults?.Invoke(i);
|
||||
});
|
||||
|
||||
protected virtual DrawableRoomPlaylistItem CreateDrawablePlaylistItem(PlaylistItem item) => new DrawableRoomPlaylistItem(item);
|
||||
|
@ -51,6 +51,11 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestResults;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this item requests to be edited.
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestEdit;
|
||||
|
||||
/// <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>.
|
||||
@ -74,6 +79,7 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private FillFlowContainer buttonsFlow;
|
||||
private UpdateableAvatar ownerAvatar;
|
||||
private Drawable showResultsButton;
|
||||
private Drawable editButton;
|
||||
private Drawable removeButton;
|
||||
private PanelBackground panelBackground;
|
||||
private FillFlowContainer mainFillFlow;
|
||||
@ -213,6 +219,23 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
}
|
||||
|
||||
private bool allowEditing;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this item can be edited.
|
||||
/// </summary>
|
||||
public bool AllowEditing
|
||||
{
|
||||
get => allowEditing;
|
||||
set
|
||||
{
|
||||
allowEditing = value;
|
||||
|
||||
if (editButton != null)
|
||||
editButton.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool showItemOwner;
|
||||
|
||||
/// <summary>
|
||||
@ -416,6 +439,13 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
TooltipText = "View results"
|
||||
},
|
||||
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
|
||||
editButton = new PlaylistEditButton
|
||||
{
|
||||
Size = new Vector2(30, 30),
|
||||
Alpha = AllowEditing ? 1 : 0,
|
||||
Action = () => RequestEdit?.Invoke(Item),
|
||||
TooltipText = "Edit"
|
||||
},
|
||||
removeButton = new PlaylistRemoveButton
|
||||
{
|
||||
Size = new Vector2(30, 30),
|
||||
@ -432,6 +462,14 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
return true;
|
||||
}
|
||||
|
||||
public class PlaylistEditButton : GrayButton
|
||||
{
|
||||
public PlaylistEditButton()
|
||||
: base(FontAwesome.Solid.Edit)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class PlaylistRemoveButton : GrayButton
|
||||
{
|
||||
public PlaylistRemoveButton()
|
||||
|
Loading…
Reference in New Issue
Block a user