1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 15:53:19 +08:00

Fix FindProvider not correctly checking legacy default in SkinManager

This commit is contained in:
Dean Herbert 2021-06-08 00:42:50 +09:00
parent 273d66a0e0
commit e7e9197f03

View File

@ -48,6 +48,8 @@ namespace osu.Game.Skinning
protected override string ImportFromStablePath => "Skins"; protected override string ImportFromStablePath => "Skins";
private readonly Skin defaultLegacySkin;
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, IResourceStore<byte[]> resources, AudioManager audio) public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, IResourceStore<byte[]> resources, AudioManager audio)
: base(storage, contextFactory, new SkinStore(contextFactory, storage), host) : base(storage, contextFactory, new SkinStore(contextFactory, storage), host)
{ {
@ -55,6 +57,8 @@ namespace osu.Game.Skinning
this.host = host; this.host = host;
this.resources = resources; this.resources = resources;
defaultLegacySkin = new DefaultLegacySkin(this);
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue); CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
CurrentSkin.ValueChanged += skin => CurrentSkin.ValueChanged += skin =>
{ {
@ -212,9 +216,16 @@ namespace osu.Game.Skinning
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => lookupWithFallback(s => s.GetConfig<TLookup, TValue>(lookup)); public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => lookupWithFallback(s => s.GetConfig<TLookup, TValue>(lookup));
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => lookupFunction(CurrentSkin.Value) ? CurrentSkin.Value : null; public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
{
if (lookupFunction(CurrentSkin.Value))
return CurrentSkin.Value;
private Skin defaultLegacySkin; if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin))
return defaultLegacySkin;
return null;
}
private T lookupWithFallback<T>(Func<ISkin, T> func) private T lookupWithFallback<T>(Func<ISkin, T> func)
where T : class where T : class
@ -224,8 +235,6 @@ namespace osu.Game.Skinning
if (selectedSkin != null) if (selectedSkin != null)
return selectedSkin; return selectedSkin;
defaultLegacySkin ??= new DefaultLegacySkin(this);
if (CurrentSkin.Value is LegacySkin) if (CurrentSkin.Value is LegacySkin)
return func(defaultLegacySkin); return func(defaultLegacySkin);