mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 13:33:03 +08:00
Implement sample + addition sample reading from hit objects.
This commit is contained in:
parent
1ef465716d
commit
e903241c7b
@ -372,7 +372,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum LegacySampleBank
|
internal enum LegacySampleBank
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Normal = 1,
|
Normal = 1,
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps.Samples
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The list of samples that are to be played to be played from this bank.
|
/// The list of samples that are to be played to be played from this bank.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Sample> Samples;
|
public List<Sample> Samples = new List<Sample>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// In conversion from osu-stable, this is equivalent to SampleSet (_not_ CustomSampleSet).
|
/// In conversion from osu-stable, this is equivalent to SampleSet (_not_ CustomSampleSet).
|
||||||
|
@ -5,7 +5,6 @@ namespace osu.Game.Beatmaps.Samples
|
|||||||
{
|
{
|
||||||
public enum SampleType
|
public enum SampleType
|
||||||
{
|
{
|
||||||
None,
|
|
||||||
Normal,
|
Normal,
|
||||||
Whistle,
|
Whistle,
|
||||||
Finish,
|
Finish,
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Modes.Objects.Drawables
|
|||||||
{
|
{
|
||||||
foreach (var bank in HitObject.SampleBanks)
|
foreach (var bank in HitObject.SampleBanks)
|
||||||
foreach (var sample in bank.Samples)
|
foreach (var sample in bank.Samples)
|
||||||
samples.Add(audio.Sample.Get($@"Gameplay/{sample.Type}-hit{bank.Name}"));
|
samples.Add(audio.Sample.Get($@"Gameplay/{bank.Name}-hit{sample.Type.ToString().ToLower()}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArmedState state;
|
private ArmedState state;
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Modes.Objects
|
|||||||
{
|
{
|
||||||
foreach (var bank in SampleBanks)
|
foreach (var bank in SampleBanks)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(bank.Name))
|
if (!string.IsNullOrEmpty(bank.Name) && bank.Name != @"none")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If the bank is not assigned a name, assign it from the relevant timing point
|
// If the bank is not assigned a name, assign it from the relevant timing point
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
// 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 OpenTK;
|
using OpenTK;
|
||||||
using osu.Game.Beatmaps.Samples;
|
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using osu.Game.Modes.Objects.Legacy;
|
using osu.Game.Modes.Objects.Legacy;
|
||||||
|
using osu.Game.Beatmaps.Samples;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Objects
|
namespace osu.Game.Modes.Objects
|
||||||
{
|
{
|
||||||
@ -20,6 +21,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
||||||
type &= ~LegacyHitObjectType.NewCombo;
|
type &= ~LegacyHitObjectType.NewCombo;
|
||||||
|
|
||||||
|
var normalSampleBank = new SampleBank();
|
||||||
|
var addSampleBank = new SampleBank();
|
||||||
|
|
||||||
HitObject result;
|
HitObject result;
|
||||||
|
|
||||||
if ((type & LegacyHitObjectType.Circle) > 0)
|
if ((type & LegacyHitObjectType.Circle) > 0)
|
||||||
@ -29,6 +33,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||||
NewCombo = combo
|
NewCombo = combo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (split.Length > 5)
|
||||||
|
readCustomSampleBanks(split[5], ref normalSampleBank, ref addSampleBank);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Slider) > 0)
|
else if ((type & LegacyHitObjectType.Slider) > 0)
|
||||||
{
|
{
|
||||||
@ -84,6 +91,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||||
NewCombo = combo
|
NewCombo = combo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (split.Length > 10)
|
||||||
|
readCustomSampleBanks(split[10], ref normalSampleBank, ref addSampleBank);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Spinner) > 0)
|
else if ((type & LegacyHitObjectType.Spinner) > 0)
|
||||||
{
|
{
|
||||||
@ -91,6 +101,9 @@ namespace osu.Game.Modes.Objects
|
|||||||
{
|
{
|
||||||
EndTime = Convert.ToDouble(split[5], CultureInfo.InvariantCulture)
|
EndTime = Convert.ToDouble(split[5], CultureInfo.InvariantCulture)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (split.Length > 6)
|
||||||
|
readCustomSampleBanks(split[6], ref normalSampleBank, ref addSampleBank);
|
||||||
}
|
}
|
||||||
else if ((type & LegacyHitObjectType.Hold) > 0)
|
else if ((type & LegacyHitObjectType.Hold) > 0)
|
||||||
{
|
{
|
||||||
@ -106,9 +119,57 @@ namespace osu.Game.Modes.Objects
|
|||||||
|
|
||||||
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
|
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
// TODO: "addition" field
|
var soundType = (LegacySoundType)int.Parse(split[4]);
|
||||||
|
|
||||||
|
normalSampleBank.Samples.Add(new Sample { Type = SampleType.Normal });
|
||||||
|
if ((soundType & LegacySoundType.Finish) > 0)
|
||||||
|
addSampleBank.Samples.Add(new Sample { Type = SampleType.Finish });
|
||||||
|
if ((soundType & LegacySoundType.Whistle) > 0)
|
||||||
|
addSampleBank.Samples.Add(new Sample { Type = SampleType.Whistle });
|
||||||
|
if ((soundType & LegacySoundType.Clap) > 0)
|
||||||
|
addSampleBank.Samples.Add(new Sample { Type = SampleType.Clap });
|
||||||
|
|
||||||
|
result.SampleBanks.Add(normalSampleBank);
|
||||||
|
result.SampleBanks.Add(addSampleBank);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readCustomSampleBanks(string str, ref SampleBank normalSampleBank, ref SampleBank addSampleBank)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
return;
|
||||||
|
|
||||||
|
string[] split = str.Split(':');
|
||||||
|
|
||||||
|
var sb = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[0]);
|
||||||
|
var addsb = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[1]);
|
||||||
|
|
||||||
|
int volume = split.Length > 3 ? int.Parse(split[3]) : 0;
|
||||||
|
|
||||||
|
//string sampleFile = split2.Length > 4 ? split2[4] : string.Empty;
|
||||||
|
|
||||||
|
normalSampleBank = new SampleBank
|
||||||
|
{
|
||||||
|
Name = sb.ToString().ToLower(),
|
||||||
|
Volume = volume
|
||||||
|
};
|
||||||
|
|
||||||
|
addSampleBank = new SampleBank
|
||||||
|
{
|
||||||
|
Name = addsb.ToString().ToLower(),
|
||||||
|
Volume = volume
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
private enum LegacySoundType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Normal = 1,
|
||||||
|
Whistle = 2,
|
||||||
|
Finish = 4,
|
||||||
|
Clap = 8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user