diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 2dafa261d0..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 @@ -35,23 +34,22 @@ namespace osu.Desktop.VisualTests.Tests }; Add(score); - ComboCounter standardCombo = new OsuComboCounter + ComboCounter comboCounter = new StandardComboCounter { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Margin = new MarginPadding(10), - 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 { @@ -74,26 +72,26 @@ namespace osu.Desktop.VisualTests.Tests AddButton(@"Reset all", delegate { score.Count = 0; - standardCombo.Count = 0; + comboCounter.Current.Value = 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.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0); + comboCounter.Increment(); numerator++; denominator++; - accuracyCombo.SetFraction(numerator, denominator); + accuracyCounter.SetFraction(numerator, denominator); }); AddButton(@"miss...", delegate { - standardCombo.Roll(); + comboCounter.Current.Value = 0; denominator++; - accuracyCombo.SetFraction(numerator, denominator); + accuracyCounter.SetFraction(numerator, denominator); }); AddButton(@"Alter stars", delegate @@ -105,8 +103,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 155d9e9a1e..41f592aa9d 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, @@ -83,6 +82,13 @@ namespace osu.Game.Modes.Catch public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; + public override IEnumerable CreateGameplayKeys() => 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 5487606b26..0b69fea746 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, @@ -104,6 +102,8 @@ namespace osu.Game.Modes.Mania public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; + public override IEnumerable CreateGameplayKeys() => 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 3cfce84448..566a22b6ad 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, @@ -113,5 +113,13 @@ namespace osu.Game.Modes.Osu protected override PlayMode PlayMode => PlayMode.Osu; public override string Description => "osu!"; + + public override IEnumerable CreateGameplayKeys() => 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/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/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index be23045f4d..e88c9cee86 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, @@ -83,6 +82,14 @@ namespace osu.Game.Modes.Taiko public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; + public override IEnumerable CreateGameplayKeys() => 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/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index c004ae4092..d8892e64e9 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 { @@ -24,8 +25,6 @@ namespace osu.Game.Modes public static IEnumerable PlayModes => availableRulesets.Keys; - public abstract ScoreOverlay CreateScoreOverlay(); - public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; public abstract IEnumerable GetModsFor(ModType type); @@ -46,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/Score.cs b/osu.Game/Modes/Score.cs index 1a761bea5d..4effe9affd 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 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 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/ComboCounter.cs b/osu.Game/Modes/UI/ComboCounter.cs index a549246011..f831677e44 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 BindableInt Current = new BindableInt { - 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 int previousValue; /// /// Base of all combo counters. @@ -113,73 +65,97 @@ namespace osu.Game.Modes.UI }; TextSize = 80; + + Current.ValueChanged += comboChanged; + } + + private void comboChanged(object sender, System.EventArgs e) + { + updateCount(Current.Value == 0); } protected override void LoadComplete() { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Count); + DisplayedCountSpriteText.Text = FormatCount(Current); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; StopRolling(); } + private int displayedCount; + /// + /// Value shown at the current moment. + /// + public virtual int 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(int amount = 1) + { + Current.Value = Current + amount; + } + /// /// Stops rollover animation, forcing the displayed count to be the actual count. /// public void StopRolling() { - updateCount(Count); + updateCount(false); } - /// - /// 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) + protected virtual string FormatCount(int 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(int currentValue, int newValue) { transformRoll(new TransformComboRoll(), currentValue, newValue); } - protected virtual void OnCountIncrement(ulong currentValue, ulong newValue) { + protected virtual void OnCountIncrement(int currentValue, int newValue) + { DisplayedCount = newValue; } - protected virtual void OnCountChange(ulong currentValue, ulong newValue) { + protected virtual void OnCountChange(int currentValue, int newValue) + { DisplayedCount = newValue; } - private double getProportionalDuration(ulong currentValue, ulong newValue) + private double getProportionalDuration(int currentValue, int newValue) { double difference = currentValue > newValue ? currentValue - newValue : newValue - currentValue; return difference * RollingDuration; } - private void updateDisplayedCount(ulong currentValue, ulong newValue, bool rolling) + private void updateDisplayedCount(int currentValue, int newValue, bool rolling) { displayedCount = newValue; if (rolling) @@ -190,10 +166,10 @@ namespace osu.Game.Modes.UI OnDisplayedCountChange(newValue); } - private void updateCount(ulong value, bool rolling = false) + private void updateCount(bool rolling) { - ulong prevCount = count; - count = value; + int prev = previousValue; + previousValue = Current; if (!IsLoaded) return; @@ -202,27 +178,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, int currentValue, int newValue) { Flush(false, typeof(TransformComboRoll)); if (RollingDuration < 1) { - DisplayedCount = Count; + DisplayedCount = Current; return; } @@ -235,9 +211,9 @@ namespace osu.Game.Modes.UI Transforms.Add(transform); } - protected class TransformComboRoll : Transform + protected class TransformComboRoll : Transform { - protected override ulong CurrentValue + protected override int CurrentValue { get { @@ -245,7 +221,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 (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing); } } @@ -256,12 +232,8 @@ namespace osu.Game.Modes.UI } } - public void Set(ulong value) - { - if (value == 0) - Roll(); - else - Count = value; - } + 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/HealthDisplay.cs b/osu.Game/Modes/UI/HealthDisplay.cs index ddd4c1db42..3471f4bc3f 100644 --- a/osu.Game/Modes/UI/HealthDisplay.cs +++ b/osu.Game/Modes/UI/HealthDisplay.cs @@ -1,72 +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 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 + public abstract class HealthDisplay : Container { - private Container fill; - - public BindableDouble Current = new BindableDouble + public readonly BindableDouble Current = new BindableDouble { MinValue = 0, MaxValue = 1 }; - public HealthDisplay() + protected 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) => SetHealth((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 SetHealth(float value); } } diff --git a/osu.Game/Modes/UI/ScoreOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs similarity index 74% rename from osu.Game/Modes/UI/ScoreOverlay.cs rename to osu.Game/Modes/UI/HudOverlay.cs index 09f34d4c2e..2a17b5efd7 100644 --- a/osu.Game/Modes/UI/ScoreOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -1,28 +1,25 @@ // 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.Graphics; using osu.Framework.Graphics.Containers; +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 + public abstract class HudOverlay : Container { - public KeyCounterCollection KeyCounter; - public ComboCounter 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; @@ -30,12 +27,7 @@ namespace osu.Game.Modes.UI 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) { @@ -46,15 +38,16 @@ namespace osu.Game.Modes.UI public virtual void OnMiss(HitObject h) { - ComboCounter?.Roll(); + ComboCounter.Current.Value = 0; AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f); } - protected ScoreOverlay() + protected HudOverlay() { RelativeSizeAxes = Axes.Both; - Children = new Drawable[] { + Children = new Drawable[] + { KeyCounter = CreateKeyCounter(), ComboCounter = CreateComboCounter(), ScoreCounter = CreateScoreCounter(), @@ -85,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.Osu/UI/OsuComboCounter.cs b/osu.Game/Modes/UI/StandardComboCounter.cs similarity index 75% rename from osu.Game.Modes.Osu/UI/OsuComboCounter.cs rename to osu.Game/Modes/UI/StandardComboCounter.cs index fe24b021a6..08bb3add84 100644 --- a/osu.Game.Modes.Osu/UI/OsuComboCounter.cs +++ b/osu.Game/Modes/UI/StandardComboCounter.cs @@ -1,15 +1,14 @@ // 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 +namespace osu.Game.Modes.UI { /// - /// Uses the 'x' symbol and has a pop-out effect while rolling over. Used in osu! standard. + /// Uses the 'x' symbol and has a pop-out effect while rolling over. /// - public class OsuComboCounter : ComboCounter + public class StandardComboCounter : ComboCounter { protected uint ScheduledPopOutCurrentId; @@ -26,12 +25,12 @@ namespace osu.Game.Modes.Osu.UI PopOutCount.Anchor = Anchor; } - protected override string FormatCount(ulong count) + protected override string FormatCount(int count) { return $@"{count}x"; } - protected virtual void TransformPopOut(ulong newValue) + protected virtual void TransformPopOut(int newValue) { PopOutCount.Text = FormatCount(newValue); @@ -44,19 +43,19 @@ namespace osu.Game.Modes.Osu.UI PopOutCount.MoveTo(DisplayedCountSpriteText.Position, PopOutDuration, PopOutEasing); } - protected virtual void TransformPopOutRolling(ulong newValue) + protected virtual void TransformPopOutRolling(int newValue) { TransformPopOut(newValue); TransformPopOutSmall(newValue); } - protected virtual void TransformNoPopOut(ulong newValue) + protected virtual void TransformNoPopOut(int newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(1); } - protected virtual void TransformPopOutSmall(ulong newValue) + protected virtual void TransformPopOutSmall(int newValue) { DisplayedCountSpriteText.Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); @@ -72,7 +71,7 @@ namespace osu.Game.Modes.Osu.UI DisplayedCount++; } - protected override void OnCountRolling(ulong currentValue, ulong newValue) + protected override void OnCountRolling(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -83,7 +82,7 @@ namespace osu.Game.Modes.Osu.UI base.OnCountRolling(currentValue, newValue); } - protected override void OnCountIncrement(ulong currentValue, ulong newValue) + protected override void OnCountIncrement(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -93,7 +92,7 @@ namespace osu.Game.Modes.Osu.UI DisplayedCountSpriteText.Show(); TransformPopOut(newValue); - + uint newTaskId = ScheduledPopOutCurrentId; Scheduler.AddDelayed(delegate { @@ -101,7 +100,7 @@ namespace osu.Game.Modes.Osu.UI }, PopOutDuration); } - protected override void OnCountChange(ulong currentValue, ulong newValue) + protected override void OnCountChange(int currentValue, int newValue) { ScheduledPopOutCurrentId++; @@ -111,7 +110,7 @@ namespace osu.Game.Modes.Osu.UI base.OnCountChange(currentValue, newValue); } - protected override void OnDisplayedCountRolling(ulong currentValue, ulong newValue) + protected override void OnDisplayedCountRolling(int currentValue, int newValue) { if (newValue == 0) DisplayedCountSpriteText.FadeOut(FadeOutDuration); @@ -124,14 +123,14 @@ namespace osu.Game.Modes.Osu.UI TransformNoPopOut(newValue); } - protected override void OnDisplayedCountChange(ulong newValue) + protected override void OnDisplayedCountChange(int newValue) { DisplayedCountSpriteText.FadeTo(newValue == 0 ? 0 : 1); TransformNoPopOut(newValue); } - protected override void OnDisplayedCountIncrement(ulong newValue) + protected override void OnDisplayedCountIncrement(int newValue) { DisplayedCountSpriteText.Show(); diff --git a/osu.Game/Modes/UI/StandardHealthDisplay.cs b/osu.Game/Modes/UI/StandardHealthDisplay.cs new file mode 100644 index 0000000000..b6a3dc7f89 --- /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 +{ + public 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 load(OsuColour colours) + { + fill.Colour = colours.BlueLighter; + fill.EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDarker.Opacity(0.6f), + Radius = 8, + Type = EdgeEffectType.Glow + }; + } + + protected override void SetHealth(float value) => fill.ScaleTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); + } +} diff --git a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs b/osu.Game/Modes/UI/StandardHudOverlay.cs similarity index 74% rename from osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs rename to osu.Game/Modes/UI/StandardHudOverlay.cs index d91a751c26..f77191adf7 100644 --- a/osu.Game.Modes.Osu/UI/OsuScoreOverlay.cs +++ b/osu.Game/Modes/UI/StandardHudOverlay.cs @@ -1,27 +1,16 @@ // 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 + public class StandardHudOverlay : HudOverlay { - 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 }, - }; - protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter { Anchor = Anchor.TopCentre, @@ -31,12 +20,19 @@ namespace osu.Game.Modes.Osu.UI Margin = new MarginPadding { Right = 5 }, }; - protected override ComboCounter CreateComboCounter() => new OsuComboCounter + 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, @@ -44,13 +40,15 @@ namespace osu.Game.Modes.Osu.UI 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), - } + }; + + 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..1a71543786 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,9 @@ namespace osu.Game.Screens.Play ruleset = Ruleset.GetRuleset(Beatmap.PlayMode); - scoreOverlay = ruleset.CreateScoreOverlay(); - scoreOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); + hudOverlay = new StandardHudOverlay(); + hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys()); + hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count)); pauseOverlay = new PauseOverlay { @@ -135,7 +136,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 +160,7 @@ namespace osu.Game.Screens.Play }, } }, - scoreOverlay, + hudOverlay, pauseOverlay }; } @@ -196,7 +197,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 +212,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..81bc844872 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -97,6 +97,9 @@ + + + @@ -167,6 +170,7 @@ + @@ -181,7 +185,6 @@ -