2022-07-29 00:37:12 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
|
2022-08-15 02:12:11 +08:00
|
|
|
namespace osu.Game.Screens.Play.HUD.ClicksPerSecond
|
2022-07-29 00:37:12 +08:00
|
|
|
{
|
2022-08-15 02:12:11 +08:00
|
|
|
public partial class ClicksPerSecondCounter : RollingCounter<int>, ISkinnableDrawable
|
2022-07-29 00:37:12 +08:00
|
|
|
{
|
2022-08-24 23:12:52 +08:00
|
|
|
[Resolved]
|
2022-08-21 09:15:30 +08:00
|
|
|
private ClicksPerSecondCalculator calculator { get; set; } = null!;
|
2022-07-31 07:29:57 +08:00
|
|
|
|
2022-08-07 06:53:00 +08:00
|
|
|
protected override double RollingDuration => 350;
|
2022-07-29 00:37:12 +08:00
|
|
|
|
|
|
|
public bool UsesFixedAnchor { get; set; }
|
|
|
|
|
2022-08-15 02:12:11 +08:00
|
|
|
public ClicksPerSecondCounter()
|
2022-07-29 00:37:12 +08:00
|
|
|
{
|
|
|
|
Current.Value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-08-21 09:15:30 +08:00
|
|
|
private void load(OsuColour colours)
|
2022-07-29 00:37:12 +08:00
|
|
|
{
|
|
|
|
Colour = colours.BlueLighter;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
2022-07-31 07:29:57 +08:00
|
|
|
base.Update();
|
2022-07-29 00:37:12 +08:00
|
|
|
|
2022-08-24 23:12:52 +08:00
|
|
|
Current.Value = calculator.Value;
|
2022-07-29 00:37:12 +08:00
|
|
|
}
|
|
|
|
|
2022-08-21 09:15:30 +08:00
|
|
|
protected override IHasText CreateText() => new TextComponent();
|
2022-07-29 00:37:12 +08:00
|
|
|
|
|
|
|
private partial class TextComponent : CompositeDrawable, IHasText
|
|
|
|
{
|
|
|
|
public LocalisableString Text
|
|
|
|
{
|
|
|
|
get => text.Text;
|
|
|
|
set => text.Text = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private readonly OsuSpriteText text;
|
|
|
|
|
|
|
|
public TextComponent()
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(2),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
text = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Font = OsuFont.Numeric.With(size: 16, fixedWidth: true)
|
|
|
|
},
|
2022-08-13 10:27:26 +08:00
|
|
|
new FillFlowContainer
|
2022-07-29 00:37:12 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2022-08-13 10:27:26 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Font = OsuFont.Numeric.With(size: 6, fixedWidth: false),
|
|
|
|
Text = @"clicks",
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Font = OsuFont.Numeric.With(size: 6, fixedWidth: false),
|
|
|
|
Text = @"/sec",
|
|
|
|
Padding = new MarginPadding { Bottom = 3f }, // align baseline better
|
|
|
|
}
|
|
|
|
}
|
2022-07-29 00:37:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|