mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Add glow to DrawableNote
This commit is contained in:
parent
8797382700
commit
73d77637ef
@ -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
|
||||
/// </summary>
|
||||
public class DrawableNote : DrawableManiaHitObject<Note>, IKeyBindingHandler<ManiaAction>
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the glow for this <see cref="DrawableNote"/> is handled by a <see cref="DrawableHitObject"/> containing it.
|
||||
/// </summary>
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user