mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 03:33:19 +08:00
Fix storyboard samples not loading from subfolders (#7419)
Fix storyboard samples not loading from subfolders
This commit is contained in:
commit
3627b4cbba
@ -26,10 +26,6 @@ namespace osu.Game.Rulesets.Taiko.Audio
|
||||
var centre = s.GetSampleInfo();
|
||||
var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP);
|
||||
|
||||
// todo: this is ugly
|
||||
centre.Namespace = "taiko";
|
||||
rim.Namespace = "taiko";
|
||||
|
||||
mappings[s.Time] = new DrumSample
|
||||
{
|
||||
Centre = addSound(centre),
|
||||
|
@ -166,8 +166,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
// Normal and clap samples are handled by the drum
|
||||
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
|
||||
|
||||
protected override string SampleNamespace => "taiko";
|
||||
|
||||
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
||||
|
||||
/// <summary>
|
||||
|
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitclap.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitclap.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitfinish.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitfinish.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitnormal.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitnormal.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitwhistle.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/normal-hitwhistle.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitclap.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitclap.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitfinish.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitfinish.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitnormal.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitnormal.wav
Executable file
Binary file not shown.
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitwhistle.wav
Executable file
BIN
osu.Game.Rulesets.Taiko/Resources/Samples/Gameplay/soft-hitwhistle.wav
Executable file
Binary file not shown.
@ -0,0 +1,55 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning
|
||||
{
|
||||
public class TaikoLegacySkinTransformer : ISkin
|
||||
{
|
||||
private readonly ISkinSource source;
|
||||
|
||||
public TaikoLegacySkinTransformer(ISkinSource source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public Drawable GetDrawableComponent(ISkinComponent component) => source.GetDrawableComponent(component);
|
||||
|
||||
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
|
||||
|
||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
|
||||
|
||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source.GetConfig<TLookup, TValue>(lookup);
|
||||
|
||||
private class LegacyTaikoSampleInfo : ISampleInfo
|
||||
{
|
||||
private readonly ISampleInfo source;
|
||||
|
||||
public LegacyTaikoSampleInfo(ISampleInfo source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public IEnumerable<string> LookupNames
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var name in source.LookupNames)
|
||||
yield return $"taiko-{name}";
|
||||
|
||||
foreach (var name in source.LookupNames)
|
||||
yield return name;
|
||||
}
|
||||
}
|
||||
|
||||
public int Volume => source.Volume;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,8 @@ using osu.Game.Rulesets.Taiko.Difficulty;
|
||||
using osu.Game.Rulesets.Taiko.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using System;
|
||||
using osu.Game.Rulesets.Taiko.Skinning;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
@ -34,6 +36,8 @@ namespace osu.Game.Rulesets.Taiko
|
||||
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
|
||||
|
||||
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new TaikoLegacySkinTransformer(source);
|
||||
|
||||
public const string SHORT_NAME = "taiko";
|
||||
|
||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||
|
74
osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
Normal file
74
osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
public class TestSceneStoryboardSamples : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestRetrieveTopLevelSample()
|
||||
{
|
||||
ISkin skin = null;
|
||||
SampleChannel channel = null;
|
||||
|
||||
AddStep("create skin", () => skin = new TestSkin("test-sample", Audio));
|
||||
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
|
||||
|
||||
AddAssert("sample is non-null", () => channel != null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRetrieveSampleInSubFolder()
|
||||
{
|
||||
ISkin skin = null;
|
||||
SampleChannel channel = null;
|
||||
|
||||
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", Audio));
|
||||
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));
|
||||
|
||||
AddAssert("sample is non-null", () => channel != null);
|
||||
}
|
||||
|
||||
private class TestSkin : LegacySkin
|
||||
{
|
||||
public TestSkin(string resourceName, AudioManager audioManager)
|
||||
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), audioManager, "skin.ini")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestResourceStore : IResourceStore<byte[]>
|
||||
{
|
||||
private readonly string resourceName;
|
||||
|
||||
public TestResourceStore(string resourceName)
|
||||
{
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/test-sample.mp3") : null;
|
||||
|
||||
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/test-sample.mp3") : null;
|
||||
|
||||
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/test-sample.mp3") : null;
|
||||
|
||||
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
osu.Game.Tests/Resources/test-sample.mp3
Normal file
BIN
osu.Game.Tests/Resources/test-sample.mp3
Normal file
Binary file not shown.
@ -17,11 +17,6 @@ namespace osu.Game.Audio
|
||||
public const string HIT_NORMAL = @"hitnormal";
|
||||
public const string HIT_CLAP = @"hitclap";
|
||||
|
||||
/// <summary>
|
||||
/// An optional ruleset namespace.
|
||||
/// </summary>
|
||||
public string Namespace;
|
||||
|
||||
/// <summary>
|
||||
/// The bank to load the sample from.
|
||||
/// </summary>
|
||||
@ -49,15 +44,6 @@ namespace osu.Game.Audio
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Namespace))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Suffix))
|
||||
yield return $"{Namespace}/{Bank}-{Name}{Suffix}";
|
||||
|
||||
yield return $"{Namespace}/{Bank}-{Name}";
|
||||
}
|
||||
|
||||
// check non-namespace as a fallback even when we have a namespace
|
||||
if (!string.IsNullOrEmpty(Suffix))
|
||||
yield return $"{Bank}-{Name}{Suffix}";
|
||||
|
||||
|
@ -31,9 +31,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// </summary>
|
||||
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Gray);
|
||||
|
||||
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
|
||||
protected virtual string SampleNamespace => null;
|
||||
|
||||
protected SkinnableSound Samples { get; private set; }
|
||||
|
||||
protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples;
|
||||
@ -154,11 +151,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
|
||||
}
|
||||
|
||||
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray();
|
||||
foreach (var s in samples)
|
||||
s.Namespace = SampleNamespace;
|
||||
|
||||
AddInternal(Samples = new SkinnableSound(samples));
|
||||
AddInternal(Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
|
||||
}
|
||||
|
||||
private void onDefaultsApplied() => apply(HitObject);
|
||||
|
@ -175,7 +175,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
foreach (var lookup in sampleInfo.LookupNames)
|
||||
{
|
||||
var sample = Samples?.Get(getFallbackName(lookup));
|
||||
var sample = Samples?.Get(lookup);
|
||||
|
||||
if (sample != null)
|
||||
return sample;
|
||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private AudioManager audio { get; set; }
|
||||
protected AudioManager Audio { get; private set; }
|
||||
|
||||
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||
|
||||
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual
|
||||
CreateWorkingBeatmap(CreateBeatmap(ruleset), null);
|
||||
|
||||
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
|
||||
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, audio);
|
||||
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, Audio);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
|
Loading…
Reference in New Issue
Block a user