From 617ceb800115064c989902965b4a23b32a689dd5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 12:26:46 +0900 Subject: [PATCH] Rename to StandardComboCounter, add HealthDisplay abstraction. --- .../Tests/TestCaseScoreCounter.cs | 2 +- osu.Game/Modes/UI/BaseComboCounter.cs | 267 -------------- osu.Game/Modes/UI/ComboCounter.cs | 325 ++++++++++++------ osu.Game/Modes/UI/HUDOverlay.cs | 22 +- osu.Game/Modes/UI/HealthDisplay.cs | 56 +-- osu.Game/Modes/UI/StandardComboCounter.cs | 140 ++++++++ osu.Game/Modes/UI/StandardHUDOverlay.cs | 9 +- osu.Game/Modes/UI/StandardHealthDisplay.cs | 60 ++++ osu.Game/osu.Game.csproj | 5 +- 9 files changed, 450 insertions(+), 436 deletions(-) delete mode 100644 osu.Game/Modes/UI/BaseComboCounter.cs create mode 100644 osu.Game/Modes/UI/StandardComboCounter.cs create mode 100644 osu.Game/Modes/UI/StandardHealthDisplay.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index abed40a919..59517beaf2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -40,7 +40,7 @@ namespace osu.Desktop.VisualTests.Tests }; Add(score); - BaseComboCounter comboCounter = new ComboCounter + ComboCounter comboCounter = new StandardComboCounter { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, diff --git a/osu.Game/Modes/UI/BaseComboCounter.cs b/osu.Game/Modes/UI/BaseComboCounter.cs deleted file mode 100644 index 73e8226c19..0000000000 --- a/osu.Game/Modes/UI/BaseComboCounter.cs +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; -using osu.Framework.MathUtils; -using osu.Game.Graphics.Sprites; - -namespace osu.Game.Modes.UI -{ - public abstract class BaseComboCounter : Container - { - public bool IsRolling - { - get; protected set; - } - - protected SpriteText PopOutCount; - - protected virtual double PopOutDuration => 150; - protected virtual float PopOutScale => 2.0f; - protected virtual EasingTypes PopOutEasing => EasingTypes.None; - protected virtual float PopOutInitialAlpha => 0.75f; - - protected virtual double FadeOutDuration => 100; - - /// - /// Duration in milliseconds for the counter roll-up animation for each element. - /// - protected virtual double RollingDuration => 20; - - /// - /// Easing for the counter rollover animation. - /// - protected EasingTypes RollingEasing => EasingTypes.None; - - private ulong displayedCount; - - /// - /// Value shown at the current moment. - /// - public virtual ulong DisplayedCount - { - get - { - return displayedCount; - } - protected set - { - if (displayedCount.Equals(value)) - return; - updateDisplayedCount(displayedCount, value, IsRolling); - } - } - - private ulong count; - - /// - /// Actual value of counter. - /// - public virtual ulong Count - { - get - { - return count; - } - set - { - updateCount(value); - } - } - - public void Increment(ulong amount = 1) - { - Count = Count + amount; - } - - protected SpriteText DisplayedCountSpriteText; - - private float textSize; - public float TextSize - { - get { return textSize; } - set - { - textSize = value; - DisplayedCountSpriteText.TextSize = TextSize; - PopOutCount.TextSize = TextSize; - } - } - - /// - /// Base of all combo counters. - /// - protected BaseComboCounter() - { - AutoSizeAxes = Axes.Both; - - Children = new Drawable[] - { - DisplayedCountSpriteText = new OsuSpriteText - { - Alpha = 0, - }, - PopOutCount = new OsuSpriteText - { - Alpha = 0, - Margin = new MarginPadding(0.05f), - } - }; - - TextSize = 80; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - DisplayedCountSpriteText.Text = FormatCount(Count); - DisplayedCountSpriteText.Anchor = Anchor; - DisplayedCountSpriteText.Origin = Origin; - - StopRolling(); - } - - /// - /// Stops rollover animation, forcing the displayed count to be the actual count. - /// - public void StopRolling() - { - updateCount(Count); - } - - /// - /// Animates roll-up/roll-back to an specific value. - /// - /// Target value. - public virtual void Roll(ulong newValue = 0) - { - updateCount(newValue, true); - } - - /// - /// Resets count to default value. - /// - public virtual void ResetCount() - { - updateCount(0); - } - - protected virtual string FormatCount(ulong count) - { - return count.ToString(); - } - - protected abstract void OnDisplayedCountRolling(ulong currentValue, ulong newValue); - protected abstract void OnDisplayedCountIncrement(ulong newValue); - protected abstract void OnDisplayedCountChange(ulong newValue); - - protected virtual void OnCountRolling(ulong currentValue, ulong newValue) - { - transformRoll(new TransformComboRoll(), currentValue, newValue); - } - - protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) { - DisplayedCount = newValue; - } - - protected virtual void OnCountChange(ulong currentValue, ulong newValue) { - DisplayedCount = newValue; - } - - private double getProportionalDuration(ulong currentValue, ulong newValue) - { - double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; - return difference * RollingDuration; - } - - private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling) - { - displayedCount = newValue; - if (rolling) - OnDisplayedCountRolling(currentValue, newValue); - else if (currentValue + 1 == newValue) - OnDisplayedCountIncrement(newValue); - else - OnDisplayedCountChange(newValue); - } - - private void updateCount(ulong value, bool rolling = false) - { - ulong prevCount = count; - count = value; - - if (!IsLoaded) - return; - - if (!rolling) - { - Flush(false, typeof(TransformComboRoll)); - IsRolling = false; - DisplayedCount = prevCount; - - if (prevCount + 1 == count) - OnCountIncrement(prevCount, count); - else - OnCountChange(prevCount, count); - } - else - { - OnCountRolling(displayedCount, count); - IsRolling = true; - } - } - - private void transformRoll(TransformComboRoll transform, ulong currentValue, ulong newValue) - { - Flush(false, typeof(TransformComboRoll)); - - if (RollingDuration < 1) - { - DisplayedCount = Count; - return; - } - - transform.StartTime = Time.Current; - transform.EndTime = Time.Current + getProportionalDuration(currentValue, newValue); - transform.StartValue = currentValue; - transform.EndValue = newValue; - transform.Easing = RollingEasing; - - Transforms.Add(transform); - } - - protected class TransformComboRoll : Transform - { - protected override ulong CurrentValue - { - get - { - double time = Time?.Current ?? 0; - if (time < StartTime) return StartValue; - if (time >= EndTime) return EndValue; - - return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); - } - } - - public override void Apply(Drawable d) - { - base.Apply(d); - ((BaseComboCounter)d).DisplayedCount = CurrentValue; - } - } - - public void Set(ulong value) - { - if (value == 0) - Roll(); - else - Count = value; - } - } -} diff --git a/osu.Game/Modes/UI/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index 7724b44940..b68489e37b 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -1,140 +1,269 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Framework.MathUtils; +using osu.Game.Graphics.Sprites; namespace osu.Game.Modes.UI { - /// - /// Uses the 'x' symbol and has a pop-out effect while rolling over. - /// - public class ComboCounter : BaseComboCounter + public abstract class ComboCounter : Container { - protected uint ScheduledPopOutCurrentId; + public bool IsRolling + { + get; protected set; + } - protected virtual float PopOutSmallScale => 1.1f; - protected virtual bool CanPopOutWhileRolling => false; + protected SpriteText PopOutCount; - public new Vector2 PopOutScale = new Vector2(1.6f); + protected virtual double PopOutDuration => 150; + protected virtual float PopOutScale => 2.0f; + protected virtual EasingTypes PopOutEasing => EasingTypes.None; + protected virtual float PopOutInitialAlpha => 0.75f; + + protected virtual double FadeOutDuration => 100; + + /// + /// Duration in milliseconds for the counter roll-up animation for each element. + /// + protected virtual double RollingDuration => 20; + + /// + /// Easing for the counter rollover animation. + /// + protected EasingTypes RollingEasing => EasingTypes.None; + + private ulong displayedCount; + + /// + /// Value shown at the current moment. + /// + public virtual ulong DisplayedCount + { + get + { + return displayedCount; + } + protected set + { + if (displayedCount.Equals(value)) + return; + updateDisplayedCount(displayedCount, value, IsRolling); + } + } + + private ulong count; + + /// + /// Actual value of counter. + /// + public virtual ulong Count + { + get + { + return count; + } + set + { + updateCount(value); + } + } + + public void Increment(ulong amount = 1) + { + Count = Count + amount; + } + + protected SpriteText DisplayedCountSpriteText; + + private float textSize; + public float TextSize + { + get { return textSize; } + set + { + textSize = value; + DisplayedCountSpriteText.TextSize = TextSize; + PopOutCount.TextSize = TextSize; + } + } + + /// + /// Base of all combo counters. + /// + protected ComboCounter() + { + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + DisplayedCountSpriteText = new OsuSpriteText + { + Alpha = 0, + }, + PopOutCount = new OsuSpriteText + { + Alpha = 0, + Margin = new MarginPadding(0.05f), + } + }; + + TextSize = 80; + } protected override void LoadComplete() { base.LoadComplete(); - PopOutCount.Origin = Origin; - PopOutCount.Anchor = Anchor; + DisplayedCountSpriteText.Text = FormatCount(Count); + DisplayedCountSpriteText.Anchor = Anchor; + DisplayedCountSpriteText.Origin = Origin; + + StopRolling(); } - protected override string FormatCount(ulong count) + /// + /// Stops rollover animation, forcing the displayed count to be the actual count. + /// + public void StopRolling() { - return $@"{count}x"; + updateCount(Count); } - protected virtual void TransformPopOut(ulong newValue) + /// + /// Animates roll-up/roll-back to an specific value. + /// + /// Target value. + public virtual void Roll(ulong newValue = 0) { - PopOutCount.Text = FormatCount(newValue); - - PopOutCount.ScaleTo(PopOutScale); - PopOutCount.FadeTo(PopOutInitialAlpha); - PopOutCount.MoveTo(Vector2.Zero); - - PopOutCount.ScaleTo(1, PopOutDuration, PopOutEasing); - PopOutCount.FadeOut(PopOutDuration, PopOutEasing); - PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); + updateCount(newValue, true); } - protected virtual void TransformPopOutRolling(ulong newValue) + /// + /// Resets count to default value. + /// + public virtual void ResetCount() { - TransformPopOut(newValue); - TransformPopOutSmall(newValue); + updateCount(0); } - protected virtual void TransformNoPopOut(ulong newValue) + protected virtual string FormatCount(ulong count) { - DisplayedCountSpriteText.Text = FormatCount(newValue); - DisplayedCountSpriteText.ScaleTo(1); + return count.ToString(); } - protected virtual void TransformPopOutSmall(ulong newValue) + protected abstract void OnDisplayedCountRolling(ulong currentValue, ulong newValue); + protected abstract void OnDisplayedCountIncrement(ulong newValue); + protected abstract void OnDisplayedCountChange(ulong newValue); + + protected virtual void OnCountRolling(ulong currentValue, ulong newValue) { - DisplayedCountSpriteText.Text = FormatCount(newValue); - DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); - DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); + transformRoll(new TransformComboRoll(), currentValue, newValue); } - protected virtual void ScheduledPopOutSmall(uint id) + protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) { - // Too late; scheduled task invalidated - if (id != ScheduledPopOutCurrentId) + DisplayedCount = newValue; + } + + protected virtual void OnCountChange(ulong currentValue, ulong newValue) + { + DisplayedCount = newValue; + } + + private double getProportionalDuration(ulong currentValue, ulong newValue) + { + double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; + return difference * RollingDuration; + } + + private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling) + { + displayedCount = newValue; + if (rolling) + OnDisplayedCountRolling(currentValue, newValue); + else if (currentValue + 1 == newValue) + OnDisplayedCountIncrement(newValue); + else + OnDisplayedCountChange(newValue); + } + + private void updateCount(ulong value, bool rolling = false) + { + ulong prevCount = count; + count = value; + + if (!IsLoaded) return; - DisplayedCount++; - } - - protected override void OnCountRolling(ulong currentValue, ulong newValue) - { - ScheduledPopOutCurrentId++; - - // Hides displayed count if was increasing from 0 to 1 but didn't finish - if (currentValue == 0 && newValue == 0) - DisplayedCountSpriteText.FadeOut(FadeOutDuration); - - base.OnCountRolling(currentValue, newValue); - } - - protected override void OnCountIncrement(ulong currentValue, ulong newValue) - { - ScheduledPopOutCurrentId++; - - if (DisplayedCount < currentValue) - DisplayedCount++; - - DisplayedCountSpriteText.Show(); - - TransformPopOut(newValue); - - uint newTaskId = ScheduledPopOutCurrentId; - Scheduler.AddDelayed(delegate + if (!rolling) { - ScheduledPopOutSmall(newTaskId); - }, PopOutDuration); - } + Flush(false, typeof(TransformComboRoll)); + IsRolling = false; + DisplayedCount = prevCount; - protected override void OnCountChange(ulong currentValue, ulong newValue) - { - ScheduledPopOutCurrentId++; - - if (newValue == 0) - DisplayedCountSpriteText.FadeOut(); - - base.OnCountChange(currentValue, newValue); - } - - protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) - { - if (newValue == 0) - DisplayedCountSpriteText.FadeOut(FadeOutDuration); + if (prevCount + 1 == count) + OnCountIncrement(prevCount, count); + else + OnCountChange(prevCount, count); + } else - DisplayedCountSpriteText.Show(); + { + OnCountRolling(displayedCount, count); + IsRolling = true; + } + } - if (CanPopOutWhileRolling) - TransformPopOutRolling(newValue); + private void transformRoll(TransformComboRoll transform, ulong currentValue, ulong newValue) + { + Flush(false, typeof(TransformComboRoll)); + + if (RollingDuration < 1) + { + DisplayedCount = Count; + return; + } + + transform.StartTime = Time.Current; + transform.EndTime = Time.Current + getProportionalDuration(currentValue, newValue); + transform.StartValue = currentValue; + transform.EndValue = newValue; + transform.Easing = RollingEasing; + + Transforms.Add(transform); + } + + protected class TransformComboRoll : Transform + { + protected override ulong CurrentValue + { + get + { + double time = Time?.Current ?? 0; + if (time < StartTime) return StartValue; + if (time >= EndTime) return EndValue; + + return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + } + } + + public override void Apply(Drawable d) + { + base.Apply(d); + ((ComboCounter)d).DisplayedCount = CurrentValue; + } + } + + public void Set(ulong value) + { + if (value == 0) + Roll(); else - TransformNoPopOut(newValue); - } - - protected override void OnDisplayedCountChange(ulong newValue) - { - DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); - - TransformNoPopOut(newValue); - } - - protected override void OnDisplayedCountIncrement(ulong newValue) - { - DisplayedCountSpriteText.Show(); - - TransformPopOutSmall(newValue); + Count = value; } } } diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index dc8ea5103c..241afea55c 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -1,12 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; using osu.Game.Modes.Objects; @@ -17,25 +15,19 @@ namespace osu.Game.Modes.UI { internal abstract class HUDOverlay : Container { - public KeyCounterCollection KeyCounter; - public BaseComboCounter ComboCounter; - public ScoreCounter ScoreCounter; - public PercentageCounter AccuracyCounter; - public HealthDisplay HealthDisplay; - public Score Score { get; set; } + public readonly KeyCounterCollection KeyCounter; + public readonly ComboCounter ComboCounter; + public readonly ScoreCounter ScoreCounter; + public readonly PercentageCounter AccuracyCounter; + public readonly HealthDisplay HealthDisplay; private Bindable showKeyCounter; protected abstract KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters); - protected abstract BaseComboCounter CreateComboCounter(); + protected abstract ComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); - protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay - { - Size = new Vector2(1, 5), - RelativeSizeAxes = Axes.X, - Margin = new MarginPadding { Top = 20 } - }; + protected abstract HealthDisplay CreateHealthDisplay(); public virtual void OnHit(HitObject h) { diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index ddd4c1db42..ddc4bcfaa6 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -1,25 +1,14 @@ // 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.Configuration; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; -using osu.Game.Graphics; -using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Modes.UI { - public class HealthDisplay : Container + internal abstract class HealthDisplay : Container { - private Container fill; - - public BindableDouble Current = new BindableDouble + public readonly BindableDouble Current = new BindableDouble { MinValue = 0, MaxValue = 1 @@ -27,46 +16,9 @@ namespace osu.Game.Modes.UI public HealthDisplay() { - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - fill = new Container - { - RelativeSizeAxes = Axes.Both, - Scale = new Vector2(0, 1), - Masking = true, - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - } - } - }, - }; - - Current.ValueChanged += current_ValueChanged; + Current.ValueChanged += (s, e) => setHP((float)Current); } - [BackgroundDependencyLoader] - private void laod(OsuColour colours) - { - fill.Colour = colours.BlueLighter; - fill.EdgeEffect = new EdgeEffect - { - Colour = colours.BlueDarker.Opacity(0.6f), - Radius = 8, - Type= EdgeEffectType.Glow - }; - } - - private void current_ValueChanged(object sender, EventArgs e) - { - fill.ScaleTo(new Vector2((float)Current, 1), 200, EasingTypes.OutQuint); - } + protected abstract void setHP(float value); } } diff --git a/osu.Game/Modes/UI/StandardComboCounter.cs b/osu.Game/Modes/UI/StandardComboCounter.cs new file mode 100644 index 0000000000..488ab40d42 --- /dev/null +++ b/osu.Game/Modes/UI/StandardComboCounter.cs @@ -0,0 +1,140 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; + +namespace osu.Game.Modes.UI +{ + /// + /// Uses the 'x' symbol and has a pop-out effect while rolling over. + /// + public class StandardComboCounter : ComboCounter + { + protected uint ScheduledPopOutCurrentId; + + protected virtual float PopOutSmallScale => 1.1f; + protected virtual bool CanPopOutWhileRolling => false; + + public new Vector2 PopOutScale = new Vector2(1.6f); + + protected override void LoadComplete() + { + base.LoadComplete(); + + PopOutCount.Origin = Origin; + PopOutCount.Anchor = Anchor; + } + + protected override string FormatCount(ulong count) + { + return $@"{count}x"; + } + + protected virtual void TransformPopOut(ulong newValue) + { + PopOutCount.Text = FormatCount(newValue); + + PopOutCount.ScaleTo(PopOutScale); + PopOutCount.FadeTo(PopOutInitialAlpha); + PopOutCount.MoveTo(Vector2.Zero); + + PopOutCount.ScaleTo(1, PopOutDuration, PopOutEasing); + PopOutCount.FadeOut(PopOutDuration, PopOutEasing); + PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); + } + + protected virtual void TransformPopOutRolling(ulong newValue) + { + TransformPopOut(newValue); + TransformPopOutSmall(newValue); + } + + protected virtual void TransformNoPopOut(ulong newValue) + { + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(1); + } + + protected virtual void TransformPopOutSmall(ulong newValue) + { + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); + DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); + } + + protected virtual void ScheduledPopOutSmall(uint id) + { + // Too late; scheduled task invalidated + if (id != ScheduledPopOutCurrentId) + return; + + DisplayedCount++; + } + + protected override void OnCountRolling(ulong currentValue, ulong newValue) + { + ScheduledPopOutCurrentId++; + + // Hides displayed count if was increasing from 0 to 1 but didn't finish + if (currentValue == 0 && newValue == 0) + DisplayedCountSpriteText.FadeOut(FadeOutDuration); + + base.OnCountRolling(currentValue, newValue); + } + + protected override void OnCountIncrement(ulong currentValue, ulong newValue) + { + ScheduledPopOutCurrentId++; + + if (DisplayedCount < currentValue) + DisplayedCount++; + + DisplayedCountSpriteText.Show(); + + TransformPopOut(newValue); + + uint newTaskId = ScheduledPopOutCurrentId; + Scheduler.AddDelayed(delegate + { + ScheduledPopOutSmall(newTaskId); + }, PopOutDuration); + } + + protected override void OnCountChange(ulong currentValue, ulong newValue) + { + ScheduledPopOutCurrentId++; + + if (newValue == 0) + DisplayedCountSpriteText.FadeOut(); + + base.OnCountChange(currentValue, newValue); + } + + protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) + { + if (newValue == 0) + DisplayedCountSpriteText.FadeOut(FadeOutDuration); + else + DisplayedCountSpriteText.Show(); + + if (CanPopOutWhileRolling) + TransformPopOutRolling(newValue); + else + TransformNoPopOut(newValue); + } + + protected override void OnDisplayedCountChange(ulong newValue) + { + DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); + + TransformNoPopOut(newValue); + } + + protected override void OnDisplayedCountIncrement(ulong newValue) + { + DisplayedCountSpriteText.Show(); + + TransformPopOutSmall(newValue); + } + } +} diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs index 09c53632a5..7bbe9a41f1 100644 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -26,12 +26,19 @@ namespace osu.Game.Modes.UI Margin = new MarginPadding { Right = 5 }, }; - protected override BaseComboCounter CreateComboCounter() => new ComboCounter + protected override ComboCounter CreateComboCounter() => new StandardComboCounter { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }; + protected override HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay + { + Size = new Vector2(1, 5), + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20 } + }; + protected override KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters) => new KeyCounterCollection { IsCounting = true, diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs new file mode 100644 index 0000000000..3357b93aed --- /dev/null +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -0,0 +1,60 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics; + +namespace osu.Game.Modes.UI +{ + class StandardHealthDisplay : HealthDisplay + { + private Container fill; + + public StandardHealthDisplay() + { + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + fill = new Container + { + RelativeSizeAxes = Axes.Both, + Scale = new Vector2(0, 1), + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + } + } + }, + }; + } + + [BackgroundDependencyLoader] + private void laod(OsuColour colours) + { + fill.Colour = colours.BlueLighter; + fill.EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDarker.Opacity(0.6f), + Radius = 8, + Type = EdgeEffectType.Glow + }; + } + + protected override void setHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d0f2d6f042..98a23ceec3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -97,6 +97,7 @@ + @@ -167,7 +168,7 @@ - + @@ -185,7 +186,7 @@ - +