From cd1717c42f2bc0b42b187d337bfac41b891a7484 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 13:08:59 +0900 Subject: [PATCH 1/7] 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 2/7] 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 c0bb2685bf466dca8068df03c84549ef0539484b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 10 Mar 2017 14:44:38 +0900 Subject: [PATCH 3/7] 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 eef18eea42e533bf236a04da510220aa40be2ed5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 11 Mar 2017 14:17:07 +0900 Subject: [PATCH 4/7] 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 5/7] 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 6/7] 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 7/7] 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;