1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00

Extract method for performing generic config lookup

This commit is contained in:
Bartłomiej Dach 2020-08-02 19:46:29 +02:00
parent 453e1dd48c
commit 3e5c3e256d

View File

@ -143,27 +143,7 @@ namespace osu.Game.Skinning
goto default;
default:
// handles lookups like some in LegacySkinConfiguration.LegacySetting
try
{
if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))
{
// special case for handling skins which use 1 or 0 to signify a boolean state.
if (typeof(TValue) == typeof(bool))
val = val == "1" ? "true" : "false";
var bindable = new Bindable<TValue>();
if (val != null)
bindable.Parse(val);
return bindable;
}
}
catch
{
}
break;
return genericLookup<TLookup, TValue>(lookup);
}
return null;
@ -286,6 +266,30 @@ namespace osu.Game.Skinning
private IBindable<string> getManiaImage(LegacyManiaSkinConfiguration source, string lookup)
=> source.ImageLookups.TryGetValue(lookup, out var image) ? new Bindable<string>(image) : null;
[CanBeNull]
private IBindable<TValue> genericLookup<TLookup, TValue>(TLookup lookup)
{
try
{
if (Configuration.ConfigDictionary.TryGetValue(lookup.ToString(), out var val))
{
// special case for handling skins which use 1 or 0 to signify a boolean state.
if (typeof(TValue) == typeof(bool))
val = val == "1" ? "true" : "false";
var bindable = new Bindable<TValue>();
if (val != null)
bindable.Parse(val);
return bindable;
}
}
catch
{
}
return null;
}
public override Drawable GetDrawableComponent(ISkinComponent component)
{
switch (component)