Reverted change to AllowConfigurationLookup and added a separate AllowColourLookup bool with config case based on lookup type in SkinProvidingContainer GetConfig call.

This commit is contained in:
Mysfit 2021-01-13 13:07:07 -05:00
parent 80bcd78a48
commit 1248d39d7e
2 changed files with 41 additions and 4 deletions

View File

@ -25,6 +25,17 @@ protected override bool AllowConfigurationLookup
if (beatmapSkins == null)
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");
return beatmapSkins.Value;
}
}
protected override bool AllowColourLookup
{
get
{
if (beatmapColours == null)
throw new InvalidOperationException($"{nameof(BeatmapSkinProvidingContainer)} needs to be loaded before being consumed.");
return beatmapColours.Value;
}
}

View File

@ -32,6 +32,8 @@ public class SkinProvidingContainer : Container, ISkinSource
protected virtual bool AllowConfigurationLookup => true;
protected virtual bool AllowColourLookup => true;
public SkinProvidingContainer(ISkin skin)
{
this.skin = skin;
@ -68,11 +70,35 @@ public SampleChannel GetSample(ISampleInfo sampleInfo)
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
if (AllowConfigurationLookup && skin != null)
if (skin != null)
{
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
if (bindable != null)
return bindable;
switch (lookup)
{
// todo: the GlobalSkinColours switch is pulled from LegacySkin and should not exist.
// will likely change based on how databased storage of skin configuration goes.
case GlobalSkinColours global:
switch (global)
{
case GlobalSkinColours.ComboColours:
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
if (bindable != null && AllowColourLookup)
return bindable;
else
return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
}
break;
default:
if (AllowConfigurationLookup)
{
var bindable = skin.GetConfig<TLookup, TValue>(lookup);
if (bindable != null)
return bindable;
}
break;
}
}
return fallbackSource?.GetConfig<TLookup, TValue>(lookup);