1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 21:27:23 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Components/ReadyButton.cs

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

49 lines
1.5 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 15:37:17 +08:00
#nullable disable
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
namespace osu.Game.Screens.OnlinePlay.Components
{
public abstract partial class ReadyButton : RoundedButton, IHasTooltip
{
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
[BackgroundDependencyLoader]
2021-04-07 15:45:06 +08:00
private void load(OnlinePlayBeatmapAvailabilityTracker beatmapTracker)
{
2022-03-24 16:14:51 +08:00
availability.BindTo(beatmapTracker.Availability);
availability.BindValueChanged(_ => updateState());
Enabled.BindValueChanged(_ => updateState(), true);
}
private void updateState() =>
2022-03-24 16:14:51 +08:00
base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
public virtual LocalisableString TooltipText
{
get
{
if (Enabled.Value)
return string.Empty;
2022-03-24 16:14:51 +08:00
if (availability.Value.State != DownloadState.LocallyAvailable)
return "Beatmap not downloaded";
return string.Empty;
}
}
}
}