mirror of
https://github.com/ppy/osu
synced 2025-01-02 04:12:13 +00:00
Add and consume sample bank constants
This commit is contained in:
parent
31f499a950
commit
579d5b51eb
@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
NewCombo = i % 8 == 0,
|
||||
Samples = new List<HitSampleInfo>(new[]
|
||||
{
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "normal", volume: 100)
|
||||
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, HitSampleInfo.BANK_NORMAL, volume: 100)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
{
|
||||
if (slider is null) return;
|
||||
|
||||
slider.SampleControlPoint.SampleBank = "soft";
|
||||
slider.SampleControlPoint.SampleBank = HitSampleInfo.BANK_SOFT;
|
||||
slider.SampleControlPoint.SampleVolume = 70;
|
||||
sample = new HitSampleInfo("hitwhistle");
|
||||
slider.Samples.Add(sample);
|
||||
@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
AddAssert("sliders have hitsounds", hasHitsounds);
|
||||
|
||||
bool hasHitsounds() => sample is not null &&
|
||||
EditorBeatmap.HitObjects.All(o => o.SampleControlPoint.SampleBank == "soft" &&
|
||||
EditorBeatmap.HitObjects.All(o => o.SampleControlPoint.SampleBank == HitSampleInfo.BANK_SOFT &&
|
||||
o.SampleControlPoint.SampleVolume == 70 &&
|
||||
o.Samples.Contains(sample));
|
||||
}
|
||||
|
@ -206,17 +206,17 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
var soundPoint = controlPoints.SamplePointAt(0);
|
||||
Assert.AreEqual(956, soundPoint.Time);
|
||||
Assert.AreEqual("soft", soundPoint.SampleBank);
|
||||
Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank);
|
||||
Assert.AreEqual(60, soundPoint.SampleVolume);
|
||||
|
||||
soundPoint = controlPoints.SamplePointAt(53373);
|
||||
Assert.AreEqual(53373, soundPoint.Time);
|
||||
Assert.AreEqual("soft", soundPoint.SampleBank);
|
||||
Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank);
|
||||
Assert.AreEqual(60, soundPoint.SampleVolume);
|
||||
|
||||
soundPoint = controlPoints.SamplePointAt(119637);
|
||||
Assert.AreEqual(119637, soundPoint.Time);
|
||||
Assert.AreEqual("soft", soundPoint.SampleBank);
|
||||
Assert.AreEqual(HitSampleInfo.BANK_SOFT, soundPoint.SampleBank);
|
||||
Assert.AreEqual(80, soundPoint.SampleVolume);
|
||||
|
||||
var effectPoint = controlPoints.EffectPointAt(0);
|
||||
@ -261,10 +261,10 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.That(controlPoints.EffectPointAt(2500).KiaiMode, Is.False);
|
||||
Assert.That(controlPoints.EffectPointAt(3500).KiaiMode, Is.True);
|
||||
|
||||
Assert.That(controlPoints.SamplePointAt(500).SampleBank, Is.EqualTo("drum"));
|
||||
Assert.That(controlPoints.SamplePointAt(1500).SampleBank, Is.EqualTo("drum"));
|
||||
Assert.That(controlPoints.SamplePointAt(2500).SampleBank, Is.EqualTo("normal"));
|
||||
Assert.That(controlPoints.SamplePointAt(3500).SampleBank, Is.EqualTo("drum"));
|
||||
Assert.That(controlPoints.SamplePointAt(500).SampleBank, Is.EqualTo(HitSampleInfo.BANK_DRUM));
|
||||
Assert.That(controlPoints.SamplePointAt(1500).SampleBank, Is.EqualTo(HitSampleInfo.BANK_DRUM));
|
||||
Assert.That(controlPoints.SamplePointAt(2500).SampleBank, Is.EqualTo(HitSampleInfo.BANK_NORMAL));
|
||||
Assert.That(controlPoints.SamplePointAt(3500).SampleBank, Is.EqualTo(HitSampleInfo.BANK_DRUM));
|
||||
|
||||
Assert.That(controlPoints.TimingPointAt(500).BeatLength, Is.EqualTo(500).Within(0.1));
|
||||
Assert.That(controlPoints.TimingPointAt(1500).BeatLength, Is.EqualTo(500).Within(0.1));
|
||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using Humanizer;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -41,7 +42,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
Position = (OsuPlayfield.BASE_SIZE - new Vector2(100, 0)) / 2,
|
||||
SampleControlPoint = new SampleControlPoint
|
||||
{
|
||||
SampleBank = "normal",
|
||||
SampleBank = HitSampleInfo.BANK_NORMAL,
|
||||
SampleVolume = 80
|
||||
}
|
||||
});
|
||||
@ -52,7 +53,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
Position = (OsuPlayfield.BASE_SIZE + new Vector2(100, 0)) / 2,
|
||||
SampleControlPoint = new SampleControlPoint
|
||||
{
|
||||
SampleBank = "soft",
|
||||
SampleBank = HitSampleInfo.BANK_SOFT,
|
||||
SampleVolume = 60
|
||||
}
|
||||
});
|
||||
@ -70,7 +71,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
public void TestSingleSelection()
|
||||
{
|
||||
clickSamplePiece(0);
|
||||
samplePopoverHasSingleBank("normal");
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_NORMAL);
|
||||
samplePopoverHasSingleVolume(80);
|
||||
|
||||
dismissPopover();
|
||||
@ -80,14 +81,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("select first object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects.First()));
|
||||
|
||||
clickSamplePiece(1);
|
||||
samplePopoverHasSingleBank("soft");
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_SOFT);
|
||||
samplePopoverHasSingleVolume(60);
|
||||
|
||||
setVolumeViaPopover(90);
|
||||
hitObjectHasSampleVolume(1, 90);
|
||||
|
||||
setBankViaPopover("drum");
|
||||
hitObjectHasSampleBank(1, "drum");
|
||||
setBankViaPopover(HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_DRUM);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -136,27 +137,27 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("unify sample bank", () =>
|
||||
{
|
||||
foreach (var h in EditorBeatmap.HitObjects)
|
||||
h.SampleControlPoint.SampleBank = "soft";
|
||||
h.SampleControlPoint.SampleBank = HitSampleInfo.BANK_SOFT;
|
||||
});
|
||||
|
||||
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||
clickSamplePiece(0);
|
||||
samplePopoverHasSingleBank("soft");
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_SOFT);
|
||||
|
||||
dismissPopover();
|
||||
|
||||
clickSamplePiece(1);
|
||||
samplePopoverHasSingleBank("soft");
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_SOFT);
|
||||
|
||||
setBankViaPopover(string.Empty);
|
||||
hitObjectHasSampleBank(0, "soft");
|
||||
hitObjectHasSampleBank(1, "soft");
|
||||
samplePopoverHasSingleBank("soft");
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_SOFT);
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_SOFT);
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_SOFT);
|
||||
|
||||
setBankViaPopover("drum");
|
||||
hitObjectHasSampleBank(0, "drum");
|
||||
hitObjectHasSampleBank(1, "drum");
|
||||
samplePopoverHasSingleBank("drum");
|
||||
setBankViaPopover(HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_DRUM);
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_DRUM);
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_DRUM);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -172,14 +173,14 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
samplePopoverHasIndeterminateBank();
|
||||
|
||||
setBankViaPopover(string.Empty);
|
||||
hitObjectHasSampleBank(0, "normal");
|
||||
hitObjectHasSampleBank(1, "soft");
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_SOFT);
|
||||
samplePopoverHasIndeterminateBank();
|
||||
|
||||
setBankViaPopover("normal");
|
||||
hitObjectHasSampleBank(0, "normal");
|
||||
hitObjectHasSampleBank(1, "normal");
|
||||
samplePopoverHasSingleBank("normal");
|
||||
setBankViaPopover(HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSampleBank(0, HitSampleInfo.BANK_NORMAL);
|
||||
hitObjectHasSampleBank(1, HitSampleInfo.BANK_NORMAL);
|
||||
samplePopoverHasSingleBank(HitSampleInfo.BANK_NORMAL);
|
||||
}
|
||||
|
||||
private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} sample piece", () =>
|
||||
|
@ -57,13 +57,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
StartTime = t += spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = HitSampleInfo.BANK_SOFT },
|
||||
},
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = t + spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE) },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = HitSampleInfo.BANK_SOFT },
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -19,11 +19,20 @@ namespace osu.Game.Audio
|
||||
public const string HIT_FINISH = @"hitfinish";
|
||||
public const string HIT_CLAP = @"hitclap";
|
||||
|
||||
public const string BANK_NORMAL = @"normal";
|
||||
public const string BANK_SOFT = @"soft";
|
||||
public const string BANK_DRUM = @"drum";
|
||||
|
||||
/// <summary>
|
||||
/// All valid sample addition constants.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> AllAdditions => new[] { HIT_WHISTLE, HIT_FINISH, HIT_CLAP };
|
||||
|
||||
/// <summary>
|
||||
/// All valid bank constants.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> AllBanks => new[] { BANK_NORMAL, BANK_SOFT, BANK_DRUM };
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sample to load.
|
||||
/// </summary>
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </remarks>
|
||||
public class SampleControlPoint : ControlPoint, IEquatable<SampleControlPoint>
|
||||
{
|
||||
public const string DEFAULT_BANK = "normal";
|
||||
public const string DEFAULT_BANK = HitSampleInfo.BANK_NORMAL;
|
||||
|
||||
public static readonly SampleControlPoint DEFAULT = new SampleControlPoint
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public readonly Bindable<string> SampleBankBindable = new Bindable<string>(DEFAULT_BANK) { Default = DEFAULT_BANK };
|
||||
|
||||
/// <summary>
|
||||
/// The speed multiplier at this control point.
|
||||
/// The sample bank at this control point.
|
||||
/// </summary>
|
||||
public string SampleBank
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.EnumExtensions;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
@ -412,7 +413,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
string stringSampleSet = sampleSet.ToString().ToLowerInvariant();
|
||||
if (stringSampleSet == @"none")
|
||||
stringSampleSet = @"normal";
|
||||
stringSampleSet = HitSampleInfo.HIT_NORMAL;
|
||||
|
||||
if (timingChange)
|
||||
{
|
||||
|
@ -547,13 +547,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
switch (sampleBank?.ToLowerInvariant())
|
||||
{
|
||||
case "normal":
|
||||
case HitSampleInfo.BANK_NORMAL:
|
||||
return LegacySampleBank.Normal;
|
||||
|
||||
case "soft":
|
||||
case HitSampleInfo.BANK_SOFT:
|
||||
return LegacySampleBank.Soft;
|
||||
|
||||
case "drum":
|
||||
case HitSampleInfo.BANK_DRUM:
|
||||
return LegacySampleBank.Drum;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user