1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:25:05 +08:00

Merge branch 'master' into centralise-judgement-display

This commit is contained in:
Dean Herbert 2018-07-23 05:23:52 +09:00 committed by GitHub
commit 6fa70ed696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 23 deletions

View File

@ -26,7 +26,7 @@ Build and run
- Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included) - Using Visual Studio 2017, Rider or Visual Studio Code (configurations are included)
- From command line using `dotnet run --project osu.Desktop --framework netcoreapp2.1` - From command line using `dotnet run --project osu.Desktop --framework netcoreapp2.1`
The above methods should automatically do so, but if you run into issues building you may need to restore nuget packages (commonly via `dotnet restore`). If you run into issues building you may need to restore nuget packages (commonly via `dotnet restore`). Visual Studio Code users must run `Restore` task from debug tab before attempt to build.
# Contributing # Contributing

View File

@ -214,10 +214,10 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
[Test] [Test]
public void TestDecodeCustomSamples() public void TestDecodeControlPointCustomSampleBank()
{ {
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("custom-samples.osu")) using (var resStream = Resource.OpenResource("controlpoint-custom-samplebank.osu"))
using (var stream = new StreamReader(resStream)) using (var stream = new StreamReader(resStream))
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
@ -228,25 +228,42 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
} }
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(new SampleInfo { Name = "hitnormal" }); SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
} }
[Test] [Test]
public void TestDecodeCustomHitObjectSamples() public void TestDecodeHitObjectCustomSampleBank()
{ {
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("custom-hitobject-samples.osu")) using (var resStream = Resource.OpenResource("hitobject-custom-samplebank.osu"))
using (var stream = new StreamReader(resStream)) using (var stream = new StreamReader(resStream))
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("hit_1.wav", hitObjects[0].Samples[0].LookupNames.First()); Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("hit_2.wav", hitObjects[1].Samples[0].LookupNames.First()); Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("hit_1.wav", hitObjects[3].Samples[0].LookupNames.First());
} }
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(new SampleInfo { Name = "hitnormal" }); SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
}
[Test]
public void TestDecodeHitObjectFileSamples()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = Resource.OpenResource("hitobject-file-samples.osu"))
using (var stream = new StreamReader(resStream))
{
var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
}
SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
} }
} }
} }

View File

@ -0,0 +1,13 @@
osu file format v14
[General]
SampleSet: Normal
[TimingPoints]
2170,468.75,4,1,0,40,1,0
3107,-100,4,1,2,40,0,0
[HitObjects]
255,193,2170,1,0,0:0:0:0:
256,191,3107,5,0,0:0:0:0:
255,193,4000,1,0,0:0:3:70:

View File

@ -40,7 +40,6 @@ namespace osu.Game.Beatmaps.ControlPoints
{ {
var newSampleInfo = sampleInfo.Clone(); var newSampleInfo = sampleInfo.Clone();
newSampleInfo.Bank = sampleInfo.Bank ?? SampleBank; newSampleInfo.Bank = sampleInfo.Bank ?? SampleBank;
newSampleInfo.Name = sampleInfo.Name;
newSampleInfo.Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume; newSampleInfo.Volume = sampleInfo.Volume > 0 ? sampleInfo.Volume : SampleVolume;
return newSampleInfo; return newSampleInfo;
} }

View File

@ -188,7 +188,7 @@ namespace osu.Game.Beatmaps.Formats
{ {
var baseInfo = base.ApplyTo(sampleInfo); var baseInfo = base.ApplyTo(sampleInfo);
if (CustomSampleBank > 1) if (string.IsNullOrEmpty(baseInfo.Suffix) && CustomSampleBank > 1)
baseInfo.Suffix = CustomSampleBank.ToString(); baseInfo.Suffix = CustomSampleBank.ToString();
return baseInfo; return baseInfo;

View File

@ -194,8 +194,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
string[] split = str.Split(':'); string[] split = str.Split(':');
var bank = (LegacyBeatmapDecoder.LegacySampleBank)Convert.ToInt32(split[0]); var bank = (LegacyBeatmapDecoder.LegacySampleBank)int.Parse(split[0]);
var addbank = (LegacyBeatmapDecoder.LegacySampleBank)Convert.ToInt32(split[1]); var addbank = (LegacyBeatmapDecoder.LegacySampleBank)int.Parse(split[1]);
string stringBank = bank.ToString().ToLower(); string stringBank = bank.ToString().ToLower();
if (stringBank == @"none") if (stringBank == @"none")
@ -207,6 +207,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
bankInfo.Normal = stringBank; bankInfo.Normal = stringBank;
bankInfo.Add = stringAddBank; bankInfo.Add = stringAddBank;
if (split.Length > 2)
bankInfo.CustomSampleBank = int.Parse(split[2]);
if (split.Length > 3) if (split.Length > 3)
bankInfo.Volume = int.Parse(split[3]); bankInfo.Volume = int.Parse(split[3]);
@ -258,41 +261,45 @@ namespace osu.Game.Rulesets.Objects.Legacy
var soundTypes = new List<SampleInfo> var soundTypes = new List<SampleInfo>
{ {
new SampleInfo new LegacySampleInfo
{ {
Bank = bankInfo.Normal, Bank = bankInfo.Normal,
Name = SampleInfo.HIT_NORMAL, Name = SampleInfo.HIT_NORMAL,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
} }
}; };
if (type.HasFlag(LegacySoundType.Finish)) if (type.HasFlag(LegacySoundType.Finish))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_FINISH, Name = SampleInfo.HIT_FINISH,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
if (type.HasFlag(LegacySoundType.Whistle)) if (type.HasFlag(LegacySoundType.Whistle))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_WHISTLE, Name = SampleInfo.HIT_WHISTLE,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
if (type.HasFlag(LegacySoundType.Clap)) if (type.HasFlag(LegacySoundType.Clap))
{ {
soundTypes.Add(new SampleInfo soundTypes.Add(new LegacySampleInfo
{ {
Bank = bankInfo.Add, Bank = bankInfo.Add,
Name = SampleInfo.HIT_CLAP, Name = SampleInfo.HIT_CLAP,
Volume = bankInfo.Volume Volume = bankInfo.Volume,
CustomSampleBank = bankInfo.CustomSampleBank
}); });
} }
@ -307,9 +314,23 @@ namespace osu.Game.Rulesets.Objects.Legacy
public string Add; public string Add;
public int Volume; public int Volume;
public int CustomSampleBank;
public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone(); public SampleBankInfo Clone() => (SampleBankInfo)MemberwiseClone();
} }
private class LegacySampleInfo : SampleInfo
{
public int CustomSampleBank
{
set
{
if (value > 1)
Suffix = value.ToString();
}
}
}
private class FileSampleInfo : SampleInfo private class FileSampleInfo : SampleInfo
{ {
public string Filename; public string Filename;