1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Replace large "show results" button with embedded button each playlist item

This commit is contained in:
Dean Herbert 2020-07-10 19:37:27 +09:00
parent 63f42c5502
commit 9556166c1b
3 changed files with 103 additions and 40 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -48,7 +49,8 @@ namespace osu.Game.Screens.Multi
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly BindableList<Mod> requiredMods = new BindableList<Mod>();
private readonly PlaylistItem item;
public readonly PlaylistItem Item;
private readonly bool allowEdit;
private readonly bool allowSelection;
@ -57,8 +59,11 @@ namespace osu.Game.Screens.Multi
public DrawableRoomPlaylistItem(PlaylistItem item, bool allowEdit, bool allowSelection)
: base(item)
{
this.item = item;
Item = item;
// TODO: edit support should be moved out into a derived class
this.allowEdit = allowEdit;
this.allowSelection = allowSelection;
beatmap.BindTo(item.Beatmap);
@ -91,6 +96,8 @@ namespace osu.Game.Screens.Multi
private ScheduledDelegate scheduledRefresh;
public FillFlowContainer ButtonsContainer { get; private set; }
private void scheduleRefresh()
{
scheduledRefresh?.Cancel();
@ -102,14 +109,14 @@ namespace osu.Game.Screens.Multi
difficultyIconContainer.Child = new DifficultyIcon(beatmap.Value, ruleset.Value) { Size = new Vector2(32) };
beatmapText.Clear();
beatmapText.AddLink(item.Beatmap.ToString(), LinkAction.OpenBeatmap, item.Beatmap.Value.OnlineBeatmapID.ToString());
beatmapText.AddLink(Item.Beatmap.ToString(), LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString());
authorText.Clear();
if (item.Beatmap?.Value?.Metadata?.Author != null)
if (Item.Beatmap?.Value?.Metadata?.Author != null)
{
authorText.AddText("mapped by ");
authorText.AddUserLink(item.Beatmap.Value?.Metadata.Author);
authorText.AddUserLink(Item.Beatmap.Value?.Metadata.Author);
}
modDisplay.Current.Value = requiredMods.ToArray();
@ -180,15 +187,22 @@ namespace osu.Game.Screens.Multi
}
}
},
new Container
ButtonsContainer = new FillFlowContainer
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
X = -18,
Children = new Drawable[]
ChildrenEnumerable = CreateButtons()
}
}
};
protected virtual IEnumerable<Drawable> CreateButtons() =>
new Drawable[]
{
new PlaylistDownloadButton(item)
new PlaylistDownloadButton(Item)
{
Size = new Vector2(50, 30)
},
@ -198,9 +212,6 @@ namespace osu.Game.Screens.Multi
Alpha = allowEdit ? 1 : 0,
Action = () => RequestDeletion?.Invoke(Model),
},
}
}
}
};
protected override bool OnClick(ClickEvent e)

View File

@ -0,0 +1,66 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
namespace osu.Game.Screens.Multi
{
public class DrawableRoomPlaylistWithResults : DrawableRoomPlaylist
{
public Action<PlaylistItem> RequestShowResults;
public DrawableRoomPlaylistWithResults()
: base(false, true)
{
}
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) =>
new DrawableRoomPlaylistItemWithResults(item, false, true)
{
RequestShowResults = () => RequestShowResults(item),
SelectedItem = { BindTarget = SelectedItem },
};
private class DrawableRoomPlaylistItemWithResults : DrawableRoomPlaylistItem
{
public Action RequestShowResults;
public DrawableRoomPlaylistItemWithResults(PlaylistItem item, bool allowEdit, bool allowSelection)
: base(item, allowEdit, allowSelection)
{
}
protected override IEnumerable<Drawable> CreateButtons() =>
base.CreateButtons().Prepend(new FilledIconButton
{
Icon = FontAwesome.Solid.ChartPie,
Action = () => RequestShowResults?.Invoke(),
TooltipText = "View results"
});
private class FilledIconButton : IconButton
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Add(new Box
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
Colour = colours.Gray4,
});
}
}
}
}
}

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.GameTypes;
@ -137,30 +136,23 @@ namespace osu.Game.Screens.Multi.Match
new Drawable[] { new OverlinedHeader("Playlist"), },
new Drawable[]
{
new DrawableRoomPlaylist(false, true) // Temporarily always allow selection
new DrawableRoomPlaylistWithResults
{
RelativeSizeAxes = Axes.Both,
Items = { BindTarget = playlist },
SelectedItem = { BindTarget = SelectedItem }
SelectedItem = { BindTarget = SelectedItem },
RequestShowResults = item =>
{
Debug.Assert(roomId.Value != null);
multiplayer?.Push(new TimeshiftResultsScreen(null, roomId.Value.Value, item, false));
}
}
},
null,
new Drawable[]
{
new TriangleButton
{
RelativeSizeAxes = Axes.X,
Text = "Show beatmap results",
Action = showBeatmapResults
}
}
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.Absolute, 5),
new Dimension(GridSizeMode.AutoSize)
}
}
},
@ -296,11 +288,5 @@ namespace osu.Game.Screens.Multi.Match
break;
}
}
private void showBeatmapResults()
{
Debug.Assert(roomId.Value != null);
multiplayer?.Push(new TimeshiftResultsScreen(null, roomId.Value.Value, SelectedItem.Value, false));
}
}
}