mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Make effect display have a built-in counter
This commit is contained in:
parent
b056cac10a
commit
667854b034
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -11,6 +12,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
|
||||
@ -26,7 +28,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private readonly Box contentBackground;
|
||||
private readonly Box labelBackground;
|
||||
private readonly Container content;
|
||||
private readonly FillFlowContainer content;
|
||||
|
||||
public Bindable<double> Current
|
||||
{
|
||||
@ -62,6 +64,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected virtual float ValueAreaWidth => 56;
|
||||
|
||||
protected virtual string CounterFormat => "N0";
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected ModsEffectDisplay()
|
||||
@ -121,12 +125,20 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
}
|
||||
},
|
||||
content = new Container
|
||||
content = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0)
|
||||
Direction = FillDirection.Horizontal,
|
||||
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
|
||||
Spacing = new Vector2(2, 0),
|
||||
Child = new EffectCounter(CounterFormat)
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Current = { BindTarget = Current }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,5 +215,24 @@ namespace osu.Game.Overlays.Mods
|
||||
DifficultyReduction,
|
||||
DifficultyIncrease
|
||||
}
|
||||
|
||||
private class EffectCounter : RollingCounter<double>
|
||||
{
|
||||
private readonly string? format;
|
||||
|
||||
public EffectCounter(string? format)
|
||||
{
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
protected override double RollingDuration => 500;
|
||||
|
||||
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(format);
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user