mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 09:05:59 +08:00
68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
// 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.Linq;
|
|
using Humanizer;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Screens;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Online.Multiplayer;
|
|
using osu.Game.Screens.Multi;
|
|
using osu.Game.Screens.Multi.Components;
|
|
|
|
namespace osu.Game.Screens.Select
|
|
{
|
|
public class MatchSongSelect : SongSelect, IMultiplayerSubScreen
|
|
{
|
|
public Action<PlaylistItem> Selected;
|
|
|
|
public string ShortTitle => "song selection";
|
|
public override string Title => ShortTitle.Humanize();
|
|
|
|
public override bool AllowEditing => false;
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
|
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
|
|
|
[Resolved]
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
public MatchSongSelect()
|
|
{
|
|
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
|
}
|
|
|
|
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new MatchBeatmapDetailArea
|
|
{
|
|
CreateNewItem = createNewItem
|
|
};
|
|
|
|
protected override bool OnStart()
|
|
{
|
|
if (Playlist.Count == 0)
|
|
createNewItem();
|
|
|
|
this.Exit();
|
|
|
|
return true;
|
|
}
|
|
|
|
private void createNewItem()
|
|
{
|
|
PlaylistItem item = new PlaylistItem
|
|
{
|
|
ID = (Playlist.LastOrDefault()?.ID + 1) ?? 0,
|
|
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
|
|
Ruleset = { Value = Ruleset.Value }
|
|
};
|
|
|
|
item.RequiredMods.AddRange(Mods.Value);
|
|
|
|
Playlist.Add(item);
|
|
}
|
|
}
|
|
}
|