1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 23:03:21 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelect.cs

65 lines
1.7 KiB
C#
Raw Normal View History

// 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
using System.Linq;
2019-01-23 19:52:00 +08:00
using osu.Framework.Screens;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.Select;
namespace osu.Game.Screens.OnlinePlay.Playlists
2018-04-13 17:19:50 +08:00
{
public class PlaylistsSongSelect : OnlinePlaySongSelect
2018-04-13 17:19:50 +08:00
{
2021-08-24 12:29:19 +08:00
public PlaylistsSongSelect(Room room)
: base(room)
{
}
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea
{
CreateNewItem = createNewItem
};
2020-02-12 18:52:47 +08:00
2021-02-01 17:50:32 +08:00
protected override void SelectItem(PlaylistItem item)
2018-04-13 17:19:50 +08:00
{
switch (Playlist.Count)
{
case 0:
createNewItem();
break;
case 1:
populateItemFromCurrent(Playlist.Single());
break;
}
this.Exit();
2018-04-13 17:19:50 +08:00
}
2019-02-01 14:42:15 +08:00
private void createNewItem()
2019-02-01 14:42:15 +08:00
{
PlaylistItem item = new PlaylistItem
{
ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1
};
populateItemFromCurrent(item);
Playlist.Add(item);
2019-02-01 14:42:15 +08:00
}
private void populateItemFromCurrent(PlaylistItem item)
{
item.Beatmap.Value = Beatmap.Value.BeatmapInfo;
item.Ruleset.Value = Ruleset.Value;
item.RequiredMods.Clear();
item.RequiredMods.AddRange(Mods.Value.Select(m => m.DeepClone()));
item.AllowedMods.Clear();
item.AllowedMods.AddRange(FreeMods.Value.Select(m => m.DeepClone()));
}
2018-04-13 17:19:50 +08:00
}
}