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-12-11 08:32:01 +00:00
|
|
|
|
2018-12-27 12:12:32 +00:00
|
|
|
using System;
|
2018-12-17 02:51:12 +00:00
|
|
|
using System.Diagnostics;
|
2019-02-28 05:58:44 +00:00
|
|
|
using System.Linq;
|
2021-06-18 07:24:07 +00:00
|
|
|
using System.Threading.Tasks;
|
2018-12-14 12:09:17 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2019-01-23 11:52:00 +00:00
|
|
|
using osu.Framework.Screens;
|
2020-12-25 04:38:11 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2019-02-27 07:17:04 +00:00
|
|
|
using osu.Game.Rulesets;
|
2018-12-14 12:09:17 +00:00
|
|
|
using osu.Game.Scoring;
|
2018-12-11 08:32:01 +00:00
|
|
|
using osu.Game.Screens.Play;
|
2020-05-26 09:12:19 +00:00
|
|
|
using osu.Game.Screens.Ranking;
|
2021-08-22 01:54:07 +00:00
|
|
|
using osu.Game.Users;
|
2018-12-11 08:32:01 +00:00
|
|
|
|
2020-12-25 15:50:00 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
2018-12-11 08:32:01 +00:00
|
|
|
{
|
2021-03-23 06:00:02 +00:00
|
|
|
public class PlaylistsPlayer : RoomSubmittingPlayer
|
2018-12-11 08:32:01 +00:00
|
|
|
{
|
2019-01-23 11:52:00 +00:00
|
|
|
public Action Exited;
|
|
|
|
|
2021-08-22 01:54:07 +00:00
|
|
|
protected override UserActivity InitialActivity => new UserActivity.InPlaylistGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
|
|
|
|
|
2021-08-24 04:22:06 +00:00
|
|
|
public PlaylistsPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration configuration = null)
|
|
|
|
: base(room, playlistItem, configuration)
|
2018-12-14 12:09:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-03-23 06:00:02 +00:00
|
|
|
private void load(IBindable<RulesetInfo> ruleset)
|
2018-12-14 12:09:17 +00:00
|
|
|
{
|
2020-12-25 04:11:21 +00:00
|
|
|
// Sanity checks to ensure that PlaylistsPlayer matches the settings for the current PlaylistItem
|
2020-12-20 15:13:05 +00:00
|
|
|
if (Beatmap.Value.BeatmapInfo.OnlineBeatmapID != PlaylistItem.Beatmap.Value.OnlineBeatmapID)
|
2019-02-27 07:17:04 +00:00
|
|
|
throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap");
|
|
|
|
|
2020-12-20 15:13:05 +00:00
|
|
|
if (ruleset.Value.ID != PlaylistItem.Ruleset.Value.ID)
|
2019-02-27 07:17:04 +00:00
|
|
|
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
|
|
|
|
2020-12-20 15:13:05 +00:00
|
|
|
if (!PlaylistItem.RequiredMods.All(m => Mods.Value.Any(m.Equals)))
|
2019-02-27 07:17:04 +00:00
|
|
|
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
2021-03-23 06:00:02 +00:00
|
|
|
}
|
2019-02-27 07:17:04 +00:00
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
public override bool OnExiting(IScreen next)
|
|
|
|
{
|
|
|
|
if (base.OnExiting(next))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Exited?.Invoke();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-26 09:12:19 +00:00
|
|
|
protected override ResultsScreen CreateResults(ScoreInfo score)
|
|
|
|
{
|
2021-08-24 05:25:29 +00:00
|
|
|
Debug.Assert(Room.RoomID.Value != null);
|
|
|
|
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true);
|
2020-05-26 09:12:19 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 07:24:07 +00:00
|
|
|
protected override async Task PrepareScoreForResultsAsync(Score score)
|
2018-12-14 12:09:17 +00:00
|
|
|
{
|
2021-06-18 07:24:07 +00:00
|
|
|
await base.PrepareScoreForResultsAsync(score).ConfigureAwait(false);
|
2021-06-02 06:44:04 +00:00
|
|
|
|
|
|
|
Score.ScoreInfo.TotalScore = (int)Math.Round(ScoreProcessor.GetStandardisedScore());
|
2020-12-18 07:51:59 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 11:52:00 +00:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
Exited = null;
|
|
|
|
}
|
2018-12-14 12:09:17 +00:00
|
|
|
}
|
2018-12-11 08:32:01 +00:00
|
|
|
}
|