mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
Add tooltips to start button to explain why it's not clickable
This commit is contained in:
parent
1c578f285a
commit
42d8d4fd38
@ -3,13 +3,15 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
{
|
||||
public abstract class ReadyButton : TriangleButton
|
||||
public abstract class ReadyButton : TriangleButton, IHasTooltip
|
||||
{
|
||||
public new readonly BindableBool Enabled = new BindableBool();
|
||||
|
||||
@ -24,6 +26,18 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
Enabled.BindValueChanged(_ => updateState(), true);
|
||||
}
|
||||
|
||||
private void updateState() => base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
|
||||
private void updateState() =>
|
||||
base.Enabled.Value = availability.Value.State == DownloadState.LocallyAvailable && Enabled.Value;
|
||||
|
||||
public virtual LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Enabled.Value)
|
||||
return string.Empty;
|
||||
|
||||
return "Beatmap not downloaded";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,10 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Rooms;
|
||||
@ -16,6 +18,12 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
[Resolved(typeof(Room), nameof(Room.EndDate))]
|
||||
private Bindable<DateTimeOffset?> endDate { get; set; }
|
||||
|
||||
[Resolved(typeof(Room), nameof(Room.MaxAttempts))]
|
||||
private Bindable<int?> maxAttempts { get; set; }
|
||||
|
||||
[Resolved(typeof(Room), nameof(Room.UserScore))]
|
||||
private Bindable<PlaylistAggregateScore> userScore { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; }
|
||||
|
||||
@ -56,6 +64,23 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft;
|
||||
}
|
||||
|
||||
public override LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Enabled.Value)
|
||||
return string.Empty;
|
||||
|
||||
if (!enoughTimeLeft)
|
||||
return "No time left!";
|
||||
|
||||
if (!hasRemainingAttempts)
|
||||
return "Attempts exhausted!";
|
||||
|
||||
return base.TooltipText;
|
||||
}
|
||||
}
|
||||
|
||||
private bool enoughTimeLeft =>
|
||||
// This should probably consider the length of the currently selected item, rather than a constant 30 seconds.
|
||||
endDate.Value != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < endDate.Value;
|
||||
|
Loading…
Reference in New Issue
Block a user