From fb3d319d0e56d015b6c3f5ec8cc37486a684c81d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 16 Mar 2018 10:36:26 +0900 Subject: [PATCH] Make fallback bool into a function Allows correct handling now that beatmap skins are also a thing. --- .../Objects/Drawables/Pieces/ExplodePiece.cs | 2 +- .../Objects/Drawables/Pieces/FlashPiece.cs | 2 +- .../Objects/Drawables/Pieces/GlowPiece.cs | 2 +- .../Objects/Drawables/Pieces/NumberPiece.cs | 2 +- osu.Game/Skinning/SkinReloadableDrawable.cs | 8 +++++--- osu.Game/Skinning/SkinnableDrawable.cs | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs index 76ed89be67..28552e6c36 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/ExplodePiece.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Blending = BlendingMode.Additive, RelativeSizeAxes = Axes.Both, Alpha = 0.2f, - }, false); + }, s => s.GetTexture("Play/osu/hitcircle") == null); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs index 921d24f69d..50dc473750 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/FlashPiece.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { RelativeSizeAxes = Axes.Both } - }, false); + }, s => s.GetTexture("Play/osu/hitcircle") == null); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs index a4e1916659..211e138b65 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/GlowPiece.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Texture = textures.Get(name), Blending = BlendingMode.Additive, Alpha = 0.5f - }, false); + }, s => s.GetTexture("Play/osu/hitcircle") == null); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs index 4220299c66..0c1fd4c364 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/NumberPiece.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces Colour = Color4.White.Opacity(0.5f), }, Child = new Box() - }, false), + }, s => s.GetTexture("Play/osu/hitcircle") == null), number = new OsuSpriteText { Text = @"1", diff --git a/osu.Game/Skinning/SkinReloadableDrawable.cs b/osu.Game/Skinning/SkinReloadableDrawable.cs index 04ba8427b2..36f33e746a 100644 --- a/osu.Game/Skinning/SkinReloadableDrawable.cs +++ b/osu.Game/Skinning/SkinReloadableDrawable.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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 /// public abstract class SkinReloadableDrawable : CompositeDrawable { + private readonly Func allowFallback; private ISkinSource skin; /// /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. /// - private readonly bool allowDefaultFallback; + private bool allowDefaultFallback => allowFallback == null || allowFallback.Invoke(skin); /// /// Create a new /// /// Whether fallback to default skin should be allowed if the custom skin is missing this resource. - protected SkinReloadableDrawable(bool fallback = true) + protected SkinReloadableDrawable(Func allowFallback = null) { - allowDefaultFallback = fallback; + this.allowFallback = allowFallback; } [BackgroundDependencyLoader] diff --git a/osu.Game/Skinning/SkinnableDrawable.cs b/osu.Game/Skinning/SkinnableDrawable.cs index 77af44d5d6..9314d16c39 100644 --- a/osu.Game/Skinning/SkinnableDrawable.cs +++ b/osu.Game/Skinning/SkinnableDrawable.cs @@ -9,8 +9,8 @@ namespace osu.Game.Skinning { public class SkinnableDrawable : SkinnableDrawable { - public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true, bool restrictSize = true) - : base(name, defaultImplementation, fallback, restrictSize) + public SkinnableDrawable(string name, Func defaultImplementation, Func allowFallback = null, bool restrictSize = true) + : base(name, defaultImplementation, allowFallback, restrictSize) { } } @@ -31,7 +31,7 @@ namespace osu.Game.Skinning /// A function to create the default skin implementation of this element. /// Whther to fallback to the default implementation when a custom skin is specified but not implementation is present. /// Whether a user-skin drawable should be limited to the size of our parent. - public SkinnableDrawable(string name, Func defaultImplementation, bool fallback = true, bool restrictSize = true) : base(fallback) + public SkinnableDrawable(string name, Func defaultImplementation, Func allowFallback = null, bool restrictSize = true) : base(allowFallback) { componentName = name; createDefault = defaultImplementation;