mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Add FindProvider
lookup function
This commit is contained in:
@ -69,10 +69,10 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
|||||||
|
|
||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
isLegacySkin = new Lazy<bool>(() => Source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
isLegacySkin = new Lazy<bool>(() => Source.FindProvider(s => s.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null) != null);
|
||||||
hasKeyTexture = new Lazy<bool>(() => Source.GetAnimation(
|
hasKeyTexture = new Lazy<bool>(() => Source.FindProvider(s => s.GetAnimation(
|
||||||
this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
||||||
?? "mania-key1", true, true) != null);
|
?? "mania-key1", true, true) != null) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
|
|
||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
hasHitCircle = new Lazy<bool>(() => Source.GetTexture("hitcircle") != null);
|
hasHitCircle = new Lazy<bool>(Source.FindProvider(s => s.GetTexture("hitcircle") != null) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
|
@ -57,5 +57,13 @@ namespace osu.Game.Skinning
|
|||||||
/// <returns>A matching value boxed in an <see cref="IBindable{TValue}"/>, or null if unavailable.</returns>
|
/// <returns>A matching value boxed in an <see cref="IBindable{TValue}"/>, or null if unavailable.</returns>
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
|
IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For the specified texture, find any potential skin that can fulfill the lookup.
|
||||||
|
/// This should be used for cases where subsequent lookups (for related components) need to occur on the same skin.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The skin to be used for subsequent lookups, or <c>null</c> if none is available.</returns>
|
||||||
|
[CanBeNull]
|
||||||
|
ISkin FindProvider(Func<ISkin, bool> lookupFunction) => lookupFunction(this) ? this : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,5 +556,16 @@ namespace osu.Game.Skinning
|
|||||||
Textures?.Dispose();
|
Textures?.Dispose();
|
||||||
Samples?.Dispose();
|
Samples?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISkin ISkin.FindProvider(Func<ISkin, bool> lookupFunction)
|
||||||
|
{
|
||||||
|
if (lookupFunction(this))
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (!fallbackToDefault)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return (legacyDefaultFallback as ISkin)?.FindProvider(lookupFunction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,14 @@ namespace osu.Game.Skinning
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
||||||
|
{
|
||||||
|
if (lookupFunction(skin))
|
||||||
|
return skin;
|
||||||
|
|
||||||
|
return fallbackSource.FindProvider(lookupFunction);
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
Drawable sourceDrawable;
|
Drawable sourceDrawable;
|
||||||
|
Reference in New Issue
Block a user