2020-12-23 22:02:37 +01: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.
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2020-12-23 22:02:37 +01:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2020-12-25 13:38:11 +09:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2020-12-25 16:50:00 +01:00
|
|
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
2020-12-23 22:02:37 +01:00
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
2020-12-23 22:02:37 +01:00
|
|
|
{
|
2021-08-03 18:05:43 +09:00
|
|
|
public partial class CreateMultiplayerMatchButton : CreateRoomButton
|
2020-12-23 22:02:37 +01:00
|
|
|
{
|
2020-12-28 21:39:11 +01:00
|
|
|
private IBindable<bool> isConnected;
|
2020-12-29 08:20:43 +01:00
|
|
|
private IBindable<bool> operationInProgress;
|
2020-12-28 21:39:11 +01:00
|
|
|
|
|
|
|
[Resolved]
|
2021-05-20 15:39:45 +09:00
|
|
|
private MultiplayerClient multiplayerClient { get; set; }
|
2020-12-28 21:39:11 +01:00
|
|
|
|
|
|
|
[Resolved]
|
2020-12-29 08:20:43 +01:00
|
|
|
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
2020-12-28 21:39:11 +01:00
|
|
|
|
2020-12-23 22:02:37 +01:00
|
|
|
[BackgroundDependencyLoader]
|
2020-12-28 21:39:11 +01:00
|
|
|
private void load()
|
2020-12-23 22:02:37 +01:00
|
|
|
{
|
2020-12-24 16:10:29 +01:00
|
|
|
Text = "Create room";
|
2020-12-23 22:02:37 +01:00
|
|
|
|
2020-12-28 21:39:11 +01:00
|
|
|
isConnected = multiplayerClient.IsConnected.GetBoundCopy();
|
2020-12-29 08:20:43 +01:00
|
|
|
operationInProgress = ongoingOperationTracker.InProgress.GetBoundCopy();
|
2020-12-30 16:22:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2021-01-12 19:04:16 +09:00
|
|
|
isConnected.BindValueChanged(_ => Scheduler.AddOnce(updateState));
|
|
|
|
operationInProgress.BindValueChanged(_ => Scheduler.AddOnce(updateState), true);
|
2020-12-23 22:02:37 +01:00
|
|
|
}
|
2020-12-28 21:39:11 +01:00
|
|
|
|
2020-12-29 08:20:43 +01:00
|
|
|
private void updateState() => Enabled.Value = isConnected.Value && !operationInProgress.Value;
|
2020-12-23 22:02:37 +01:00
|
|
|
}
|
|
|
|
}
|