mirror of
https://github.com/ppy/osu.git
synced 2026-05-21 02:19:55 +08:00
Improve shared code paths in legacy skins
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
// 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.IO;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
@@ -12,20 +10,11 @@ namespace osu.Game.Skinning
|
||||
public class BeatmapSkin : LegacySkin
|
||||
{
|
||||
public BeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: base(new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() })
|
||||
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)
|
||||
{
|
||||
storage = new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage);
|
||||
|
||||
Samples = audioManager.GetSampleManager(storage);
|
||||
|
||||
Textures = new TextureStore(new RawTextureLoaderStore(storage));
|
||||
|
||||
var decoder = new LegacySkinDecoder();
|
||||
|
||||
using (StreamReader reader = new StreamReader(storage.GetStream(beatmap.Path)))
|
||||
{
|
||||
Configuration = decoder.Decode(reader);
|
||||
}
|
||||
}
|
||||
|
||||
private static SkinInfo createSkinInfo(BeatmapInfo beatmap) =>
|
||||
new SkinInfo { Name = beatmap.ToString(), Creator = beatmap.Metadata.Author.ToString() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,22 +21,21 @@ namespace osu.Game.Skinning
|
||||
protected SampleManager Samples;
|
||||
|
||||
public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: this(skin)
|
||||
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, storage), audioManager, "skin.ini")
|
||||
{
|
||||
storage = new LegacySkinResourceStore<SkinFileInfo>(skin, storage);
|
||||
Samples = audioManager.GetSampleManager(storage);
|
||||
Textures = new TextureStore(new RawTextureLoaderStore(storage));
|
||||
}
|
||||
|
||||
Stream stream = storage.GetStream("skin.ini");
|
||||
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename) : base(skin)
|
||||
{
|
||||
Stream stream = storage.GetStream(filename);
|
||||
if (stream != null)
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
Configuration = new LegacySkinDecoder().Decode(reader);
|
||||
else
|
||||
Configuration = new SkinConfiguration();
|
||||
}
|
||||
|
||||
protected LegacySkin(SkinInfo skin) : base(skin)
|
||||
{
|
||||
Samples = audioManager.GetSampleManager(storage);
|
||||
Textures = new TextureStore(new RawTextureLoaderStore(storage));
|
||||
}
|
||||
|
||||
public override Drawable GetDrawableComponent(string componentName)
|
||||
|
||||
Reference in New Issue
Block a user