1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 07:23:14 +08:00

Further split out a player class which submits to "rooms"

This commit is contained in:
Dean Herbert 2021-03-23 15:33:31 +09:00
parent 7045fce555
commit 12f050264a
4 changed files with 37 additions and 23 deletions

View File

@ -11,7 +11,6 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Ranking;
@ -19,7 +18,7 @@ using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
public class MultiplayerPlayer : PlaylistsPlayer
public class MultiplayerPlayer : RoomSubmittingPlayer
{
protected override bool PauseOnFocusLost => false;

View File

@ -7,7 +7,6 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets;
using osu.Game.Scoring;
@ -20,12 +19,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{
public Action Exited;
protected readonly PlaylistItem PlaylistItem;
public PlaylistsPlayer(PlaylistItem playlistItem, PlayerConfiguration configuration = null)
: base(configuration)
: base(playlistItem, configuration)
{
PlaylistItem = playlistItem;
}
[BackgroundDependencyLoader]
@ -42,10 +38,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
}
protected override APIRequest<APIScoreToken> CreateTokenRequestRequest() => new CreateRoomScoreRequest(RoomId.Value ?? 0, PlaylistItem.ID, Game.VersionHash);
public override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, int token) => new SubmitRoomScoreRequest(token, RoomId.Value ?? 0, PlaylistItem.ID, score.ScoreInfo);
public override bool OnExiting(IScreen next)
{
if (base.OnExiting(next))

View File

@ -0,0 +1,32 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
{
/// <summary>
/// A player instance which submits to a room backing. This is generally used by playlists and multiplayer.
/// </summary>
public abstract class RoomSubmittingPlayer : SubmittingPlayer
{
[Resolved(typeof(Room), nameof(Room.RoomID))]
protected Bindable<long?> RoomId { get; private set; }
protected readonly PlaylistItem PlaylistItem;
protected RoomSubmittingPlayer(PlaylistItem playlistItem, PlayerConfiguration configuration = null)
: base(configuration)
{
PlaylistItem = playlistItem;
}
protected override APIRequest<APIScoreToken> CreateTokenRequestRequest() => new CreateRoomScoreRequest(RoomId.Value ?? 0, PlaylistItem.ID, Game.VersionHash);
public override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, int token) => new SubmitRoomScoreRequest(token, RoomId.Value ?? 0, PlaylistItem.ID, score.ScoreInfo);
}
}

View File

@ -5,7 +5,6 @@ using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Online.API;
@ -14,17 +13,9 @@ using osu.Game.Scoring;
namespace osu.Game.Screens.Play
{
public abstract class RoomSubmittingPlayer : SubmittingPlayer
{
[Resolved(typeof(Room), nameof(Room.RoomID))]
protected Bindable<long?> RoomId { get; private set; }
protected RoomSubmittingPlayer(PlayerConfiguration configuration)
: base(configuration)
{
}
}
/// <summary>
/// A player instance which supports submitting scores to an online store.
/// </summary>
public abstract class SubmittingPlayer : Player
{
protected long? Token { get; private set; }