mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Cleanup duplicated classes in DrawableRoomPlaylistItem
This commit is contained in:
parent
968da1bb3c
commit
f9af239ed9
@ -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));
|
||||
|
||||
@ -263,7 +273,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
private void assertDeleteButtonVisibility(int index, bool visible)
|
||||
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(2 + index * 2).RemoveButton.Alpha > 0) == visible);
|
||||
|
||||
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
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);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(0).RemoveButton, offset);
|
||||
});
|
||||
|
||||
private void createPlaylist()
|
||||
|
@ -154,7 +154,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep($"move mouse to delete button {index}", () =>
|
||||
{
|
||||
item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0));
|
||||
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(0).RemoveButton);
|
||||
});
|
||||
|
||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||
@ -164,6 +164,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
private void assertDeleteButtonVisibility(int index, bool visible)
|
||||
=> AddUntilStep($"delete button {index} {(visible ? "is" : "is not")} visible",
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(index).Alpha > 0) == visible);
|
||||
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(index).RemoveButton.Alpha > 0) == visible);
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
public readonly PlaylistItem Item;
|
||||
|
||||
public Drawable RemoveButton { get; private set; }
|
||||
|
||||
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>();
|
||||
@ -73,7 +75,6 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
private ModDisplay modDisplay;
|
||||
private FillFlowContainer buttonsFlow;
|
||||
private UpdateableAvatar ownerAvatar;
|
||||
private Drawable removeButton;
|
||||
private Drawable showResultsButton;
|
||||
private PanelBackground panelBackground;
|
||||
private FillFlowContainer mainFillFlow;
|
||||
@ -191,8 +192,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
allowDeletion = value;
|
||||
|
||||
if (removeButton != null)
|
||||
removeButton.Alpha = value ? 1 : 0;
|
||||
if (RemoveButton != null)
|
||||
RemoveButton.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,35 +409,23 @@ 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
|
||||
RemoveButton = new GrayButton(FontAwesome.Solid.MinusSquare)
|
||||
{
|
||||
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)
|
||||
@ -497,23 +486,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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user