From 5cafec3b6ae5fbfdcfe2fb071523fa4885c3f87c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 13:13:45 +0900 Subject: [PATCH] Add back CreateScoreProcessor to Ruleset to instantiate a non-generic ScoreProcessor for ScoreDatabase. --- osu.Game.Modes.Catch/CatchRuleset.cs | 2 ++ osu.Game.Modes.Catch/CatchScoreProcessor.cs | 4 ++++ osu.Game.Modes.Mania/ManiaRuleset.cs | 2 ++ osu.Game.Modes.Mania/ManiaScoreProcessor.cs | 4 ++++ osu.Game.Modes.Osu/OsuRuleset.cs | 2 ++ osu.Game.Modes.Osu/OsuScoreProcessor.cs | 10 ++++++++++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 2 ++ osu.Game.Modes.Taiko/TaikoScoreProcessor.cs | 4 ++++ osu.Game/Database/ScoreDatabase.cs | 4 ++-- osu.Game/Modes/Ruleset.cs | 2 ++ osu.Game/Modes/ScoreProcessor.cs | 15 +++++++++++++-- 11 files changed, 47 insertions(+), 4 deletions(-) diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 0166948fcb..50224e3fdb 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -88,5 +88,7 @@ namespace osu.Game.Modes.Catch }; public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap); + + public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(); } } diff --git a/osu.Game.Modes.Catch/CatchScoreProcessor.cs b/osu.Game.Modes.Catch/CatchScoreProcessor.cs index e653297a15..be4ae8b799 100644 --- a/osu.Game.Modes.Catch/CatchScoreProcessor.cs +++ b/osu.Game.Modes.Catch/CatchScoreProcessor.cs @@ -9,6 +9,10 @@ namespace osu.Game.Modes.Catch { internal class CatchScoreProcessor : ScoreProcessor { + public CatchScoreProcessor() + { + } + public CatchScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 8b4d79ac38..27b3fcdf60 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -103,5 +103,7 @@ namespace osu.Game.Modes.Mania public override IEnumerable CreateGameplayKeys() => new KeyCounter[] { /* Todo: Should be keymod specific */ }; public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap); + + public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(); } } diff --git a/osu.Game.Modes.Mania/ManiaScoreProcessor.cs b/osu.Game.Modes.Mania/ManiaScoreProcessor.cs index 5a763dc273..60ed336c8e 100644 --- a/osu.Game.Modes.Mania/ManiaScoreProcessor.cs +++ b/osu.Game.Modes.Mania/ManiaScoreProcessor.cs @@ -9,6 +9,10 @@ namespace osu.Game.Modes.Mania { internal class ManiaScoreProcessor : ScoreProcessor { + public ManiaScoreProcessor() + { + } + public ManiaScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index 109809126a..bbaf7eed5f 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -108,5 +108,7 @@ namespace osu.Game.Modes.Osu new KeyCounterMouse(MouseButton.Left), new KeyCounterMouse(MouseButton.Right) }; + + public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(); } } diff --git a/osu.Game.Modes.Osu/OsuScoreProcessor.cs b/osu.Game.Modes.Osu/OsuScoreProcessor.cs index 20b19a68a4..50eb685ecd 100644 --- a/osu.Game.Modes.Osu/OsuScoreProcessor.cs +++ b/osu.Game.Modes.Osu/OsuScoreProcessor.cs @@ -10,9 +10,19 @@ namespace osu.Game.Modes.Osu { internal class OsuScoreProcessor : ScoreProcessor { + public OsuScoreProcessor() + { + } + public OsuScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { + } + + protected override void Reset() + { + base.Reset(); + Health.Value = 1; Accuracy.Value = 1; } diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index dfbee82693..ff481e9162 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -89,5 +89,7 @@ namespace osu.Game.Modes.Taiko }; public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new TaikoDifficultyCalculator(beatmap); + + public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(); } } diff --git a/osu.Game.Modes.Taiko/TaikoScoreProcessor.cs b/osu.Game.Modes.Taiko/TaikoScoreProcessor.cs index 184d431c42..1e5c70cd2e 100644 --- a/osu.Game.Modes.Taiko/TaikoScoreProcessor.cs +++ b/osu.Game.Modes.Taiko/TaikoScoreProcessor.cs @@ -9,6 +9,10 @@ namespace osu.Game.Modes.Taiko { internal class TaikoScoreProcessor : ScoreProcessor { + public TaikoScoreProcessor() + { + } + public TaikoScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { diff --git a/osu.Game/Database/ScoreDatabase.cs b/osu.Game/Database/ScoreDatabase.cs index 88d2f360ba..a8eb5e1886 100644 --- a/osu.Game/Database/ScoreDatabase.cs +++ b/osu.Game/Database/ScoreDatabase.cs @@ -38,8 +38,8 @@ namespace osu.Game.Database using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename))) using (SerializationReader sr = new SerializationReader(s)) { - Ruleset.GetRuleset((PlayMode)sr.ReadByte()); - score = new Score(); + var ruleset = Ruleset.GetRuleset((PlayMode)sr.ReadByte()); + score = ruleset.CreateScoreProcessor().GetScore(); /* score.Pass = true;*/ var version = sr.ReadInt32(); diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index cce4b4ae33..013ea1d4fc 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -33,6 +33,8 @@ namespace osu.Game.Modes public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap); + public abstract ScoreProcessor CreateScoreProcessor(); + public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType()); protected abstract PlayMode PlayMode { get; } diff --git a/osu.Game/Modes/ScoreProcessor.cs b/osu.Game/Modes/ScoreProcessor.cs index cc30117831..35e19626b2 100644 --- a/osu.Game/Modes/ScoreProcessor.cs +++ b/osu.Game/Modes/ScoreProcessor.cs @@ -68,11 +68,17 @@ namespace osu.Game.Modes /// protected bool HasFailed { get; private set; } - protected ScoreProcessor(HitRenderer hitRenderer) + protected ScoreProcessor() { Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; - Judgements = new List(hitRenderer.Beatmap.HitObjects.Count); + Reset(); + } + + protected ScoreProcessor(HitRenderer hitRenderer) + : this() + { + Judgements = new List(hitRenderer.Beatmap.HitObjects.Count); hitRenderer.OnJudgement += addJudgement; } @@ -90,6 +96,11 @@ namespace osu.Game.Modes } } + /// + /// Resets this ScoreProcessor to a stale state. + /// + protected virtual void Reset() { } + /// /// Update any values that potentially need post-processing on a judgement change. ///