mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Expose resources to skin via interface (and share common pieces with beatmap)
This commit is contained in:
@ -10,9 +10,11 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics.Audio;
|
using osu.Framework.Graphics.Audio;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -27,7 +29,7 @@ using osu.Game.Tests.Visual;
|
|||||||
namespace osu.Game.Tests.Gameplay
|
namespace osu.Game.Tests.Gameplay
|
||||||
{
|
{
|
||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public class TestSceneStoryboardSamples : OsuTestScene
|
public class TestSceneStoryboardSamples : OsuTestScene, IStorageResourceProvider
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRetrieveTopLevelSample()
|
public void TestRetrieveTopLevelSample()
|
||||||
@ -35,7 +37,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
ISkin skin = null;
|
ISkin skin = null;
|
||||||
SampleChannel channel = null;
|
SampleChannel channel = null;
|
||||||
|
|
||||||
AddStep("create skin", () => skin = new TestSkin("test-sample", Audio));
|
AddStep("create skin", () => skin = new TestSkin("test-sample", this));
|
||||||
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
|
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
|
||||||
|
|
||||||
AddAssert("sample is non-null", () => channel != null);
|
AddAssert("sample is non-null", () => channel != null);
|
||||||
@ -47,7 +49,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
ISkin skin = null;
|
ISkin skin = null;
|
||||||
SampleChannel channel = null;
|
SampleChannel channel = null;
|
||||||
|
|
||||||
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", Audio));
|
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", this));
|
||||||
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));
|
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));
|
||||||
|
|
||||||
AddAssert("sample is non-null", () => channel != null);
|
AddAssert("sample is non-null", () => channel != null);
|
||||||
@ -105,7 +107,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
AddStep("setup storyboard sample", () =>
|
AddStep("setup storyboard sample", () =>
|
||||||
{
|
{
|
||||||
Beatmap.Value = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, Audio);
|
Beatmap.Value = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, this);
|
||||||
SelectedMods.Value = new[] { testedMod };
|
SelectedMods.Value = new[] { testedMod };
|
||||||
|
|
||||||
var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);
|
||||||
@ -128,8 +130,8 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
private class TestSkin : LegacySkin
|
private class TestSkin : LegacySkin
|
||||||
{
|
{
|
||||||
public TestSkin(string resourceName, AudioManager audioManager)
|
public TestSkin(string resourceName, IStorageResourceProvider resources)
|
||||||
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), audioManager, "skin.ini")
|
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), resources, "skin.ini")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,15 +160,15 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
private class TestCustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
private class TestCustomSkinWorkingBeatmap : ClockBackedTestWorkingBeatmap
|
||||||
{
|
{
|
||||||
private readonly AudioManager audio;
|
private readonly IStorageResourceProvider resources;
|
||||||
|
|
||||||
public TestCustomSkinWorkingBeatmap(RulesetInfo ruleset, AudioManager audio)
|
public TestCustomSkinWorkingBeatmap(RulesetInfo ruleset, IStorageResourceProvider resources)
|
||||||
: base(ruleset, null, audio)
|
: base(ruleset, null, resources.AudioManager)
|
||||||
{
|
{
|
||||||
this.audio = audio;
|
this.resources = resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new TestSkin("test-sample", audio);
|
protected override ISkin GetSkin() => new TestSkin("test-sample", resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDrawableStoryboardSample : DrawableStoryboardSample
|
private class TestDrawableStoryboardSample : DrawableStoryboardSample
|
||||||
@ -176,5 +178,9 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AudioManager AudioManager => Audio;
|
||||||
|
public IResourceStore<byte[]> Files => null;
|
||||||
|
public IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,9 +498,9 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
TextureStore IBeatmapResourceProvider.LargeTextureStore => largeTextureStore;
|
TextureStore IBeatmapResourceProvider.LargeTextureStore => largeTextureStore;
|
||||||
ITrackStore IBeatmapResourceProvider.Tracks => trackStore;
|
ITrackStore IBeatmapResourceProvider.Tracks => trackStore;
|
||||||
AudioManager IBeatmapResourceProvider.AudioManager => audioManager;
|
AudioManager IStorageResourceProvider.AudioManager => audioManager;
|
||||||
IResourceStore<byte[]> IBeatmapResourceProvider.Files => Files.Store;
|
IResourceStore<byte[]> IStorageResourceProvider.Files => Files.Store;
|
||||||
IResourceStore<TextureUpload> IBeatmapResourceProvider.CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host.CreateTextureLoaderStore(underlyingStore);
|
IResourceStore<TextureUpload> IStorageResourceProvider.CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host.CreateTextureLoaderStore(underlyingStore);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dummy WorkingBeatmap for the purpose of retrieving a beatmap for star difficulty calculation.
|
/// A dummy WorkingBeatmap for the purpose of retrieving a beatmap for star difficulty calculation.
|
||||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new LegacyBeatmapSkin(BeatmapInfo, resources.Files, AudioManager);
|
return new LegacyBeatmapSkin(BeatmapInfo, resources.Files, resources);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Game.IO;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
public interface IBeatmapResourceProvider
|
public interface IBeatmapResourceProvider : IStorageResourceProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieve a global large texture store, used for loading beatmap backgrounds.
|
/// Retrieve a global large texture store, used for loading beatmap backgrounds.
|
||||||
@ -19,22 +18,5 @@ namespace osu.Game.Beatmaps
|
|||||||
/// Access a global track store for retrieving beatmap tracks from.
|
/// Access a global track store for retrieving beatmap tracks from.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ITrackStore Tracks { get; }
|
ITrackStore Tracks { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieve the game-wide audio manager.
|
|
||||||
/// </summary>
|
|
||||||
AudioManager AudioManager { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Access game-wide user files.
|
|
||||||
/// </summary>
|
|
||||||
IResourceStore<byte[]> Files { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a texture loader store based on an underlying data store.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="underlyingStore">The underlying provider of texture data (in arbitrary image formats).</param>
|
|
||||||
/// <returns>A texture loader store.</returns>
|
|
||||||
IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
osu.Game/IO/IStorageResourceProvider.cs
Normal file
29
osu.Game/IO/IStorageResourceProvider.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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 osu.Framework.Audio;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.IO.Stores;
|
||||||
|
|
||||||
|
namespace osu.Game.IO
|
||||||
|
{
|
||||||
|
public interface IStorageResourceProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve the game-wide audio manager.
|
||||||
|
/// </summary>
|
||||||
|
AudioManager AudioManager { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Access game-wide user files.
|
||||||
|
/// </summary>
|
||||||
|
IResourceStore<byte[]> Files { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a texture loader store based on an underlying data store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="underlyingStore">The underlying provider of texture data (in arbitrary image formats).</param>
|
||||||
|
/// <returns>A texture loader store.</returns>
|
||||||
|
IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Game.IO;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class DefaultLegacySkin : LegacySkin
|
public class DefaultLegacySkin : LegacySkin
|
||||||
{
|
{
|
||||||
public DefaultLegacySkin(IResourceStore<byte[]> storage, AudioManager audioManager)
|
public DefaultLegacySkin(IResourceStore<byte[]> storage, IStorageResourceProvider resources)
|
||||||
: base(Info, storage, audioManager, string.Empty)
|
: base(Info, storage, resources, string.Empty)
|
||||||
{
|
{
|
||||||
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);
|
||||||
Configuration.AddComboColours(
|
Configuration.AddComboColours(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets.Objects.Legacy;
|
using osu.Game.Rulesets.Objects.Legacy;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -16,8 +16,8 @@ namespace osu.Game.Skinning
|
|||||||
protected override bool AllowManiaSkin => false;
|
protected override bool AllowManiaSkin => false;
|
||||||
protected override bool UseCustomSampleBanks => true;
|
protected override bool UseCustomSampleBanks => true;
|
||||||
|
|
||||||
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
|
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, IStorageResourceProvider resources)
|
||||||
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)
|
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), resources, beatmap.Path)
|
||||||
{
|
{
|
||||||
// Disallow default colours fallback on beatmap skins to allow using parent skin combo colours. (via SkinProvidingContainer)
|
// Disallow default colours fallback on beatmap skins to allow using parent skin combo colours. (via SkinProvidingContainer)
|
||||||
Configuration.AllowDefaultComboColoursFallback = false;
|
Configuration.AllowDefaultComboColoursFallback = false;
|
||||||
|
@ -7,7 +7,6 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -54,12 +53,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
|
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
|
||||||
|
|
||||||
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
|
||||||
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
|
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, resources.Files), resources, "skin.ini")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
|
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, IStorageResourceProvider resources, string filename)
|
||||||
: base(skin)
|
: base(skin)
|
||||||
{
|
{
|
||||||
using (var stream = storage?.GetStream(filename))
|
using (var stream = storage?.GetStream(filename))
|
||||||
@ -85,12 +84,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
if (storage != null)
|
if (storage != null)
|
||||||
{
|
{
|
||||||
var samples = audioManager?.GetSampleStore(storage);
|
var samples = resources?.AudioManager?.GetSampleStore(storage);
|
||||||
if (samples != null)
|
if (samples != null)
|
||||||
samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
|
samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
|
||||||
|
|
||||||
Samples = samples;
|
Samples = samples;
|
||||||
Textures = new TextureStore(new TextureLoaderStore(storage));
|
Textures = new TextureStore(resources?.CreateTextureLoaderStore(storage));
|
||||||
|
|
||||||
(storage as ResourceStore<byte[]>)?.AddExtension("ogg");
|
(storage as ResourceStore<byte[]>)?.AddExtension("ogg");
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,18 @@ using osu.Framework.Testing;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
public class SkinManager : ArchiveModelManager<SkinInfo, SkinFileInfo>, ISkinSource
|
public class SkinManager : ArchiveModelManager<SkinInfo, SkinFileInfo>, ISkinSource, IStorageResourceProvider
|
||||||
{
|
{
|
||||||
private readonly AudioManager audio;
|
private readonly AudioManager audio;
|
||||||
|
|
||||||
|
private readonly GameHost host;
|
||||||
|
|
||||||
private readonly IResourceStore<byte[]> legacyDefaultResources;
|
private readonly IResourceStore<byte[]> legacyDefaultResources;
|
||||||
|
|
||||||
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>(new DefaultSkin());
|
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>(new DefaultSkin());
|
||||||
@ -42,10 +45,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override string ImportFromStablePath => "Skins";
|
protected override string ImportFromStablePath => "Skins";
|
||||||
|
|
||||||
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio, IResourceStore<byte[]> legacyDefaultResources)
|
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, AudioManager audio, IResourceStore<byte[]> legacyDefaultResources)
|
||||||
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
: base(storage, contextFactory, new SkinStore(contextFactory, storage), host)
|
||||||
{
|
{
|
||||||
this.audio = audio;
|
this.audio = audio;
|
||||||
|
this.host = host;
|
||||||
|
|
||||||
this.legacyDefaultResources = legacyDefaultResources;
|
this.legacyDefaultResources = legacyDefaultResources;
|
||||||
|
|
||||||
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
|
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
|
||||||
@ -148,9 +153,9 @@ namespace osu.Game.Skinning
|
|||||||
return new DefaultSkin();
|
return new DefaultSkin();
|
||||||
|
|
||||||
if (skinInfo == DefaultLegacySkin.Info)
|
if (skinInfo == DefaultLegacySkin.Info)
|
||||||
return new DefaultLegacySkin(legacyDefaultResources, audio);
|
return new DefaultLegacySkin(legacyDefaultResources, this);
|
||||||
|
|
||||||
return new LegacySkin(skinInfo, Files.Store, audio);
|
return new LegacySkin(skinInfo, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -169,5 +174,9 @@ namespace osu.Game.Skinning
|
|||||||
public SampleChannel GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
|
||||||
|
|
||||||
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => CurrentSkin.Value.GetConfig<TLookup, TValue>(lookup);
|
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => CurrentSkin.Value.GetConfig<TLookup, TValue>(lookup);
|
||||||
|
|
||||||
|
AudioManager IStorageResourceProvider.AudioManager => audio;
|
||||||
|
IResourceStore<byte[]> IStorageResourceProvider.Files => Files.Store;
|
||||||
|
IResourceStore<TextureUpload> IStorageResourceProvider.CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host.CreateTextureLoaderStore(underlyingStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
@ -25,7 +26,7 @@ using osu.Game.Users;
|
|||||||
namespace osu.Game.Tests.Beatmaps
|
namespace osu.Game.Tests.Beatmaps
|
||||||
{
|
{
|
||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public abstract class HitObjectSampleTest : PlayerTestScene
|
public abstract class HitObjectSampleTest : PlayerTestScene, IStorageResourceProvider
|
||||||
{
|
{
|
||||||
protected abstract IResourceStore<byte[]> Resources { get; }
|
protected abstract IResourceStore<byte[]> Resources { get; }
|
||||||
protected LegacySkin Skin { get; private set; }
|
protected LegacySkin Skin { get; private set; }
|
||||||
@ -58,7 +59,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
protected sealed override IBeatmap CreateBeatmap(RulesetInfo ruleset) => currentTestBeatmap;
|
||||||
|
|
||||||
protected sealed override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
protected sealed override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||||
=> new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, Audio);
|
=> new TestWorkingBeatmap(beatmapInfo, beatmapSkinResourceStore, beatmap, storyboard, Clock, this);
|
||||||
|
|
||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false);
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false);
|
||||||
|
|
||||||
@ -109,7 +110,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Need to refresh the cached skin source to refresh the skin resource store.
|
// Need to refresh the cached skin source to refresh the skin resource store.
|
||||||
dependencies.SkinSource = new SkinProvidingContainer(Skin = new LegacySkin(userSkinInfo, userSkinResourceStore, Audio));
|
dependencies.SkinSource = new SkinProvidingContainer(Skin = new LegacySkin(userSkinInfo, this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,10 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
protected void AssertNoLookup(string name) => AddAssert($"\"{name}\" not looked up",
|
protected void AssertNoLookup(string name) => AddAssert($"\"{name}\" not looked up",
|
||||||
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && !userSkinResourceStore.PerformedLookups.Contains(name));
|
() => !beatmapSkinResourceStore.PerformedLookups.Contains(name) && !userSkinResourceStore.PerformedLookups.Contains(name));
|
||||||
|
|
||||||
|
public AudioManager AudioManager => Audio;
|
||||||
|
public IResourceStore<byte[]> Files => userSkinResourceStore;
|
||||||
|
public IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => null;
|
||||||
|
|
||||||
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
private class SkinSourceDependencyContainer : IReadOnlyDependencyContainer
|
||||||
{
|
{
|
||||||
public ISkinSource SkinSource;
|
public ISkinSource SkinSource;
|
||||||
@ -191,14 +196,17 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
private readonly BeatmapInfo skinBeatmapInfo;
|
private readonly BeatmapInfo skinBeatmapInfo;
|
||||||
private readonly IResourceStore<byte[]> resourceStore;
|
private readonly IResourceStore<byte[]> resourceStore;
|
||||||
|
|
||||||
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, AudioManager audio)
|
private readonly IStorageResourceProvider resources;
|
||||||
: base(beatmap, storyboard, referenceClock, audio)
|
|
||||||
|
public TestWorkingBeatmap(BeatmapInfo skinBeatmapInfo, IResourceStore<byte[]> resourceStore, IBeatmap beatmap, Storyboard storyboard, IFrameBasedClock referenceClock, IStorageResourceProvider resources)
|
||||||
|
: base(beatmap, storyboard, referenceClock, resources.AudioManager)
|
||||||
{
|
{
|
||||||
this.skinBeatmapInfo = skinBeatmapInfo;
|
this.skinBeatmapInfo = skinBeatmapInfo;
|
||||||
this.resourceStore = resourceStore;
|
this.resourceStore = resourceStore;
|
||||||
|
this.resources = resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, AudioManager);
|
protected override ISkin GetSkin() => new LegacyBeatmapSkin(skinBeatmapInfo, resourceStore, resources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -18,9 +17,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new SkinProvidingPlayer(legacySkinSource);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, OsuGameBase game)
|
private void load(OsuGameBase game, SkinManager skins)
|
||||||
{
|
{
|
||||||
var legacySkin = new DefaultLegacySkin(new NamespacedResourceStore<byte[]>(game.Resources, "Skins/Legacy"), audio);
|
var legacySkin = new DefaultLegacySkin(new NamespacedResourceStore<byte[]>(game.Resources, "Skins/Legacy"), skins);
|
||||||
legacySkinSource = new SkinProvidingContainer(legacySkin);
|
legacySkinSource = new SkinProvidingContainer(legacySkin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,10 @@ using osu.Framework.Graphics.OpenGL.Textures;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -22,13 +24,16 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
public abstract class SkinnableTestScene : OsuGridTestScene
|
public abstract class SkinnableTestScene : OsuGridTestScene, IStorageResourceProvider
|
||||||
{
|
{
|
||||||
private Skin metricsSkin;
|
private Skin metricsSkin;
|
||||||
private Skin defaultSkin;
|
private Skin defaultSkin;
|
||||||
private Skin specialSkin;
|
private Skin specialSkin;
|
||||||
private Skin oldSkin;
|
private Skin oldSkin;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
protected SkinnableTestScene()
|
protected SkinnableTestScene()
|
||||||
: base(2, 3)
|
: base(2, 3)
|
||||||
{
|
{
|
||||||
@ -39,10 +44,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
var dllStore = new DllResourceStore(DynamicCompilationOriginal.GetType().Assembly);
|
var dllStore = new DllResourceStore(DynamicCompilationOriginal.GetType().Assembly);
|
||||||
|
|
||||||
metricsSkin = new TestLegacySkin(new SkinInfo { Name = "metrics-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/metrics_skin"), audio, true);
|
metricsSkin = new TestLegacySkin(new SkinInfo { Name = "metrics-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/metrics_skin"), this, true);
|
||||||
defaultSkin = new DefaultLegacySkin(new NamespacedResourceStore<byte[]>(game.Resources, "Skins/Legacy"), audio);
|
defaultSkin = new DefaultLegacySkin(new NamespacedResourceStore<byte[]>(game.Resources, "Skins/Legacy"), this);
|
||||||
specialSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/special_skin"), audio, true);
|
specialSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/special_skin"), this, true);
|
||||||
oldSkin = new TestLegacySkin(new SkinInfo { Name = "old-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/old_skin"), audio, true);
|
oldSkin = new TestLegacySkin(new SkinInfo { Name = "old-skin" }, new NamespacedResourceStore<byte[]>(dllStore, "Resources/old_skin"), this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<Drawable> createdDrawables = new List<Drawable>();
|
private readonly List<Drawable> createdDrawables = new List<Drawable>();
|
||||||
@ -147,6 +152,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected virtual IBeatmap CreateBeatmapForSkinProvider() => CreateWorkingBeatmap(Ruleset.Value).GetPlayableBeatmap(Ruleset.Value);
|
protected virtual IBeatmap CreateBeatmapForSkinProvider() => CreateWorkingBeatmap(Ruleset.Value).GetPlayableBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
|
public AudioManager AudioManager => Audio;
|
||||||
|
public IResourceStore<byte[]> Files => null;
|
||||||
|
public IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host.CreateTextureLoaderStore(underlyingStore);
|
||||||
|
|
||||||
private class OutlineBox : CompositeDrawable
|
private class OutlineBox : CompositeDrawable
|
||||||
{
|
{
|
||||||
public OutlineBox()
|
public OutlineBox()
|
||||||
@ -170,8 +179,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
private readonly bool extrapolateAnimations;
|
private readonly bool extrapolateAnimations;
|
||||||
|
|
||||||
public TestLegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, bool extrapolateAnimations)
|
public TestLegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, IStorageResourceProvider resources, bool extrapolateAnimations)
|
||||||
: base(skin, storage, audioManager, "skin.ini")
|
: base(skin, storage, resources, "skin.ini")
|
||||||
{
|
{
|
||||||
this.extrapolateAnimations = extrapolateAnimations;
|
this.extrapolateAnimations = extrapolateAnimations;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user