mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 08:22:56 +08:00
Expose the skin lookup layers of SkinManager
to a property
This commit is contained in:
parent
6538d44708
commit
9e652715ce
@ -42,6 +42,24 @@ namespace osu.Game.Skinning
|
|||||||
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>();
|
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>();
|
||||||
public readonly Bindable<SkinInfo> CurrentSkinInfo = new Bindable<SkinInfo>(SkinInfo.Default) { Default = SkinInfo.Default };
|
public readonly Bindable<SkinInfo> CurrentSkinInfo = new Bindable<SkinInfo>(SkinInfo.Default) { Default = SkinInfo.Default };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The skin layers of the currently selected user skin for performing lookups on,
|
||||||
|
/// in order of preference (user skin first, then fallback skins).
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<ISkin> CurrentSkinLayers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return CurrentSkin.Value;
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
yield return defaultLegacySkin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> HandledExtensions => new[] { ".osk" };
|
public override IEnumerable<string> HandledExtensions => new[] { ".osk" };
|
||||||
|
|
||||||
protected override string[] HashableFileTypes => new[] { ".ini" };
|
protected override string[] HashableFileTypes => new[] { ".ini" };
|
||||||
@ -220,11 +238,11 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
|
||||||
{
|
{
|
||||||
if (lookupFunction(CurrentSkin.Value))
|
foreach (var skin in CurrentSkinLayers)
|
||||||
return CurrentSkin.Value;
|
{
|
||||||
|
if (lookupFunction(skin))
|
||||||
if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin))
|
return skin;
|
||||||
return defaultLegacySkin;
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -232,16 +250,12 @@ namespace osu.Game.Skinning
|
|||||||
private T lookupWithFallback<T>(Func<ISkin, T> func)
|
private T lookupWithFallback<T>(Func<ISkin, T> func)
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
var selectedSkin = func(CurrentSkin.Value);
|
foreach (var skin in CurrentSkinLayers)
|
||||||
|
{
|
||||||
if (selectedSkin != null)
|
var result = func(skin);
|
||||||
return selectedSkin;
|
if (result != null)
|
||||||
|
return result;
|
||||||
// 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)
|
|
||||||
return func(defaultLegacySkin);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user