mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 08:23:22 +08:00
Improve ready/countdown button UX
This commit is contained in:
parent
3ad092d808
commit
9963efce51
@ -62,6 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
Size = new Vector2(40, 1),
|
Size = new Vector2(40, 1),
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Action = startCountdown,
|
Action = startCountdown,
|
||||||
|
CancelAction = cancelCountdown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,30 +107,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
Debug.Assert(clickOperation == null);
|
Debug.Assert(clickOperation == null);
|
||||||
clickOperation = ongoingOperationTracker.BeginOperation();
|
clickOperation = ongoingOperationTracker.BeginOperation();
|
||||||
|
|
||||||
// Ensure the current user becomes ready before being able to do anything else (start match, stop countdown, unready).
|
if (isReady() && Client.IsHost && Room.Countdown == null)
|
||||||
if (!isReady() || !Client.IsHost || Room.Settings.AutoStartEnabled)
|
|
||||||
{
|
|
||||||
toggleReady();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Local user is the room host and is in a ready state.
|
|
||||||
// The only action they can take is to stop a countdown if one's currently running.
|
|
||||||
if (Room.Countdown != null)
|
|
||||||
{
|
|
||||||
stopCountdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// And if a countdown isn't running, start the match.
|
|
||||||
startMatch();
|
startMatch();
|
||||||
|
else
|
||||||
|
toggleReady();
|
||||||
|
|
||||||
bool isReady() => Client.LocalUser?.State == MultiplayerUserState.Ready || Client.LocalUser?.State == MultiplayerUserState.Spectating;
|
bool isReady() => Client.LocalUser?.State == MultiplayerUserState.Ready || Client.LocalUser?.State == MultiplayerUserState.Spectating;
|
||||||
|
|
||||||
void toggleReady() => Client.ToggleReady().ContinueWith(_ => endOperation());
|
void toggleReady() => Client.ToggleReady().ContinueWith(_ => endOperation());
|
||||||
|
|
||||||
void stopCountdown() => Client.SendMatchRequest(new StopCountdownRequest()).ContinueWith(_ => endOperation());
|
|
||||||
|
|
||||||
void startMatch() => Client.StartMatch().ContinueWith(t =>
|
void startMatch() => Client.StartMatch().ContinueWith(t =>
|
||||||
{
|
{
|
||||||
// accessing Exception here silences any potential errors from the antecedent task
|
// accessing Exception here silences any potential errors from the antecedent task
|
||||||
@ -151,6 +137,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
Client.SendMatchRequest(new StartMatchCountdownRequest { Duration = duration }).ContinueWith(_ => endOperation());
|
Client.SendMatchRequest(new StartMatchCountdownRequest { Duration = duration }).ContinueWith(_ => endOperation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelCountdown()
|
||||||
|
{
|
||||||
|
Debug.Assert(clickOperation == null);
|
||||||
|
clickOperation = ongoingOperationTracker.BeginOperation();
|
||||||
|
|
||||||
|
Client.SendMatchRequest(new StopCountdownRequest()).ContinueWith(_ => endOperation());
|
||||||
|
}
|
||||||
|
|
||||||
private void endOperation()
|
private void endOperation()
|
||||||
{
|
{
|
||||||
clickOperation?.Dispose();
|
clickOperation?.Dispose();
|
||||||
@ -197,7 +191,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
|
|
||||||
// When the local user is the host and spectating the match, the ready button should be enabled only if any users are ready.
|
// When the local user is the host and spectating the match, the ready button should be enabled only if any users are ready.
|
||||||
if (localUser?.State == MultiplayerUserState.Spectating)
|
if (localUser?.State == MultiplayerUserState.Spectating)
|
||||||
readyButton.Enabled.Value &= Client.IsHost && newCountReady > 0;
|
readyButton.Enabled.Value &= Client.IsHost && newCountReady > 0 && Room.Countdown == null;
|
||||||
|
|
||||||
if (newCountReady == countReady)
|
if (newCountReady == countReady)
|
||||||
return;
|
return;
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics.UserInterface;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osu.Game.Online.Multiplayer;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||||
@ -29,6 +30,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
};
|
};
|
||||||
|
|
||||||
public new Action<TimeSpan> Action;
|
public new Action<TimeSpan> Action;
|
||||||
|
public Action CancelAction;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private MultiplayerClient multiplayerClient { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly Drawable background;
|
private readonly Drawable background;
|
||||||
|
|
||||||
@ -77,6 +85,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (multiplayerClient.Room?.Countdown != null && multiplayerClient.IsHost)
|
||||||
|
{
|
||||||
|
flow.Add(new OsuButton
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Cancel",
|
||||||
|
BackgroundColour = colours.Red,
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
CancelAction();
|
||||||
|
this.HidePopover();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return new OsuPopover { Child = flow };
|
return new OsuPopover { Child = flow };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user