osu/osu.Game/Screens/OnlinePlay/Multiplayer/CreateMultiplayerMatchButto...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.4 KiB
C#
Raw Normal View History

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