This commit is contained in:
Dean Herbert 2017-04-07 21:20:31 +09:00
parent 4aadd3a8f8
commit c615762da6
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
7 changed files with 97 additions and 14 deletions

View File

@ -5,6 +5,7 @@
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
using System;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface
{
@ -30,6 +31,12 @@ public PercentageCounter()
Current.Value = DisplayedCount = 1.0f;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
DisplayedCountSpriteText.Colour = colours.BlueLighter;
}
protected override string FormatCount(double count)
{
return $@"{count:P2}";

View File

@ -111,8 +111,6 @@ protected override void LoadComplete()
Flush(false, TransformType);
DisplayedCountSpriteText.Text = FormatCount(Current);
DisplayedCountSpriteText.Anchor = Anchor;
DisplayedCountSpriteText.Origin = Origin;
}
/// <summary>

View File

@ -5,6 +5,7 @@
using osu.Framework.Graphics.Transforms;
using osu.Framework.MathUtils;
using System;
using osu.Framework.Allocation;
namespace osu.Game.Graphics.UserInterface
{
@ -34,6 +35,12 @@ public ScoreCounter(uint leading = 0)
LeadingZeroes = leading;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
DisplayedCountSpriteText.Colour = colours.BlueLighter;
}
protected override double GetProportionalDuration(double currentValue, double newValue)
{
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;

View 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;
}
}
}
}

View File

@ -22,9 +22,9 @@ public abstract class HudOverlay : Container
private readonly Container content;
public readonly KeyCounterCollection KeyCounter;
public readonly ComboCounter ComboCounter;
public readonly RollingCounter<int> ComboCounter;
public readonly ScoreCounter ScoreCounter;
public readonly PercentageCounter AccuracyCounter;
public readonly RollingCounter<double> AccuracyCounter;
public readonly HealthDisplay HealthDisplay;
private Bindable<bool> showKeyCounter;
@ -33,8 +33,8 @@ public abstract class HudOverlay : Container
private static bool hasShownNotificationOnce;
protected abstract KeyCounterCollection CreateKeyCounter();
protected abstract ComboCounter CreateComboCounter();
protected abstract PercentageCounter CreateAccuracyCounter();
protected abstract RollingCounter<int> CreateComboCounter();
protected abstract RollingCounter<double> CreateAccuracyCounter();
protected abstract ScoreCounter CreateScoreCounter();
protected abstract HealthDisplay CreateHealthDisplay();

View File

@ -11,19 +11,22 @@ namespace osu.Game.Modes.UI
{
public class StandardHudOverlay : HudOverlay
{
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter
protected override RollingCounter<double> CreateAccuracyCounter() => new PercentageCounter
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Position = new Vector2(0, 65),
Origin = Anchor.TopRight,
Position = new Vector2(0, 35),
TextSize = 20,
Margin = new MarginPadding { Right = 5 },
Margin = new MarginPadding { Right = 140 },
};
protected override ComboCounter CreateComboCounter() => new StandardComboCounter
protected override RollingCounter<int> CreateComboCounter() => new SimpleComboCounter
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopLeft,
Position = new Vector2(0, 35),
Margin = new MarginPadding { Left = 140 },
TextSize = 20,
};
protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay
@ -49,7 +52,6 @@ public class StandardHudOverlay : HudOverlay
Origin = Anchor.TopCentre,
TextSize = 40,
Position = new Vector2(0, 30),
Margin = new MarginPadding { Right = 5 },
};
}
}

View File

@ -93,6 +93,7 @@
<Compile Include="Graphics\UserInterface\OsuPasswordTextBox.cs" />
<Compile Include="Graphics\UserInterface\OsuSliderBar.cs" />
<Compile Include="Graphics\UserInterface\OsuTextBox.cs" />
<Compile Include="Graphics\UserInterface\SimpleComboCounter.cs" />
<Compile Include="Graphics\UserInterface\TwoLayerButton.cs" />
<Compile Include="Input\Handlers\ReplayInputHandler.cs" />
<Compile Include="IO\Legacy\ILegacySerializable.cs" />