2019-01-24 17:43:03 +09: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 17:32:01 +09:00
|
|
|
|
2018-12-27 21:12:32 +09:00
|
|
|
using System;
|
2018-12-17 11:51:12 +09:00
|
|
|
using System.Diagnostics;
|
2019-02-28 14:58:44 +09:00
|
|
|
using System.Linq;
|
2018-12-14 21:09:17 +09:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
using osu.Framework.Bindables;
|
2019-01-23 20:52:00 +09:00
|
|
|
using osu.Framework.Screens;
|
2021-11-15 14:38:14 +09:00
|
|
|
using osu.Game.Extensions;
|
2020-12-25 13:38:11 +09:00
|
|
|
using osu.Game.Online.Rooms;
|
2019-02-27 16:17:04 +09:00
|
|
|
using osu.Game.Rulesets;
|
2018-12-14 21:09:17 +09:00
|
|
|
using osu.Game.Scoring;
|
2018-12-11 17:32:01 +09:00
|
|
|
using osu.Game.Screens.Play;
|
2020-05-26 18:12:19 +09:00
|
|
|
using osu.Game.Screens.Ranking;
|
2021-08-22 09:54:07 +08:00
|
|
|
using osu.Game.Users;
|
2018-12-11 17:32:01 +09:00
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Playlists
|
2018-12-11 17:32:01 +09:00
|
|
|
{
|
2021-03-23 15:00:02 +09:00
|
|
|
public partial class PlaylistsPlayer : RoomSubmittingPlayer
|
2018-12-11 17:32:01 +09:00
|
|
|
{
|
2024-11-13 16:28:39 +09:00
|
|
|
public Action? Exited;
|
2019-01-23 20:52:00 +09:00
|
|
|
|
2021-08-22 09:54:07 +08:00
|
|
|
protected override UserActivity InitialActivity => new UserActivity.InPlaylistGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
|
|
|
|
|
2024-11-13 16:28:39 +09:00
|
|
|
public PlaylistsPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration? configuration = null)
|
2021-08-24 13:22:06 +09:00
|
|
|
: base(room, playlistItem, configuration)
|
2018-12-14 21:09:17 +09:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-03-23 15:00:02 +09:00
|
|
|
private void load(IBindable<RulesetInfo> ruleset)
|
2018-12-14 21:09:17 +09:00
|
|
|
{
|
2020-12-25 13:11:21 +09:00
|
|
|
// Sanity checks to ensure that PlaylistsPlayer matches the settings for the current PlaylistItem
|
2022-02-15 23:33:26 +09:00
|
|
|
if (!Beatmap.Value.BeatmapInfo.MatchesOnlineID(PlaylistItem.Beatmap))
|
2019-02-27 16:17:04 +09:00
|
|
|
throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap");
|
|
|
|
|
2022-02-15 16:01:14 +09:00
|
|
|
if (ruleset.Value.OnlineID != PlaylistItem.RulesetID)
|
2019-02-27 16:17:04 +09:00
|
|
|
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
|
|
|
|
2022-02-24 17:01:43 +09:00
|
|
|
var requiredLocalMods = PlaylistItem.RequiredMods.Select(m => m.ToMod(GameplayState.Ruleset));
|
|
|
|
if (!requiredLocalMods.All(m => Mods.Value.Any(m.Equals)))
|
2019-02-27 16:17:04 +09:00
|
|
|
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
2021-03-23 15:00:02 +09:00
|
|
|
}
|
2019-02-27 16:17:04 +09:00
|
|
|
|
2022-04-22 00:52:44 +09:00
|
|
|
public override bool OnExiting(ScreenExitEvent e)
|
2019-01-23 20:52:00 +09:00
|
|
|
{
|
2022-04-22 00:52:44 +09:00
|
|
|
if (base.OnExiting(e))
|
2019-01-23 20:52:00 +09:00
|
|
|
return true;
|
|
|
|
|
|
|
|
Exited?.Invoke();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:12:19 +09:00
|
|
|
protected override ResultsScreen CreateResults(ScoreInfo score)
|
|
|
|
{
|
2024-11-13 16:28:39 +09:00
|
|
|
Debug.Assert(Room.RoomID != null);
|
|
|
|
return new PlaylistItemUserResultsScreen(score, Room.RoomID.Value, PlaylistItem)
|
2024-02-22 19:15:02 +01:00
|
|
|
{
|
|
|
|
AllowRetry = true,
|
2024-02-22 19:49:14 +01:00
|
|
|
ShowUserStatistics = true,
|
2024-02-22 19:15:02 +01:00
|
|
|
};
|
2020-05-26 18:12:19 +09:00
|
|
|
}
|
|
|
|
|
2019-01-23 20:52:00 +09:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
Exited = null;
|
|
|
|
}
|
2018-12-14 21:09:17 +09:00
|
|
|
}
|
2018-12-11 17:32:01 +09:00
|
|
|
}
|