mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 10:03:05 +08:00
Restructure reading normal/add/volume members into class to make code a bit more readable/usable.
This commit is contained in:
parent
ac9f0ccb48
commit
bd7341c5a1
@ -23,9 +23,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
bool combo = type.HasFlag(HitObjectType.NewCombo);
|
bool combo = type.HasFlag(HitObjectType.NewCombo);
|
||||||
type &= ~HitObjectType.NewCombo;
|
type &= ~HitObjectType.NewCombo;
|
||||||
|
|
||||||
int sampleVolume = 0;
|
var soundType = (LegacySoundType)int.Parse(split[4]);
|
||||||
string normalSampleBank = null;
|
|
||||||
string addSampleBank = null;
|
SampleBankInfo bankInfo = new SampleBankInfo();
|
||||||
|
|
||||||
HitObject result;
|
HitObject result;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
result = CreateHit(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo);
|
result = CreateHit(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo);
|
||||||
|
|
||||||
if (split.Length > 5)
|
if (split.Length > 5)
|
||||||
readCustomSampleBanks(split[5], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
readCustomSampleBanks(split[5], bankInfo);
|
||||||
}
|
}
|
||||||
else if ((type & HitObjectType.Slider) > 0)
|
else if ((type & HitObjectType.Slider) > 0)
|
||||||
{
|
{
|
||||||
@ -76,18 +76,19 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
if (split.Length > 7)
|
if (split.Length > 7)
|
||||||
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
|
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
if (split.Length > 10)
|
||||||
|
readCustomSampleBanks(split[10], bankInfo);
|
||||||
|
|
||||||
result = CreateSlider(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, points, length, curveType, repeatCount);
|
result = CreateSlider(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, points, length, curveType, repeatCount);
|
||||||
|
|
||||||
if (split.Length > 10)
|
|
||||||
readCustomSampleBanks(split[10], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
|
||||||
}
|
}
|
||||||
else if ((type & HitObjectType.Spinner) > 0)
|
else if ((type & HitObjectType.Spinner) > 0)
|
||||||
{
|
{
|
||||||
result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture));
|
result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
if (split.Length > 6)
|
if (split.Length > 6)
|
||||||
readCustomSampleBanks(split[6], ref normalSampleBank, ref addSampleBank, ref sampleVolume);
|
readCustomSampleBanks(split[6], bankInfo);
|
||||||
}
|
}
|
||||||
else if ((type & HitObjectType.Hold) > 0)
|
else if ((type & HitObjectType.Hold) > 0)
|
||||||
{
|
{
|
||||||
@ -106,15 +107,12 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
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.Samples = convertSoundType(soundType, bankInfo);
|
||||||
var soundType = (LegacySoundType)int.Parse(split[4]);
|
|
||||||
result.Samples = convertSoundType(soundType, normalSampleBank, addSampleBank);
|
|
||||||
result.Samples.ForEach(s => s.Volume = sampleVolume);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCustomSampleBanks(string str, ref string normalSampleBank, ref string addSampleBank, ref int sampleVolume)
|
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str))
|
if (string.IsNullOrEmpty(str))
|
||||||
return;
|
return;
|
||||||
@ -134,9 +132,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
if (stringAddBank == @"none")
|
if (stringAddBank == @"none")
|
||||||
stringAddBank = null;
|
stringAddBank = null;
|
||||||
|
|
||||||
normalSampleBank = stringBank;
|
bankInfo.Normal = stringBank;
|
||||||
addSampleBank = stringAddBank;
|
bankInfo.Add = stringAddBank;
|
||||||
sampleVolume = split.Length > 3 ? int.Parse(split[3]) : 0;
|
|
||||||
|
if (split.Length > 3)
|
||||||
|
bankInfo.Volume = int.Parse(split[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -167,7 +167,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
/// <returns>The hit object.</returns>
|
/// <returns>The hit object.</returns>
|
||||||
protected abstract HitObject CreateSpinner(Vector2 position, double endTime);
|
protected abstract HitObject CreateSpinner(Vector2 position, double endTime);
|
||||||
|
|
||||||
private List<SampleInfo> convertSoundType(LegacySoundType type, string normalSampleBank, string addSampleBank)
|
private List<SampleInfo> convertSoundType(LegacySoundType type, SampleBankInfo bankInfo)
|
||||||
{
|
{
|
||||||
List<SampleInfo> soundTypes = new List<SampleInfo>();
|
List<SampleInfo> soundTypes = new List<SampleInfo>();
|
||||||
|
|
||||||
@ -175,8 +175,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
{
|
{
|
||||||
soundTypes.Add(new SampleInfo
|
soundTypes.Add(new SampleInfo
|
||||||
{
|
{
|
||||||
Bank = normalSampleBank,
|
Bank = bankInfo.Normal,
|
||||||
Name = SampleInfo.HIT_NORMAL
|
Name = SampleInfo.HIT_NORMAL,
|
||||||
|
Volume = bankInfo.Volume
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +185,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
{
|
{
|
||||||
soundTypes.Add(new SampleInfo
|
soundTypes.Add(new SampleInfo
|
||||||
{
|
{
|
||||||
Bank = addSampleBank,
|
Bank = bankInfo.Add,
|
||||||
Name = SampleInfo.HIT_FINISH
|
Name = SampleInfo.HIT_FINISH,
|
||||||
|
Volume = bankInfo.Volume
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +195,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
{
|
{
|
||||||
soundTypes.Add(new SampleInfo
|
soundTypes.Add(new SampleInfo
|
||||||
{
|
{
|
||||||
Bank = addSampleBank,
|
Bank = bankInfo.Add,
|
||||||
Name = SampleInfo.HIT_WHISTLE
|
Name = SampleInfo.HIT_WHISTLE,
|
||||||
|
Volume = bankInfo.Volume
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,14 +205,27 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
{
|
{
|
||||||
soundTypes.Add(new SampleInfo
|
soundTypes.Add(new SampleInfo
|
||||||
{
|
{
|
||||||
Bank = addSampleBank,
|
Bank = bankInfo.Add,
|
||||||
Name = SampleInfo.HIT_CLAP
|
Name = SampleInfo.HIT_CLAP,
|
||||||
|
Volume = bankInfo.Volume
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return soundTypes;
|
return soundTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SampleBankInfo
|
||||||
|
{
|
||||||
|
public string Normal = null;
|
||||||
|
public string Add = null;
|
||||||
|
public int Volume = 0;
|
||||||
|
|
||||||
|
public SampleBankInfo Clone()
|
||||||
|
{
|
||||||
|
return (SampleBankInfo)MemberwiseClone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum LegacySoundType
|
private enum LegacySoundType
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user