2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-02-14 18:56:01 +08:00
|
|
|
|
using System.Linq;
|
2019-01-23 19:52:00 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2022-02-15 15:01:14 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2020-12-25 12:38:11 +08:00
|
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-25 23:50:00 +08:00
|
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
2021-02-01 19:16:58 +08:00
|
|
|
|
using osu.Game.Screens.Select;
|
2018-12-04 16:43:44 +08:00
|
|
|
|
|
2021-02-01 19:16:58 +08:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2021-02-01 19:16:58 +08:00
|
|
|
|
public class PlaylistsSongSelect : OnlinePlaySongSelect
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2021-08-24 12:29:19 +08:00
|
|
|
|
public PlaylistsSongSelect(Room room)
|
|
|
|
|
: base(room)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-14 16:51:42 +08:00
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea
|
|
|
|
|
{
|
|
|
|
|
CreateNewItem = createNewItem
|
|
|
|
|
};
|
2020-02-12 18:52:47 +08:00
|
|
|
|
|
2022-06-18 13:28:25 +08:00
|
|
|
|
protected override bool SelectItem(PlaylistItem item)
|
2017-12-28 20:07:19 +08:00
|
|
|
|
{
|
2020-02-15 13:41:16 +08:00
|
|
|
|
switch (Playlist.Count)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
createNewItem();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
2022-02-15 15:01:14 +08:00
|
|
|
|
Playlist.Clear();
|
|
|
|
|
createNewItem();
|
2020-02-15 13:41:16 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-12-14 12:38:27 +08:00
|
|
|
|
|
2020-02-14 16:51:42 +08:00
|
|
|
|
this.Exit();
|
2022-06-18 13:28:25 +08:00
|
|
|
|
return true;
|
2017-12-28 20:07:19 +08:00
|
|
|
|
}
|
2019-02-01 14:42:15 +08:00
|
|
|
|
|
2020-02-14 16:51:42 +08:00
|
|
|
|
private void createNewItem()
|
2019-02-01 14:42:15 +08:00
|
|
|
|
{
|
2022-02-15 22:33:26 +08:00
|
|
|
|
PlaylistItem item = new PlaylistItem(Beatmap.Value.BeatmapInfo)
|
2019-03-07 13:09:28 +08:00
|
|
|
|
{
|
2022-02-15 15:01:14 +08:00
|
|
|
|
ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1,
|
|
|
|
|
RulesetID = Ruleset.Value.OnlineID,
|
|
|
|
|
RequiredMods = Mods.Value.Select(m => new APIMod(m)).ToArray(),
|
|
|
|
|
AllowedMods = FreeMods.Value.Select(m => new APIMod(m)).ToArray()
|
2020-02-14 16:51:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Playlist.Add(item);
|
2019-02-01 14:42:15 +08:00
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|