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