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

Merge pull request #16254 from bdach/storyboard-samples-vs-skin-hitsounds

Fix "disable beatmap hitsounds" setting also preventing storyboard samples from playing
This commit is contained in:
Dean Herbert 2021-12-26 23:20:15 +09:00 committed by GitHub
commit edf5e558ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 3 deletions

View File

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics.Audio;
@ -16,6 +17,7 @@ using osu.Framework.IO.Stores;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.IO;
using osu.Game.Rulesets;
@ -35,6 +37,9 @@ namespace osu.Game.Tests.Gameplay
[HeadlessTest]
public class TestSceneStoryboardSamples : OsuTestScene, IStorageResourceProvider
{
[Resolved]
private OsuConfigManager config { get; set; }
[Test]
public void TestRetrieveTopLevelSample()
{
@ -166,6 +171,39 @@ namespace osu.Game.Tests.Gameplay
((IApplicableToRate)testedMod).ApplyToRate(sampleInfo.StartTime)));
}
[Test]
public void TestSamplePlaybackWithBeatmapHitsoundsOff()
{
GameplayClockContainer gameplayContainer = null;
TestDrawableStoryboardSample sample = null;
AddStep("disable beatmap hitsounds", () => config.SetValue(OsuSetting.BeatmapHitsounds, false));
AddStep("setup storyboard sample", () =>
{
Beatmap.Value = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, this);
var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
Add(gameplayContainer = new MasterGameplayClockContainer(Beatmap.Value, 0)
{
Child = beatmapSkinSourceContainer
});
beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
{
Clock = gameplayContainer.GameplayClock
});
});
AddStep("start", () => gameplayContainer.Start());
AddUntilStep("sample played", () => sample.IsPlayed);
AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
AddStep("restore default", () => config.GetBindable<bool>(OsuSetting.BeatmapHitsounds).SetDefault());
}
private class TestSkin : LegacySkin
{
public TestSkin(string resourceName, IStorageResourceProvider resources)

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Storyboards;
namespace osu.Game.Skinning
{
@ -56,12 +57,12 @@ namespace osu.Game.Skinning
return beatmapSkins.Value;
}
protected override bool AllowSampleLookup(ISampleInfo componentName)
protected override bool AllowSampleLookup(ISampleInfo sampleInfo)
{
if (beatmapSkins == null)
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");
return beatmapHitsounds.Value;
return sampleInfo is StoryboardSampleInfo || beatmapHitsounds.Value;
}
public BeatmapSkinProvidingContainer(ISkin skin)

View File

@ -35,7 +35,7 @@ namespace osu.Game.Skinning
protected virtual bool AllowTextureLookup(string componentName) => true;
protected virtual bool AllowSampleLookup(ISampleInfo componentName) => true;
protected virtual bool AllowSampleLookup(ISampleInfo sampleInfo) => true;
protected virtual bool AllowConfigurationLookup => true;