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.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.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; 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; - } - - } -} 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/HUDOverlay.cs b/osu.Game/Modes/UI/HUDOverlay.cs deleted file mode 100644 index 87cbbb5446..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(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/HudOverlay.cs b/osu.Game/Modes/UI/HudOverlay.cs index 87cbbb5446..979831f89f 100644 --- a/osu.Game/Modes/UI/HudOverlay.cs +++ b/osu.Game/Modes/UI/HudOverlay.cs @@ -29,7 +29,7 @@ namespace osu.Game.Modes.UI protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); - protected HudOverlay(Ruleset ruleset) + protected HudOverlay() { RelativeSizeAxes = Axes.Both; 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(); 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 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 @@ -