From bfe3b039457281c803531488f60501ba4863a573 Mon Sep 17 00:00:00 2001 From: Dragicafit Date: Tue, 11 Dec 2018 18:06:41 +0100 Subject: [PATCH] using SkinReloadableDrawable --- .../UI/Cursor/GameplayCursor.cs | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index 5489ccf2bd..0d2e5c272d 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -27,24 +27,24 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private readonly Container fadeContainer; + private SkinnableCursor skinnableCursor; + public GameplayCursor() { - InternalChild = fadeContainer = new Container + InternalChildren = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + fadeContainer = new Container { - new CursorTrail { Depth = 1 } - } + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new CursorTrail { Depth = 1 } + } + }, + skinnableCursor = new SkinnableCursor() }; } - [BackgroundDependencyLoader] - private void load(ISkinSource source) - { - cursorExpand = source.GetValue(s => s.CursorExpand) ?? true; - } - private int downCount; private const float pressed_scale = 1.2f; @@ -54,6 +54,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public bool OnPressed(OsuAction action) { + cursorExpand = skinnableCursor.CursorExpand; + if (!cursorExpand) return false; @@ -205,4 +207,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor } } } + + public class SkinnableCursor : SkinReloadableDrawable + { + public bool CursorExpand { get; set; } = true; + + protected override void SkinChanged(ISkinSource skin, bool allowFallback) + { + CursorExpand = skin.GetValue(s => s.CursorExpand) ?? true; + } + } }