mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Rewrite CirclePiece to be referenced to 128x128px and handle accented hits more sanely.
This commit is contained in:
@ -8,6 +8,9 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Allocation;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
{
|
||||
@ -18,15 +21,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
/// a regular "circle" is the result of setting Width to 0.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Hitobjects that have a length need only to set Width and the extra corner radius will be added internally.
|
||||
/// Hitobjects that have a length (e.g. DrumRolls) need only to set Width and the extra corner radius will be added internally.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public abstract class CirclePiece : ScrollingPiece
|
||||
public class CirclePiece : Container
|
||||
{
|
||||
private Color4 accentColour;
|
||||
/// <summary>
|
||||
/// The colour of the inner circle and outer glows.
|
||||
/// </summary>
|
||||
public Color4 AccentColour { get; protected set; }
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour; }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
innerBackground.Colour = AccentColour;
|
||||
|
||||
triangles.ColourLight = AccentColour;
|
||||
triangles.ColourDark = AccentColour.Darken(0.1f);
|
||||
|
||||
resetEdgeEffects();
|
||||
}
|
||||
}
|
||||
|
||||
private bool kiaiMode;
|
||||
/// <summary>
|
||||
@ -39,129 +57,99 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
{
|
||||
kiaiMode = value;
|
||||
|
||||
if (innerCircleContainer != null)
|
||||
innerCircleContainer.EdgeEffect = value ? createKiaiEdgeEffect() : default(EdgeEffect);
|
||||
resetEdgeEffects();
|
||||
}
|
||||
}
|
||||
|
||||
public override Anchor Origin
|
||||
{
|
||||
get { return Anchor.CentreLeft; }
|
||||
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
|
||||
}
|
||||
|
||||
public override Vector2 Size => new Vector2(base.Size.X, TaikoHitObject.CIRCLE_RADIUS * 2);
|
||||
|
||||
private readonly Container innerLayer;
|
||||
private readonly Container backingGlowContainer;
|
||||
private readonly Container innerCircleContainer;
|
||||
private readonly Box innerBackground;
|
||||
private readonly Triangles triangles;
|
||||
private readonly Sprite symbol;
|
||||
|
||||
protected CirclePiece()
|
||||
private readonly string symbolName;
|
||||
|
||||
public CirclePiece(string symbolName)
|
||||
{
|
||||
Container iconContainer;
|
||||
this.symbolName = symbolName;
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
// The "inner layer" overshoots the the CirclePiece by Height/2 px on both sides
|
||||
AddInternal(innerLayer = new Container
|
||||
{
|
||||
// The "inner layer" overshoots the ObjectPiece by 64px on both sides
|
||||
innerLayer = new Container
|
||||
Name = "Inner Layer",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
Name = "Inner Layer",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
innerCircleContainer = new CircularContainer
|
||||
{
|
||||
backingGlowContainer = new CircularContainer
|
||||
Name = "Inner Circle",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
Name = "Backing Glow",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
innerBackground = new Box
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
}
|
||||
},
|
||||
innerCircleContainer = new CircularContainer
|
||||
{
|
||||
Name = "Inner Circle",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
triangles = new Triangles
|
||||
{
|
||||
innerBackground = new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
triangles = new Triangles
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Name = "Ring",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BorderThickness = 8,
|
||||
BorderColour = Color4.White,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
}
|
||||
},
|
||||
iconContainer = new Container
|
||||
{
|
||||
Name = "Icon Container",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Name = "Ring",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BorderThickness = 8,
|
||||
BorderColour = Color4.White,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
}
|
||||
},
|
||||
symbol = new Sprite
|
||||
{
|
||||
Name = "Symbol",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Framework.Graphics.Drawable icon = CreateIcon();
|
||||
|
||||
if (icon != null)
|
||||
iconContainer.Add(icon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
backingGlowContainer.EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = AccentColour,
|
||||
Radius = 8
|
||||
};
|
||||
|
||||
if (KiaiMode)
|
||||
innerCircleContainer.EdgeEffect = createKiaiEdgeEffect();
|
||||
|
||||
innerBackground.Colour = AccentColour;
|
||||
|
||||
triangles.ColourLight = AccentColour;
|
||||
triangles.ColourDark = AccentColour.Darken(0.1f);
|
||||
if (!string.IsNullOrEmpty(symbolName))
|
||||
symbol.Texture = textures.Get($@"Play/Taiko/{symbolName}-symbol");
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -169,20 +157,14 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
|
||||
innerLayer.Width = DrawWidth + DrawHeight;
|
||||
}
|
||||
|
||||
private EdgeEffect createKiaiEdgeEffect()
|
||||
private void resetEdgeEffects()
|
||||
{
|
||||
return new EdgeEffect
|
||||
innerCircleContainer.EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Glow,
|
||||
Colour = AccentColour,
|
||||
Radius = 50
|
||||
Radius = KiaiMode ? 50 : 8
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the icon that's shown in the middle of this object piece.
|
||||
/// </summary>
|
||||
/// <returns>The icon.</returns>
|
||||
protected virtual Framework.Graphics.Drawable CreateIcon() => null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user