osu/osu.Game/Screens/OnlinePlay/Components/ReadyButton.cs

30 lines
1.0 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.
using osu.Framework.Allocation;
2019-02-21 10:04:31 +00:00
using osu.Framework.Bindables;
2020-02-14 11:14:25 +00:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Online;
2020-12-25 04:38:11 +00:00
using osu.Game.Online.Rooms;
namespace osu.Game.Screens.OnlinePlay.Components
{
public abstract class ReadyButton : TriangleButton
{
public new readonly BindableBool Enabled = new BindableBool();
private IBindable<BeatmapAvailability> availability;
2020-05-19 07:44:22 +00:00
[BackgroundDependencyLoader]
2021-04-07 07:45:06 +00:00
private void load(OnlinePlayBeatmapAvailabilityTracker beatmapTracker)
{
availability = beatmapTracker.Availability.GetBoundCopy();
availability.BindValueChanged(_ => updateState());
Enabled.BindValueChanged(_ => updateState(), true);
}
private void updateState() => base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
}
}