From 427a0dd0f5ddbb8ae2e4fc0c72aa885763a4bcaa Mon Sep 17 00:00:00 2001 From: Lahvuun Date: Thu, 9 Mar 2017 22:29:39 +0200 Subject: [PATCH 01/40] Options sidebar flickering fix. --- osu.Game/Overlays/OptionsOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OptionsOverlay.cs b/osu.Game/Overlays/OptionsOverlay.cs index 463f21bcdd..53d8cb3593 100644 --- a/osu.Game/Overlays/OptionsOverlay.cs +++ b/osu.Game/Overlays/OptionsOverlay.cs @@ -147,8 +147,8 @@ namespace osu.Game.Overlays var previous = sidebarButtons.SingleOrDefault(sb => sb.Selected); var next = sidebarButtons.SingleOrDefault(sb => sb.Section == bestCandidate); - if (next != null) next.Selected = true; if (previous != null) previous.Selected = false; + if (next != null) next.Selected = true; } } From d9a4a677fd41fd51526defb72490a0d61d1f912e Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 9 Mar 2017 21:37:03 +0100 Subject: [PATCH 02/40] Added Descriptions to Rulesets + PlayModes list --- osu.Game.Modes.Catch/CatchRuleset.cs | 2 ++ osu.Game.Modes.Mania/ManiaRuleset.cs | 2 ++ osu.Game.Modes.Osu/OsuRuleset.cs | 2 ++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 ++ osu.Game/Modes/PlayMode.cs | 6 ------ osu.Game/Modes/Ruleset.cs | 4 ++++ osu.Game/Overlays/Toolbar/ToolbarModeButton.cs | 4 ++-- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 737bd99f94..155d9e9a1e 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -79,6 +79,8 @@ namespace osu.Game.Modes.Catch protected override PlayMode PlayMode => PlayMode.Catch; + public override string Description => "osu!catch"; + public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; 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 6d5606f796..5487606b26 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -100,6 +100,8 @@ namespace osu.Game.Modes.Mania protected override PlayMode PlayMode => PlayMode.Mania; + public override string Description => "osu!mania"; + public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; 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 68f700cabb..3cfce84448 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -111,5 +111,7 @@ namespace osu.Game.Modes.Osu } protected override PlayMode PlayMode => PlayMode.Osu; + + public override string Description => "osu!"; } } diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index fad60a98b5..36fe81b6d2 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -79,6 +79,8 @@ namespace osu.Game.Modes.Taiko protected override PlayMode PlayMode => PlayMode.Taiko; + public override string Description => "osu!taiko"; + public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null; diff --git a/osu.Game/Modes/PlayMode.cs b/osu.Game/Modes/PlayMode.cs index 8d1e5158b0..fa6d94a650 100644 --- a/osu.Game/Modes/PlayMode.cs +++ b/osu.Game/Modes/PlayMode.cs @@ -1,19 +1,13 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.ComponentModel; - namespace osu.Game.Modes { public enum PlayMode { - [Description(@"osu!")] Osu = 0, - [Description(@"osu!taiko")] Taiko = 1, - [Description(@"osu!catch")] Catch = 2, - [Description(@"osu!mania")] Mania = 3 } } diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index fefba6caf8..c004ae4092 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -22,6 +22,8 @@ namespace osu.Game.Modes { private static ConcurrentDictionary availableRulesets = new ConcurrentDictionary(); + public static IEnumerable PlayModes => availableRulesets.Keys; + public abstract ScoreOverlay CreateScoreOverlay(); public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; @@ -42,6 +44,8 @@ namespace osu.Game.Modes 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) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs b/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs index 1bcc0bf828..0de0d725df 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs @@ -17,8 +17,8 @@ namespace osu.Game.Overlays.Toolbar set { mode = value; - TooltipMain = mode.GetDescription(); - TooltipSub = $"Play some {mode.GetDescription()}"; + TooltipMain = Ruleset.GetRuleset(mode).Description; + TooltipSub = $"Play some {Ruleset.GetRuleset(mode).Description}"; Icon = Ruleset.GetRuleset(mode).Icon; } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 8b24157381..30474ad796 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Toolbar } }; - foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) + foreach (PlayMode m in Ruleset.PlayModes) { var localMode = m; modeButtons.Add(new ToolbarModeButton From 9dd835e256cef48219b493b322ab20644e8c761d Mon Sep 17 00:00:00 2001 From: Jorolf Date: Thu, 9 Mar 2017 21:43:11 +0100 Subject: [PATCH 03/40] didn't see this was unnecessary after my changes --- osu.Game/Overlays/Toolbar/ToolbarModeButton.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs b/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs index 0de0d725df..62359b05ae 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeButton.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 osu.Framework.Extensions; using osu.Framework.Graphics.Containers; using osu.Game.Modes; using OpenTK.Graphics; From fa9110ce6eeb367eea77ee7a867053d1f90499d2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 11:04:46 +0900 Subject: [PATCH 04/40] Remove custom combo counters. --- .../Tests/TestCaseScoreCounter.cs | 66 ++-------------- osu.Game.Modes.Catch/UI/CatchComboCounter.cs | 65 ---------------- .../osu.Game.Modes.Catch.csproj | 1 - osu.Game.Modes.Mania/UI/ManiaComboCounter.cs | 78 ------------------- .../osu.Game.Modes.Mania.csproj | 1 - osu.Game.Modes.Taiko/TaikoRuleset.cs | 4 +- osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs | 63 --------------- .../osu.Game.Modes.Taiko.csproj | 1 - 8 files changed, 7 insertions(+), 272 deletions(-) delete mode 100644 osu.Game.Modes.Catch/UI/CatchComboCounter.cs delete mode 100644 osu.Game.Modes.Mania/UI/ManiaComboCounter.cs delete mode 100644 osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index f4b2afee08..a3560e7400 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -1,20 +1,20 @@ // 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.Screens.Testing; +using OpenTK; +using OpenTK.Graphics; using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; +using osu.Framework.Screens.Testing; using osu.Game.Graphics.UserInterface; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Graphics.Primitives; +using System; namespace osu.Desktop.VisualTests.Tests { @@ -50,36 +50,6 @@ namespace osu.Desktop.VisualTests.Tests }; Add(standardCombo); - CatchComboCounter catchCombo = new CatchComboCounter - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Count = 0, - TextSize = 40, - }; - Add(catchCombo); - - ComboCounter taikoCombo = new TaikoComboCounter - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.Centre, - Position = new Vector2(0, -160), - Count = 0, - TextSize = 40, - }; - Add(taikoCombo); - - ManiaComboCounter maniaCombo = new ManiaComboCounter - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Position = new Vector2(0, -80), - Count = 0, - TextSize = 40, - }; - Add(maniaCombo); - - PercentageCounter accuracyCombo = new PercentageCounter { Origin = Anchor.TopRight, @@ -110,9 +80,6 @@ namespace osu.Desktop.VisualTests.Tests { score.Count = 0; standardCombo.Count = 0; - taikoCombo.Count = 0; - maniaCombo.Count = 0; - catchCombo.Count = 0; numerator = denominator = 0; accuracyCombo.SetFraction(0, 0); stars.Count = 0; @@ -123,14 +90,6 @@ namespace osu.Desktop.VisualTests.Tests { score.Count += 300 + (ulong)(300.0 * (standardCombo.Count > 0 ? standardCombo.Count - 1 : 0) / 25.0); standardCombo.Count++; - taikoCombo.Count++; - maniaCombo.Count++; - catchCombo.CatchFruit(new Color4( - Math.Max(0.5f, RNG.NextSingle()), - Math.Max(0.5f, RNG.NextSingle()), - Math.Max(0.5f, RNG.NextSingle()), - 1) - ); numerator++; denominator++; accuracyCombo.SetFraction(numerator, denominator); }); @@ -138,22 +97,10 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"miss...", delegate { standardCombo.Roll(); - taikoCombo.Roll(); - maniaCombo.Roll(); - catchCombo.Roll(); denominator++; accuracyCombo.SetFraction(numerator, denominator); }); - AddButton(@"mania hold", delegate - { - if (!maniaHold) - maniaCombo.HoldStart(); - else - maniaCombo.HoldEnd(); - maniaHold = !maniaHold; - }); - AddButton(@"Alter stars", delegate { stars.Count = RNG.NextSingle() * (stars.StarCount + 1); @@ -164,9 +111,6 @@ namespace osu.Desktop.VisualTests.Tests { score.StopRolling(); standardCombo.StopRolling(); - catchCombo.StopRolling(); - taikoCombo.StopRolling(); - maniaCombo.StopRolling(); accuracyCombo.StopRolling(); stars.StopAnimation(); }); diff --git a/osu.Game.Modes.Catch/UI/CatchComboCounter.cs b/osu.Game.Modes.Catch/UI/CatchComboCounter.cs deleted file mode 100644 index e0a07dc295..0000000000 --- a/osu.Game.Modes.Catch/UI/CatchComboCounter.cs +++ /dev/null @@ -1,65 +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.Osu.UI; -using OpenTK.Graphics; - -namespace osu.Game.Modes.Catch.UI -{ - /// - /// Similar to Standard, but without the 'x' and has tinted pop-ups. Used in osu!catch. - /// - public class CatchComboCounter : OsuComboCounter - { - protected override bool CanPopOutWhileRolling => true; - - protected virtual double FadeOutDelay => 1000; - protected override double FadeOutDuration => 300; - - protected override string FormatCount(ulong count) - { - return $@"{count:#,0}"; - } - - private void animateFade() - { - Show(); - Delay(FadeOutDelay); - FadeOut(FadeOutDuration); - DelayReset(); - } - - protected override void OnCountChange(ulong currentValue, ulong newValue) - { - if (newValue != 0) - animateFade(); - base.OnCountChange(currentValue, newValue); - } - - protected override void OnCountRolling(ulong currentValue, ulong newValue) - { - if (!IsRolling) - { - PopOutCount.Colour = DisplayedCountSpriteText.Colour; - FadeOut(FadeOutDuration); - } - base.OnCountRolling(currentValue, newValue); - } - - protected override void OnCountIncrement(ulong currentValue, ulong newValue) - { - animateFade(); - base.OnCountIncrement(currentValue, newValue); - } - - /// - /// Increaces counter and tints pop-out before animation. - /// - /// Last grabbed fruit colour. - public void CatchFruit(Color4 colour) - { - PopOutCount.Colour = colour; - Count++; - } - } -} diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 42f06608b9..663d12bb4d 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -54,7 +54,6 @@ - diff --git a/osu.Game.Modes.Mania/UI/ManiaComboCounter.cs b/osu.Game.Modes.Mania/UI/ManiaComboCounter.cs deleted file mode 100644 index c5ed557854..0000000000 --- a/osu.Game.Modes.Mania/UI/ManiaComboCounter.cs +++ /dev/null @@ -1,78 +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.Transforms; -using osu.Game.Modes.Taiko.UI; -using OpenTK.Graphics; - -namespace osu.Game.Modes.Mania.UI -{ - /// - /// Similar to osu!taiko, with a pop-out animation when failing (rolling). Used in osu!mania. - /// - public class ManiaComboCounter : TaikoComboCounter - { - protected ushort KeysHeld; - - protected Color4 OriginalColour; - - protected Color4 TintColour => Color4.Orange; - protected EasingTypes TintEasing => EasingTypes.None; - protected int TintDuration => 500; - - protected Color4 PopOutColor => Color4.Red; - protected override float PopOutInitialAlpha => 1.0f; - protected override double PopOutDuration => 300; - - protected override void LoadComplete() - { - base.LoadComplete(); - - PopOutCount.Anchor = Anchor.BottomCentre; - PopOutCount.Origin = Anchor.Centre; - PopOutCount.FadeColour(PopOutColor); - OriginalColour = DisplayedCountSpriteText.Colour; - } - - protected override void OnCountRolling(ulong currentValue, ulong newValue) - { - if (!IsRolling && newValue < currentValue) - { - PopOutCount.Text = FormatCount(currentValue); - - PopOutCount.FadeTo(PopOutInitialAlpha); - PopOutCount.ScaleTo(1.0f); - - PopOutCount.FadeOut(PopOutDuration, PopOutEasing); - PopOutCount.ScaleTo(PopOutScale, PopOutDuration, PopOutEasing); - } - - base.OnCountRolling(currentValue, newValue); - } - - /// - /// Tints text while holding a key. - /// - /// - /// Does not alter combo. This has to be done depending of the scoring system. - /// (i.e. v1 = each period of time; v2 = when starting and ending a key hold) - /// - public void HoldStart() - { - if (KeysHeld == 0) - DisplayedCountSpriteText.FadeColour(TintColour, TintDuration, TintEasing); - KeysHeld++; - } - - /// - /// Ends tinting. - /// - public void HoldEnd() - { - KeysHeld--; - if (KeysHeld == 0) - DisplayedCountSpriteText.FadeColour(OriginalColour, TintDuration, TintEasing); - } - } -} diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 457fb38e00..354f0b8541 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -54,7 +54,6 @@ - diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index fad60a98b5..585b3e97b0 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -1,13 +1,13 @@ // 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.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; -using osu.Game.Beatmaps; +using System.Collections.Generic; namespace osu.Game.Modes.Taiko { diff --git a/osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs b/osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs deleted file mode 100644 index 44afa85989..0000000000 --- a/osu.Game.Modes.Taiko/UI/TaikoComboCounter.cs +++ /dev/null @@ -1,63 +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.Transforms; -using osu.Game.Modes.UI; -using OpenTK; - -namespace osu.Game.Modes.Taiko.UI -{ - /// - /// Allows tint and scaling animations. Used in osu!taiko. - /// - public class TaikoComboCounter : ComboCounter - { - protected virtual int AnimationDuration => 300; - protected virtual float ScaleFactor => 2; - protected virtual EasingTypes AnimationEasing => EasingTypes.None; - protected virtual bool CanAnimateWhenBackwards => false; - - public TaikoComboCounter() - { - DisplayedCountSpriteText.Origin = Framework.Graphics.Anchor.BottomCentre; - DisplayedCountSpriteText.Anchor = Framework.Graphics.Anchor.BottomCentre; - } - - protected virtual void TransformAnimate(ulong newValue) - { - DisplayedCountSpriteText.Text = FormatCount(newValue); - DisplayedCountSpriteText.ScaleTo(new Vector2(1, ScaleFactor)); - DisplayedCountSpriteText.ScaleTo(new Vector2(1, 1), AnimationDuration, AnimationEasing); - } - - protected virtual void TransformNotAnimate(ulong newValue) - { - DisplayedCountSpriteText.Text = FormatCount(newValue); - DisplayedCountSpriteText.ScaleTo(1); - } - - protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) - { - if (newValue == 0) - DisplayedCountSpriteText.FadeOut(FadeOutDuration); - else - DisplayedCountSpriteText.Show(); - - TransformNotAnimate(newValue); - } - - protected override void OnDisplayedCountChange(ulong newValue) - { - DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); - - TransformNotAnimate(newValue); - } - - protected override void OnDisplayedCountIncrement(ulong newValue) - { - DisplayedCountSpriteText.Show(); - - TransformAnimate(newValue); - } - } -} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 6c379b1b70..35f5a2d686 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -52,7 +52,6 @@ - From 2b64de9dd83c1639e40b604564c91faa422b034a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Mar 2017 11:37:53 +0900 Subject: [PATCH 05/40] Fix using statements. --- osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index a3560e7400..2dafa261d0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -2,19 +2,14 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.MathUtils; using osu.Framework.Screens.Testing; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Catch.UI; -using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Osu.UI; -using osu.Game.Modes.Taiko.UI; using osu.Game.Modes.UI; -using System; namespace osu.Desktop.VisualTests.Tests { From 31f6cbd8cfaf229256ce8f7879d94f0824531922 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 11:59:08 +0900 Subject: [PATCH 06/40] 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 07/40] 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 08/40] 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 09/40] 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 10/40] 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 11/40] 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 12/40] 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 cd1717c42f2bc0b42b187d337bfac41b891a7484 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:08:59 +0900 Subject: [PATCH 13/40] More bindables! --- .../Tests/TestCaseScoreCounter.cs | 5 +- .../UserInterface/PercentageCounter.cs | 29 ++++++++--- .../Graphics/UserInterface/RollingCounter.cs | 52 +++++++------------ .../Graphics/UserInterface/ScoreCounter.cs | 18 +++---- osu.Game/Modes/ScoreProcesssor.cs | 4 +- osu.Game/Modes/UI/ComboResultCounter.cs | 4 +- osu.Game/Modes/UI/HUDOverlay.cs | 12 +++-- 7 files changed, 64 insertions(+), 60 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 3beddff814..500859d5cf 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -29,7 +29,6 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.TopRight, Anchor = Anchor.TopRight, TextSize = 40, - Count = 0, Margin = new MarginPadding(20), }; Add(score); @@ -72,7 +71,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Reset all", delegate { - score.Count = 0; + score.Current.Value = 0; comboCounter.Count = 0; numerator = denominator = 0; accuracyCounter.SetFraction(0, 0); @@ -82,7 +81,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Hit! :D", delegate { - score.Count += 300 + (ulong)(300.0 * (comboCounter.Count > 0 ? comboCounter.Count - 1 : 0) / 25.0); + score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Count > 0 ? comboCounter.Count - 1 : 0) / 25.0); comboCounter.Count++; numerator++; denominator++; accuracyCounter.SetFraction(numerator, denominator); diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 068b46c02b..66c9e7d461 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; +using osu.Framework.MathUtils; using System; namespace osu.Game.Graphics.UserInterface @@ -10,7 +11,7 @@ namespace osu.Game.Graphics.UserInterface /// /// Used as an accuracy counter. Represented visually as a percentage. /// - public class PercentageCounter : RollingCounter + public class PercentageCounter : RollingCounter { protected override Type TransformType => typeof(TransformAccuracy); @@ -20,32 +21,44 @@ namespace osu.Game.Graphics.UserInterface public void SetFraction(float numerator, float denominator) { - Count = Math.Abs(denominator) < epsilon ? 1.0f : numerator / denominator; + Current.Value = Math.Abs(denominator) < epsilon ? 1.0f : numerator / denominator; } public PercentageCounter() { DisplayedCountSpriteText.FixedWidth = true; - Count = DisplayedCount = 1.0f; + Current.Value = DisplayedCount = 1.0f; } - protected override string FormatCount(float count) + protected override string FormatCount(double count) { return $@"{count:P2}"; } - protected override double GetProportionalDuration(float currentValue, float newValue) + protected override double GetProportionalDuration(double currentValue, double newValue) { return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f; } - public override void Increment(float amount) + public override void Increment(double amount) { - Count = Count + amount; + Current.Value = Current + amount; } - protected class TransformAccuracy : TransformFloat + protected class TransformAccuracy : Transform { + protected override double CurrentValue + { + get + { + double time = Time?.Current ?? 0; + if (time < StartTime) return StartValue; + if (time >= EndTime) return EndValue; + + return Interpolation.ValueAt(time, (float)StartValue, (float)EndValue, StartTime, EndTime, Easing); + } + } + public override void Apply(Drawable d) { base.Apply(d); diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 447f07c3ae..a4f6092d66 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -1,19 +1,25 @@ // 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.Sprites; using osu.Framework.Graphics.Transforms; +using osu.Game.Graphics.Sprites; using System; using System.Collections.Generic; using System.Diagnostics; -using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { public abstract class RollingCounter : Container { + /// + /// The current value. + /// + public Bindable Current = new Bindable(); + /// /// Type of the Transform to use. /// @@ -60,32 +66,6 @@ namespace osu.Game.Graphics.UserInterface } } - private T count; - - /// - /// Actual value of counter. - /// - public virtual T Count - { - get - { - return count; - } - set - { - count = value; - if (IsLoaded) - { - TransformCount(displayedCount, count); - } - } - } - - public void Set(T value) - { - Count = value; - } - public abstract void Increment(T amount); private float textSize; @@ -116,7 +96,15 @@ namespace osu.Game.Graphics.UserInterface TextSize = 40; AutoSizeAxes = Axes.Both; - DisplayedCount = Count; + DisplayedCount = Current; + + Current.ValueChanged += currentChanged; + } + + private void currentChanged(object sender, EventArgs e) + { + if (IsLoaded) + TransformCount(displayedCount, Current); } protected override void LoadComplete() @@ -125,7 +113,7 @@ namespace osu.Game.Graphics.UserInterface Flush(false, TransformType); - DisplayedCountSpriteText.Text = FormatCount(count); + DisplayedCountSpriteText.Text = FormatCount(Current); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; } @@ -136,7 +124,7 @@ namespace osu.Game.Graphics.UserInterface /// New count value. public virtual void SetCountWithoutRolling(T count) { - Count = count; + Current.Value = count; StopRolling(); } @@ -146,7 +134,7 @@ namespace osu.Game.Graphics.UserInterface public virtual void StopRolling() { Flush(false, TransformType); - DisplayedCount = Count; + DisplayedCount = Current; } /// @@ -211,7 +199,7 @@ namespace osu.Game.Graphics.UserInterface if (RollingDuration < 1) { - DisplayedCount = Count; + DisplayedCount = Current; return; } diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 2961a6de40..c9a1040185 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -8,7 +8,7 @@ using System; namespace osu.Game.Graphics.UserInterface { - public class ScoreCounter : RollingCounter + public class ScoreCounter : RollingCounter { protected override Type TransformType => typeof(TransformScore); @@ -34,24 +34,24 @@ namespace osu.Game.Graphics.UserInterface LeadingZeroes = leading; } - protected override double GetProportionalDuration(ulong currentValue, ulong newValue) + protected override double GetProportionalDuration(double currentValue, double newValue) { return currentValue > newValue ? currentValue - newValue : newValue - currentValue; } - protected override string FormatCount(ulong count) + protected override string FormatCount(double count) { - return count.ToString("D" + LeadingZeroes); + return ((long)count).ToString("D" + LeadingZeroes); } - public override void Increment(ulong amount) + public override void Increment(double amount) { - Count = Count + amount; + Current.Value = Current + amount; } - protected class TransformScore : Transform + protected class TransformScore : Transform { - protected override ulong CurrentValue + protected override double CurrentValue { get { @@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface if (time < StartTime) return StartValue; if (time >= EndTime) return EndValue; - return (ulong)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); + return Interpolation.ValueAt(time, (float)StartValue, (float)EndValue, StartTime, EndTime, Easing); } } diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index 0433df66a9..554996c145 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 { diff --git a/osu.Game/Modes/UI/ComboResultCounter.cs b/osu.Game/Modes/UI/ComboResultCounter.cs index 03c8b5611f..957a720c94 100644 --- a/osu.Game/Modes/UI/ComboResultCounter.cs +++ b/osu.Game/Modes/UI/ComboResultCounter.cs @@ -1,11 +1,11 @@ // 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.Graphics; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; using osu.Game.Graphics.UserInterface; +using System; namespace osu.Game.Modes.UI { @@ -31,7 +31,7 @@ namespace osu.Game.Modes.UI public override void Increment(ulong amount) { - Count = Count + amount; + Current.Value = Current + amount; } protected class TransformComboResult : Transform diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index e9b31dc519..0f6db35d2b 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -34,13 +34,17 @@ namespace osu.Game.Modes.UI { ComboCounter?.Increment(); ScoreCounter?.Increment(300); - AccuracyCounter?.Set(Math.Min(1, AccuracyCounter.Count + 0.01f)); + + if (AccuracyCounter != null) + AccuracyCounter.Current.Value = Math.Min(1, AccuracyCounter.Current + 0.01f); } public virtual void OnMiss(HitObject h) { ComboCounter?.Roll(); - AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); + + if (AccuracyCounter != null) + AccuracyCounter.Current.Value = AccuracyCounter.Current - 0.01f; } protected HudOverlay(Ruleset ruleset) @@ -77,8 +81,8 @@ namespace osu.Game.Modes.UI { //bind processor bindables to combocounter, score display etc. //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); }; + ScoreCounter?.Current.BindTo(processor.TotalScore); + AccuracyCounter?.Current.BindTo(processor.Accuracy); processor.Combo.ValueChanged += delegate { ComboCounter?.Set((ulong)processor.Combo.Value); }; HealthDisplay?.Current.BindTo(processor.Health); } From 122792eb939481978bf255821a9b8579e8f994d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:37:48 +0900 Subject: [PATCH 14/40] Remove unused methods. --- osu.Game/Modes/UI/HUDOverlay.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 0f6db35d2b..1cf1e47bc5 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Objects; using osu.Game.Screens.Play; using System; using System.Collections.Generic; @@ -30,23 +29,6 @@ namespace osu.Game.Modes.UI protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); - public virtual void OnHit(HitObject h) - { - ComboCounter?.Increment(); - ScoreCounter?.Increment(300); - - if (AccuracyCounter != null) - AccuracyCounter.Current.Value = Math.Min(1, AccuracyCounter.Current + 0.01f); - } - - public virtual void OnMiss(HitObject h) - { - ComboCounter?.Roll(); - - if (AccuracyCounter != null) - AccuracyCounter.Current.Value = AccuracyCounter.Current - 0.01f; - } - protected HudOverlay(Ruleset ruleset) { RelativeSizeAxes = Axes.Both; From 712739d7799125e69814e81ac742bcba6fd0fb26 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:58:17 +0900 Subject: [PATCH 15/40] 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 16/40] 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 5f72265eff753c83bac54ea01066e5f25d0ac90e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:09:07 +0900 Subject: [PATCH 17/40] Remove float ValueAt method. --- osu-framework | 2 +- osu.Game/Graphics/UserInterface/StarCounter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 1c80609e7a..a50dd75b11 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1c80609e7aa686f4abdc82bcd6a8f03439463ce7 +Subproject commit a50dd75b114da963c75e6a5314099d99140035b8 diff --git a/osu.Game/Graphics/UserInterface/StarCounter.cs b/osu.Game/Graphics/UserInterface/StarCounter.cs index a1da18e95a..c46eda6582 100644 --- a/osu.Game/Graphics/UserInterface/StarCounter.cs +++ b/osu.Game/Graphics/UserInterface/StarCounter.cs @@ -123,7 +123,7 @@ namespace osu.Game.Graphics.UserInterface if (value <= i) return minStarScale; - return i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1); + return i + 1 <= value ? 1.0f : (float)Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1); } private void transformCount(float newValue) From 2fb5334d09eabed8c990fc5153c381e6fefbec65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:15:56 +0900 Subject: [PATCH 18/40] 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 19/40] 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 20/40] 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 21/40] 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 c0bb2685bf466dca8068df03c84549ef0539484b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:44:38 +0900 Subject: [PATCH 22/40] Fix post-merge errors. --- osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index afa83b672b..be313efed3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -80,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Hit! :D", delegate { - score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Count > 0 ? comboCounter.Count - 1 : 0) / 25.0); + score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0); comboCounter.Increment(); numerator++; denominator++; accuracyCounter.SetFraction(numerator, denominator); From d3e14aad1b5712dd1f9f407d1e5c7f39ebef1ca1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:55:43 +0900 Subject: [PATCH 23/40] 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 02281d8a2a989c0b31e553ed096b76a9142af3fb Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 15:08:53 +0900 Subject: [PATCH 24/40] Make HitRenderer not have a publicly-settable Beatmap, replace AllObjectsJudged for performance. --- .../Tests/TestCaseGamefield.cs | 18 ++-- osu.Game.Modes.Catch/CatchRuleset.cs | 9 +- osu.Game.Modes.Catch/UI/CatchHitRenderer.cs | 6 ++ osu.Game.Modes.Mania/ManiaRuleset.cs | 9 +- osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs | 4 +- osu.Game.Modes.Osu/OsuRuleset.cs | 9 +- osu.Game.Modes.Osu/UI/OsuHitRenderer.cs | 6 ++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 5 +- osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs | 6 ++ osu.Game/Modes/UI/HitRenderer.cs | 90 +++++++++++-------- 10 files changed, 91 insertions(+), 71 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index 79616d777f..ede430478e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -1,11 +1,11 @@ // 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.Framework.Screens.Testing; +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.MathUtils; +using osu.Framework.Screens.Testing; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Modes.Catch.UI; @@ -14,7 +14,7 @@ using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.Taiko.UI; -using OpenTK; +using System.Collections.Generic; namespace osu.Desktop.VisualTests.Tests { @@ -55,30 +55,26 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(), Children = new Drawable[] { - new OsuHitRenderer + new OsuHitRenderer(beatmap) { - Beatmap = beatmap, Scale = new Vector2(0.5f), Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft }, - new TaikoHitRenderer + new TaikoHitRenderer(beatmap) { - Beatmap = beatmap, Scale = new Vector2(0.5f), Anchor = Anchor.TopRight, Origin = Anchor.TopRight }, - new CatchHitRenderer + new CatchHitRenderer(beatmap) { - Beatmap = beatmap, Scale = new Vector2(0.5f), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft }, - new ManiaHitRenderer + new ManiaHitRenderer(beatmap) { - Beatmap = beatmap, Scale = new Vector2(0.5f), Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 155d9e9a1e..f397bd1248 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -1,13 +1,13 @@ // 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.Catch.UI; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.UI; using osu.Game.Modes.UI; -using osu.Game.Beatmaps; +using System.Collections.Generic; namespace osu.Game.Modes.Catch { @@ -15,10 +15,7 @@ namespace osu.Game.Modes.Catch { public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer - { - Beatmap = beatmap, - }; + public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new CatchHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs b/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs index dd61fdd453..ed0c8b4747 100644 --- a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs +++ b/osu.Game.Modes.Catch/UI/CatchHitRenderer.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.Game.Beatmaps; using osu.Game.Modes.Catch.Objects; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; @@ -10,6 +11,11 @@ namespace osu.Game.Modes.Catch.UI { public class CatchHitRenderer : HitRenderer { + public CatchHitRenderer(Beatmap beatmap) + : base(beatmap) + { + } + protected override HitObjectConverter Converter => new CatchConverter(); protected override Playfield CreatePlayfield() => new CatchPlayfield(); diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 5487606b26..95b2cd6d6b 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -1,13 +1,13 @@ // 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 System.Collections.Generic; namespace osu.Game.Modes.Mania { @@ -15,10 +15,7 @@ namespace osu.Game.Modes.Mania { public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer - { - Beatmap = beatmap, - }; + public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new ManiaHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs index 31bc4fffe4..82dd2f2eeb 100644 --- a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.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.Game.Beatmaps; using osu.Game.Modes.Mania.Objects; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; @@ -12,7 +13,8 @@ namespace osu.Game.Modes.Mania.UI { private readonly int columns; - public ManiaHitRenderer(int columns = 5) + public ManiaHitRenderer(Beatmap beatmap, int columns = 5) + : base(beatmap) { this.columns = columns; } diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 3cfce84448..243ce64d9e 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -1,14 +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 System.Linq; 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 System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes.Osu { @@ -16,10 +16,7 @@ namespace osu.Game.Modes.Osu { public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer - { - Beatmap = beatmap, - }; + public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new OsuHitRenderer(beatmap); public override IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] { diff --git a/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs b/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs index 4801862a91..dab46aed8f 100644 --- a/osu.Game.Modes.Osu/UI/OsuHitRenderer.cs +++ b/osu.Game.Modes.Osu/UI/OsuHitRenderer.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.Game.Beatmaps; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; @@ -11,6 +12,11 @@ namespace osu.Game.Modes.Osu.UI { public class OsuHitRenderer : HitRenderer { + public OsuHitRenderer(Beatmap beatmap) + : base(beatmap) + { + } + protected override HitObjectConverter Converter => new OsuHitObjectConverter(); protected override Playfield CreatePlayfield() => new OsuPlayfield(); diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index be23045f4d..f6fbea6198 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -15,10 +15,7 @@ namespace osu.Game.Modes.Taiko { public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay(); - public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new TaikoHitRenderer - { - Beatmap = beatmap, - }; + public override HitRenderer CreateHitRendererWith(Beatmap beatmap) => new TaikoHitRenderer(beatmap); public override IEnumerable GetModsFor(ModType type) { diff --git a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs index 1b9bb682f1..e29e13823d 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.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.Game.Beatmaps; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Taiko.Objects; @@ -10,6 +11,11 @@ namespace osu.Game.Modes.Taiko.UI { public class TaikoHitRenderer : HitRenderer { + public TaikoHitRenderer(Beatmap beatmap) + : base(beatmap) + { + } + protected override HitObjectConverter Converter => new TaikoConverter(); protected override Playfield CreatePlayfield() => new TaikoPlayfield(); diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index fb28dd6c47..360551c89f 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -1,24 +1,22 @@ // 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 OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; -using osu.Game.Beatmaps; using osu.Game.Screens.Play; -using OpenTK; +using System; +using System.Collections.Generic; namespace osu.Game.Modes.UI { public abstract class HitRenderer : Container { public event Action OnJudgement; - public event Action OnAllJudged; internal readonly PlayerInputManager InputManager = new PlayerInputManager(); @@ -28,12 +26,39 @@ namespace osu.Game.Modes.UI /// public abstract Func MapPlayfieldToScreenSpace { get; } - public abstract bool AllObjectsJudged { get; } + /// + /// The number of Judgements required to be triggered + /// before the game enters post-play routines. + /// + protected abstract int JudgementCount { get; } + + /// + /// The beatmap this HitRenderer is initialized with. + /// + protected readonly Beatmap Beatmap; + + private int maxJudgements; + private int countJudgements; + + protected HitRenderer(Beatmap beatmap) + { + Beatmap = beatmap; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + maxJudgements = JudgementCount; + } protected void TriggerOnJudgement(JudgementInfo j) { + countJudgements++; + OnJudgement?.Invoke(j); - if (AllObjectsJudged) + + if (countJudgements == maxJudgements) OnAllJudged?.Invoke(); } } @@ -41,33 +66,23 @@ namespace osu.Game.Modes.UI public abstract class HitRenderer : HitRenderer where TObject : HitObject { - private List objects; + public override Func MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace; + public IEnumerable DrawableObjects => Playfield.HitObjects.Children; + + protected abstract HitObjectConverter Converter { get; } + protected virtual List Convert(Beatmap beatmap) => Converter.Convert(beatmap); + + protected override Container Content => content; + + private int judgementCount; + protected override int JudgementCount => judgementCount; protected Playfield Playfield; - public override Func MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace; + private Container content; - public override bool AllObjectsJudged => Playfield.HitObjects.Children.First()?.Judgement.Result != null; //reverse depth sort means First() instead of Last(). - - public IEnumerable DrawableObjects => Playfield.HitObjects.Children; - - public Beatmap Beatmap - { - set - { - objects = Convert(value); - if (IsLoaded) - loadObjects(); - } - } - - protected abstract Playfield CreatePlayfield(); - - protected abstract HitObjectConverter Converter { get; } - - protected virtual List Convert(Beatmap beatmap) => Converter.Convert(beatmap); - - protected HitRenderer() + protected HitRenderer(Beatmap beatmap) + : base(beatmap) { RelativeSizeAxes = Axes.Both; @@ -83,9 +98,6 @@ namespace osu.Game.Modes.UI AddInternal(InputManager); } - protected override Container Content => content; - - private Container content; [BackgroundDependencyLoader] private void load() @@ -95,22 +107,26 @@ namespace osu.Game.Modes.UI private void loadObjects() { - if (objects == null) return; - foreach (TObject h in objects) + foreach (TObject h in Convert(Beatmap)) { DrawableHitObject drawableObject = GetVisualRepresentation(h); - if (drawableObject == null) continue; + if (drawableObject == null) + continue; drawableObject.OnJudgement += onJudgement; Playfield.Add(drawableObject); + + judgementCount++; } + Playfield.PostProcess(); } private void onJudgement(DrawableHitObject o, JudgementInfo j) => TriggerOnJudgement(j); protected abstract DrawableHitObject GetVisualRepresentation(TObject h); + protected abstract Playfield CreatePlayfield(); } } From eca980bb9530d4901b277231e32fef0263050b40 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 15:57:14 +0900 Subject: [PATCH 25/40] 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 26/40] 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 27/40] 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 28/40] 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 From eef18eea42e533bf236a04da510220aa40be2ed5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:17:07 +0900 Subject: [PATCH 29/40] General fixes. --- osu.Game/Modes/UI/HUDOverlay.cs | 6 +- osu.Game/Modes/UI/HudOverlay.cs | 77 +++++++++++++++++++++++++ osu.Game/Modes/UI/StandardHUDOverlay.cs | 9 +-- osu.Game/Modes/UI/StandardHudOverlay.cs | 54 +++++++++++++++++ 4 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 osu.Game/Modes/UI/HudOverlay.cs create mode 100644 osu.Game/Modes/UI/StandardHudOverlay.cs diff --git a/osu.Game/Modes/UI/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs index 06776f9163..87cbbb5446 100644 --- a/osu.Game/Modes/UI/HUDOverlay.cs +++ b/osu.Game/Modes/UI/HUDOverlay.cs @@ -7,9 +7,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; 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 +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(); @@ -35,7 +35,7 @@ namespace osu.Game.Modes.UI Children = new Drawable[] { - KeyCounter = CreateKeyCounter(ruleset.CreateGameplayKeys()), + KeyCounter = CreateKeyCounter(), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), AccuracyCounter = CreateAccuracyCounter(), diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs new file mode 100644 index 0000000000..87cbbb5446 --- /dev/null +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; +using osu.Game.Modes.Objects; +using osu.Game.Screens.Play; +using System; + +namespace osu.Game.Modes.UI +{ + public abstract class HudOverlay : Container + { + 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(); + protected abstract ComboCounter CreateComboCounter(); + protected abstract PercentageCounter CreateAccuracyCounter(); + protected abstract ScoreCounter CreateScoreCounter(); + protected abstract HealthDisplay CreateHealthDisplay(); + + protected HudOverlay(Ruleset ruleset) + { + RelativeSizeAxes = Axes.Both; + + Children = new Drawable[] + { + KeyCounter = CreateKeyCounter(), + ComboCounter = CreateComboCounter(), + ScoreCounter = CreateScoreCounter(), + AccuracyCounter = CreateAccuracyCounter(), + HealthDisplay = CreateHealthDisplay(), + }; + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + showKeyCounter = config.GetBindable(OsuConfig.KeyOverlay); + showKeyCounter.ValueChanged += visibilityChanged; + showKeyCounter.TriggerChange(); + } + + private void visibilityChanged(object sender, EventArgs e) + { + if (showKeyCounter) + KeyCounter.Show(); + else + KeyCounter.Hide(); + } + + public void BindProcessor(ScoreProcessor processor) + { + //bind processor bindables to combocounter, score display etc. + //TODO: these should be bindable binds, not events! + ScoreCounter?.Current.BindTo(processor.TotalScore); + AccuracyCounter?.Current.BindTo(processor.Accuracy); + ComboCounter?.Current.BindTo(processor.Combo); + HealthDisplay?.Current.BindTo(processor.Health); + } + + public void BindHitRenderer(HitRenderer hitRenderer) + { + hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); + } + } +} 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/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs new file mode 100644 index 0000000000..f77191adf7 --- /dev/null +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -0,0 +1,54 @@ +// 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; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Play; + +namespace osu.Game.Modes.UI +{ + public class StandardHudOverlay : HudOverlay + { + protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 65), + TextSize = 20, + Margin = new MarginPadding { Right = 5 }, + }; + + 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() => new KeyCounterCollection + { + IsCounting = true, + FadeTime = 50, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding(10), + }; + + 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 }, + }; + } +} From b63a1c549ea0f3ddba74b727ef845a325684d5b1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:26:58 +0900 Subject: [PATCH 30/40] Remove files temporarily. --- osu.Game/Modes/UI/HudOverlay.cs | 77 ------------------------- osu.Game/Modes/UI/StandardHUDOverlay.cs | 54 ----------------- osu.Game/Modes/UI/StandardHudOverlay.cs | 54 ----------------- 3 files changed, 185 deletions(-) delete mode 100644 osu.Game/Modes/UI/HudOverlay.cs delete mode 100644 osu.Game/Modes/UI/StandardHUDOverlay.cs delete mode 100644 osu.Game/Modes/UI/StandardHudOverlay.cs diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs deleted file mode 100644 index 979831f89f..0000000000 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ /dev/null @@ -1,77 +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.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Objects; -using osu.Game.Screens.Play; -using System; - -namespace osu.Game.Modes.UI -{ - public abstract class HudOverlay : Container - { - 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(); - protected abstract ComboCounter CreateComboCounter(); - protected abstract PercentageCounter CreateAccuracyCounter(); - protected abstract ScoreCounter CreateScoreCounter(); - protected abstract HealthDisplay CreateHealthDisplay(); - - protected HudOverlay() - { - RelativeSizeAxes = Axes.Both; - - Children = new Drawable[] - { - KeyCounter = CreateKeyCounter(), - ComboCounter = CreateComboCounter(), - ScoreCounter = CreateScoreCounter(), - AccuracyCounter = CreateAccuracyCounter(), - HealthDisplay = CreateHealthDisplay(), - }; - } - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - showKeyCounter = config.GetBindable(OsuConfig.KeyOverlay); - showKeyCounter.ValueChanged += visibilityChanged; - showKeyCounter.TriggerChange(); - } - - private void visibilityChanged(object sender, EventArgs e) - { - if (showKeyCounter) - KeyCounter.Show(); - else - KeyCounter.Hide(); - } - - public void BindProcessor(ScoreProcessor processor) - { - //bind processor bindables to combocounter, score display etc. - //TODO: these should be bindable binds, not events! - ScoreCounter?.Current.BindTo(processor.TotalScore); - AccuracyCounter?.Current.BindTo(processor.Accuracy); - ComboCounter?.Current.BindTo(processor.Combo); - HealthDisplay?.Current.BindTo(processor.Health); - } - - public void BindHitRenderer(HitRenderer hitRenderer) - { - hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); - } - } -} diff --git a/osu.Game/Modes/UI/StandardHUDOverlay.cs b/osu.Game/Modes/UI/StandardHUDOverlay.cs deleted file mode 100644 index f77191adf7..0000000000 --- a/osu.Game/Modes/UI/StandardHUDOverlay.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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; -using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play; - -namespace osu.Game.Modes.UI -{ - public class StandardHudOverlay : HudOverlay - { - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Position = new Vector2(0, 65), - TextSize = 20, - Margin = new MarginPadding { Right = 5 }, - }; - - 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() => new KeyCounterCollection - { - IsCounting = true, - FadeTime = 50, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Margin = new MarginPadding(10), - }; - - 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/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs deleted file mode 100644 index f77191adf7..0000000000 --- a/osu.Game/Modes/UI/StandardHudOverlay.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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; -using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Play; - -namespace osu.Game.Modes.UI -{ - public class StandardHudOverlay : HudOverlay - { - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Position = new Vector2(0, 65), - TextSize = 20, - Margin = new MarginPadding { Right = 5 }, - }; - - 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() => new KeyCounterCollection - { - IsCounting = true, - FadeTime = 50, - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Margin = new MarginPadding(10), - }; - - 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 }, - }; - } -} From 42b19cd3b3282b2a90a51e0f1c970352ea8e19ff Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:27:18 +0900 Subject: [PATCH 31/40] Re-add files. --- osu.Game/Modes/UI/HudOverlay.cs | 77 +++++++++++++++++++++++++ osu.Game/Modes/UI/StandardHudOverlay.cs | 54 +++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 osu.Game/Modes/UI/HudOverlay.cs create mode 100644 osu.Game/Modes/UI/StandardHudOverlay.cs diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs new file mode 100644 index 0000000000..979831f89f --- /dev/null +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; +using osu.Game.Modes.Objects; +using osu.Game.Screens.Play; +using System; + +namespace osu.Game.Modes.UI +{ + public abstract class HudOverlay : Container + { + 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(); + protected abstract ComboCounter CreateComboCounter(); + protected abstract PercentageCounter CreateAccuracyCounter(); + protected abstract ScoreCounter CreateScoreCounter(); + protected abstract HealthDisplay CreateHealthDisplay(); + + protected HudOverlay() + { + RelativeSizeAxes = Axes.Both; + + Children = new Drawable[] + { + KeyCounter = CreateKeyCounter(), + ComboCounter = CreateComboCounter(), + ScoreCounter = CreateScoreCounter(), + AccuracyCounter = CreateAccuracyCounter(), + HealthDisplay = CreateHealthDisplay(), + }; + } + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + showKeyCounter = config.GetBindable(OsuConfig.KeyOverlay); + showKeyCounter.ValueChanged += visibilityChanged; + showKeyCounter.TriggerChange(); + } + + private void visibilityChanged(object sender, EventArgs e) + { + if (showKeyCounter) + KeyCounter.Show(); + else + KeyCounter.Hide(); + } + + public void BindProcessor(ScoreProcessor processor) + { + //bind processor bindables to combocounter, score display etc. + //TODO: these should be bindable binds, not events! + ScoreCounter?.Current.BindTo(processor.TotalScore); + AccuracyCounter?.Current.BindTo(processor.Accuracy); + ComboCounter?.Current.BindTo(processor.Combo); + HealthDisplay?.Current.BindTo(processor.Health); + } + + public void BindHitRenderer(HitRenderer hitRenderer) + { + hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); + } + } +} diff --git a/osu.Game/Modes/UI/StandardHudOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs new file mode 100644 index 0000000000..f77191adf7 --- /dev/null +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -0,0 +1,54 @@ +// 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; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Play; + +namespace osu.Game.Modes.UI +{ + public class StandardHudOverlay : HudOverlay + { + protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 65), + TextSize = 20, + Margin = new MarginPadding { Right = 5 }, + }; + + 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() => new KeyCounterCollection + { + IsCounting = true, + FadeTime = 50, + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding(10), + }; + + 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 }, + }; + } +} From e126a5600a5355a881a9e84afdca2d55bfd1c0e6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:28:06 +0900 Subject: [PATCH 32/40] Fix using. --- osu.Game/Modes/UI/HudOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Modes/UI/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index 979831f89f..4b454797ce 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; -using osu.Game.Modes.Objects; using osu.Game.Screens.Play; using System; From 592e05a2c8f44ceb66eb4d5458b824f0513a079b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sun, 12 Mar 2017 00:34:21 +0900 Subject: [PATCH 33/40] Better beatmap conversion model. --- .../Beatmaps/CatchBeatmapConverter.cs | 21 ++++++ .../CatchDifficultyCalculator.cs | 3 - osu.Game.Modes.Catch/CatchRuleset.cs | 6 ++ osu.Game.Modes.Catch/UI/CatchHitRenderer.cs | 3 - .../osu.Game.Modes.Catch.csproj | 1 + .../Beatmaps/ManiaBeatmapConverter.cs | 21 ++++++ .../ManiaDifficultyCalculator.cs | 3 - osu.Game.Modes.Mania/ManiaRuleset.cs | 6 ++ osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs | 3 - .../osu.Game.Modes.Mania.csproj | 2 + .../OsuBeatmapConverter.cs} | 39 +++++++---- osu.Game.Modes.Osu/OsuDifficultyCalculator.cs | 3 - osu.Game.Modes.Osu/OsuRuleset.cs | 6 ++ osu.Game.Modes.Osu/UI/OsuHitRenderer.cs | 3 - osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj | 2 +- .../Beatmaps/TaikoBeatmapConverter.cs | 20 ++++++ .../TaikoDifficultyCalculator.cs | 3 - osu.Game.Modes.Taiko/TaikoRuleset.cs | 6 ++ osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs | 3 - .../osu.Game.Modes.Taiko.csproj | 1 + osu.Game/Beatmaps/Beatmap.cs | 68 ++++++++++++++++--- osu.Game/Beatmaps/DifficultyCalculator.cs | 4 +- osu.Game/Beatmaps/IBeatmapCoverter.cs | 12 ++++ osu.Game/Modes/Ruleset.cs | 2 + osu.Game/Modes/UI/HitRenderer.cs | 20 ++---- osu.Game/osu.Game.csproj | 1 + 26 files changed, 196 insertions(+), 66 deletions(-) create mode 100644 osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs create mode 100644 osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs rename osu.Game.Modes.Osu/{Objects/OsuHitObjectConverter.cs => Beatmaps/OsuBeatmapConverter.cs} (87%) create mode 100644 osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs create mode 100644 osu.Game/Beatmaps/IBeatmapCoverter.cs diff --git a/osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs new file mode 100644 index 0000000000..6460751570 --- /dev/null +++ b/osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs @@ -0,0 +1,21 @@ +// 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.Modes.Catch.Objects; +using System.Collections.Generic; + +namespace osu.Game.Modes.Catch.Beatmaps +{ + internal class CatchBeatmapConverter : IBeatmapConverter + { + public Beatmap Convert(Beatmap original) + { + return new Beatmap(original) + { + HitObjects = new List() // Todo: Convert HitObjects + }; + } + } +} diff --git a/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs index ccc4097d59..01fa1a00d4 100644 --- a/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs +++ b/osu.Game.Modes.Catch/CatchDifficultyCalculator.cs @@ -3,7 +3,6 @@ using osu.Game.Beatmaps; using osu.Game.Modes.Catch.Objects; -using osu.Game.Modes.Objects; using System; using System.Collections.Generic; @@ -17,8 +16,6 @@ namespace osu.Game.Modes.Catch { } - protected override HitObjectConverter Converter => new CatchConverter(); - protected override double CalculateInternal(Dictionary categoryDifficulty) { return 0; diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 08edeb7bcb..2cdd35cf3a 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -4,6 +4,7 @@ using OpenTK.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Catch.Beatmaps; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; @@ -91,5 +92,10 @@ namespace osu.Game.Modes.Catch public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap); + + public override IBeatmapConverter CreateBeatmapConverter() + { + return (IBeatmapConverter)new CatchBeatmapConverter(); + } } } diff --git a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs b/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs index ed0c8b4747..703eb6fe91 100644 --- a/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs +++ b/osu.Game.Modes.Catch/UI/CatchHitRenderer.cs @@ -3,7 +3,6 @@ using osu.Game.Beatmaps; using osu.Game.Modes.Catch.Objects; -using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.UI; @@ -16,8 +15,6 @@ namespace osu.Game.Modes.Catch.UI { } - protected override HitObjectConverter Converter => new CatchConverter(); - protected override Playfield CreatePlayfield() => new CatchPlayfield(); protected override DrawableHitObject GetVisualRepresentation(CatchBaseHit h) => null;// new DrawableFruit(h); diff --git a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj index 663d12bb4d..10abb312fc 100644 --- a/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj +++ b/osu.Game.Modes.Catch/osu.Game.Modes.Catch.csproj @@ -47,6 +47,7 @@ + diff --git a/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs new file mode 100644 index 0000000000..0f42da4ac8 --- /dev/null +++ b/osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -0,0 +1,21 @@ +// 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.Modes.Mania.Objects; +using System.Collections.Generic; + +namespace osu.Game.Modes.Mania.Beatmaps +{ + internal class ManiaBeatmapConverter : IBeatmapConverter + { + public Beatmap Convert(Beatmap original) + { + return new Beatmap(original) + { + HitObjects = new List() // Todo: Implement + }; + } + } +} diff --git a/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs index 975b78c215..07c0749904 100644 --- a/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Modes.Mania/ManiaDifficultyCalculator.cs @@ -3,7 +3,6 @@ using osu.Game.Beatmaps; using osu.Game.Modes.Mania.Objects; -using osu.Game.Modes.Objects; using System; using System.Collections.Generic; @@ -20,8 +19,6 @@ namespace osu.Game.Modes.Mania this.columns = columns; } - protected override HitObjectConverter Converter => new ManiaConverter(columns); - protected override double CalculateInternal(Dictionary categoryDifficulty) { return 0; diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index e6e9cfd799..7d88942798 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -3,6 +3,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Modes.Mania.Beatmaps; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; @@ -106,5 +107,10 @@ namespace osu.Game.Modes.Mania public override HitObjectParser CreateHitObjectParser() => new NullHitObjectParser(); public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap); + + public override IBeatmapConverter CreateBeatmapConverter() + { + return (IBeatmapConverter)new ManiaBeatmapConverter(); + } } } diff --git a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs index 82dd2f2eeb..33b82738f8 100644 --- a/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Modes.Mania/UI/ManiaHitRenderer.cs @@ -3,7 +3,6 @@ using osu.Game.Beatmaps; using osu.Game.Modes.Mania.Objects; -using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.UI; @@ -19,8 +18,6 @@ namespace osu.Game.Modes.Mania.UI this.columns = columns; } - protected override HitObjectConverter Converter => new ManiaConverter(columns); - protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); protected override DrawableHitObject GetVisualRepresentation(ManiaBaseHit h) diff --git a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj index 354f0b8541..66e46f9e48 100644 --- a/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj +++ b/osu.Game.Modes.Mania/osu.Game.Modes.Mania.csproj @@ -47,6 +47,7 @@ + @@ -85,6 +86,7 @@ +