2022-02-20 22:48:33 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-02-20 22:48:33 +08:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-02-20 23:02:46 +08:00
|
|
|
using osu.Framework.Localisation;
|
2022-02-20 22:48:33 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-02-20 23:02:46 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-02-20 22:48:33 +08:00
|
|
|
using osuTK;
|
2022-05-07 16:48:15 +08:00
|
|
|
using osu.Game.Localisation;
|
2022-02-20 22:48:33 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2022-08-30 03:48:45 +08:00
|
|
|
public sealed class DifficultyMultiplierDisplay : ModsEffectDisplay<double>
|
2022-02-20 22:48:33 +08:00
|
|
|
{
|
2022-08-28 01:26:05 +08:00
|
|
|
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
|
2022-08-30 03:48:45 +08:00
|
|
|
protected override ModEffect CalculateEffect(double value) => CalculateForSign(value.CompareTo(1d));
|
2022-02-20 22:48:33 +08:00
|
|
|
|
2022-02-20 23:02:46 +08:00
|
|
|
private readonly MultiplierCounter multiplierCounter;
|
2022-02-20 22:48:33 +08:00
|
|
|
|
|
|
|
public DifficultyMultiplierDisplay()
|
|
|
|
{
|
2022-08-30 03:48:45 +08:00
|
|
|
Current.Default = 1d;
|
|
|
|
Current.Value = 1d;
|
2022-08-28 01:26:05 +08:00
|
|
|
Add(new FillFlowContainer
|
2022-02-20 22:48:33 +08:00
|
|
|
{
|
2022-08-28 01:26:05 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
Spacing = new Vector2(2, 0),
|
2022-02-20 22:48:33 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-08-28 01:26:05 +08:00
|
|
|
multiplierCounter = new MultiplierCounter
|
2022-02-20 22:48:33 +08:00
|
|
|
{
|
2022-08-28 01:26:05 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Current = { BindTarget = Current }
|
2022-02-20 22:48:33 +08:00
|
|
|
},
|
2022-08-28 01:26:05 +08:00
|
|
|
new SpriteIcon
|
2022-02-20 22:48:33 +08:00
|
|
|
{
|
2022-08-28 01:26:05 +08:00
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Icon = FontAwesome.Solid.Times,
|
|
|
|
Size = new Vector2(7),
|
|
|
|
Margin = new MarginPadding { Top = 1 }
|
2022-02-20 22:48:33 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-28 01:26:05 +08:00
|
|
|
});
|
2022-02-20 22:48:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2022-04-05 17:25:27 +08:00
|
|
|
|
2022-03-08 06:11:20 +08:00
|
|
|
// required to prevent the counter initially rolling up from 0 to 1
|
|
|
|
// due to `Current.Value` having a nonstandard default value of 1.
|
2022-08-30 03:48:45 +08:00
|
|
|
multiplierCounter.SetCountWithoutRolling(Current.Value);
|
2022-02-20 22:48:33 +08:00
|
|
|
}
|
2022-02-20 23:02:46 +08:00
|
|
|
|
|
|
|
private class MultiplierCounter : RollingCounter<double>
|
|
|
|
{
|
|
|
|
protected override double RollingDuration => 500;
|
|
|
|
|
2022-03-08 05:55:55 +08:00
|
|
|
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"N2");
|
2022-02-20 23:02:46 +08:00
|
|
|
|
|
|
|
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
|
|
|
};
|
|
|
|
}
|
2022-02-20 22:48:33 +08:00
|
|
|
}
|
|
|
|
}
|