1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Merge pull request #16019 from smoogipoo/cleanup-playlist-item-buttons

Cleanup duplicated classes in DrawableRoomPlaylistItem
This commit is contained in:
Dean Herbert 2021-12-10 12:01:26 +09:00 committed by GitHub
commit 1952819db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 34 deletions

View File

@ -248,6 +248,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("owner visible", () => playlist.ChildrenOfType<UpdateableAvatar>().All(a => a.IsPresent == withOwner));
}
[Test]
public void TestWithAllButtonsEnabled()
{
createPlaylist(p =>
{
p.AllowDeletion = true;
p.AllowShowingResults = true;
});
}
private void moveToItem(int index, Vector2? offset = null)
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DifficultyIcon>().ElementAt(index), offset));

View File

@ -73,8 +73,8 @@ namespace osu.Game.Screens.OnlinePlay
private ModDisplay modDisplay;
private FillFlowContainer buttonsFlow;
private UpdateableAvatar ownerAvatar;
private Drawable removeButton;
private Drawable showResultsButton;
private Drawable removeButton;
private PanelBackground panelBackground;
private FillFlowContainer mainFillFlow;
@ -408,10 +408,12 @@ namespace osu.Game.Screens.OnlinePlay
private IEnumerable<Drawable> createButtons() => new[]
{
showResultsButton = new ShowResultsButton
showResultsButton = new GrayButton(FontAwesome.Solid.ChartPie)
{
Size = new Vector2(30, 30),
Action = () => RequestResults?.Invoke(Item),
Alpha = AllowShowingResults ? 1 : 0,
TooltipText = "View results"
},
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
removeButton = new PlaylistRemoveButton
@ -419,24 +421,10 @@ namespace osu.Game.Screens.OnlinePlay
Size = new Vector2(30, 30),
Alpha = AllowDeletion ? 1 : 0,
Action = () => RequestDeletion?.Invoke(Item),
TooltipText = "Remove from playlist"
},
};
public class PlaylistRemoveButton : GrayButton
{
public PlaylistRemoveButton()
: base(FontAwesome.Solid.MinusSquare)
{
TooltipText = "Remove from playlist";
}
[BackgroundDependencyLoader]
private void load()
{
Icon.Scale = new Vector2(0.8f);
}
}
protected override bool OnClick(ClickEvent e)
{
if (AllowSelection && valid.Value)
@ -444,6 +432,14 @@ namespace osu.Game.Screens.OnlinePlay
return true;
}
public class PlaylistRemoveButton : GrayButton
{
public PlaylistRemoveButton()
: base(FontAwesome.Solid.MinusSquare)
{
}
}
private sealed class PlaylistDownloadButton : BeatmapDownloadButton
{
private readonly PlaylistItem playlistItem;
@ -497,23 +493,6 @@ 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)
{