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
|
|
|
|
|
2018-12-14 12:38:27 +08:00
|
|
|
|
using System;
|
2020-02-13 17:12:47 +08:00
|
|
|
|
using System.Linq;
|
2018-12-25 16:17:51 +08:00
|
|
|
|
using Humanizer;
|
2019-02-22 19:26:06 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
2019-01-31 17:16:28 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-01-23 19:52:00 +08:00
|
|
|
|
using osu.Framework.Screens;
|
2019-02-22 19:26:06 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-12-14 12:38:27 +08:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
2019-02-28 14:01:32 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-12-10 18:20:41 +08:00
|
|
|
|
using osu.Game.Screens.Multi;
|
2018-12-04 16:43:44 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2018-12-26 19:05:57 +08:00
|
|
|
|
public class MatchSongSelect : SongSelect, IMultiplayerSubScreen
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-14 12:38:27 +08:00
|
|
|
|
public Action<PlaylistItem> Selected;
|
|
|
|
|
|
2018-12-04 16:43:44 +08:00
|
|
|
|
public string ShortTitle => "song selection";
|
2018-12-25 16:17:51 +08:00
|
|
|
|
public override string Title => ShortTitle.Humanize();
|
2018-12-04 16:43:44 +08:00
|
|
|
|
|
2020-01-29 21:20:34 +08:00
|
|
|
|
public override bool AllowEditing => false;
|
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
|
|
|
|
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
|
|
|
|
|
2019-02-22 19:26:06 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
|
2019-01-31 17:16:28 +08:00
|
|
|
|
public MatchSongSelect()
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 14:44:35 +08:00
|
|
|
|
protected override bool OnStart()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-12-14 12:38:27 +08:00
|
|
|
|
var item = new PlaylistItem
|
|
|
|
|
{
|
2020-02-13 17:12:47 +08:00
|
|
|
|
Beatmap = { Value = Beatmap.Value.BeatmapInfo },
|
|
|
|
|
Ruleset = { Value = Ruleset.Value },
|
2018-12-14 16:35:05 +08:00
|
|
|
|
RulesetID = Ruleset.Value.ID ?? 0
|
2018-12-14 12:38:27 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-04-10 11:03:57 +08:00
|
|
|
|
item.RequiredMods.AddRange(Mods.Value);
|
2018-12-14 12:38:27 +08:00
|
|
|
|
|
|
|
|
|
Selected?.Invoke(item);
|
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
|
if (this.IsCurrentScreen())
|
|
|
|
|
this.Exit();
|
2018-12-14 12:38:27 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-02-01 14:42:15 +08:00
|
|
|
|
|
|
|
|
|
public override bool OnExiting(IScreen next)
|
|
|
|
|
{
|
2019-02-22 19:26:06 +08:00
|
|
|
|
if (base.OnExiting(next))
|
|
|
|
|
return true;
|
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
|
var firstItem = Playlist.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (firstItem != null)
|
2019-03-07 13:09:28 +08:00
|
|
|
|
{
|
2020-02-13 17:48:28 +08:00
|
|
|
|
Ruleset.Value = firstItem.Ruleset.Value;
|
|
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(firstItem.Beatmap.Value);
|
|
|
|
|
Mods.Value = firstItem.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
2019-03-07 13:09:28 +08:00
|
|
|
|
}
|
2019-02-27 15:16:13 +08:00
|
|
|
|
|
2019-02-22 19:26:06 +08:00
|
|
|
|
return false;
|
2019-02-01 14:42:15 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|