2019-01-24 08:43:03 +00: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.
|
2018-12-11 08:32:01 +00:00
|
|
|
|
2018-12-14 06:04:04 +00:00
|
|
|
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;
|
2021-01-16 20:02:30 +00:00
|
|
|
using osu.Game.Online;
|
2020-12-25 04:38:11 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2018-12-11 08:32:01 +00:00
|
|
|
|
2020-12-25 15:50:00 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2018-12-11 08:32:01 +00:00
|
|
|
{
|
2020-12-18 17:55:48 +00:00
|
|
|
public abstract class ReadyButton : TriangleButton
|
2018-12-11 08:32:01 +00:00
|
|
|
{
|
2020-12-18 17:55:48 +00:00
|
|
|
public new readonly BindableBool Enabled = new BindableBool();
|
2018-12-19 01:52:15 +00:00
|
|
|
|
2021-01-16 20:02:30 +00:00
|
|
|
private IBindable<BeatmapAvailability> availability;
|
2020-05-19 07:44:22 +00:00
|
|
|
|
2018-12-14 06:04:04 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2021-04-07 07:45:06 +00:00
|
|
|
private void load(OnlinePlayBeatmapAvailabilityTracker beatmapTracker)
|
2020-06-02 05:03:50 +00:00
|
|
|
{
|
2021-01-16 20:02:30 +00:00
|
|
|
availability = beatmapTracker.Availability.GetBoundCopy();
|
2020-06-02 05:03:50 +00:00
|
|
|
|
2021-01-16 20:02:30 +00:00
|
|
|
availability.BindValueChanged(_ => updateState());
|
|
|
|
Enabled.BindValueChanged(_ => updateState(), true);
|
2020-06-02 05:03:50 +00:00
|
|
|
}
|
|
|
|
|
2021-01-16 20:02:30 +00:00
|
|
|
private void updateState() => base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
|
2018-12-11 08:32:01 +00:00
|
|
|
}
|
|
|
|
}
|