1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Rename LoadAborted -> GameplayAborted, AbortGameplayReal -> AbortMatch

This commit is contained in:
Dan Balasescu 2023-12-01 18:26:59 +09:00
parent 894c31753b
commit a94180c8c6
No known key found for this signature in database
8 changed files with 45 additions and 23 deletions

View File

@ -0,0 +1,11 @@
// 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.
namespace osu.Game.Online.Multiplayer
{
public enum GameplayAbortReason
{
LoadTookTooLong,
HostAbortedTheMatch
}
}

View File

@ -107,17 +107,18 @@ namespace osu.Game.Online.Multiplayer
/// </summary>
Task LoadRequested();
/// <summary>
/// Signals that loading of gameplay is to be aborted.
/// </summary>
Task LoadAborted();
/// <summary>
/// Signals that gameplay has started.
/// All users in the <see cref="MultiplayerUserState.Loaded"/> or <see cref="MultiplayerUserState.ReadyForGameplay"/> states should begin gameplay as soon as possible.
/// </summary>
Task GameplayStarted();
/// <summary>
/// Signals that gameplay has been aborted.
/// </summary>
/// <param name="reason">The reason why gameplay was aborted.</param>
Task GameplayAborted(GameplayAbortReason reason);
/// <summary>
/// Signals that the match has ended, all players have finished and results are ready to be displayed.
/// </summary>

View File

@ -77,16 +77,16 @@ namespace osu.Game.Online.Multiplayer
/// <exception cref="InvalidStateException">If an attempt to start the game occurs when the game's (or users') state disallows it.</exception>
Task StartMatch();
/// <summary>
/// As the host of a room, aborts an on-going match.
/// </summary>
Task AbortMatch();
/// <summary>
/// Aborts an ongoing gameplay load.
/// </summary>
Task AbortGameplay();
/// <summary>
/// Real.
/// </summary>
Task AbortGameplayReal();
/// <summary>
/// Adds an item to the playlist.
/// </summary>

View File

@ -73,9 +73,9 @@ namespace osu.Game.Online.Multiplayer
public virtual event Action? LoadRequested;
/// <summary>
/// Invoked when the multiplayer server requests loading of play to be aborted.
/// Invoked when the multiplayer server requests gameplay to be aborted.
/// </summary>
public event Action? LoadAborted;
public event Action<GameplayAbortReason>? GameplayAborted;
/// <summary>
/// Invoked when the multiplayer server requests gameplay to be started.
@ -374,7 +374,7 @@ namespace osu.Game.Online.Multiplayer
public abstract Task AbortGameplay();
public abstract Task AbortGameplayReal();
public abstract Task AbortMatch();
public abstract Task AddPlaylistItem(MultiplayerPlaylistItem item);
@ -684,14 +684,14 @@ namespace osu.Game.Online.Multiplayer
return Task.CompletedTask;
}
Task IMultiplayerClient.LoadAborted()
Task IMultiplayerClient.GameplayAborted(GameplayAbortReason reason)
{
Scheduler.Add(() =>
{
if (Room == null)
return;
LoadAborted?.Invoke();
GameplayAborted?.Invoke(reason);
}, false);
return Task.CompletedTask;

View File

@ -58,7 +58,7 @@ namespace osu.Game.Online.Multiplayer
connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);
connection.On(nameof(IMultiplayerClient.LoadRequested), ((IMultiplayerClient)this).LoadRequested);
connection.On(nameof(IMultiplayerClient.GameplayStarted), ((IMultiplayerClient)this).GameplayStarted);
connection.On(nameof(IMultiplayerClient.LoadAborted), ((IMultiplayerClient)this).LoadAborted);
connection.On<GameplayAbortReason>(nameof(IMultiplayerClient.GameplayAborted), ((IMultiplayerClient)this).GameplayAborted);
connection.On(nameof(IMultiplayerClient.ResultsReady), ((IMultiplayerClient)this).ResultsReady);
connection.On<int, IEnumerable<APIMod>>(nameof(IMultiplayerClient.UserModsChanged), ((IMultiplayerClient)this).UserModsChanged);
connection.On<int, BeatmapAvailability>(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged);
@ -226,14 +226,14 @@ namespace osu.Game.Online.Multiplayer
return connection.InvokeAsync(nameof(IMultiplayerServer.AbortGameplay));
}
public override Task AbortGameplayReal()
public override Task AbortMatch()
{
if (!IsConnected.Value)
return Task.CompletedTask;
Debug.Assert(connection != null);
return connection.InvokeAsync(nameof(IMultiplayerServer.AbortGameplayReal));
return connection.InvokeAsync(nameof(IMultiplayerServer.AbortMatch));
}
public override Task AddPlaylistItem(MultiplayerPlaylistItem item)

View File

@ -148,7 +148,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
endOperation();
});
void abortMatch() => Client.AbortGameplayReal().FireAndForget(endOperation, _ => endOperation());
void abortMatch() => Client.AbortMatch().FireAndForget(endOperation, _ => endOperation());
}
private void startCountdown(TimeSpan duration)

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.LoadComplete();
client.RoomUpdated += onRoomUpdated;
client.LoadAborted += onLoadAborted;
client.GameplayAborted += onGameplayAborted;
onRoomUpdated();
}
@ -39,12 +39,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
transitionFromResults();
}
private void onLoadAborted()
private void onGameplayAborted(GameplayAbortReason reason)
{
// If the server aborts gameplay for this user (due to loading too slow), exit gameplay screens.
if (!this.IsCurrentScreen())
{
Logger.Log("Gameplay aborted because loading the beatmap took too long.", LoggingTarget.Runtime, LogLevel.Important);
switch (reason)
{
case GameplayAbortReason.LoadTookTooLong:
Logger.Log("Gameplay aborted because loading the beatmap took too long.", LoggingTarget.Runtime, LogLevel.Important);
break;
case GameplayAbortReason.HostAbortedTheMatch:
Logger.Log("The host aborted the match.", LoggingTarget.Runtime, LogLevel.Important);
break;
}
this.MakeCurrent();
}
}

View File

@ -396,7 +396,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
return Task.CompletedTask;
}
public override Task AbortGameplayReal()
public override Task AbortMatch()
{
// Todo:
return Task.CompletedTask;