Make fallback bool into a function

Allows correct handling now that beatmap skins are also a thing.
This commit is contained in:
Dean Herbert
2018-03-16 10:36:26 +09:00
parent f03abb3145
commit fb3d319d0e
6 changed files with 12 additions and 10 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
@ -11,20 +12,21 @@ namespace osu.Game.Skinning
/// </summary>
public abstract class SkinReloadableDrawable : CompositeDrawable
{
private readonly Func<ISkinSource, bool> allowFallback;
private ISkinSource skin;
/// <summary>
/// Whether fallback to default skin should be allowed if the custom skin is missing this resource.
/// </summary>
private readonly bool allowDefaultFallback;
private bool allowDefaultFallback => allowFallback == null || allowFallback.Invoke(skin);
/// <summary>
/// Create a new <see cref="SkinReloadableDrawable"/>
/// </summary>
/// <param name="fallback">Whether fallback to default skin should be allowed if the custom skin is missing this resource.</param>
protected SkinReloadableDrawable(bool fallback = true)
protected SkinReloadableDrawable(Func<ISkinSource, bool> allowFallback = null)
{
allowDefaultFallback = fallback;
this.allowFallback = allowFallback;
}
[BackgroundDependencyLoader]