2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2020-02-14 19:56:01 +09:00
|
|
|
|
using System.Linq;
|
2019-02-22 11:26:06 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-01-23 20:52:00 +09:00
|
|
|
|
using osu.Framework.Screens;
|
2019-02-22 11:26:06 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-12-25 13:38:11 +09:00
|
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-25 16:50:00 +01:00
|
|
|
|
using osu.Game.Screens.OnlinePlay.Components;
|
2021-02-01 20:16:58 +09:00
|
|
|
|
using osu.Game.Screens.Select;
|
2018-12-04 17:43:44 +09:00
|
|
|
|
|
2021-02-01 20:16:58 +09:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2021-02-01 20:16:58 +09:00
|
|
|
|
public class PlaylistsSongSelect : OnlinePlaySongSelect
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2019-02-22 11:26:06 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
|
2020-02-14 17:51:42 +09:00
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea
|
|
|
|
|
{
|
|
|
|
|
CreateNewItem = createNewItem
|
|
|
|
|
};
|
2020-02-12 19:52:47 +09:00
|
|
|
|
|
2021-02-01 18:50:32 +09:00
|
|
|
|
protected override void SelectItem(PlaylistItem item)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-02-15 14:41:16 +09:00
|
|
|
|
switch (Playlist.Count)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
createNewItem();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
populateItemFromCurrent(Playlist.Single());
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-12-14 13:38:27 +09:00
|
|
|
|
|
2020-02-14 17:51:42 +09:00
|
|
|
|
this.Exit();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
2019-02-01 15:42:15 +09:00
|
|
|
|
|
2020-02-14 17:51:42 +09:00
|
|
|
|
private void createNewItem()
|
2019-02-01 15:42:15 +09:00
|
|
|
|
{
|
2020-02-14 17:51:42 +09:00
|
|
|
|
PlaylistItem item = new PlaylistItem
|
2019-03-07 14:09:28 +09:00
|
|
|
|
{
|
2020-02-17 17:02:19 +09:00
|
|
|
|
ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1
|
2020-02-14 17:51:42 +09:00
|
|
|
|
};
|
|
|
|
|
|
2020-02-15 14:41:16 +09:00
|
|
|
|
populateItemFromCurrent(item);
|
2019-02-27 16:16:13 +09:00
|
|
|
|
|
2020-02-14 17:51:42 +09:00
|
|
|
|
Playlist.Add(item);
|
2019-02-01 15:42:15 +09:00
|
|
|
|
}
|
2020-02-15 14:41:16 +09:00
|
|
|
|
|
|
|
|
|
private void populateItemFromCurrent(PlaylistItem item)
|
|
|
|
|
{
|
|
|
|
|
item.Beatmap.Value = Beatmap.Value.BeatmapInfo;
|
|
|
|
|
item.Ruleset.Value = Ruleset.Value;
|
|
|
|
|
|
|
|
|
|
item.RequiredMods.Clear();
|
2020-09-04 15:20:55 +09:00
|
|
|
|
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
2020-02-15 14:41:16 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|