From 730824fa58990955352341e8bd7f4c3278374d0f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 20 Mar 2017 16:50:22 +0900 Subject: [PATCH] Move pieces out of the visual test, fix up comments, rewrite FinisherPiece. --- .../Tests/TestCaseTaikoHitObjects.cs | 347 +----------------- .../Drawable/Pieces/BashCirclePiece.cs | 33 ++ .../Drawable/Pieces/CentreHitCirclePiece.cs | 42 +++ .../Objects/Drawable/Pieces/CirclePiece.cs | 201 ++++++++++ .../Drawable/Pieces/DrumRollCirclePiece.cs | 17 + .../Objects/Drawable/Pieces/FinisherPiece.cs | 28 ++ .../Drawable/Pieces/RimHitCirclePiece.cs | 47 +++ .../Drawable/Pieces/ScrollingCirclePiece.cs | 16 + .../osu.Game.Modes.Taiko.csproj | 11 +- 9 files changed, 393 insertions(+), 349 deletions(-) create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/BashCirclePiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitCirclePiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/DrumRollCirclePiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/FinisherPiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitCirclePiece.cs create mode 100644 osu.Game.Modes.Taiko/Objects/Drawable/Pieces/ScrollingCirclePiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs index e1c08c8770..a918cc31a1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs @@ -1,14 +1,6 @@ using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Screens.Testing; -using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; +using osu.Game.Modes.Taiko.Objects.Drawable.Pieces; namespace osu.Desktop.VisualTests.Tests { @@ -65,341 +57,4 @@ public override void Reset() }); } } - - class FinisherPiece : ScrollingCirclePiece - { - public FinisherPiece(CirclePiece originalPiece) - { - Scale = new Vector2(1.5f); - - Children = new[] - { - originalPiece - }; - } - } - - /// - /// A circle piece which is used to visualise RimHit objects. - /// - class RimHitCirclePiece : CirclePiece - { - public RimHitCirclePiece() - { - Height = 128; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - AccentColour = colours.BlueDarker; - } - - protected override Drawable CreateIcon() - { - return new CircularContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - Size = new Vector2(61f), - - BorderThickness = 8, - BorderColour = Color4.White, - - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - - Alpha = 0, - AlwaysPresent = true - } - } - }; - } - } - - /// - /// A circle piece which is used to visualise CentreHit objects. - /// - class CentreHitCirclePiece : CirclePiece - { - public CentreHitCirclePiece() - { - Height = 128; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - AccentColour = colours.PinkDarker; - } - - protected override Drawable CreateIcon() - { - return new CircularContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - Size = new Vector2(45f), - - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - - Alpha = 1 - } - } - }; - } - } - - /// - /// A circle piece which is used to visualise Bash objects. - /// - class BashCirclePiece : CirclePiece - { - private Sprite icon; - - public BashCirclePiece() - { - Height = 128; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures) - { - AccentColour = colours.YellowDark; - - icon.Texture = textures.Get(@"Play/Taiko/bash-hit-inner"); - } - - protected override Drawable CreateIcon() - { - return icon = new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }; - } - } - - /// - /// A circle piece which is used to visualise DrumRoll objects. - /// - class DrumRollCirclePiece : CirclePiece - { - public DrumRollCirclePiece() - { - Height = 128; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - AccentColour = colours.YellowDark; - } - } - - /// - /// A circle piece which is used uniformly through osu!taiko to visualise hitobjects. - /// This is used uniformly throughout all osu!taiko hitobjects. - /// - /// The contents of this piece will overshoot it by 64px on both sides on the X-axis, such that - /// a regular "circle" is created by setting the width of this piece to 0px (resulting in a 64px radius circle). - /// - /// - abstract class CirclePiece : ScrollingCirclePiece - { - private bool kiaiMode; - /// - /// Whether Kiai mode is active for this object. - /// - public bool KiaiMode - { - get { return kiaiMode; } - set - { - kiaiMode = value; - - if (innerCircleContainer != null) - innerCircleContainer.EdgeEffect = value ? createKiaiEdgeEffect() : default(EdgeEffect); - } - } - - /// - /// The colour of the inner circle and outer glows. - /// - public Color4 AccentColour { get; protected set; } - - private Container innerLayer; - private Container backingGlowContainer; - private Container innerCircleContainer; - private Box innerBackground; - private Triangles triangles; - - protected CirclePiece() - { - Container iconContainer; - - Children = new Drawable[] - { - // 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 Drawable[] - { - backingGlowContainer = new CircularContainer - { - Name = "Backing Glow", - - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - RelativeSizeAxes = Axes.Both, - - Children = new[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - - Alpha = 0, - AlwaysPresent = true - } - } - }, - innerCircleContainer = new CircularContainer - { - Name = "Inner Circle", - - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - RelativeSizeAxes = Axes.Both, - - Children = new Drawable[] - { - innerBackground = new Box - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - RelativeSizeAxes = Axes.Both, - }, - triangles = new Triangles - { - 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, - - 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, - } - } - }, - }; - - Drawable icon = CreateIcon(); - - if (icon != null) - iconContainer.Add(icon); - } - - protected override void LoadComplete() - { - 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); - } - - protected override void Update() - { - innerLayer.Width = DrawWidth + 128; - } - - private EdgeEffect createKiaiEdgeEffect() - { - return new EdgeEffect - { - Type = EdgeEffectType.Glow, - Colour = AccentColour, - Radius = 50 - }; - } - - /// - /// Creates the icon that's shown in the middle of this object piece. - /// - /// The icon. - protected virtual Drawable CreateIcon() => null; - } - - class ScrollingCirclePiece : Container - { - public ScrollingCirclePiece() - { - Origin = Anchor.CentreLeft; - - // Todo: Relative X position - } - } } diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/BashCirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/BashCirclePiece.cs new file mode 100644 index 0000000000..a53ef34cca --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/BashCirclePiece.cs @@ -0,0 +1,33 @@ +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 +{ + /// + /// A circle piece which is used to visualise Bash objects. + /// + public class BashCirclePiece : CirclePiece + { + private Sprite icon; + + [BackgroundDependencyLoader] + private void load(OsuColour colours, TextureStore textures) + { + AccentColour = colours.YellowDark; + + icon.Texture = textures.Get(@"Play/Taiko/bash-hit-inner"); + } + + protected override Framework.Graphics.Drawable CreateIcon() + { + return icon = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitCirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitCirclePiece.cs new file mode 100644 index 0000000000..3c4ea3630c --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CentreHitCirclePiece.cs @@ -0,0 +1,42 @@ +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 +{ + /// + /// A circle piece which is used to visualise CentreHit objects. + /// + public class CentreHitCirclePiece : CirclePiece + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.PinkDarker; + } + + protected override Framework.Graphics.Drawable CreateIcon() + { + return new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + + Size = new Vector2(45f), + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + + Alpha = 1 + } + } + }; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs new file mode 100644 index 0000000000..4cf723f267 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/CirclePiece.cs @@ -0,0 +1,201 @@ +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; +using OpenTK; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// A circle piece which is used uniformly through osu!taiko to visualise hitobjects. + /// + /// The body of this piece will overshoot it by Height/2 on both sides of its length, such that + /// a regular "circle" the result of setting Width to 0. + /// + /// + /// Hitobjects that have a length need only to set Width and the extra corner radius will be added internally. + /// + /// + public abstract class CirclePiece : ScrollingCirclePiece + { + /// + /// The colour of the inner circle and outer glows. + /// + public Color4 AccentColour { get; protected set; } + + private bool kiaiMode; + /// + /// Whether Kiai mode is active for this object. + /// + public bool KiaiMode + { + get { return kiaiMode; } + set + { + kiaiMode = value; + + if (innerCircleContainer != null) + innerCircleContainer.EdgeEffect = value ? createKiaiEdgeEffect() : default(EdgeEffect); + } + } + + public override Vector2 Size => new Vector2(base.Size.X, 128); + + private Container innerLayer; + private Container backingGlowContainer; + private Container innerCircleContainer; + private Box innerBackground; + private Triangles triangles; + + protected CirclePiece() + { + Container iconContainer; + + Children = new Framework.Graphics.Drawable[] + { + // 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[] + { + backingGlowContainer = new CircularContainer + { + Name = "Backing Glow", + + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + + RelativeSizeAxes = Axes.Both, + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + + Alpha = 0, + AlwaysPresent = true + } + } + }, + innerCircleContainer = new CircularContainer + { + Name = "Inner Circle", + + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + + RelativeSizeAxes = Axes.Both, + + Children = new Framework.Graphics.Drawable[] + { + innerBackground = new Box + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + + RelativeSizeAxes = Axes.Both, + }, + triangles = new Triangles + { + 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, + + 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, + } + } + }, + }; + + Framework.Graphics.Drawable icon = CreateIcon(); + + if (icon != null) + iconContainer.Add(icon); + } + + protected override void LoadComplete() + { + 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); + } + + protected override void Update() + { + innerLayer.Width = DrawWidth + DrawHeight; + } + + private EdgeEffect createKiaiEdgeEffect() + { + return new EdgeEffect + { + Type = EdgeEffectType.Glow, + Colour = AccentColour, + Radius = 50 + }; + } + + /// + /// Creates the icon that's shown in the middle of this object piece. + /// + /// The icon. + protected virtual Framework.Graphics.Drawable CreateIcon() => null; + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/DrumRollCirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/DrumRollCirclePiece.cs new file mode 100644 index 0000000000..aaeccdb321 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/DrumRollCirclePiece.cs @@ -0,0 +1,17 @@ +using osu.Framework.Allocation; +using osu.Game.Graphics; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// A circle piece which is used to visualise DrumRoll objects. + /// + public class DrumRollCirclePiece : CirclePiece + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.YellowDark; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/FinisherPiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/FinisherPiece.cs new file mode 100644 index 0000000000..6f40c9580e --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/FinisherPiece.cs @@ -0,0 +1,28 @@ +using OpenTK; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// A type of circle piece that encapsulates a circle piece to visualise it as a "finisher" hitobject. + /// + /// Finisher hitobjects are 1.5x larger, while maintaining the same length. + /// + /// + public class FinisherPiece : ScrollingCirclePiece + { + public FinisherPiece(ScrollingCirclePiece 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; + } + } +} diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitCirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitCirclePiece.cs new file mode 100644 index 0000000000..0bcad944fd --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/RimHitCirclePiece.cs @@ -0,0 +1,47 @@ +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 +{ + /// + /// A circle piece which is used to visualise RimHit objects. + /// + public class RimHitCirclePiece : CirclePiece + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.BlueDarker; + } + + protected override Framework.Graphics.Drawable CreateIcon() + { + return new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + + Size = new Vector2(61f), + + BorderThickness = 8, + BorderColour = Color4.White, + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + + Alpha = 0, + AlwaysPresent = true + } + } + }; + } + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/ScrollingCirclePiece.cs b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/ScrollingCirclePiece.cs new file mode 100644 index 0000000000..f355ffc176 --- /dev/null +++ b/osu.Game.Modes.Taiko/Objects/Drawable/Pieces/ScrollingCirclePiece.cs @@ -0,0 +1,16 @@ +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Modes.Taiko.Objects.Drawable.Pieces +{ + /// + /// A type of circle piece that will be scrolling the screen. + /// + /// A scrolling circle piece must always have a centre-left origin due to how scroll position is calculated. + /// + /// + public class ScrollingCirclePiece : Container + { + public override Anchor Origin => Anchor.CentreLeft; + } +} \ No newline at end of file diff --git a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj index e4c56621fb..ad04475f5b 100644 --- a/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj +++ b/osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj @@ -50,6 +50,13 @@ + + + + + + + @@ -81,9 +88,7 @@ osu.Game - - - +