Replace usages of IHasFiles with IHasRealmFiles

This commit is contained in:
Dean Herbert
2021-11-23 13:24:43 +09:00
parent 4c2b0dd2d1
commit 0a961fd9d8
4 changed files with 7 additions and 8 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Skinning
resources, resources,
// A default legacy skin may still have a skin.ini if it is modified by the user. // A default legacy skin may still have a skin.ini if it is modified by the user.
// We must specify the stream directly as we are redirecting storage to the osu-resources location for other files. // We must specify the stream directly as we are redirecting storage to the osu-resources location for other files.
new LegacySkinResourceStore<SkinFileInfo>(skin, resources.Files).GetStream("skin.ini") new LegacySkinResourceStore(skin, resources.Files).GetStream("skin.ini")
) )
{ {
Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255); Configuration.CustomColours["SliderBall"] = new Color4(2, 170, 255, 255);

View File

@ -21,7 +21,7 @@ namespace osu.Game.Skinning
protected override bool UseCustomSampleBanks => true; protected override bool UseCustomSampleBanks => true;
public LegacyBeatmapSkin(BeatmapInfo beatmapInfo, IResourceStore<byte[]> storage, IStorageResourceProvider resources) public LegacyBeatmapSkin(BeatmapInfo beatmapInfo, IResourceStore<byte[]> storage, IStorageResourceProvider resources)
: base(createSkinInfo(beatmapInfo), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmapInfo.BeatmapSet, storage), resources, beatmapInfo.Path) : base(createSkinInfo(beatmapInfo), new LegacySkinResourceStore(beatmapInfo.BeatmapSet, storage), resources, beatmapInfo.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;

View File

@ -51,7 +51,7 @@ namespace osu.Game.Skinning
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)] [UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
public LegacySkin(SkinInfo skin, IStorageResourceProvider resources) public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, resources.Files), resources, "skin.ini") : this(skin, new LegacySkinResourceStore(skin, resources.Files), resources, "skin.ini")
{ {
} }

View File

@ -11,12 +11,11 @@ using osu.Game.Extensions;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class LegacySkinResourceStore<T> : ResourceStore<byte[]> public class LegacySkinResourceStore : ResourceStore<byte[]>
where T : INamedFileInfo
{ {
private readonly IHasFiles<T> source; private readonly IHasRealmFiles source;
public LegacySkinResourceStore(IHasFiles<T> source, IResourceStore<byte[]> underlyingStore) public LegacySkinResourceStore(IHasRealmFiles source, IResourceStore<byte[]> underlyingStore)
: base(underlyingStore) : base(underlyingStore)
{ {
this.source = source; this.source = source;
@ -33,7 +32,7 @@ namespace osu.Game.Skinning
} }
private string getPathForFile(string filename) => private string getPathForFile(string filename) =>
source.Files.Find(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath(); source.Files.FirstOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
public override IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename); public override IEnumerable<string> GetAvailableResources() => source.Files.Select(f => f.Filename);
} }