2019-01-24 17:43:03 +09: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 17:32:01 +09:00
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2018-12-14 15:04:04 +09:00
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
using osu.Framework.Bindables;
|
2021-10-26 16:55:24 +09:00
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Localisation;
|
2020-02-14 20:14:25 +09:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-01-16 23:02:30 +03:00
|
|
|
using osu.Game.Online;
|
2020-12-25 13:38:11 +09:00
|
|
|
using osu.Game.Online.Rooms;
|
2018-12-11 17:32:01 +09:00
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2018-12-11 17:32:01 +09:00
|
|
|
{
|
2021-10-26 16:55:24 +09:00
|
|
|
public abstract class ReadyButton : TriangleButton, IHasTooltip
|
2018-12-11 17:32:01 +09:00
|
|
|
{
|
2020-12-19 02:55:48 +09:00
|
|
|
public new readonly BindableBool Enabled = new BindableBool();
|
2022-03-24 17:14:51 +09:00
|
|
|
|
|
|
|
private readonly IBindable<BeatmapAvailability> availability = new Bindable<BeatmapAvailability>();
|
2020-05-19 16:44:22 +09:00
|
|
|
|
2018-12-14 15:04:04 +09:00
|
|
|
[BackgroundDependencyLoader]
|
2021-04-07 16:45:06 +09:00
|
|
|
private void load(OnlinePlayBeatmapAvailabilityTracker beatmapTracker)
|
2020-06-02 14:03:50 +09:00
|
|
|
{
|
2022-03-24 17:14:51 +09:00
|
|
|
availability.BindTo(beatmapTracker.Availability);
|
|
|
|
|
|
|
|
availability.BindValueChanged(_ => updateState());
|
2021-01-16 23:02:30 +03:00
|
|
|
Enabled.BindValueChanged(_ => updateState(), true);
|
2020-06-02 14:03:50 +09:00
|
|
|
}
|
|
|
|
|
2021-10-26 16:55:24 +09:00
|
|
|
private void updateState() =>
|
2022-03-24 17:14:51 +09:00
|
|
|
base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
|
2021-10-26 16:55:24 +09:00
|
|
|
|
|
|
|
public virtual LocalisableString TooltipText
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (Enabled.Value)
|
|
|
|
return string.Empty;
|
|
|
|
|
2022-03-24 17:14:51 +09:00
|
|
|
if (availability.Value.State != DownloadState.LocallyAvailable)
|
2021-11-16 14:48:52 +09:00
|
|
|
return "Beatmap not downloaded";
|
|
|
|
|
|
|
|
return string.Empty;
|
2021-10-26 16:55:24 +09:00
|
|
|
}
|
|
|
|
}
|
2018-12-11 17:32:01 +09:00
|
|
|
}
|
|
|
|
}
|