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