1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Display difficulty on nub

This commit is contained in:
Dean Herbert 2022-07-01 15:17:26 +09:00
parent cb9947b1c9
commit 545df0a8e8
2 changed files with 20 additions and 5 deletions

View File

@ -19,7 +19,7 @@ using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterface
{
public class Nub : CompositeDrawable, IHasCurrentValue<bool>, IHasAccentColour
public class Nub : Container, IHasCurrentValue<bool>, IHasAccentColour
{
public const float HEIGHT = 15;

View File

@ -83,8 +83,6 @@ namespace osu.Game.Screens.Select
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
base.ReceivePositionalInputAt(screenSpacePos)
&& screenSpacePos.X <= Nub.ScreenSpaceDrawQuad.TopRight.X;
public override LocalisableString TooltipText => Current.IsDefault ? UserInterfaceStrings.NoLimit : base.TooltipText;
}
private class MaximumStarsSlider : StarsSlider
@ -99,12 +97,15 @@ namespace osu.Game.Screens.Select
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
base.ReceivePositionalInputAt(screenSpacePos)
&& screenSpacePos.X >= Nub.ScreenSpaceDrawQuad.TopLeft.X;
public override LocalisableString TooltipText => Current.IsDefault ? UserInterfaceStrings.NoLimit : base.TooltipText;
}
private class StarsSlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => Current.Value.ToString(@"0.## stars");
private OsuSpriteText currentDisplay;
public override LocalisableString TooltipText => Current.IsDefault
? UserInterfaceStrings.NoLimit
: Current.Value.ToString(@"0.## stars");
public new Nub Nub => base.Nub;
@ -113,6 +114,20 @@ namespace osu.Game.Screens.Select
base.LoadComplete();
Nub.Width = Nub.HEIGHT;
RangePadding = Nub.Width / 2;
Nub.Add(currentDisplay = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = -0.5f,
Colour = Color4.White,
Font = OsuFont.Torus.With(size: 10),
});
Current.BindValueChanged(current =>
{
currentDisplay.Text = current.NewValue != Current.Default ? current.NewValue.ToString("N1") : "∞";
}, true);
}
}
}