From 73d77637efe4e54294779e8cc15dc220115cd447 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 11 Sep 2017 04:22:05 +0900 Subject: [PATCH] Add glow to DrawableNote --- .../Objects/Drawables/DrawableNote.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 6d4f921020..707b83ef13 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,8 +2,10 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Extensions.Color4Extensions; using OpenTK.Graphics; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; @@ -16,6 +18,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableNote : DrawableManiaHitObject, IKeyBindingHandler { + /// + /// Whether the glow for this is handled by a containing it. + /// + protected bool HasOwnGlow = true; + private readonly NotePiece headPiece; public DrawableNote(Note hitObject, ManiaAction action) @@ -23,6 +30,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + Masking = true; Add(headPiece = new NotePiece { @@ -31,6 +39,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables }); } + protected override void LoadComplete() + { + base.LoadComplete(); + + UpdateGlow(); + } + public override Color4 AccentColour { get { return base.AccentColour; } @@ -41,6 +56,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables base.AccentColour = value; headPiece.AccentColour = value; + + UpdateGlow(); } } @@ -79,6 +96,23 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } + protected virtual void UpdateGlow() + { + if (!IsLoaded) + return; + + if (!HasOwnGlow) + return; + + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Glow, + Colour = AccentColour.Opacity(0.5f), + Radius = 10, + Hollow = true + }; + } + public virtual bool OnPressed(ManiaAction action) { if (action != Action)