mirror of
https://github.com/osukey/osukey.git
synced 2025-06-02 19:37:19 +09:00
Move path mapping to the resource store, so caching can happen against the component's name rather than the skin path. Fixes regression of beatmap load time when a custom skin is selected.
30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
// 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));
|
|
}
|
|
}
|