From 31f6cbd8cfaf229256ce8f7879d94f0824531922 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 11:59:08 +0900 Subject: [PATCH 01/18] Rename ScoreOverlay -> HUDOverlay, move to osu.Game, make it not overridable by rulesets. --- .../Tests/TestCaseScoreCounter.cs | 26 +- osu.Game.Modes.Catch/CatchRuleset.cs | 16 +- osu.Game.Modes.Mania/ManiaRuleset.cs | 10 +- osu.Game.Modes.Osu/OsuRuleset.cs | 16 +- osu.Game.Modes.Osu/UI/OsuComboCounter.cs | 141 -------- osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 2 - osu.Game.Modes.Taiko/Objects/DrumHit.cs | 15 + osu.Game.Modes.Taiko/TaikoRuleset.cs | 13 +- .../osu.Game.Modes.Taiko.csproj | 1 + osu.Game/Modes/Ruleset.cs | 15 +- osu.Game/Modes/UI/BaseComboCounter.cs | 267 ++++++++++++++ osu.Game/Modes/UI/ComboCounter.cs | 325 ++++++------------ .../UI/{ScoreOverlay.cs => HUDOverlay.cs} | 27 +- .../Modes/UI/StandardHUDOverlay.cs | 42 ++- osu.Game/Screens/Play/Player.cs | 40 +-- osu.Game/osu.Game.csproj | 6 +- 16 files changed, 499 insertions(+), 463 deletions(-) delete mode 100644 osu.Game.Modes.Osu/UI/OsuComboCounter.cs create mode 100644 osu.Game.Modes.Taiko/Objects/DrumHit.cs create mode 100644 osu.Game/Modes/UI/BaseComboCounter.cs rename osu.Game/Modes/UI/{ScoreOverlay.cs => HUDOverlay.cs} (87%) rename osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs => osu.Game/Modes/UI/StandardHUDOverlay.cs (69%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index a3560e7400..abed40a919 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); - ComboCounter standardCombo = new OsuComboCounter + BaseComboCounter comboCounter = new ComboCounter { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -48,15 +48,15 @@ namespace osu.Desktop.VisualTests.Tests Count = 0, TextSize = 40, }; - Add(standardCombo); + Add(comboCounter); - PercentageCounter accuracyCombo = new PercentageCounter + PercentageCounter accuracyCounter = new PercentageCounter { Origin = Anchor.TopRight, Anchor = Anchor.TopRight, Position = new Vector2(-20, 60), }; - Add(accuracyCombo); + Add(accuracyCounter); StarCounter stars = new StarCounter { @@ -79,26 +79,26 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Reset all", delegate { score.Count = 0; - standardCombo.Count = 0; + comboCounter.Count = 0; numerator = denominator = 0; - accuracyCombo.SetFraction(0, 0); + accuracyCounter.SetFraction(0, 0); stars.Count = 0; starsLabel.Text = stars.Count.ToString("0.00"); }); AddButton(@"Hit! :D", delegate { - score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0); - standardCombo.Count++; + score.Count += 300 + (ulong)(300.0 * (comboCounter.Count > 0 ? comboCounter.Count - 1 : 0) / 25.0); + comboCounter.Count++; numerator++; denominator++; - accuracyCombo.SetFraction(numerator, denominator); + accuracyCounter.SetFraction(numerator, denominator); }); AddButton(@"miss...", delegate { - standardCombo.Roll(); + comboCounter.Roll(); denominator++; - accuracyCombo.SetFraction(numerator, denominator); + accuracyCounter.SetFraction(numerator, denominator); }); AddButton(@"Alter stars", delegate @@ -110,8 +110,8 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Stop counters", delegate { score.StopRolling(); - standardCombo.StopRolling(); - accuracyCombo.StopRolling(); + comboCounter.StopRolling(); + accuracyCounter.StopRolling(); stars.StopAnimation(); }); } diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 737bd99f94..b552278cec 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -1,20 +1,19 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; +using OpenTK.Input; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; -using osu.Game.Beatmaps; +using osu.Game.Screens.Play; +using System.Collections.Generic; namespace osu.Game.Modes.Catch { public class CatchRuleset : Ruleset { - public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer { Beatmap = beatmap, @@ -81,6 +80,13 @@ namespace osu.Game.Modes.Catch public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; + public override KeyCounter[] GameplayKeys => new KeyCounter[] + { + new KeyCounterKeyboard(Key.ShiftLeft), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 6d5606f796..51a33ce7bc 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -1,20 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; -using osu.Game.Beatmaps; +using osu.Game.Screens.Play; +using System.Collections.Generic; namespace osu.Game.Modes.Mania { public class ManiaRuleset : Ruleset { - public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer { Beatmap = beatmap, @@ -102,6 +100,8 @@ namespace osu.Game.Modes.Mania public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; + public override KeyCounter[] GameplayKeys => new KeyCounter[] { /* Todo: Should be keymod specific */ }; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 68f700cabb..72c4b6988c 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -1,21 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; -using System.Linq; +using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; +using osu.Game.Screens.Play; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Osu { public class OsuRuleset : Ruleset { - public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer { Beatmap = beatmap, @@ -111,5 +111,13 @@ namespace osu.Game.Modes.Osu } protected override PlayMode PlayMode => PlayMode.Osu; + + public override KeyCounter[] GameplayKeys => new KeyCounter[] + { + new KeyCounterKeyboard(Key.Z), + new KeyCounterKeyboard(Key.X), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; } } diff --git a/osu.Game.Modes.Osu/UI/OsuComboCounter.cs b/osu.Game.Modes.Osu/UI/OsuComboCounter.cs deleted file mode 100644 index fe24b021a6..0000000000 --- a/osu.Game.Modes.Osu/UI/OsuComboCounter.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Modes.UI; -using OpenTK; - -namespace osu.Game.Modes.Osu.UI -{ - /// - /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard. - /// - public class OsuComboCounter : 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.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 0571ec2956..ea03841b82 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -74,7 +74,6 @@ - @@ -85,7 +84,6 @@ - diff --git a/osu.Game.Modes.Taiko/Objects/DrumHit.cs b/osu.Game.Modes.Taiko/Objects/DrumHit.cs new file mode 100644 index 0000000000..f3fac33f76 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/DrumHit.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Game.Modes.Taiko.Objects +{ + class DrumHit + { + } +} diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index 585b3e97b0..19432e5383 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -1,20 +1,19 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; +using osu.Game.Screens.Play; using System.Collections.Generic; namespace osu.Game.Modes.Taiko { public class TaikoRuleset : Ruleset { - public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new TaikoHitRenderer { Beatmap = beatmap, @@ -81,6 +80,14 @@ namespace osu.Game.Modes.Taiko public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; + public override KeyCounter[] GameplayKeys => new KeyCounter[] + { + new KeyCounterKeyboard(Key.D), + new KeyCounterKeyboard(Key.F), + new KeyCounterKeyboard(Key.J), + new KeyCounterKeyboard(Key.K) + }; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 35f5a2d686..ab9ebfa1c7 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index fefba6caf8..d373b62a21 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -1,13 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; -using osu.Game.Modes.Objects; -using osu.Game.Modes.UI; -using System; -using System.Collections.Concurrent; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Objects; +using osu.Game.Modes.UI; +using osu.Game.Screens.Play; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; namespace osu.Game.Modes { @@ -20,9 +21,9 @@ namespace osu.Game.Modes public abstract class Ruleset { - private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); + public abstract KeyCounter[] GameplayKeys { get; } - public abstract ScoreOverlay CreateScoreOverlay(); + private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; diff --git a/osu.Game/Modes/UI/BaseComboCounter.cs b/osu.Game/Modes/UI/BaseComboCounter.cs new file mode 100644 index 0000000000..73e8226c19 --- /dev/null +++ b/osu.Game/Modes/UI/BaseComboCounter.cs @@ -0,0 +1,267 @@ +// 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 a549246011..7724b44940 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -1,267 +1,140 @@ // 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; +using OpenTK; namespace osu.Game.Modes.UI { - public abstract class ComboCounter : Container + /// + /// Uses the 'x' symbol and has a pop-out effect while rolling over. + /// + public class ComboCounter : BaseComboCounter { - public bool IsRolling - { - get; protected set; - } + protected uint ScheduledPopOutCurrentId; - protected SpriteText PopOutCount; + protected virtual float PopOutSmallScale => 1.1f; + protected virtual bool CanPopOutWhileRolling => false; - 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; - } + public new Vector2 PopOutScale = new Vector2(1.6f); protected override void LoadComplete() { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Count); - DisplayedCountSpriteText.Anchor = Anchor; - DisplayedCountSpriteText.Origin = Origin; - - StopRolling(); + PopOutCount.Origin = Origin; + PopOutCount.Anchor = Anchor; } - /// - /// Stops rollover animation, forcing the displayed count to be the actual count. - /// - public void StopRolling() + protected override string FormatCount(ulong count) { - updateCount(Count); + return $@"{count}x"; } - /// - /// Animates roll-up/roll-back to an specific value. - /// - /// Target value. - public virtual void Roll(ulong newValue = 0) + protected virtual void TransformPopOut(ulong newValue) { - updateCount(newValue, true); + 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); } - /// - /// Resets count to default value. - /// - public virtual void ResetCount() + protected virtual void TransformPopOutRolling(ulong newValue) { - updateCount(0); + TransformPopOut(newValue); + TransformPopOutSmall(newValue); } - protected virtual string FormatCount(ulong count) + protected virtual void TransformNoPopOut(ulong newValue) { - return count.ToString(); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(1); } - 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) + protected virtual void TransformPopOutSmall(ulong newValue) { - transformRoll(new TransformComboRoll(), currentValue, newValue); + DisplayedCountSpriteText.Text = FormatCount(newValue); + DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); + DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); } - 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) + protected virtual void ScheduledPopOutSmall(uint id) { - 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) + // Too late; scheduled task invalidated + if (id != ScheduledPopOutCurrentId) return; - if (!rolling) - { - Flush(false, typeof(TransformComboRoll)); - IsRolling = false; - DisplayedCount = prevCount; + DisplayedCount++; + } - if (prevCount + 1 == count) - OnCountIncrement(prevCount, count); - else - OnCountChange(prevCount, count); - } + 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 - { - OnCountRolling(displayedCount, count); - IsRolling = true; - } - } + DisplayedCountSpriteText.Show(); - 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(); + if (CanPopOutWhileRolling) + TransformPopOutRolling(newValue); else - Count = value; + 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/ScoreOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs similarity index 87% rename from osu.Game/Modes/UI/ScoreOverlay.cs rename to osu.Game/Modes/UI/HUDOverlay.cs index 09f34d4c2e..dc8ea5103c 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -1,24 +1,24 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; +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; -using OpenTK; -using osu.Framework.Graphics.Primitives; using osu.Game.Screens.Play; -using osu.Framework.Allocation; -using osu.Game.Configuration; -using osu.Framework.Configuration; +using System; namespace osu.Game.Modes.UI { - public abstract class ScoreOverlay : Container + internal abstract class HUDOverlay : Container { public KeyCounterCollection KeyCounter; - public ComboCounter ComboCounter; + public BaseComboCounter ComboCounter; public ScoreCounter ScoreCounter; public PercentageCounter AccuracyCounter; public HealthDisplay HealthDisplay; @@ -26,8 +26,8 @@ namespace osu.Game.Modes.UI private Bindable showKeyCounter; - protected abstract KeyCounterCollection CreateKeyCounter(); - protected abstract ComboCounter CreateComboCounter(); + protected abstract KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters); + protected abstract BaseComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); protected virtual HealthDisplay CreateHealthDisplay() => new HealthDisplay @@ -50,12 +50,13 @@ namespace osu.Game.Modes.UI AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } - protected ScoreOverlay() + protected HUDOverlay(Ruleset ruleset) { RelativeSizeAxes = Axes.Both; - Children = new Drawable[] { - KeyCounter = CreateKeyCounter(), + Children = new Drawable[] + { + KeyCounter = CreateKeyCounter(ruleset.GameplayKeys), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), diff --git a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs similarity index 69% rename from osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs rename to osu.Game/Modes/UI/StandardHUDOverlay.cs index d91a751c26..09c53632a5 100644 --- a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -1,26 +1,21 @@ // 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.Game.Graphics.UserInterface; -using osu.Game.Modes.UI; + using OpenTK; -using OpenTK.Input; +using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Play; -namespace osu.Game.Modes.Osu.UI +namespace osu.Game.Modes.UI { - public class OsuScoreOverlay : ScoreOverlay + internal class StandardHUDOverlay : HUDOverlay { - protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) + public StandardHUDOverlay(Ruleset ruleset) + : base(ruleset) { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - TextSize = 40, - Position = new Vector2(0, 30), - Margin = new MarginPadding { Right = 5 }, - }; + } protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter { @@ -31,26 +26,29 @@ namespace osu.Game.Modes.Osu.UI Margin = new MarginPadding { Right = 5 }, }; - protected override ComboCounter CreateComboCounter() => new OsuComboCounter + protected override BaseComboCounter CreateComboCounter() => new ComboCounter { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, }; - protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection + protected override KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters) => new KeyCounterCollection { IsCounting = true, FadeTime = 50, Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Margin = new MarginPadding(10), - Children = new KeyCounter[] - { - new KeyCounterKeyboard(Key.Z), - new KeyCounterKeyboard(Key.X), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right), - } + Children = keyCounters + }; + + protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + TextSize = 40, + Position = new Vector2(0, 30), + Margin = new MarginPadding { Right = 5 }, }; } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index cb494ef79f..3119fd5d74 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -1,29 +1,29 @@ // 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.Audio; using osu.Framework.Audio.Track; -using osu.Framework.Graphics; -using osu.Framework.Timing; -using osu.Game.Database; -using osu.Game.Modes; -using osu.Game.Screens.Backgrounds; -using OpenTK; -using osu.Framework.Screens; -using osu.Game.Modes.UI; -using osu.Game.Screens.Ranking; -using osu.Game.Configuration; using osu.Framework.Configuration; -using System; -using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; -using OpenTK.Graphics; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Framework.Logging; +using osu.Framework.Screens; +using osu.Framework.Timing; +using osu.Game.Configuration; +using osu.Game.Database; using osu.Game.Input.Handlers; +using osu.Game.Modes; +using osu.Game.Modes.UI; +using osu.Game.Screens.Backgrounds; +using osu.Game.Screens.Ranking; +using System; +using System.Linq; namespace osu.Game.Screens.Play { @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play private Bindable dimLevel; private SkipButton skipButton; - private ScoreOverlay scoreOverlay; + private HUDOverlay hudOverlay; private PauseOverlay pauseOverlay; [BackgroundDependencyLoader] @@ -112,8 +112,8 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(Beatmap.PlayMode); - scoreOverlay = ruleset.CreateScoreOverlay(); - scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); + hudOverlay = new StandardHUDOverlay(ruleset); + hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay { @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Play hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler; } - scoreOverlay.BindHitRenderer(hitRenderer); + hudOverlay.BindHitRenderer(hitRenderer); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) hitRenderer.OnJudgement += scoreProcessor.AddJudgement; @@ -159,7 +159,7 @@ namespace osu.Game.Screens.Play }, } }, - scoreOverlay, + hudOverlay, pauseOverlay }; } @@ -196,7 +196,7 @@ namespace osu.Game.Screens.Play if (canPause || force) { lastPauseActionTime = Time.Current; - scoreOverlay.KeyCounter.IsCounting = false; + hudOverlay.KeyCounter.IsCounting = false; pauseOverlay.Retries = RestartCount; pauseOverlay.Show(); sourceClock.Stop(); @@ -211,7 +211,7 @@ namespace osu.Game.Screens.Play public void Resume() { lastPauseActionTime = Time.Current; - scoreOverlay.KeyCounter.IsCounting = true; + hudOverlay.KeyCounter.IsCounting = true; pauseOverlay.Hide(); sourceClock.Start(); IsPaused = false; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 61c31a6cee..d0f2d6f042 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -167,6 +167,8 @@ + + @@ -181,9 +183,9 @@ - + - + From 617ceb800115064c989902965b4a23b32a689dd5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 12:26:46 +0900 Subject: [PATCH 02/18] 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 @@ - + From 4cc032e1d73c2bc07fe060d82d5a82f2de637769 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 12:55:10 +0900 Subject: [PATCH 03/18] Make ComboCounter count a bindable, and properly bind it to the processor. --- .../Tests/TestCaseScoreCounter.cs | 7 +- osu.Game/Modes/Score.cs | 4 +- osu.Game/Modes/ScoreProcesssor.cs | 8 +- osu.Game/Modes/UI/ComboCounter.cs | 166 ++++++++---------- osu.Game/Modes/UI/HUDOverlay.cs | 2 +- osu.Game/Modes/UI/StandardComboCounter.cs | 22 +-- 6 files changed, 99 insertions(+), 110 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 59517beaf2..b21aee29d7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -45,7 +45,6 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Margin = new MarginPadding(10), - Count = 0, TextSize = 40, }; Add(comboCounter); @@ -79,7 +78,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Reset all", delegate { score.Count = 0; - comboCounter.Count = 0; + comboCounter.Current.Value = 0; numerator = denominator = 0; accuracyCounter.SetFraction(0, 0); stars.Count = 0; @@ -88,8 +87,8 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Hit! :D", delegate { - score.Count += 300 + (ulong)(300.0 * (comboCounter.Count > 0 ? comboCounter.Count - 1 : 0) / 25.0); - comboCounter.Count++; + score.Count += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0); + comboCounter.Increment(); numerator++; denominator++; accuracyCounter.SetFraction(numerator, denominator); }); diff --git a/osu.Game/Modes/Score.cs b/osu.Game/Modes/Score.cs index 1a761bea5d..8a06e8a60b 100644 --- a/osu.Game/Modes/Score.cs +++ b/osu.Game/Modes/Score.cs @@ -9,9 +9,9 @@ namespace osu.Game.Modes { public double TotalScore { get; set; } public double Accuracy { get; set; } - public double Combo { get; set; } - public double MaxCombo { get; set; } public double Health { get; set; } + public long Combo { get; set; } + public long MaxCombo { get; set; } public Replay Replay; public BeatmapInfo Beatmap; diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index 0433df66a9..ffae81fa82 100644 --- a/osu.Game/Modes/ScoreProcesssor.cs +++ b/osu.Game/Modes/ScoreProcesssor.cs @@ -1,10 +1,10 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; using osu.Framework.Configuration; using osu.Game.Modes.Objects.Drawables; +using System; +using System.Collections.Generic; namespace osu.Game.Modes { @@ -25,7 +25,7 @@ namespace osu.Game.Modes public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 }; - public readonly BindableInt Combo = new BindableInt(); + public readonly BindableLong Combo = new BindableLong(); /// /// Are we allowed to fail? @@ -43,7 +43,7 @@ namespace osu.Game.Modes /// Keeps track of the highest combo ever achieved in this play. /// This is handled automatically by ScoreProcessor. /// - public readonly BindableInt HighestCombo = new BindableInt(); + public readonly BindableLong HighestCombo = new BindableLong(); public readonly List Judgements; diff --git a/osu.Game/Modes/UI/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index b68489e37b..a276da3e5a 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -13,10 +14,12 @@ namespace osu.Game.Modes.UI { public abstract class ComboCounter : Container { - public bool IsRolling + public BindableLong Current = new BindableLong { - get; protected set; - } + MinValue = 0, + }; + + public bool IsRolling { get; protected set; } protected SpriteText PopOutCount; @@ -37,60 +40,9 @@ namespace osu.Game.Modes.UI /// 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; - } - } + private long previousValue; /// /// Base of all combo counters. @@ -113,32 +65,78 @@ namespace osu.Game.Modes.UI }; TextSize = 80; + + Current.ValueChanged += comboChanged; + } + + private void comboChanged(object sender, System.EventArgs e) + { + if (Current.Value == 0) + Roll(); + else + updateCount(Current); } protected override void LoadComplete() { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Count); + DisplayedCountSpriteText.Text = FormatCount(Current); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; StopRolling(); } + private long displayedCount; + /// + /// Value shown at the current moment. + /// + public virtual long DisplayedCount + { + get { return displayedCount; } + protected set + { + if (displayedCount.Equals(value)) + return; + updateDisplayedCount(displayedCount, value, IsRolling); + } + } + + private float textSize; + public float TextSize + { + get { return textSize; } + set + { + textSize = value; + DisplayedCountSpriteText.TextSize = TextSize; + PopOutCount.TextSize = TextSize; + } + } + + /// + /// Increments the combo by an amount. + /// + /// + public void Increment(long amount = 1) + { + Current.Value = Current + amount; + } + /// /// Stops rollover animation, forcing the displayed count to be the actual count. /// public void StopRolling() { - updateCount(Count); + updateCount(Current); } /// /// Animates roll-up/roll-back to an specific value. /// /// Target value. - public virtual void Roll(ulong newValue = 0) + public virtual void Roll(long newValue = 0) { updateCount(newValue, true); } @@ -151,37 +149,33 @@ namespace osu.Game.Modes.UI updateCount(0); } - protected virtual string FormatCount(ulong count) + protected virtual string FormatCount(long 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) + protected virtual void OnCountRolling(long currentValue, long newValue) { transformRoll(new TransformComboRoll(), currentValue, newValue); } - protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) + protected virtual void OnCountIncrement(long currentValue, long newValue) { DisplayedCount = newValue; } - protected virtual void OnCountChange(ulong currentValue, ulong newValue) + protected virtual void OnCountChange(long currentValue, long newValue) { DisplayedCount = newValue; } - private double getProportionalDuration(ulong currentValue, ulong newValue) + private double getProportionalDuration(long currentValue, long newValue) { double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; return difference * RollingDuration; } - private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling) + private void updateDisplayedCount(long currentValue, long newValue, bool rolling) { displayedCount = newValue; if (rolling) @@ -192,10 +186,10 @@ namespace osu.Game.Modes.UI OnDisplayedCountChange(newValue); } - private void updateCount(ulong value, bool rolling = false) + private void updateCount(long value, bool rolling = false) { - ulong prevCount = count; - count = value; + long prev = previousValue; + previousValue = Current.Value; if (!IsLoaded) return; @@ -204,27 +198,27 @@ namespace osu.Game.Modes.UI { Flush(false, typeof(TransformComboRoll)); IsRolling = false; - DisplayedCount = prevCount; + DisplayedCount = prev; - if (prevCount + 1 == count) - OnCountIncrement(prevCount, count); + if (prev + 1 == Current) + OnCountIncrement(prev, Current); else - OnCountChange(prevCount, count); + OnCountChange(prev, Current); } else { - OnCountRolling(displayedCount, count); + OnCountRolling(displayedCount, Current); IsRolling = true; } } - private void transformRoll(TransformComboRoll transform, ulong currentValue, ulong newValue) + private void transformRoll(TransformComboRoll transform, long currentValue, long newValue) { Flush(false, typeof(TransformComboRoll)); if (RollingDuration < 1) { - DisplayedCount = Count; + DisplayedCount = Current; return; } @@ -237,9 +231,9 @@ namespace osu.Game.Modes.UI Transforms.Add(transform); } - protected class TransformComboRoll : Transform + protected class TransformComboRoll : Transform { - protected override ulong CurrentValue + protected override long CurrentValue { get { @@ -247,7 +241,7 @@ namespace osu.Game.Modes.UI if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; - return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + return (long)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); } } @@ -258,12 +252,8 @@ namespace osu.Game.Modes.UI } } - public void Set(ulong value) - { - if (value == 0) - Roll(); - else - Count = value; - } + protected abstract void OnDisplayedCountRolling(long currentValue, long newValue); + protected abstract void OnDisplayedCountIncrement(long newValue); + protected abstract void OnDisplayedCountChange(long newValue); } } diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 241afea55c..23c4690ace 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -78,7 +78,7 @@ namespace osu.Game.Modes.UI //TODO: these should be bindable binds, not events! processor.TotalScore.ValueChanged += delegate { ScoreCounter?.Set((ulong)processor.TotalScore.Value); }; processor.Accuracy.ValueChanged += delegate { AccuracyCounter?.Set((float)processor.Accuracy.Value); }; - processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; + ComboCounter?.Current.BindTo(processor.Combo); HealthDisplay?.Current.BindTo(processor.Health); } diff --git a/osu.Game/Modes/UI/StandardComboCounter.cs b/osu.Game/Modes/UI/StandardComboCounter.cs index 488ab40d42..86b689fa89 100644 --- a/osu.Game/Modes/UI/StandardComboCounter.cs +++ b/osu.Game/Modes/UI/StandardComboCounter.cs @@ -25,12 +25,12 @@ namespace osu.Game.Modes.UI PopOutCount.Anchor = Anchor; } - protected override string FormatCount(ulong count) + protected override string FormatCount(long count) { return $@"{count}x"; } - protected virtual void TransformPopOut(ulong newValue) + protected virtual void TransformPopOut(long newValue) { PopOutCount.Text = FormatCount(newValue); @@ -43,19 +43,19 @@ namespace osu.Game.Modes.UI PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); } - protected virtual void TransformPopOutRolling(ulong newValue) + protected virtual void TransformPopOutRolling(long newValue) { TransformPopOut(newValue); TransformPopOutSmall(newValue); } - protected virtual void TransformNoPopOut(ulong newValue) + protected virtual void TransformNoPopOut(long newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(1); } - protected virtual void TransformPopOutSmall(ulong newValue) + protected virtual void TransformPopOutSmall(long newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); @@ -71,7 +71,7 @@ namespace osu.Game.Modes.UI DisplayedCount++; } - protected override void OnCountRolling(ulong currentValue, ulong newValue) + protected override void OnCountRolling(long currentValue, long newValue) { ScheduledPopOutCurrentId++; @@ -82,7 +82,7 @@ namespace osu.Game.Modes.UI base.OnCountRolling(currentValue, newValue); } - protected override void OnCountIncrement(ulong currentValue, ulong newValue) + protected override void OnCountIncrement(long currentValue, long newValue) { ScheduledPopOutCurrentId++; @@ -100,7 +100,7 @@ namespace osu.Game.Modes.UI }, PopOutDuration); } - protected override void OnCountChange(ulong currentValue, ulong newValue) + protected override void OnCountChange(long currentValue, long newValue) { ScheduledPopOutCurrentId++; @@ -110,7 +110,7 @@ namespace osu.Game.Modes.UI base.OnCountChange(currentValue, newValue); } - protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) + protected override void OnDisplayedCountRolling(long currentValue, long newValue) { if (newValue == 0) DisplayedCountSpriteText.FadeOut(FadeOutDuration); @@ -123,14 +123,14 @@ namespace osu.Game.Modes.UI TransformNoPopOut(newValue); } - protected override void OnDisplayedCountChange(ulong newValue) + protected override void OnDisplayedCountChange(long newValue) { DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); TransformNoPopOut(newValue); } - protected override void OnDisplayedCountIncrement(ulong newValue) + protected override void OnDisplayedCountIncrement(long newValue) { DisplayedCountSpriteText.Show(); From 444c645da0b8075936f31b5f883363310e6e61fe Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:02:50 +0900 Subject: [PATCH 04/18] General fixes. --- osu.Game/Modes/UI/HUDOverlay.cs | 4 ++-- osu.Game/Modes/UI/HealthDisplay.cs | 6 +++--- osu.Game/Modes/UI/StandardHUDOverlay.cs | 4 ++-- osu.Game/Modes/UI/StandardHealthDisplay.cs | 4 ++-- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/osu.Game.csproj | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 23c4690ace..9dbccffdbd 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -13,7 +13,7 @@ using System; namespace osu.Game.Modes.UI { - internal abstract class HUDOverlay : Container + internal abstract class HudOverlay : Container { public readonly KeyCounterCollection KeyCounter; public readonly ComboCounter ComboCounter; @@ -42,7 +42,7 @@ namespace osu.Game.Modes.UI AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } - protected HUDOverlay(Ruleset ruleset) + protected HudOverlay(Ruleset ruleset) { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index ddc4bcfaa6..b920dcd68a 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -14,11 +14,11 @@ namespace osu.Game.Modes.UI MaxValue = 1 }; - public HealthDisplay() + protected HealthDisplay() { - Current.ValueChanged += (s, e) => setHP((float)Current); + Current.ValueChanged += (s, e) => SetHP((float)Current); } - protected abstract void setHP(float value); + protected abstract void SetHP(float value); } } diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs index 7bbe9a41f1..5d39d518d3 100644 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -10,9 +10,9 @@ using osu.Game.Screens.Play; namespace osu.Game.Modes.UI { - internal class StandardHUDOverlay : HUDOverlay + internal class StandardHudOverlay : HudOverlay { - public StandardHUDOverlay(Ruleset ruleset) + public StandardHudOverlay(Ruleset ruleset) : base(ruleset) { } diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index 3357b93aed..11b0bcd0c0 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -14,7 +14,7 @@ using osu.Game.Graphics; namespace osu.Game.Modes.UI { - class StandardHealthDisplay : HealthDisplay + internal class StandardHealthDisplay : HealthDisplay { private Container fill; @@ -55,6 +55,6 @@ namespace osu.Game.Modes.UI }; } - protected override void setHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + protected override void SetHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3119fd5d74..6a5f5f948e 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play private Bindable dimLevel; private SkipButton skipButton; - private HUDOverlay hudOverlay; + private HudOverlay hudOverlay; private PauseOverlay pauseOverlay; [BackgroundDependencyLoader] @@ -112,7 +112,7 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(Beatmap.PlayMode); - hudOverlay = new StandardHUDOverlay(ruleset); + hudOverlay = new StandardHudOverlay(ruleset); hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 98a23ceec3..638f6e76c5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -169,7 +169,7 @@ - + @@ -184,7 +184,7 @@ - + From 7c1a3067e66b721599c9b049106df44802a5de6b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:03:13 +0900 Subject: [PATCH 05/18] Oops o_o. --- osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index ab9ebfa1c7..35f5a2d686 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -47,7 +47,6 @@ - From 4015b879653790b07caffb90d9eb309d53ac229a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:02:50 +0900 Subject: [PATCH 06/18] General fixes. --- osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs | 1 - osu.Game/Modes/UI/HUDOverlay.cs | 4 ++-- osu.Game/Modes/UI/HealthDisplay.cs | 6 +++--- osu.Game/Modes/UI/StandardHUDOverlay.cs | 4 ++-- osu.Game/Modes/UI/StandardHealthDisplay.cs | 4 ++-- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/osu.Game.csproj | 4 ++-- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index ee60aa61a7..3beddff814 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 241afea55c..d392765e47 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -13,7 +13,7 @@ using System; namespace osu.Game.Modes.UI { - internal abstract class HUDOverlay : Container + internal abstract class HudOverlay : Container { public readonly KeyCounterCollection KeyCounter; public readonly ComboCounter ComboCounter; @@ -42,7 +42,7 @@ namespace osu.Game.Modes.UI AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } - protected HUDOverlay(Ruleset ruleset) + protected HudOverlay(Ruleset ruleset) { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index ddc4bcfaa6..b920dcd68a 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -14,11 +14,11 @@ namespace osu.Game.Modes.UI MaxValue = 1 }; - public HealthDisplay() + protected HealthDisplay() { - Current.ValueChanged += (s, e) => setHP((float)Current); + Current.ValueChanged += (s, e) => SetHP((float)Current); } - protected abstract void setHP(float value); + protected abstract void SetHP(float value); } } diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs index 7bbe9a41f1..5d39d518d3 100644 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -10,9 +10,9 @@ using osu.Game.Screens.Play; namespace osu.Game.Modes.UI { - internal class StandardHUDOverlay : HUDOverlay + internal class StandardHudOverlay : HudOverlay { - public StandardHUDOverlay(Ruleset ruleset) + public StandardHudOverlay(Ruleset ruleset) : base(ruleset) { } diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index 3357b93aed..11b0bcd0c0 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -14,7 +14,7 @@ using osu.Game.Graphics; namespace osu.Game.Modes.UI { - class StandardHealthDisplay : HealthDisplay + internal class StandardHealthDisplay : HealthDisplay { private Container fill; @@ -55,6 +55,6 @@ namespace osu.Game.Modes.UI }; } - protected override void setHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + protected override void SetHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3119fd5d74..6a5f5f948e 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play private Bindable dimLevel; private SkipButton skipButton; - private HUDOverlay hudOverlay; + private HudOverlay hudOverlay; private PauseOverlay pauseOverlay; [BackgroundDependencyLoader] @@ -112,7 +112,7 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(Beatmap.PlayMode); - hudOverlay = new StandardHUDOverlay(ruleset); + hudOverlay = new StandardHudOverlay(ruleset); hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 98a23ceec3..638f6e76c5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -169,7 +169,7 @@ - + @@ -184,7 +184,7 @@ - + From 2d6e667c7c3c2d39d9899fd8251ff0bedffb04c7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:40:44 +0900 Subject: [PATCH 07/18] Renaming + use IEnumerable. --- osu.Game.Modes.Catch/CatchRuleset.cs | 3 ++- osu.Game.Modes.Mania/ManiaRuleset.cs | 2 +- osu.Game.Modes.Osu/OsuRuleset.cs | 2 +- osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 +- osu.Game/Modes/Ruleset.cs | 2 +- osu.Game/Modes/UI/HUDOverlay.cs | 5 +++-- osu.Game/Modes/UI/StandardHUDOverlay.cs | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index b552278cec..32dcedb784 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -80,7 +80,8 @@ namespace osu.Game.Modes.Catch public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; - public override KeyCounter[] GameplayKeys => new KeyCounter[] + + public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] { new KeyCounterKeyboard(Key.ShiftLeft), new KeyCounterMouse(MouseButton.Left), diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 51a33ce7bc..d31588f92c 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -100,7 +100,7 @@ namespace osu.Game.Modes.Mania public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; - public override KeyCounter[] GameplayKeys => new KeyCounter[] { /* Todo: Should be keymod specific */ }; + public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] { /* Todo: Should be keymod specific */ }; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 72c4b6988c..e6d828fb9a 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -112,7 +112,7 @@ namespace osu.Game.Modes.Osu protected override PlayMode PlayMode => PlayMode.Osu; - public override KeyCounter[] GameplayKeys => new KeyCounter[] + public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] { new KeyCounterKeyboard(Key.Z), new KeyCounterKeyboard(Key.X), diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index 19432e5383..733c89c7c1 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -80,7 +80,7 @@ namespace osu.Game.Modes.Taiko public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; - public override KeyCounter[] GameplayKeys => new KeyCounter[] + public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] { new KeyCounterKeyboard(Key.D), new KeyCounterKeyboard(Key.F), diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index d373b62a21..69b0d2fbb3 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -21,7 +21,7 @@ namespace osu.Game.Modes public abstract class Ruleset { - public abstract KeyCounter[] GameplayKeys { get; } + public abstract KeyCounter[] CreateGameplayKeys { get; } private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index d392765e47..e9b31dc519 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Modes.Objects; using osu.Game.Screens.Play; using System; +using System.Collections.Generic; namespace osu.Game.Modes.UI { @@ -23,7 +24,7 @@ namespace osu.Game.Modes.UI private Bindable showKeyCounter; - protected abstract KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters); + protected abstract KeyCounterCollection CreateKeyCounter(IEnumerable keyCounters); protected abstract ComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); @@ -48,7 +49,7 @@ namespace osu.Game.Modes.UI Children = new Drawable[] { - KeyCounter = CreateKeyCounter(ruleset.GameplayKeys), + KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs index 5d39d518d3..b67a1d72b1 100644 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Play; +using System.Collections.Generic; namespace osu.Game.Modes.UI { @@ -39,7 +40,7 @@ namespace osu.Game.Modes.UI Margin = new MarginPadding { Top = 20 } }; - protected override KeyCounterCollection CreateKeyCounter(KeyCounter[] keyCounters) => new KeyCounterCollection + protected override KeyCounterCollection CreateKeyCounter(IEnumerable keyCounters) => new KeyCounterCollection { IsCounting = true, FadeTime = 50, From 712739d7799125e69814e81ac742bcba6fd0fb26 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:58:17 +0900 Subject: [PATCH 08/18] s/SetHP/SetHealth. --- osu.Game/Modes/UI/HealthDisplay.cs | 4 ++-- osu.Game/Modes/UI/StandardHealthDisplay.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index b920dcd68a..3efda1cd4e 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -16,9 +16,9 @@ namespace osu.Game.Modes.UI protected HealthDisplay() { - Current.ValueChanged += (s, e) => SetHP((float)Current); + Current.ValueChanged += (s, e) => SetHealth((float)Current); } - protected abstract void SetHP(float value); + protected abstract void SetHealth(float value); } } diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index 11b0bcd0c0..ca4a1410ab 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -55,6 +55,6 @@ namespace osu.Game.Modes.UI }; } - protected override void SetHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + protected override void SetHealth(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); } } From ff3faeaf40ad073ef930b393c9f9bb7ae61bc82e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:01:54 +0900 Subject: [PATCH 09/18] Fix silly spelling mistake. --- osu.Game/Modes/UI/StandardHealthDisplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index ca4a1410ab..a90e16b743 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -44,7 +44,7 @@ namespace osu.Game.Modes.UI } [BackgroundDependencyLoader] - private void laod(OsuColour colours) + private void load(OsuColour colours) { fill.Colour = colours.BlueLighter; fill.EdgeEffect = new EdgeEffect From 2fb5334d09eabed8c990fc5153c381e6fefbec65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:15:56 +0900 Subject: [PATCH 10/18] Why tho? --- osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index ab9ebfa1c7..35f5a2d686 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -47,7 +47,6 @@ - From b56d7f19e0713a38b2dabfd864ba592389c80587 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:23:57 +0900 Subject: [PATCH 11/18] Remove DrumHit. --- osu.Game.Modes.Taiko/Objects/DrumHit.cs | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 osu.Game.Modes.Taiko/Objects/DrumHit.cs diff --git a/osu.Game.Modes.Taiko/Objects/DrumHit.cs b/osu.Game.Modes.Taiko/Objects/DrumHit.cs deleted file mode 100644 index f3fac33f76..0000000000 --- a/osu.Game.Modes.Taiko/Objects/DrumHit.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace osu.Game.Modes.Taiko.Objects -{ - class DrumHit - { - } -} From 605326e8f6a43dc342ba05c997d9fdbaff059b65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:34:08 +0900 Subject: [PATCH 12/18] More ComboCounter fixups + refactorings. --- .../Tests/TestCaseScoreCounter.cs | 3 +- osu.Game/Modes/UI/ComboCounter.cs | 28 +++---------------- osu.Game/Modes/UI/HUDOverlay.cs | 2 +- osu.Game/Modes/UI/HealthDisplay.cs | 4 +-- osu.Game/Modes/UI/StandardHealthDisplay.cs | 2 +- 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 011f5e07a3..774d1e00d3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; namespace osu.Desktop.VisualTests.Tests @@ -90,7 +89,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"miss...", delegate { - comboCounter.Roll(); + comboCounter.Current.Value = 0; denominator++; accuracyCounter.SetFraction(numerator, denominator); }); diff --git a/osu.Game/Modes/UI/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index a276da3e5a..75d22ed0ad 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -71,10 +71,7 @@ namespace osu.Game.Modes.UI private void comboChanged(object sender, System.EventArgs e) { - if (Current.Value == 0) - Roll(); - else - updateCount(Current); + updateCount(Current.Value == 0); } protected override void LoadComplete() @@ -129,24 +126,7 @@ namespace osu.Game.Modes.UI /// public void StopRolling() { - updateCount(Current); - } - - /// - /// Animates roll-up/roll-back to an specific value. - /// - /// Target value. - public virtual void Roll(long newValue = 0) - { - updateCount(newValue, true); - } - - /// - /// Resets count to default value. - /// - public virtual void ResetCount() - { - updateCount(0); + updateCount(false); } protected virtual string FormatCount(long count) @@ -186,10 +166,10 @@ namespace osu.Game.Modes.UI OnDisplayedCountChange(newValue); } - private void updateCount(long value, bool rolling = false) + private void updateCount(bool rolling) { long prev = previousValue; - previousValue = Current.Value; + previousValue = Current; if (!IsLoaded) return; diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 9dbccffdbd..0baea91bce 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -38,7 +38,7 @@ namespace osu.Game.Modes.UI public virtual void OnMiss(HitObject h) { - ComboCounter?.Roll(); + ComboCounter.Current.Value = 0; AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index b920dcd68a..3efda1cd4e 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -16,9 +16,9 @@ namespace osu.Game.Modes.UI protected HealthDisplay() { - Current.ValueChanged += (s, e) => SetHP((float)Current); + Current.ValueChanged += (s, e) => SetHealth((float)Current); } - protected abstract void SetHP(float value); + protected abstract void SetHealth(float value); } } diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index 11b0bcd0c0..ca4a1410ab 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -55,6 +55,6 @@ namespace osu.Game.Modes.UI }; } - protected override void SetHP(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + protected override void SetHealth(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); } } From 58a88cc715e893176dc63a0dbd07ec031da5ff51 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:42:14 +0900 Subject: [PATCH 13/18] More general refactorings. --- osu.Game.Modes.Catch/CatchRuleset.cs | 14 ++- osu.Game.Modes.Mania/ManiaRuleset.cs | 5 +- osu.Game.Modes.Osu/OsuRuleset.cs | 16 ++- osu.Game.Modes.Osu/OsuRuleset.cs.orig | 128 +++++++++++++++++++++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 15 ++- osu.Game/Modes/Ruleset.cs | 5 +- osu.Game/Modes/Ruleset.cs.orig | 69 +++++++++++ osu.Game/Modes/UI/HUDOverlay.cs | 4 +- osu.Game/Modes/UI/HealthDisplay.cs | 2 +- osu.Game/Modes/UI/StandardHUDOverlay.cs | 3 +- osu.Game/Modes/UI/StandardHealthDisplay.cs | 2 +- 11 files changed, 235 insertions(+), 28 deletions(-) create mode 100644 osu.Game.Modes.Osu/OsuRuleset.cs.orig create mode 100644 osu.Game/Modes/Ruleset.cs.orig diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index cefcfe4299..e2753cb62d 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -82,13 +82,15 @@ namespace osu.Game.Modes.Catch public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; - - public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] + public override IEnumerable CreateGameplayKeys() { - new KeyCounterKeyboard(Key.ShiftLeft), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right) - }; + return new KeyCounter[] + { + new KeyCounterKeyboard(Key.ShiftLeft), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; + } public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 81307b2a53..8ca13d7512 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -102,7 +102,10 @@ namespace osu.Game.Modes.Mania public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; - public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] { /* Todo: Should be keymod specific */ }; + public override IEnumerable CreateGameplayKeys() + { + return new KeyCounter[] { /* Todo: Should be keymod specific */ }; + } public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 5fd35df4d1..d7fdc972f0 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -113,12 +113,16 @@ namespace osu.Game.Modes.Osu protected override PlayMode PlayMode => PlayMode.Osu; public override string Description => "osu!"; - public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] + + public override IEnumerable CreateGameplayKeys() { - new KeyCounterKeyboard(Key.Z), - new KeyCounterKeyboard(Key.X), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right) - }; + return new KeyCounter[] + { + new KeyCounterKeyboard(Key.Z), + new KeyCounterKeyboard(Key.X), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; + } } } diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs.orig b/osu.Game.Modes.Osu/OsuRuleset.cs.orig new file mode 100644 index 0000000000..014b0cedab --- /dev/null +++ b/osu.Game.Modes.Osu/OsuRuleset.cs.orig @@ -0,0 +1,128 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Input; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Modes.Objects; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Modes.Osu.UI; +using osu.Game.Modes.UI; +using osu.Game.Screens.Play; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Modes.Osu +{ + public class OsuRuleset : Ruleset + { + public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer + { + Beatmap = beatmap, + }; + + public override IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] + { + new BeatmapStatistic + { + Name = @"Circle count", + Content = beatmap.Beatmap.HitObjects.Count(h => h is HitCircle).ToString(), + Icon = FontAwesome.fa_dot_circle_o + }, + new BeatmapStatistic + { + Name = @"Slider count", + Content = beatmap.Beatmap.HitObjects.Count(h => h is Slider).ToString(), + Icon = FontAwesome.fa_circle_o + } + }; + + public override IEnumerable GetModsFor(ModType type) + { + switch (type) + { + case ModType.DifficultyReduction: + return new Mod[] + { + new OsuModEasy(), + new OsuModNoFail(), + new OsuModHalfTime(), + }; + + case ModType.DifficultyIncrease: + return new Mod[] + { + new OsuModHardRock(), + new MultiMod + { + Mods = new Mod[] + { + new OsuModSuddenDeath(), + new OsuModPerfect(), + }, + }, + new MultiMod + { + Mods = new Mod[] + { + new OsuModDoubleTime(), + new OsuModNightcore(), + }, + }, + new OsuModHidden(), + new OsuModFlashlight(), + }; + + case ModType.Special: + return new Mod[] + { + new OsuModRelax(), + new OsuModAutopilot(), + new OsuModSpunOut(), + new MultiMod + { + Mods = new Mod[] + { + new OsuModAutoplay(), + new ModCinema(), + }, + }, + new OsuModTarget(), + }; + + default: + return new Mod[] { }; + } + } + + public override FontAwesome Icon => FontAwesome.fa_osu_osu_o; + + public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); + + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => new OsuScoreProcessor(hitObjectCount); + + public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); + + public override Score CreateAutoplayScore(Beatmap beatmap) + { + var score = CreateScoreProcessor().GetScore(); + score.Replay = new OsuAutoReplay(beatmap); + return score; + } + + protected override PlayMode PlayMode => PlayMode.Osu; + + public override string Description => "osu!"; +<<<<<<< HEAD + public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] +======= + public override KeyCounter[] GameplayKeys => new KeyCounter[] +>>>>>>> combocounter_bindable + { + new KeyCounterKeyboard(Key.Z), + new KeyCounterKeyboard(Key.X), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; + } +} diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index 3de7cf4b67..a2de092a07 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -82,13 +82,16 @@ namespace osu.Game.Modes.Taiko public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; - public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] + public override IEnumerable CreateGameplayKeys() { - new KeyCounterKeyboard(Key.D), - new KeyCounterKeyboard(Key.F), - new KeyCounterKeyboard(Key.J), - new KeyCounterKeyboard(Key.K) - }; + return new KeyCounter[] + { + new KeyCounterKeyboard(Key.D), + new KeyCounterKeyboard(Key.F), + new KeyCounterKeyboard(Key.J), + new KeyCounterKeyboard(Key.K) + }; + } public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index f6901469b3..d8892e64e9 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -21,13 +21,10 @@ namespace osu.Game.Modes public abstract class Ruleset { - public abstract KeyCounter[] CreateGameplayKeys { get; } - private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); public static IEnumerable PlayModes => availableRulesets.Keys; - public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; public abstract IEnumerable GetModsFor(ModType type); @@ -48,6 +45,8 @@ namespace osu.Game.Modes public abstract string Description { get; } + public abstract IEnumerable CreateGameplayKeys(); + public virtual Score CreateAutoplayScore(Beatmap beatmap) => null; public static Ruleset GetRuleset(PlayMode mode) diff --git a/osu.Game/Modes/Ruleset.cs.orig b/osu.Game/Modes/Ruleset.cs.orig new file mode 100644 index 0000000000..3b8d961029 --- /dev/null +++ b/osu.Game/Modes/Ruleset.cs.orig @@ -0,0 +1,69 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Modes.Objects; +using osu.Game.Modes.UI; +using osu.Game.Screens.Play; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; + +namespace osu.Game.Modes +{ + public class BeatmapStatistic + { + public FontAwesome Icon; + public string Content; + public string Name; + } + + public abstract class Ruleset + { + public abstract KeyCounter[] CreateGameplayKeys { get; } + + private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); +<<<<<<< HEAD + + public static IEnumerable PlayModes => availableRulesets.Keys; +======= + + public static IEnumerable PlayModes => availableRulesets.Keys; + +>>>>>>> combocounter_bindable + + public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; + + public abstract IEnumerable GetModsFor(ModType type); + + public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0); + + public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap); + + public abstract HitObjectParser CreateHitObjectParser(); + + public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); + + public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); + + protected abstract PlayMode PlayMode { get; } + + public virtual FontAwesome Icon => FontAwesome.fa_question_circle; + + public abstract string Description { get; } + + public virtual Score CreateAutoplayScore(Beatmap beatmap) => null; + + public static Ruleset GetRuleset(PlayMode mode) + { + Type type; + + if (!availableRulesets.TryGetValue(mode, out type)) + return null; + + return Activator.CreateInstance(type) as Ruleset; + } + + } +} diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 176ffc987e..a9eaeb07b6 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -14,7 +14,7 @@ using System.Collections.Generic; namespace osu.Game.Modes.UI { - internal abstract class HudOverlay : Container + public abstract class HudOverlay : Container { public readonly KeyCounterCollection KeyCounter; public readonly ComboCounter ComboCounter; @@ -49,7 +49,7 @@ namespace osu.Game.Modes.UI Children = new Drawable[] { - KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys), + KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys()), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), diff --git a/osu.Game/Modes/UI/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index 3efda1cd4e..3471f4bc3f 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; namespace osu.Game.Modes.UI { - internal abstract class HealthDisplay : Container + public abstract class HealthDisplay : Container { public readonly BindableDouble Current = new BindableDouble { diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs index b67a1d72b1..03db6f0bda 100644 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ b/osu.Game/Modes/UI/StandardHUDOverlay.cs @@ -1,7 +1,6 @@ // 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.Primitives; @@ -11,7 +10,7 @@ using System.Collections.Generic; namespace osu.Game.Modes.UI { - internal class StandardHudOverlay : HudOverlay + public class StandardHudOverlay : HudOverlay { public StandardHudOverlay(Ruleset ruleset) : base(ruleset) diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs index a90e16b743..b6a3dc7f89 100644 --- a/osu.Game/Modes/UI/StandardHealthDisplay.cs +++ b/osu.Game/Modes/UI/StandardHealthDisplay.cs @@ -14,7 +14,7 @@ using osu.Game.Graphics; namespace osu.Game.Modes.UI { - internal class StandardHealthDisplay : HealthDisplay + public class StandardHealthDisplay : HealthDisplay { private Container fill; From d3e14aad1b5712dd1f9f407d1e5c7f39ebef1ca1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:55:43 +0900 Subject: [PATCH 14/18] Use =>. --- osu.Game.Modes.Catch/CatchRuleset.cs | 13 +++++-------- osu.Game.Modes.Mania/ManiaRuleset.cs | 5 +---- osu.Game.Modes.Osu/OsuRuleset.cs | 15 ++++++--------- osu.Game.Modes.Taiko/TaikoRuleset.cs | 15 ++++++--------- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index e2753cb62d..41f592aa9d 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -82,15 +82,12 @@ namespace osu.Game.Modes.Catch public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; - public override IEnumerable CreateGameplayKeys() + public override IEnumerable CreateGameplayKeys() => new KeyCounter[] { - return new KeyCounter[] - { - new KeyCounterKeyboard(Key.ShiftLeft), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right) - }; - } + new KeyCounterKeyboard(Key.ShiftLeft), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 8ca13d7512..0b69fea746 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -102,10 +102,7 @@ namespace osu.Game.Modes.Mania public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; - public override IEnumerable CreateGameplayKeys() - { - return new KeyCounter[] { /* Todo: Should be keymod specific */ }; - } + public override IEnumerable CreateGameplayKeys() => new KeyCounter[] { /* Todo: Should be keymod specific */ }; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index d7fdc972f0..566a22b6ad 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -114,15 +114,12 @@ namespace osu.Game.Modes.Osu public override string Description => "osu!"; - public override IEnumerable CreateGameplayKeys() + public override IEnumerable CreateGameplayKeys() => new KeyCounter[] { - return new KeyCounter[] - { - new KeyCounterKeyboard(Key.Z), - new KeyCounterKeyboard(Key.X), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right) - }; - } + new KeyCounterKeyboard(Key.Z), + new KeyCounterKeyboard(Key.X), + new KeyCounterMouse(MouseButton.Left), + new KeyCounterMouse(MouseButton.Right) + }; } } diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index a2de092a07..e88c9cee86 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -82,16 +82,13 @@ namespace osu.Game.Modes.Taiko public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; - public override IEnumerable CreateGameplayKeys() + public override IEnumerable CreateGameplayKeys() => new KeyCounter[] { - return new KeyCounter[] - { - new KeyCounterKeyboard(Key.D), - new KeyCounterKeyboard(Key.F), - new KeyCounterKeyboard(Key.J), - new KeyCounterKeyboard(Key.K) - }; - } + new KeyCounterKeyboard(Key.D), + new KeyCounterKeyboard(Key.F), + new KeyCounterKeyboard(Key.J), + new KeyCounterKeyboard(Key.K) + }; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; From eca980bb9530d4901b277231e32fef0263050b40 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 15:57:14 +0900 Subject: [PATCH 15/18] Remove .orig files (not sure how they got here). --- osu.Game.Modes.Osu/OsuRuleset.cs.orig | 128 -------------------------- osu.Game/Modes/Ruleset.cs.orig | 69 -------------- 2 files changed, 197 deletions(-) delete mode 100644 osu.Game.Modes.Osu/OsuRuleset.cs.orig delete mode 100644 osu.Game/Modes/Ruleset.cs.orig diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs.orig b/osu.Game.Modes.Osu/OsuRuleset.cs.orig deleted file mode 100644 index 014b0cedab..0000000000 --- a/osu.Game.Modes.Osu/OsuRuleset.cs.orig +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK.Input; -using osu.Game.Beatmaps; -using osu.Game.Graphics; -using osu.Game.Modes.Objects; -using osu.Game.Modes.Osu.Objects; -using osu.Game.Modes.Osu.UI; -using osu.Game.Modes.UI; -using osu.Game.Screens.Play; -using System.Collections.Generic; -using System.Linq; - -namespace osu.Game.Modes.Osu -{ - public class OsuRuleset : Ruleset - { - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer - { - Beatmap = beatmap, - }; - - public override IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] - { - new BeatmapStatistic - { - Name = @"Circle count", - Content = beatmap.Beatmap.HitObjects.Count(h => h is HitCircle).ToString(), - Icon = FontAwesome.fa_dot_circle_o - }, - new BeatmapStatistic - { - Name = @"Slider count", - Content = beatmap.Beatmap.HitObjects.Count(h => h is Slider).ToString(), - Icon = FontAwesome.fa_circle_o - } - }; - - public override IEnumerable GetModsFor(ModType type) - { - switch (type) - { - case ModType.DifficultyReduction: - return new Mod[] - { - new OsuModEasy(), - new OsuModNoFail(), - new OsuModHalfTime(), - }; - - case ModType.DifficultyIncrease: - return new Mod[] - { - new OsuModHardRock(), - new MultiMod - { - Mods = new Mod[] - { - new OsuModSuddenDeath(), - new OsuModPerfect(), - }, - }, - new MultiMod - { - Mods = new Mod[] - { - new OsuModDoubleTime(), - new OsuModNightcore(), - }, - }, - new OsuModHidden(), - new OsuModFlashlight(), - }; - - case ModType.Special: - return new Mod[] - { - new OsuModRelax(), - new OsuModAutopilot(), - new OsuModSpunOut(), - new MultiMod - { - Mods = new Mod[] - { - new OsuModAutoplay(), - new ModCinema(), - }, - }, - new OsuModTarget(), - }; - - default: - return new Mod[] { }; - } - } - - public override FontAwesome Icon => FontAwesome.fa_osu_osu_o; - - public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); - - public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => new OsuScoreProcessor(hitObjectCount); - - public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); - - public override Score CreateAutoplayScore(Beatmap beatmap) - { - var score = CreateScoreProcessor().GetScore(); - score.Replay = new OsuAutoReplay(beatmap); - return score; - } - - protected override PlayMode PlayMode => PlayMode.Osu; - - public override string Description => "osu!"; -<<<<<<< HEAD - public override KeyCounter[] CreateGameplayKeys => new KeyCounter[] -======= - public override KeyCounter[] GameplayKeys => new KeyCounter[] ->>>>>>> combocounter_bindable - { - new KeyCounterKeyboard(Key.Z), - new KeyCounterKeyboard(Key.X), - new KeyCounterMouse(MouseButton.Left), - new KeyCounterMouse(MouseButton.Right) - }; - } -} diff --git a/osu.Game/Modes/Ruleset.cs.orig b/osu.Game/Modes/Ruleset.cs.orig deleted file mode 100644 index 3b8d961029..0000000000 --- a/osu.Game/Modes/Ruleset.cs.orig +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps; -using osu.Game.Graphics; -using osu.Game.Modes.Objects; -using osu.Game.Modes.UI; -using osu.Game.Screens.Play; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; - -namespace osu.Game.Modes -{ - public class BeatmapStatistic - { - public FontAwesome Icon; - public string Content; - public string Name; - } - - public abstract class Ruleset - { - public abstract KeyCounter[] CreateGameplayKeys { get; } - - private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); -<<<<<<< HEAD - - public static IEnumerable PlayModes => availableRulesets.Keys; -======= - - public static IEnumerable PlayModes => availableRulesets.Keys; - ->>>>>>> combocounter_bindable - - public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; - - public abstract IEnumerable GetModsFor(ModType type); - - public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0); - - public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap); - - public abstract HitObjectParser CreateHitObjectParser(); - - public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); - - public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); - - protected abstract PlayMode PlayMode { get; } - - public virtual FontAwesome Icon => FontAwesome.fa_question_circle; - - public abstract string Description { get; } - - public virtual Score CreateAutoplayScore(Beatmap beatmap) => null; - - public static Ruleset GetRuleset(PlayMode mode) - { - Type type; - - if (!availableRulesets.TryGetValue(mode, out type)) - return null; - - return Activator.CreateInstance(type) as Ruleset; - } - - } -} From 2bc36fecc61ff3424c36bb5084dc58b05b797b8e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 16:05:05 +0900 Subject: [PATCH 16/18] Combo should not be longs. --- osu.Game/Modes/Score.cs | 4 +-- osu.Game/Modes/ScoreProcesssor.cs | 4 +-- osu.Game/Modes/UI/ComboCounter.cs | 38 +++++++++++------------ osu.Game/Modes/UI/StandardComboCounter.cs | 22 ++++++------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/osu.Game/Modes/Score.cs b/osu.Game/Modes/Score.cs index 8a06e8a60b..4effe9affd 100644 --- a/osu.Game/Modes/Score.cs +++ b/osu.Game/Modes/Score.cs @@ -10,8 +10,8 @@ namespace osu.Game.Modes public double TotalScore { get; set; } public double Accuracy { get; set; } public double Health { get; set; } - public long Combo { get; set; } - public long MaxCombo { get; set; } + public int MaxCombo { get; set; } + public int Combo { get; set; } public Replay Replay; public BeatmapInfo Beatmap; diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index ffae81fa82..554996c145 100644 --- a/osu.Game/Modes/ScoreProcesssor.cs +++ b/osu.Game/Modes/ScoreProcesssor.cs @@ -25,7 +25,7 @@ namespace osu.Game.Modes public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 }; - public readonly BindableLong Combo = new BindableLong(); + public readonly BindableInt Combo = new BindableInt(); /// /// Are we allowed to fail? @@ -43,7 +43,7 @@ namespace osu.Game.Modes /// Keeps track of the highest combo ever achieved in this play. /// This is handled automatically by ScoreProcessor. /// - public readonly BindableLong HighestCombo = new BindableLong(); + public readonly BindableInt HighestCombo = new BindableInt(); public readonly List Judgements; diff --git a/osu.Game/Modes/UI/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index 75d22ed0ad..f831677e44 100644 --- a/osu.Game/Modes/UI/ComboCounter.cs +++ b/osu.Game/Modes/UI/ComboCounter.cs @@ -14,7 +14,7 @@ namespace osu.Game.Modes.UI { public abstract class ComboCounter : Container { - public BindableLong Current = new BindableLong + public BindableInt Current = new BindableInt { MinValue = 0, }; @@ -42,7 +42,7 @@ namespace osu.Game.Modes.UI protected SpriteText DisplayedCountSpriteText; - private long previousValue; + private int previousValue; /// /// Base of all combo counters. @@ -85,11 +85,11 @@ namespace osu.Game.Modes.UI StopRolling(); } - private long displayedCount; + private int displayedCount; /// /// Value shown at the current moment. /// - public virtual long DisplayedCount + public virtual int DisplayedCount { get { return displayedCount; } protected set @@ -116,7 +116,7 @@ namespace osu.Game.Modes.UI /// Increments the combo by an amount. /// /// - public void Increment(long amount = 1) + public void Increment(int amount = 1) { Current.Value = Current + amount; } @@ -129,33 +129,33 @@ namespace osu.Game.Modes.UI updateCount(false); } - protected virtual string FormatCount(long count) + protected virtual string FormatCount(int count) { return count.ToString(); } - protected virtual void OnCountRolling(long currentValue, long newValue) + protected virtual void OnCountRolling(int currentValue, int newValue) { transformRoll(new TransformComboRoll(), currentValue, newValue); } - protected virtual void OnCountIncrement(long currentValue, long newValue) + protected virtual void OnCountIncrement(int currentValue, int newValue) { DisplayedCount = newValue; } - protected virtual void OnCountChange(long currentValue, long newValue) + protected virtual void OnCountChange(int currentValue, int newValue) { DisplayedCount = newValue; } - private double getProportionalDuration(long currentValue, long newValue) + private double getProportionalDuration(int currentValue, int newValue) { double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; return difference * RollingDuration; } - private void updateDisplayedCount(long currentValue, long newValue, bool rolling) + private void updateDisplayedCount(int currentValue, int newValue, bool rolling) { displayedCount = newValue; if (rolling) @@ -168,7 +168,7 @@ namespace osu.Game.Modes.UI private void updateCount(bool rolling) { - long prev = previousValue; + int prev = previousValue; previousValue = Current; if (!IsLoaded) @@ -192,7 +192,7 @@ namespace osu.Game.Modes.UI } } - private void transformRoll(TransformComboRoll transform, long currentValue, long newValue) + private void transformRoll(TransformComboRoll transform, int currentValue, int newValue) { Flush(false, typeof(TransformComboRoll)); @@ -211,9 +211,9 @@ namespace osu.Game.Modes.UI Transforms.Add(transform); } - protected class TransformComboRoll : Transform + protected class TransformComboRoll : Transform { - protected override long CurrentValue + protected override int CurrentValue { get { @@ -221,7 +221,7 @@ namespace osu.Game.Modes.UI if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; - return (long)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + return (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); } } @@ -232,8 +232,8 @@ namespace osu.Game.Modes.UI } } - protected abstract void OnDisplayedCountRolling(long currentValue, long newValue); - protected abstract void OnDisplayedCountIncrement(long newValue); - protected abstract void OnDisplayedCountChange(long newValue); + protected abstract void OnDisplayedCountRolling(int currentValue, int newValue); + protected abstract void OnDisplayedCountIncrement(int newValue); + protected abstract void OnDisplayedCountChange(int newValue); } } diff --git a/osu.Game/Modes/UI/StandardComboCounter.cs b/osu.Game/Modes/UI/StandardComboCounter.cs index 86b689fa89..08bb3add84 100644 --- a/osu.Game/Modes/UI/StandardComboCounter.cs +++ b/osu.Game/Modes/UI/StandardComboCounter.cs @@ -25,12 +25,12 @@ namespace osu.Game.Modes.UI PopOutCount.Anchor = Anchor; } - protected override string FormatCount(long count) + protected override string FormatCount(int count) { return $@"{count}x"; } - protected virtual void TransformPopOut(long newValue) + protected virtual void TransformPopOut(int newValue) { PopOutCount.Text = FormatCount(newValue); @@ -43,19 +43,19 @@ namespace osu.Game.Modes.UI PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); } - protected virtual void TransformPopOutRolling(long newValue) + protected virtual void TransformPopOutRolling(int newValue) { TransformPopOut(newValue); TransformPopOutSmall(newValue); } - protected virtual void TransformNoPopOut(long newValue) + protected virtual void TransformNoPopOut(int newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(1); } - protected virtual void TransformPopOutSmall(long newValue) + protected virtual void TransformPopOutSmall(int newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); @@ -71,7 +71,7 @@ namespace osu.Game.Modes.UI DisplayedCount++; } - protected override void OnCountRolling(long currentValue, long newValue) + protected override void OnCountRolling(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -82,7 +82,7 @@ namespace osu.Game.Modes.UI base.OnCountRolling(currentValue, newValue); } - protected override void OnCountIncrement(long currentValue, long newValue) + protected override void OnCountIncrement(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -100,7 +100,7 @@ namespace osu.Game.Modes.UI }, PopOutDuration); } - protected override void OnCountChange(long currentValue, long newValue) + protected override void OnCountChange(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -110,7 +110,7 @@ namespace osu.Game.Modes.UI base.OnCountChange(currentValue, newValue); } - protected override void OnDisplayedCountRolling(long currentValue, long newValue) + protected override void OnDisplayedCountRolling(int currentValue, int newValue) { if (newValue == 0) DisplayedCountSpriteText.FadeOut(FadeOutDuration); @@ -123,14 +123,14 @@ namespace osu.Game.Modes.UI TransformNoPopOut(newValue); } - protected override void OnDisplayedCountChange(long newValue) + protected override void OnDisplayedCountChange(int newValue) { DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); TransformNoPopOut(newValue); } - protected override void OnDisplayedCountIncrement(long newValue) + protected override void OnDisplayedCountIncrement(int newValue) { DisplayedCountSpriteText.Show(); From 75a5da62d0027b4336ff1f08664b0fdebe3060c1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 16:11:07 +0900 Subject: [PATCH 17/18] Fix filenames. --- osu.Game/Modes/UI/{HUDOverlay.cs => HudOverlay.cs} | 0 .../Modes/UI/{StandardHUDOverlay.cs => StandardHudOverlay.cs} | 0 osu.Game/osu.Game.csproj | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename osu.Game/Modes/UI/{HUDOverlay.cs => HudOverlay.cs} (100%) rename osu.Game/Modes/UI/{StandardHUDOverlay.cs => StandardHudOverlay.cs} (100%) diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs similarity index 100% rename from osu.Game/Modes/UI/HUDOverlay.cs rename to osu.Game/Modes/UI/HudOverlay.cs diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs similarity index 100% rename from osu.Game/Modes/UI/StandardHUDOverlay.cs rename to osu.Game/Modes/UI/StandardHudOverlay.cs diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 638f6e76c5..81bc844872 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -97,7 +97,9 @@ + + @@ -169,7 +171,6 @@ - @@ -184,7 +185,6 @@ - From 529cabb001bc16a68d8f306269f93d1d122710e3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 16:16:07 +0900 Subject: [PATCH 18/18] Make HudOverlay not dependent on Ruleset. --- osu.Game/Modes/UI/HudOverlay.cs | 7 +++---- osu.Game/Modes/UI/StandardHudOverlay.cs | 9 +-------- osu.Game/Screens/Play/Player.cs | 3 ++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index a9eaeb07b6..2a17b5efd7 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -10,7 +10,6 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Modes.Objects; using osu.Game.Screens.Play; using System; -using System.Collections.Generic; namespace osu.Game.Modes.UI { @@ -24,7 +23,7 @@ namespace osu.Game.Modes.UI private Bindable showKeyCounter; - protected abstract KeyCounterCollection CreateKeyCounter(IEnumerable keyCounters); + protected abstract KeyCounterCollection CreateKeyCounter(); protected abstract ComboCounter CreateComboCounter(); protected abstract PercentageCounter CreateAccuracyCounter(); protected abstract ScoreCounter CreateScoreCounter(); @@ -43,13 +42,13 @@ namespace osu.Game.Modes.UI AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } - protected HudOverlay(Ruleset ruleset) + protected HudOverlay() { RelativeSizeAxes = Axes.Both; Children = new Drawable[] { - KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys()), + KeyCounter = CreateKeyCounter(), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs index 03db6f0bda..f77191adf7 100644 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -6,17 +6,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Play; -using System.Collections.Generic; namespace osu.Game.Modes.UI { public class StandardHudOverlay : HudOverlay { - public StandardHudOverlay(Ruleset ruleset) - : base(ruleset) - { - } - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter { Anchor = Anchor.TopCentre, @@ -39,14 +33,13 @@ namespace osu.Game.Modes.UI Margin = new MarginPadding { Top = 20 } }; - protected override KeyCounterCollection CreateKeyCounter(IEnumerable keyCounters) => new KeyCounterCollection + protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection { IsCounting = true, FadeTime = 50, Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, Margin = new MarginPadding(10), - Children = keyCounters }; protected override ScoreCounter CreateScoreCounter() => new ScoreCounter(6) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 6a5f5f948e..1a71543786 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -112,7 +112,8 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(Beatmap.PlayMode); - hudOverlay = new StandardHudOverlay(ruleset); + hudOverlay = new StandardHudOverlay(); + hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys()); hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay