Rewrite CirclePiece to be referenced to 128x128px and handle accented hits more sanely.

This commit is contained in:
smoogipooo
2017-03-24 18:37:56 +09:00
parent 47065d8031
commit 5281842965
12 changed files with 221 additions and 323 deletions

View File

@ -49,6 +49,6 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
UpdateScrollPosition(Time.Current);
}
protected abstract ScrollingPiece CreateCircle();
protected abstract CirclePiece CreateCircle();
}
}

View File

@ -0,0 +1,14 @@
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
public class AccentedCirclePiece : CirclePiece
{
public AccentedCirclePiece(string symbolName)
: base(symbolName)
{
}
public override Vector2 Size => new Vector2(base.Size.X, base.Size.Y * 1.5f);
}
}

View File

@ -1,36 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise Bash objects.
/// </summary>
public class BashCirclePiece : CirclePiece
{
private Sprite icon;
protected override Framework.Graphics.Drawable CreateIcon()
{
return icon ?? (icon = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures)
{
AccentColour = colours.YellowDark;
icon.Texture = textures.Get(@"Play/Taiko/bash-hit-inner");
}
}
}

View File

@ -1,42 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise CentreHit objects.
/// </summary>
public class CentreHitCirclePiece : CirclePiece
{
protected override Framework.Graphics.Drawable CreateIcon()
{
return new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(45f),
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.PinkDarker;
}
}
}

View File

@ -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;
}
}

View File

@ -1,20 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Game.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise DrumRoll objects.
/// </summary>
public class DrumRollCirclePiece : CirclePiece
{
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.YellowDark;
}
}
}

View File

@ -1,31 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A type of circle piece that encapsulates a circle piece to visualise it as a "finisher" hitobject.
/// <para>
/// Finisher hitobjects are 1.5x larger, while maintaining the same length.
/// </para>
/// </summary>
public class FinisherPiece : ScrollingPiece
{
public FinisherPiece(ScrollingPiece original)
{
// First we scale the note up
Scale = new Vector2(1.5f);
Children = new[]
{
original
};
// Next we reduce the draw width for drum rolls to keep the width
// equal to that of a non-finisher drum roll
original.Width /= 1.5f;
}
}
}

View File

@ -1,47 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A circle piece which is used to visualise RimHit objects.
/// </summary>
public class RimHitCirclePiece : CirclePiece
{
protected override Framework.Graphics.Drawable CreateIcon()
{
return new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(61f),
BorderThickness = 8,
BorderColour = Color4.White,
Masking = true,
Children = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.BlueDarker;
}
}
}

View File

@ -1,19 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces
{
/// <summary>
/// A type of circle piece that will be scrolling the screen.
/// <para>
/// A scrolling circle piece must always have a centre-left origin due to how scroll position is calculated.
/// </para>
/// </summary>
public class ScrollingPiece : Container
{
public override Anchor Origin => Anchor.CentreLeft;
}
}