From c615762da6e571d127d5c92c4b2a1e20e91ad39c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 7 Apr 2017 21:20:31 +0900 Subject: [PATCH] wip --- .../UserInterface/PercentageCounter.cs | 7 ++ .../Graphics/UserInterface/RollingCounter.cs | 2 - .../Graphics/UserInterface/ScoreCounter.cs | 7 ++ .../UserInterface/SimpleComboCounter.cs | 68 +++++++++++++++++++ osu.Game/Modes/UI/HudOverlay.cs | 8 +-- osu.Game/Modes/UI/StandardHudOverlay.cs | 18 ++--- osu.Game/osu.Game.csproj | 1 + 7 files changed, 97 insertions(+), 14 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/SimpleComboCounter.cs diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index c32b654840..d9438af17e 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using System; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface { @@ -30,6 +31,12 @@ namespace osu.Game.Graphics.UserInterface Current.Value = DisplayedCount = 1.0f; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + DisplayedCountSpriteText.Colour = colours.BlueLighter; + } + protected override string FormatCount(double count) { return $@"{count:P2}"; diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 12eeb771dd..4b244fc540 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -111,8 +111,6 @@ namespace osu.Game.Graphics.UserInterface Flush(false, TransformType); DisplayedCountSpriteText.Text = FormatCount(Current); - DisplayedCountSpriteText.Anchor = Anchor; - DisplayedCountSpriteText.Origin = Origin; } /// diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index c2b1b026b6..367e3bbb1a 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using System; +using osu.Framework.Allocation; namespace osu.Game.Graphics.UserInterface { @@ -34,6 +35,12 @@ namespace osu.Game.Graphics.UserInterface 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; diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs new file mode 100644 index 0000000000..c9891885bd --- /dev/null +++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs @@ -0,0 +1,68 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// 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 +{ + /// + /// Used as an accuracy counter. Represented visually as a percentage. + /// + public class SimpleComboCounter : RollingCounter + { + 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 + { + 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; + } + } + } +} \ No newline at end of file diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index 355b62bc57..0e1a3fb1c2 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -22,9 +22,9 @@ namespace osu.Game.Modes.UI private readonly Container content; public readonly KeyCounterCollection KeyCounter; - public readonly ComboCounter ComboCounter; + public readonly RollingCounter ComboCounter; public readonly ScoreCounter ScoreCounter; - public readonly PercentageCounter AccuracyCounter; + public readonly RollingCounter AccuracyCounter; public readonly HealthDisplay HealthDisplay; private Bindable showKeyCounter; @@ -33,8 +33,8 @@ namespace osu.Game.Modes.UI private static bool hasShownNotificationOnce; protected abstract KeyCounterCollection CreateKeyCounter(); - protected abstract ComboCounter CreateComboCounter(); - protected abstract PercentageCounter CreateAccuracyCounter(); + protected abstract RollingCounter CreateComboCounter(); + protected abstract RollingCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index f07e421f00..87ec631b35 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -11,19 +11,22 @@ namespace osu.Game.Modes.UI { public class StandardHudOverlay : HudOverlay { - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter + protected override RollingCounter 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 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 @@ namespace osu.Game.Modes.UI Origin = Anchor.TopCentre, TextSize = 40, Position = new Vector2(0, 30), - Margin = new MarginPadding { Right = 5 }, }; } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d90fdda41a..7b9d41a4e1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -93,6 +93,7 @@ +