mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
wip
This commit is contained in:
68
osu.Game/Graphics/UserInterface/SimpleComboCounter.cs
Normal file
68
osu.Game/Graphics/UserInterface/SimpleComboCounter.cs
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as an accuracy counter. Represented visually as a percentage.
|
||||
/// </summary>
|
||||
public class SimpleComboCounter : RollingCounter<int>
|
||||
{
|
||||
protected override Type TransformType => typeof(TransformCount);
|
||||
|
||||
protected override double RollingDuration => 750;
|
||||
|
||||
public SimpleComboCounter()
|
||||
{
|
||||
Current.Value = DisplayedCount = 0;
|
||||
}
|
||||
|
||||
protected override string FormatCount(int count)
|
||||
{
|
||||
return $@"{count}x";
|
||||
}
|
||||
|
||||
protected override double GetProportionalDuration(int currentValue, int newValue)
|
||||
{
|
||||
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
|
||||
}
|
||||
|
||||
public override void Increment(int amount)
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
DisplayedCountSpriteText.Colour = colours.BlueLighter;
|
||||
}
|
||||
|
||||
protected class TransformCount : Transform<int>
|
||||
{
|
||||
public override int CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
double time = Time?.Current ?? 0;
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(Drawable d)
|
||||
{
|
||||
base.Apply(d);
|
||||
((SimpleComboCounter)d).DisplayedCount = CurrentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user