Allow LegacySkin to be constructed with all nulls

This commit is contained in:
Dean Herbert 2019-09-04 13:29:55 +09:00
parent 343af28ed5
commit 04c2c33c64
1 changed files with 6 additions and 2 deletions

View File

@ -30,14 +30,14 @@ public LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager au
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
: base(skin)
{
Stream stream = storage.GetStream(filename);
Stream stream = storage?.GetStream(filename);
if (stream != null)
using (StreamReader reader = new StreamReader(stream))
Configuration = new LegacySkinDecoder().Decode(reader);
else
Configuration = new DefaultSkinConfiguration();
Samples = audioManager.GetSampleStore(storage);
Samples = audioManager?.GetSampleStore(storage);
Textures = new TextureStore(new TextureLoaderStore(storage));
}
@ -72,6 +72,10 @@ public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
{
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>();
bindable.Parse(val);
return bindable;