Move FindProvider to ISkinSource

This commit is contained in:
Dean Herbert
2021-06-06 11:08:54 +09:00
parent ae2165b3be
commit 39f99bf785
6 changed files with 18 additions and 33 deletions

View File

@ -54,9 +54,6 @@ namespace osu.Game.Skinning
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
[CanBeNull]
private readonly DefaultLegacySkin legacyDefaultFallback;
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
public LegacySkin(SkinInfo skin, IStorageResourceProvider resources)
: this(skin, new LegacySkinResourceStore<SkinFileInfo>(skin, resources.Files), resources, "skin.ini")
@ -73,9 +70,6 @@ namespace osu.Game.Skinning
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, string configurationFilename)
: base(skin, resources)
{
if (resources != null)
legacyDefaultFallback = CreateFallbackSkin(storage, resources);
using (var stream = storage?.GetStream(configurationFilename))
{
if (stream != null)
@ -158,7 +152,7 @@ namespace osu.Game.Skinning
return genericLookup<TLookup, TValue>(lookup);
}
return legacyDefaultFallback?.GetConfig<TLookup, TValue>(lookup);
return null;
}
private IBindable<TValue> lookupForMania<TValue>(LegacyManiaSkinConfigurationLookup maniaLookup)
@ -335,7 +329,7 @@ namespace osu.Game.Skinning
{
}
return legacyDefaultFallback?.GetConfig<TLookup, TValue>(lookup);
return null;
}
public override Drawable GetDrawableComponent(ISkinComponent component)
@ -406,6 +400,7 @@ namespace osu.Game.Skinning
return null;
case GameplaySkinComponent<HitResult> resultComponent:
// TODO: this should be inside the judgement pieces.
Func<Drawable> createDrawable = () => getJudgementAnimation(resultComponent.Component);
// kind of wasteful that we throw this away, but should do for now.
@ -427,7 +422,7 @@ namespace osu.Game.Skinning
if (animation != null)
return animation;
return legacyDefaultFallback?.GetDrawableComponent(component);
return null;
}
private Texture getParticleTexture(HitResult result)
@ -487,7 +482,7 @@ namespace osu.Game.Skinning
return texture;
}
return legacyDefaultFallback?.GetTexture(componentName, wrapModeS, wrapModeT);
return null;
}
public override ISample GetSample(ISampleInfo sampleInfo)
@ -511,17 +506,7 @@ namespace osu.Game.Skinning
}
}
return legacyDefaultFallback?.GetSample(sampleInfo);
}
public override ISkin FindProvider(Func<ISkin, bool> lookupFunction)
{
var source = base.FindProvider(lookupFunction);
if (source != null)
return source;
return legacyDefaultFallback?.FindProvider(lookupFunction);
return null;
}
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)