Rewrite DMD

This commit is contained in:
ansel 2022-09-10 23:23:04 +03:00
parent 3f93ec8538
commit 324a3723a5

View File

@ -3,14 +3,9 @@
#nullable disable #nullable disable
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
using osu.Game.Localisation; using osu.Game.Localisation;
@ -20,34 +15,19 @@ namespace osu.Game.Overlays.Mods
{ {
protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier; protected override LocalisableString Label => DifficultyMultiplierDisplayStrings.DifficultyMultiplier;
private readonly MultiplierCounter multiplierCounter; protected override string CounterFormat => @"N2";
public DifficultyMultiplierDisplay() public DifficultyMultiplierDisplay()
{ {
Current.Default = 1d; Current.Default = 1d;
Current.Value = 1d; Current.Value = 1d;
Add(new FillFlowContainer Add(new SpriteIcon
{ {
AutoSizeAxes = Axes.Both, Anchor = Anchor.CentreLeft,
Direction = FillDirection.Horizontal, Origin = Anchor.CentreLeft,
Spacing = new Vector2(2, 0), Icon = FontAwesome.Solid.Times,
Children = new Drawable[] Size = new Vector2(7),
{ Margin = new MarginPadding { Top = 1 }
multiplierCounter = new MultiplierCounter
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = { BindTarget = Current }
},
new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Icon = FontAwesome.Solid.Times,
Size = new Vector2(7),
Margin = new MarginPadding { Top = 1 }
}
}
}); });
} }
@ -57,19 +37,7 @@ namespace osu.Game.Overlays.Mods
// required to prevent the counter initially rolling up from 0 to 1 // required to prevent the counter initially rolling up from 0 to 1
// due to `Current.Value` having a nonstandard default value of 1. // due to `Current.Value` having a nonstandard default value of 1.
multiplierCounter.SetCountWithoutRolling(Current.Value); Counter.SetCountWithoutRolling(Current.Value);
}
private class MultiplierCounter : RollingCounter<double>
{
protected override double RollingDuration => 500;
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"N2");
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
};
} }
} }
} }