From 4cc309e5a76c3f9beccc25a1ded65492672b0eaa Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 6 Apr 2017 12:14:06 +0900 Subject: [PATCH] Make hit sounds into consts. --- osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs | 4 ++-- osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs | 5 +++-- osu.Game/Audio/SampleInfo.cs | 5 +++++ osu.Game/Modes/Objects/LegacyHitObjectParser.cs | 8 ++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs index 5aa3cf5024..d978774666 100644 --- a/osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -59,7 +59,7 @@ private IEnumerable convertHitObject(HitObject obj, Beatmap beat // Old osu! used hit sounding to determine various hit type information List samples = obj.Samples; - bool strong = samples.Any(s => s.Name == @"hitfinish"); + bool strong = samples.Any(s => s.Name == SampleInfo.HIT_FINISH); if (distanceData != null) { @@ -133,7 +133,7 @@ private IEnumerable convertHitObject(HitObject obj, Beatmap beat } else { - bool isRim = samples.Any(s => s.Name == @"hitclap" || s.Name == @"hitwhistle"); + bool isRim = samples.Any(s => s.Name == SampleInfo.HIT_CLAP || s.Name == SampleInfo.HIT_WHISTLE); if (isRim) { diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs index 6adc523f94..8183bc952e 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs @@ -11,6 +11,7 @@ using osu.Game.Modes.Osu; using osu.Game.Modes.Objects.Legacy; using System.Linq; +using osu.Game.Audio; namespace osu.Game.Tests.Beatmaps.Formats { @@ -136,12 +137,12 @@ public void TestDecodeHitObjects() Assert.IsNotNull(slider); Assert.AreEqual(new Vector2(192, 168), slider.Position); Assert.AreEqual(956, slider.StartTime); - Assert.IsTrue(slider.Samples.Any(s => s.Name == @"hitnormal")); + Assert.IsTrue(slider.Samples.Any(s => s.Name == SampleInfo.HIT_NORMAL)); var hit = beatmap.HitObjects[1] as LegacyHit; Assert.IsNotNull(hit); Assert.AreEqual(new Vector2(304, 56), hit.Position); Assert.AreEqual(1285, hit.StartTime); - Assert.IsTrue(hit.Samples.Any(s => s.Name == @"hitclap")); + Assert.IsTrue(hit.Samples.Any(s => s.Name == SampleInfo.HIT_CLAP)); } } } diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index 4357861f89..171a1bdf75 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -5,6 +5,11 @@ namespace osu.Game.Audio { public class SampleInfo { + public const string HIT_WHISTLE = @"hitwhistle"; + public const string HIT_FINISH = @"hitfinish"; + public const string HIT_NORMAL = @"hitnormal"; + public const string HIT_CLAP = @"hitclap"; + /// /// The bank to load the sample from. /// diff --git a/osu.Game/Modes/Objects/LegacyHitObjectParser.cs b/osu.Game/Modes/Objects/LegacyHitObjectParser.cs index 952730e256..ae85cd8cf4 100644 --- a/osu.Game/Modes/Objects/LegacyHitObjectParser.cs +++ b/osu.Game/Modes/Objects/LegacyHitObjectParser.cs @@ -129,7 +129,7 @@ public override HitObject Parse(string text) result.Samples.Add(new SampleInfo { Bank = normalSampleBank, - Name = "hitnormal", + Name = SampleInfo.HIT_NORMAL, Volume = sampleVolume }); @@ -138,7 +138,7 @@ public override HitObject Parse(string text) result.Samples.Add(new SampleInfo { Bank = addSampleBank, - Name = "hitfinish", + Name = SampleInfo.HIT_FINISH, Volume = sampleVolume }); } @@ -148,7 +148,7 @@ public override HitObject Parse(string text) result.Samples.Add(new SampleInfo { Bank = addSampleBank, - Name = "hitwhistle", + Name = SampleInfo.HIT_WHISTLE, Volume = sampleVolume }); } @@ -158,7 +158,7 @@ public override HitObject Parse(string text) result.Samples.Add(new SampleInfo { Bank = addSampleBank, - Name = "hitclap", + Name = SampleInfo.HIT_CLAP, Volume = sampleVolume }); }