mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 22:34:09 +08:00
Fully parse control points.
This commit is contained in:
parent
a742664675
commit
4b424263ce
@ -55,7 +55,6 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
var beatmapInfo = decoder.Decode(new StreamReader(stream)).BeatmapInfo;
|
var beatmapInfo = decoder.Decode(new StreamReader(stream)).BeatmapInfo;
|
||||||
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
|
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
|
||||||
Assert.AreEqual(false, beatmapInfo.Countdown);
|
Assert.AreEqual(false, beatmapInfo.Countdown);
|
||||||
Assert.AreEqual(SampleSet.Soft, beatmapInfo.SampleSet);
|
|
||||||
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
|
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
|
||||||
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
|
Assert.AreEqual(false, beatmapInfo.SpecialStyle);
|
||||||
Assert.AreEqual(PlayMode.Osu, beatmapInfo.Mode);
|
Assert.AreEqual(PlayMode.Osu, beatmapInfo.Mode);
|
||||||
|
@ -31,6 +31,10 @@ 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 SampleSet defaultSampleSet;
|
||||||
|
private int defaultSampleVolume;
|
||||||
|
private bool samplesMatchPlaybackRate;
|
||||||
|
|
||||||
private readonly int beatmapVersion;
|
private readonly int beatmapVersion;
|
||||||
|
|
||||||
public OsuLegacyDecoder()
|
public OsuLegacyDecoder()
|
||||||
@ -73,7 +77,13 @@ 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":
|
||||||
beatmap.BeatmapInfo.SampleSet = (SampleSet)Enum.Parse(typeof(SampleSet), val);
|
defaultSampleSet = (SampleSet)Enum.Parse(typeof(SampleSet), val);
|
||||||
|
break;
|
||||||
|
case @"SampleVolume":
|
||||||
|
defaultSampleVolume = int.Parse(val);
|
||||||
|
break;
|
||||||
|
case "SamplesMatchPlaybackRate":
|
||||||
|
samplesMatchPlaybackRate = val[0] == '1';
|
||||||
break;
|
break;
|
||||||
case @"StackLeniency":
|
case @"StackLeniency":
|
||||||
beatmap.BeatmapInfo.StackLeniency = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
beatmap.BeatmapInfo.StackLeniency = float.Parse(val, NumberFormatInfo.InvariantInfo);
|
||||||
@ -203,28 +213,56 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
private void handleTimingPoints(Beatmap beatmap, string val)
|
private void handleTimingPoints(Beatmap beatmap, string val)
|
||||||
{
|
{
|
||||||
ControlPoint cp = null;
|
|
||||||
|
|
||||||
string[] split = val.Split(',');
|
string[] split = val.Split(',');
|
||||||
|
|
||||||
if (split.Length > 2)
|
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
||||||
{
|
|
||||||
int effectFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
|
|
||||||
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
||||||
cp = new ControlPoint
|
|
||||||
|
TimeSignatures timeSignature = TimeSignatures.SimpleQuadruple;
|
||||||
|
if (split.Length >= 3)
|
||||||
|
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
|
||||||
|
|
||||||
|
SampleSet sampleSet = defaultSampleSet;
|
||||||
|
if (split.Length >= 4)
|
||||||
|
sampleSet = (SampleSet)int.Parse(split[3]);
|
||||||
|
|
||||||
|
SampleBank sampleBank = SampleBank.Default;
|
||||||
|
if (split.Length >= 5)
|
||||||
|
sampleBank = (SampleBank)int.Parse(split[4]);
|
||||||
|
|
||||||
|
int sampleVolume = defaultSampleVolume;
|
||||||
|
if (split.Length >= 6)
|
||||||
|
sampleVolume = int.Parse(split[5]);
|
||||||
|
|
||||||
|
bool timingChange = true;
|
||||||
|
if (split.Length >= 7)
|
||||||
|
timingChange = split[6][0] == '1';
|
||||||
|
|
||||||
|
bool kiaiMode = false;
|
||||||
|
bool omitFirstBarSignature = false;
|
||||||
|
if (split.Length >= 8)
|
||||||
{
|
{
|
||||||
Time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo),
|
int effectFlags = int.Parse(split[7]);
|
||||||
BeatLength = beatLength > 0 ? beatLength : 0,
|
kiaiMode = (effectFlags & 1) > 0;
|
||||||
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
omitFirstBarSignature = (effectFlags & 8) > 0;
|
||||||
TimingChange = split.Length <= 6 || split[6][0] == '1',
|
|
||||||
KiaiMode = (effectFlags & 1) > 0,
|
|
||||||
OmitFirstBarLine = (effectFlags & 8) > 0,
|
|
||||||
TimeSignature = (TimeSignatures)int.Parse(split[2])
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp != null)
|
beatmap.TimingInfo.ControlPoints.Add(new ControlPoint
|
||||||
beatmap.TimingInfo.ControlPoints.Add(cp);
|
{
|
||||||
|
Time = time,
|
||||||
|
BeatLength = beatLength,
|
||||||
|
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
||||||
|
TimingChange = timingChange,
|
||||||
|
TimeSignature = timeSignature,
|
||||||
|
Sample = new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = sampleBank,
|
||||||
|
Set = sampleSet,
|
||||||
|
Volume = sampleVolume
|
||||||
|
},
|
||||||
|
KiaiMode = kiaiMode,
|
||||||
|
OmitFirstBarLine = omitFirstBarSignature
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours)
|
private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours)
|
||||||
|
@ -5,6 +5,6 @@ namespace osu.Game.Beatmaps.Samples
|
|||||||
{
|
{
|
||||||
public class HitSampleInfo : SampleInfo
|
public class HitSampleInfo : SampleInfo
|
||||||
{
|
{
|
||||||
public SampleType Type { get; set; }
|
public SampleType Type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,6 @@ namespace osu.Game.Beatmaps.Samples
|
|||||||
{
|
{
|
||||||
public SampleBank Bank;
|
public SampleBank Bank;
|
||||||
public SampleSet Set;
|
public SampleSet Set;
|
||||||
|
public int Volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Beatmaps.Samples;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Timing
|
namespace osu.Game.Beatmaps.Timing
|
||||||
{
|
{
|
||||||
public class ControlPoint
|
public class ControlPoint
|
||||||
@ -11,6 +13,7 @@ namespace osu.Game.Beatmaps.Timing
|
|||||||
TimingChange = true,
|
TimingChange = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public SampleInfo Sample;
|
||||||
public TimeSignatures TimeSignature;
|
public TimeSignatures TimeSignature;
|
||||||
public double Time;
|
public double Time;
|
||||||
public double BeatLength;
|
public double BeatLength;
|
||||||
|
@ -46,7 +46,6 @@ namespace osu.Game.Database
|
|||||||
// General
|
// General
|
||||||
public int AudioLeadIn { get; set; }
|
public int AudioLeadIn { get; set; }
|
||||||
public bool Countdown { get; set; }
|
public bool Countdown { get; set; }
|
||||||
public SampleSet SampleSet { get; set; }
|
|
||||||
public float StackLeniency { get; set; }
|
public float StackLeniency { get; set; }
|
||||||
public bool SpecialStyle { get; set; }
|
public bool SpecialStyle { get; set; }
|
||||||
public PlayMode Mode { get; set; }
|
public PlayMode Mode { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user