2017-03-20 16:02:06 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-03-20 15:50:22 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
using OpenTK.Graphics;
|
2017-03-24 17:37:56 +08:00
|
|
|
using System;
|
2017-03-20 15:50:22 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
|
|
|
|
/// <para>
|
2017-03-24 19:09:58 +08:00
|
|
|
/// The body of this piece will overshoot its parent by <see cref="CirclePiece.Height"/> to form
|
|
|
|
/// a rounded (_[-Width-]_) figure such that a regular "circle" is the result of a parent with Width = 0.
|
2017-03-20 15:50:22 +08:00
|
|
|
/// </para>
|
|
|
|
/// </summary>
|
2017-03-24 17:37:56 +08:00
|
|
|
public class CirclePiece : Container
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
private Color4 accentColour;
|
2017-03-20 15:50:22 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The colour of the inner circle and outer glows.
|
|
|
|
/// </summary>
|
2017-03-24 17:37:56 +08:00
|
|
|
public Color4 AccentColour
|
|
|
|
{
|
|
|
|
get { return accentColour; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
innerBackground.Colour = AccentColour;
|
|
|
|
|
|
|
|
triangles.ColourLight = AccentColour;
|
|
|
|
triangles.ColourDark = AccentColour.Darken(0.1f);
|
|
|
|
|
|
|
|
resetEdgeEffects();
|
|
|
|
}
|
|
|
|
}
|
2017-03-20 15:50:22 +08:00
|
|
|
|
|
|
|
private bool kiaiMode;
|
|
|
|
/// <summary>
|
2017-03-24 14:55:25 +08:00
|
|
|
/// Whether Kiai mode effects are enabled for this circle piece.
|
2017-03-20 15:50:22 +08:00
|
|
|
/// </summary>
|
|
|
|
public bool KiaiMode
|
|
|
|
{
|
|
|
|
get { return kiaiMode; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
kiaiMode = value;
|
|
|
|
|
2017-03-24 17:37:56 +08:00
|
|
|
resetEdgeEffects();
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-24 17:37:56 +08:00
|
|
|
public override Anchor Origin
|
|
|
|
{
|
|
|
|
get { return Anchor.CentreLeft; }
|
|
|
|
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
|
|
|
|
}
|
|
|
|
|
2017-03-24 19:08:40 +08:00
|
|
|
protected override Container<Framework.Graphics.Drawable> Content => SymbolContainer;
|
|
|
|
protected readonly Container SymbolContainer;
|
|
|
|
|
2017-03-24 13:42:42 +08:00
|
|
|
private readonly Container innerLayer;
|
|
|
|
private readonly Container innerCircleContainer;
|
|
|
|
private readonly Box innerBackground;
|
|
|
|
private readonly Triangles triangles;
|
2017-03-20 15:50:22 +08:00
|
|
|
|
2017-03-24 19:08:40 +08:00
|
|
|
public CirclePiece()
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 19:09:58 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-03-24 18:04:32 +08:00
|
|
|
Height = TaikoHitObject.CIRCLE_RADIUS * 2;
|
2017-03-24 18:05:45 +08:00
|
|
|
|
|
|
|
// The "inner layer" is the body of the CirclePiece that overshoots it by Height/2 px on both sides
|
2017-03-24 17:37:56 +08:00
|
|
|
AddInternal(innerLayer = new Container
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
Name = "Inner Layer",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
innerCircleContainer = new CircularContainer
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
Name = "Inner Circle",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
innerBackground = new Box
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
triangles = new Triangles
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
2017-03-24 17:37:56 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new CircularContainer
|
|
|
|
{
|
|
|
|
Name = "Ring",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BorderThickness = 8,
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
Masking = true,
|
|
|
|
Children = new[]
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
new Box
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0,
|
|
|
|
AlwaysPresent = true
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
}
|
2017-03-24 17:37:56 +08:00
|
|
|
},
|
2017-03-24 19:08:40 +08:00
|
|
|
SymbolContainer = new Container
|
2017-03-24 17:37:56 +08:00
|
|
|
{
|
|
|
|
Name = "Symbol",
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
2017-03-24 17:37:56 +08:00
|
|
|
}
|
|
|
|
});
|
2017-03-20 15:50:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
2017-03-24 18:05:45 +08:00
|
|
|
// Add the overshoot to compensate for corner radius
|
2017-03-20 15:50:22 +08:00
|
|
|
innerLayer.Width = DrawWidth + DrawHeight;
|
|
|
|
}
|
|
|
|
|
2017-03-24 17:37:56 +08:00
|
|
|
private void resetEdgeEffects()
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
2017-03-24 17:37:56 +08:00
|
|
|
innerCircleContainer.EdgeEffect = new EdgeEffect
|
2017-03-20 15:50:22 +08:00
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = AccentColour,
|
2017-03-24 17:37:56 +08:00
|
|
|
Radius = KiaiMode ? 50 : 8
|
2017-03-20 15:50:22 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|