From 1ef465716daa49a44de01c03fa3c1ecd5f352c17 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 5 Apr 2017 21:59:40 +0900 Subject: [PATCH] Proper legacy timing point parsing. --- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 27 ++++++++++++------- .../Modes/Objects/LegacyHitObjectParser.cs | 5 ---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 7c042b4907..cfef8e947b 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -31,7 +31,7 @@ namespace osu.Game.Beatmaps.Formats // TODO: Not sure how far back to go, or differences between versions } - private Sample defaultSampleSet; + private LegacySampleBank defaultSampleBank; private int defaultSampleVolume = 100; private bool samplesMatchPlaybackRate; @@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps.Formats beatmap.BeatmapInfo.Countdown = int.Parse(val) == 1; break; case @"SampleSet": - defaultSampleSet = (Sample)Enum.Parse(typeof(Sample), val); + defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), val); break; case @"SampleVolume": defaultSampleVolume = int.Parse(val); @@ -222,13 +222,13 @@ namespace osu.Game.Beatmaps.Formats if (split.Length >= 3) timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]); - Sample sampleSet = defaultSampleSet; + LegacySampleBank sampleSet = defaultSampleBank; if (split.Length >= 4) - sampleSet = (Sample)int.Parse(split[3]); + sampleSet = (LegacySampleBank)int.Parse(split[3]); - SampleBank sampleBank = SampleBank.Default; - if (split.Length >= 5) - sampleBank = (SampleBank)int.Parse(split[4]); + //SampleBank sampleBank = SampleBank.Default; + //if (split.Length >= 5) + // sampleBank = (SampleBank)int.Parse(split[4]); int sampleVolume = defaultSampleVolume; if (split.Length >= 6) @@ -254,10 +254,9 @@ namespace osu.Game.Beatmaps.Formats VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1, TimingChange = timingChange, TimeSignature = timeSignature, - Sample = new SampleInfo + SampleBank = new SampleBank { - Bank = sampleBank, - Set = sampleSet, + Name = sampleSet.ToString().ToLower(), Volume = sampleVolume }, KiaiMode = kiaiMode, @@ -372,5 +371,13 @@ namespace osu.Game.Beatmaps.Formats } } } + + private enum LegacySampleBank + { + None = 0, + Normal = 1, + Soft = 2, + Drum = 3 + } } } diff --git a/osu.Game/Modes/Objects/LegacyHitObjectParser.cs b/osu.Game/Modes/Objects/LegacyHitObjectParser.cs index bb94d02d38..4bf3d0f093 100644 --- a/osu.Game/Modes/Objects/LegacyHitObjectParser.cs +++ b/osu.Game/Modes/Objects/LegacyHitObjectParser.cs @@ -105,11 +105,6 @@ namespace osu.Game.Modes.Objects throw new InvalidOperationException($@"Unknown hit object type {type}"); result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); - result.SampleBank = new HitSampleInfo - { - Type = (SampleType)int.Parse(split[4]), - Set = Sample.Soft, - }; // TODO: "addition" field