1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Expose as Skins and consume SkinInfo from instances

This commit is contained in:
Dean Herbert 2021-06-11 14:49:35 +09:00
parent 2240e2c39c
commit b9050f91a4

View File

@ -48,19 +48,15 @@ namespace osu.Game.Skinning
protected override string ImportFromStablePath => "Skins";
private readonly Skin defaultSkin;
/// <summary>
/// An <see cref="ISkin"/> providing the resources of the default skin.
/// </summary>
public ISkin DefaultSkin => defaultSkin;
private readonly Skin defaultLegacySkin;
public Skin DefaultSkin { get; }
/// <summary>
/// An <see cref="ISkin"/> providing the resources of the default legacy skin.
/// </summary>
public ISkin DefaultLegacySkin => defaultLegacySkin;
public Skin DefaultLegacySkin { get; }
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, IResourceStore<byte[]> resources, AudioManager audio)
: base(storage, contextFactory, new SkinStore(contextFactory, storage), host)
@ -69,12 +65,12 @@ namespace osu.Game.Skinning
this.host = host;
this.resources = resources;
defaultLegacySkin = new DefaultLegacySkin(this);
defaultSkin = new DefaultSkin(this);
DefaultLegacySkin = new DefaultLegacySkin(this);
DefaultSkin = new DefaultSkin(this);
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
CurrentSkin.Value = defaultSkin;
CurrentSkin.Value = DefaultSkin;
CurrentSkin.ValueChanged += skin =>
{
if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
@ -93,8 +89,8 @@ namespace osu.Game.Skinning
public List<SkinInfo> GetAllUsableSkins()
{
var userSkins = GetAllUserSkins();
userSkins.Insert(0, SkinInfo.Default);
userSkins.Insert(1, Skinning.DefaultLegacySkin.Info);
userSkins.Insert(0, DefaultSkin.SkinInfo);
userSkins.Insert(1, DefaultLegacySkin.SkinInfo);
return userSkins;
}
@ -236,11 +232,11 @@ namespace osu.Game.Skinning
if (lookupFunction(CurrentSkin.Value))
return CurrentSkin.Value;
if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin))
return defaultLegacySkin;
if (CurrentSkin.Value is LegacySkin && lookupFunction(DefaultLegacySkin))
return DefaultLegacySkin;
if (lookupFunction(defaultSkin))
return defaultSkin;
if (lookupFunction(DefaultSkin))
return DefaultSkin;
return null;
}
@ -254,11 +250,11 @@ namespace osu.Game.Skinning
// TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements.
// When attempting to address this, we may want to move the full DefaultLegacySkin fallback logic to within Player itself (to better allow
// for beatmap skin visibility).
if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin) is T legacySourced)
if (CurrentSkin.Value is LegacySkin && lookupFunction(DefaultLegacySkin) is T legacySourced)
return legacySourced;
// Finally fall back to the (non-legacy) default.
return lookupFunction(defaultSkin);
return lookupFunction(DefaultSkin);
}
#region IResourceStorageProvider