1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 07:57:20 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelect.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.4 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 18:19:50 +09:00
using System.Linq;
2019-01-23 20:52:00 +09:00
using osu.Framework.Screens;
using osu.Game.Online.API;
2020-12-25 13:38:11 +09:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.Select;
namespace osu.Game.Screens.OnlinePlay.Playlists
2016-09-29 20:13:58 +09:00
{
public partial class PlaylistsSongSelect : OnlinePlaySongSelect
2016-09-29 20:13:58 +09:00
{
2024-11-14 17:57:32 +09:00
private readonly Room room;
2021-08-24 13:29:19 +09:00
public PlaylistsSongSelect(Room room)
: base(room)
{
2024-11-14 17:57:32 +09:00
this.room = room;
2021-08-24 13:29:19 +09:00
}
2024-11-14 17:57:32 +09:00
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea(room)
{
2024-11-14 17:57:32 +09:00
CreateNewItem = () => room.Playlist = room.Playlist.Append(createNewItem()).ToArray()
};
2020-02-12 19:52:47 +09:00
protected override bool SelectItem(PlaylistItem item)
{
2024-11-14 17:57:32 +09:00
if (room.Playlist.Count <= 1)
room.Playlist = [createNewItem()];
this.Exit();
return true;
}
2019-02-01 15:42:15 +09:00
2024-11-14 17:57:32 +09:00
private PlaylistItem createNewItem() => new PlaylistItem(Beatmap.Value.BeatmapInfo)
2019-02-01 15:42:15 +09:00
{
2024-11-14 17:57:32 +09:00
ID = room.Playlist.Count == 0 ? 0 : room.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()
};
2016-09-29 20:13:58 +09:00
}
}