mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 12:47:44 +08:00
Disable ready button after host click
This commit is contained in:
parent
9e6994166c
commit
47ab7c9fd6
@ -7,11 +7,14 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.OnlinePlay;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
@ -27,6 +30,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private BeatmapManager beatmaps;
|
||||
private RulesetStore rulesets;
|
||||
|
||||
[Cached]
|
||||
private OngoingOperationTracker gameplayStartTracker = new OngoingOperationTracker();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
@ -89,8 +95,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
addClickButtonStep();
|
||||
AddAssert("user is ready", () => Client.Room?.Users[0].State == MultiplayerUserState.Ready);
|
||||
|
||||
addClickButtonStep();
|
||||
AddAssert("match started", () => Client.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
||||
verifyGameplayStartFlow();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -105,8 +110,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
addClickButtonStep();
|
||||
AddStep("make user host", () => Client.TransferHost(Client.Room?.Users[0].UserID ?? 0));
|
||||
|
||||
addClickButtonStep();
|
||||
AddAssert("match started", () => Client.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
||||
verifyGameplayStartFlow();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -160,5 +164,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
InputManager.MoveMouseTo(button);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
private void verifyGameplayStartFlow()
|
||||
{
|
||||
addClickButtonStep();
|
||||
AddAssert("user waiting for load", () => Client.Room?.Users[0].State == MultiplayerUserState.WaitingForLoad);
|
||||
AddAssert("ready button disabled", () => !button.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
||||
|
||||
AddStep("transitioned to gameplay", () => gameplayStartTracker.EndOperation());
|
||||
AddAssert("ready button enabled", () => button.ChildrenOfType<OsuButton>().Single().Enabled.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OngoingOperationTracker gameplayStartTracker { get; set; }
|
||||
|
||||
private SampleChannel sampleReadyCount;
|
||||
|
||||
private readonly ButtonWithTrianglesExposed button;
|
||||
|
||||
private int countReady;
|
||||
private IBindable<bool> gameplayStartInProgress;
|
||||
|
||||
public MultiplayerReadyButton()
|
||||
{
|
||||
@ -54,6 +58,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleReadyCount = audio.Samples.Get(@"SongSelect/select-difficulty");
|
||||
|
||||
gameplayStartInProgress = gameplayStartTracker.InProgress.GetBoundCopy();
|
||||
gameplayStartInProgress.BindValueChanged(_ => updateState());
|
||||
}
|
||||
|
||||
protected override void OnRoomUpdated()
|
||||
@ -63,7 +70,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
// this method is called on leaving the room, so the local user may not exist in the room any more.
|
||||
localUser = Room?.Users.SingleOrDefault(u => u.User?.Id == api.LocalUser.Value.Id);
|
||||
|
||||
button.Enabled.Value = Client.Room?.State == MultiplayerRoomState.Open;
|
||||
updateState();
|
||||
}
|
||||
|
||||
@ -100,6 +106,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
break;
|
||||
}
|
||||
|
||||
button.Enabled.Value = Client.Room?.State == MultiplayerRoomState.Open && !gameplayStartInProgress.Value;
|
||||
|
||||
if (newCountReady != countReady)
|
||||
{
|
||||
countReady = newCountReady;
|
||||
@ -142,7 +150,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
else
|
||||
{
|
||||
if (Room?.Host?.Equals(localUser) == true)
|
||||
{
|
||||
gameplayStartTracker.BeginOperation();
|
||||
Client.StartMatch().CatchUnobservedExceptions(true);
|
||||
}
|
||||
else
|
||||
Client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
[Resolved]
|
||||
private StatefulMultiplayerClient client { get; set; }
|
||||
|
||||
[Cached]
|
||||
private OngoingOperationTracker gameplayStartTracker = new OngoingOperationTracker();
|
||||
|
||||
private MultiplayerMatchSettingsOverlay settingsOverlay;
|
||||
|
||||
private IBindable<bool> isConnected;
|
||||
@ -203,6 +206,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
int[] userIds = client.Room.Users.Where(u => u.State >= MultiplayerUserState.WaitingForLoad).Select(u => u.UserID).ToArray();
|
||||
|
||||
StartPlay(() => new MultiplayerPlayer(SelectedItem.Value, userIds));
|
||||
gameplayStartTracker.EndOperation();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
Loading…
x
Reference in New Issue
Block a user