Proper legacy timing point parsing.

This commit is contained in:
smoogipooo
2017-04-05 21:59:40 +09:00
parent d607207b69
commit 1ef465716d
2 changed files with 17 additions and 15 deletions

View File

@ -31,7 +31,7 @@ namespace osu.Game.Beatmaps.Formats
// TODO: Not sure how far back to go, or differences between versions // TODO: Not sure how far back to go, or differences between versions
} }
private Sample defaultSampleSet; private LegacySampleBank defaultSampleBank;
private int defaultSampleVolume = 100; private int defaultSampleVolume = 100;
private bool samplesMatchPlaybackRate; private bool samplesMatchPlaybackRate;
@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps.Formats
beatmap.BeatmapInfo.Countdown = int.Parse(val) == 1; beatmap.BeatmapInfo.Countdown = int.Parse(val) == 1;
break; break;
case @"SampleSet": case @"SampleSet":
defaultSampleSet = (Sample)Enum.Parse(typeof(Sample), val); defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), val);
break; break;
case @"SampleVolume": case @"SampleVolume":
defaultSampleVolume = int.Parse(val); defaultSampleVolume = int.Parse(val);
@ -222,13 +222,13 @@ namespace osu.Game.Beatmaps.Formats
if (split.Length >= 3) if (split.Length >= 3)
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]); timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
Sample sampleSet = defaultSampleSet; LegacySampleBank sampleSet = defaultSampleBank;
if (split.Length >= 4) if (split.Length >= 4)
sampleSet = (Sample)int.Parse(split[3]); sampleSet = (LegacySampleBank)int.Parse(split[3]);
SampleBank sampleBank = SampleBank.Default; //SampleBank sampleBank = SampleBank.Default;
if (split.Length >= 5) //if (split.Length >= 5)
sampleBank = (SampleBank)int.Parse(split[4]); // sampleBank = (SampleBank)int.Parse(split[4]);
int sampleVolume = defaultSampleVolume; int sampleVolume = defaultSampleVolume;
if (split.Length >= 6) if (split.Length >= 6)
@ -254,10 +254,9 @@ namespace osu.Game.Beatmaps.Formats
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1, VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
TimingChange = timingChange, TimingChange = timingChange,
TimeSignature = timeSignature, TimeSignature = timeSignature,
Sample = new SampleInfo SampleBank = new SampleBank
{ {
Bank = sampleBank, Name = sampleSet.ToString().ToLower(),
Set = sampleSet,
Volume = sampleVolume Volume = sampleVolume
}, },
KiaiMode = kiaiMode, KiaiMode = kiaiMode,
@ -372,5 +371,13 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
} }
private enum LegacySampleBank
{
None = 0,
Normal = 1,
Soft = 2,
Drum = 3
}
} }
} }

View File

@ -105,11 +105,6 @@ namespace osu.Game.Modes.Objects
throw new InvalidOperationException($@"Unknown hit object type {type}"); throw new InvalidOperationException($@"Unknown hit object type {type}");
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
result.SampleBank = new HitSampleInfo
{
Type = (SampleType)int.Parse(split[4]),
Set = Sample.Soft,
};
// TODO: "addition" field // TODO: "addition" field