2020-12-24 05:02:37 +08:00
|
|
|
// 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;
|
2020-12-25 12:38:11 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-12-25 23:50:00 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2020-12-24 05:02:37 +08:00
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
2020-12-24 05:02:37 +08:00
|
|
|
{
|
2020-12-25 12:38:11 +08:00
|
|
|
public class CreateMultiplayerMatchButton : PurpleTriangleButton
|
2020-12-24 05:02:37 +08:00
|
|
|
{
|
2020-12-29 04:39:11 +08:00
|
|
|
private IBindable<bool> isConnected;
|
2020-12-29 15:20:43 +08:00
|
|
|
private IBindable<bool> operationInProgress;
|
2020-12-29 04:39:11 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private StatefulMultiplayerClient multiplayerClient { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
2020-12-29 15:20:43 +08:00
|
|
|
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
2020-12-29 04:39:11 +08:00
|
|
|
|
2020-12-24 05:02:37 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-12-29 04:39:11 +08:00
|
|
|
private void load()
|
2020-12-24 05:02:37 +08:00
|
|
|
{
|
|
|
|
Triangles.TriangleScale = 1.5f;
|
|
|
|
|
2020-12-24 23:10:29 +08:00
|
|
|
Text = "Create room";
|
2020-12-24 05:02:37 +08:00
|
|
|
|
2020-12-29 04:39:11 +08:00
|
|
|
isConnected = multiplayerClient.IsConnected.GetBoundCopy();
|
2020-12-29 15:20:43 +08:00
|
|
|
operationInProgress = ongoingOperationTracker.InProgress.GetBoundCopy();
|
2020-12-30 23:22:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-01-12 18:04:16 +08:00
|
|
|
isConnected.BindValueChanged(_ => Scheduler.AddOnce(updateState));
|
|
|
|
operationInProgress.BindValueChanged(_ => Scheduler.AddOnce(updateState), true);
|
2020-12-24 05:02:37 +08:00
|
|
|
}
|
2020-12-29 04:39:11 +08:00
|
|
|
|
2020-12-29 15:20:43 +08:00
|
|
|
private void updateState() => Enabled.Value = isConnected.Value && !operationInProgress.Value;
|
2020-12-24 05:02:37 +08:00
|
|
|
}
|
|
|
|
}
|