From 99b96236719cbb348aa276021d847322481de16e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 24 Mar 2017 14:09:58 +0900 Subject: [PATCH] Implement taiko replays + key conversion. --- osu.Game.Modes.Taiko/LegacyTaikoReplay.cs | 43 +++++++++++++++++++ .../Scoring/TaikoScoreProcessor.cs | 9 ++++ osu.Game.Modes.Taiko/TaikoScore.cs | 13 ++++++ .../osu.Game.Modes.Taiko.csproj | 2 + osu.Game/Database/ScoreDatabase.cs | 2 +- 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Modes.Taiko/LegacyTaikoReplay.cs create mode 100644 osu.Game.Modes.Taiko/TaikoScore.cs diff --git a/osu.Game.Modes.Taiko/LegacyTaikoReplay.cs b/osu.Game.Modes.Taiko/LegacyTaikoReplay.cs new file mode 100644 index 0000000000..3e6ccd4ac7 --- /dev/null +++ b/osu.Game.Modes.Taiko/LegacyTaikoReplay.cs @@ -0,0 +1,43 @@ +// 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.IO; +using osu.Framework.Input; +using osu.Game.Input.Handlers; +using OpenTK.Input; + +namespace osu.Game.Modes.Taiko +{ + public class LegacyTaikoReplay : LegacyReplay + { + public LegacyTaikoReplay(StreamReader reader) + : base(reader) + { + } + + public override ReplayInputHandler CreateInputHandler() => new LegacyTaikoReplayInputHandler(Frames); + + private class LegacyTaikoReplayInputHandler : LegacyReplayInputHandler + { + public LegacyTaikoReplayInputHandler(List replayContent) + : base(replayContent) + { + } + + public override List GetPendingStates() => new List + { + new InputState + { + Keyboard = new ReplayKeyboardState(new List(new[] + { + CurrentFrame?.MouseRight1 == true ? Key.F : Key.Unknown, + CurrentFrame?.MouseRight2 == true ? Key.J : Key.Unknown, + CurrentFrame?.MouseLeft1 == true ? Key.D : Key.Unknown, + CurrentFrame?.MouseLeft2 == true ? Key.K : Key.Unknown + })) + } + }; + } + } +} diff --git a/osu.Game.Modes.Taiko/Scoring/TaikoScoreProcessor.cs b/osu.Game.Modes.Taiko/Scoring/TaikoScoreProcessor.cs index 3007411230..25800f1e07 100644 --- a/osu.Game.Modes.Taiko/Scoring/TaikoScoreProcessor.cs +++ b/osu.Game.Modes.Taiko/Scoring/TaikoScoreProcessor.cs @@ -119,6 +119,15 @@ namespace osu.Game.Modes.Taiko.Scoring { } + public override Score CreateScore() => new TaikoScore + { + TotalScore = TotalScore, + Combo = Combo, + MaxCombo = HighestCombo, + Accuracy = Accuracy, + Health = Health, + }; + protected override void ComputeTargets(Beatmap beatmap) { double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.DrainRate, 0.5, 0.75, 0.98)); diff --git a/osu.Game.Modes.Taiko/TaikoScore.cs b/osu.Game.Modes.Taiko/TaikoScore.cs new file mode 100644 index 0000000000..2d5c3e750b --- /dev/null +++ b/osu.Game.Modes.Taiko/TaikoScore.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Modes.Scoring; +using System.IO; + +namespace osu.Game.Modes.Taiko +{ + public class TaikoScore : Score + { + public override Replay CreateLegacyReplayFrom(StreamReader reader) => new LegacyTaikoReplay(reader); + } +} diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index 937c5a5e51..54ebba138f 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -52,6 +52,7 @@ + @@ -61,6 +62,7 @@ + diff --git a/osu.Game/Database/ScoreDatabase.cs b/osu.Game/Database/ScoreDatabase.cs index 665ae8649e..096c0dcc29 100644 --- a/osu.Game/Database/ScoreDatabase.cs +++ b/osu.Game/Database/ScoreDatabase.cs @@ -101,7 +101,7 @@ namespace osu.Game.Database using (var lzma = new LzmaStream(properties, replayInStream, compressedSize, outSize)) using (var reader = new StreamReader(lzma)) - score.Replay = new LegacyReplay(reader); + score.Replay = score.CreateLegacyReplayFrom(reader); } }