mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Integrate spectate button implementation
This commit is contained in:
parent
e3cbde5099
commit
461d41529b
@ -71,16 +71,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(200, 50),
|
||||
OnSpectateClick = () =>
|
||||
{
|
||||
readyClickOperation = OngoingOperationTracker.BeginOperation();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await MultiplayerClient.ToggleSpectate();
|
||||
readyClickOperation.Dispose();
|
||||
});
|
||||
}
|
||||
},
|
||||
readyButton = new MultiplayerReadyButton
|
||||
{
|
||||
|
@ -17,13 +17,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
set => readyButton.OnReadyClick = value;
|
||||
}
|
||||
|
||||
public Action OnSpectateClick
|
||||
{
|
||||
set => spectateButton.OnSpectateClick = value;
|
||||
}
|
||||
|
||||
private readonly MultiplayerReadyButton readyButton;
|
||||
private readonly MultiplayerSpectateButton spectateButton;
|
||||
|
||||
public MultiplayerMatchFooter()
|
||||
{
|
||||
@ -37,7 +31,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
new Drawable[]
|
||||
{
|
||||
null,
|
||||
spectateButton = new MultiplayerSpectateButton
|
||||
new MultiplayerSpectateButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -15,11 +14,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
{
|
||||
public class MultiplayerSpectateButton : MultiplayerRoomComposite
|
||||
{
|
||||
public Action OnSpectateClick
|
||||
{
|
||||
set => button.Action = value;
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
||||
|
||||
@ -37,9 +31,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = Vector2.One,
|
||||
Enabled = { Value = true },
|
||||
Action = onClick
|
||||
};
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
var clickOperation = ongoingOperationTracker.BeginOperation();
|
||||
|
||||
Client.ToggleSpectate().ContinueWith(t => endOperation());
|
||||
|
||||
void endOperation() => clickOperation?.Dispose();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
@ -233,7 +233,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
protected override Drawable CreateFooter() => new MultiplayerMatchFooter
|
||||
{
|
||||
OnReadyClick = onReadyClick,
|
||||
OnSpectateClick = onSpectateClick
|
||||
};
|
||||
|
||||
protected override RoomSettingsOverlay CreateRoomSettingsOverlay(Room room) => new MultiplayerMatchSettingsOverlay(room);
|
||||
@ -364,20 +363,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
private void onSpectateClick()
|
||||
{
|
||||
Debug.Assert(readyClickOperation == null);
|
||||
readyClickOperation = ongoingOperationTracker.BeginOperation();
|
||||
|
||||
client.ToggleSpectate().ContinueWith(t => endOperation());
|
||||
|
||||
void endOperation()
|
||||
{
|
||||
readyClickOperation?.Dispose();
|
||||
readyClickOperation = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void onRoomUpdated()
|
||||
{
|
||||
// may happen if the client is kicked or otherwise removed from the room.
|
||||
|
Loading…
Reference in New Issue
Block a user