mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Move to private implementation
This commit is contained in:
parent
0d817e8e98
commit
02690e5f25
@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
@ -19,7 +22,7 @@ namespace osu.Game.Skinning
|
||||
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: base(skin)
|
||||
{
|
||||
storage = new SkinResourceStore(skin, storage);
|
||||
storage = new LegacySkinResourceStore(skin, storage);
|
||||
samples = audioManager.GetSampleManager(storage);
|
||||
textures = new TextureStore(new RawTextureLoaderStore(storage));
|
||||
}
|
||||
@ -38,5 +41,24 @@ namespace osu.Game.Skinning
|
||||
}
|
||||
|
||||
public override SampleChannel GetSample(string sampleName) => samples.Get(sampleName);
|
||||
|
||||
private class LegacySkinResourceStore : IResourceStore<byte[]>
|
||||
{
|
||||
private readonly SkinInfo skin;
|
||||
private readonly IResourceStore<byte[]> underlyingStore;
|
||||
|
||||
private string getPathForFile(string filename) =>
|
||||
skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
public LegacySkinResourceStore(SkinInfo skin, IResourceStore<byte[]> underlyingStore)
|
||||
{
|
||||
this.skin = skin;
|
||||
this.underlyingStore = underlyingStore;
|
||||
}
|
||||
|
||||
public Stream GetStream(string name) => underlyingStore.GetStream(getPathForFile(name));
|
||||
|
||||
byte[] IResourceStore<byte[]>.Get(string name) => underlyingStore.Get(getPathForFile(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.IO.Stores;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class SkinResourceStore : IResourceStore<byte[]>
|
||||
{
|
||||
private readonly SkinInfo skin;
|
||||
private readonly IResourceStore<byte[]> underlyingStore;
|
||||
|
||||
private string getPathForFile(string filename) =>
|
||||
skin.Files.FirstOrDefault(f => string.Equals(Path.GetFileNameWithoutExtension(f.Filename), filename.Split('/').Last(), StringComparison.InvariantCultureIgnoreCase))?.FileInfo.StoragePath;
|
||||
|
||||
public SkinResourceStore(SkinInfo skin, IResourceStore<byte[]> underlyingStore)
|
||||
{
|
||||
this.skin = skin;
|
||||
this.underlyingStore = underlyingStore;
|
||||
}
|
||||
|
||||
public Stream GetStream(string name) => underlyingStore.GetStream(getPathForFile(name));
|
||||
|
||||
byte[] IResourceStore<byte[]>.Get(string name) => underlyingStore.Get(getPathForFile(name));
|
||||
}
|
||||
}
|
@ -870,7 +870,6 @@
|
||||
<Compile Include="Skinning\SkinnableDrawable.cs" />
|
||||
<Compile Include="Skinning\SkinnableSound.cs" />
|
||||
<Compile Include="Skinning\SkinReloadableDrawable.cs" />
|
||||
<Compile Include="Skinning\SkinResourceStore.cs" />
|
||||
<Compile Include="Skinning\SkinStore.cs" />
|
||||
<Compile Include="Storyboards\CommandLoop.cs" />
|
||||
<Compile Include="Storyboards\CommandTimeline.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user