mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Major rsefinements to taiko drawable classes.
This commit is contained in:
@ -1,12 +1,10 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -15,26 +13,30 @@ namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
|
||||
/// <summary>
|
||||
/// A circle piece which is used uniformly through osu!taiko to visualise hitobjects.
|
||||
/// <para>
|
||||
/// 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.
|
||||
/// Note that this can actually be non-circle if the width is changed. See <see cref="ElongatedCirclePiece"/>
|
||||
/// for a usage example.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class CirclePiece : Container, IHasAccentColour
|
||||
public class CirclePiece : TaikoPiece
|
||||
{
|
||||
public const float SYMBOL_SIZE = TaikoHitObject.CIRCLE_RADIUS * 2f * 0.45f;
|
||||
public const float SYMBOL_BORDER = 8;
|
||||
public const float SYMBOL_INNER_SIZE = SYMBOL_SIZE - 2 * SYMBOL_BORDER;
|
||||
|
||||
private Color4 accentColour;
|
||||
/// <summary>
|
||||
/// The amount to scale up the base circle to show it as a "strong" piece.
|
||||
/// </summary>
|
||||
private const float strong_scale = 1.5f;
|
||||
|
||||
/// <summary>
|
||||
/// The colour of the inner circle and outer glows.
|
||||
/// </summary>
|
||||
public Color4 AccentColour
|
||||
public override Color4 AccentColour
|
||||
{
|
||||
get { return accentColour; }
|
||||
get { return base.AccentColour; }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
base.AccentColour = value;
|
||||
|
||||
background.Colour = AccentColour;
|
||||
|
||||
@ -42,107 +44,92 @@ namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
private bool kiaiMode;
|
||||
/// <summary>
|
||||
/// Whether Kiai mode effects are enabled for this circle piece.
|
||||
/// </summary>
|
||||
public bool KiaiMode
|
||||
public override bool KiaiMode
|
||||
{
|
||||
get { return kiaiMode; }
|
||||
get { return base.KiaiMode; }
|
||||
set
|
||||
{
|
||||
kiaiMode = value;
|
||||
base.KiaiMode = value;
|
||||
|
||||
resetEdgeEffects();
|
||||
}
|
||||
}
|
||||
|
||||
public override Anchor Origin
|
||||
{
|
||||
get { return Anchor.CentreLeft; }
|
||||
set { throw new InvalidOperationException($"{nameof(CirclePiece)} must always use CentreLeft origin."); }
|
||||
}
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected override Container<Drawable> Content => SymbolContainer;
|
||||
protected readonly Container SymbolContainer;
|
||||
private readonly Container content;
|
||||
|
||||
private readonly Container background;
|
||||
private readonly Container innerLayer;
|
||||
|
||||
public CirclePiece()
|
||||
public CirclePiece(bool isStrong = false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = TaikoHitObject.CIRCLE_RADIUS * 2;
|
||||
|
||||
// The "inner layer" is the body of the CirclePiece that overshoots it by Height/2 px on both sides
|
||||
AddInternal(innerLayer = new Container
|
||||
AddInternal(new Drawable[]
|
||||
{
|
||||
Name = "Inner Layer",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
background = new CircularContainer
|
||||
{
|
||||
background = new CircularContainer
|
||||
Name = "Background",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Name = "Background",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
new Box
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Triangles
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourLight = Color4.White,
|
||||
ColourDark = Color4.White.Darken(0.1f)
|
||||
}
|
||||
}
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Name = "Ring",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BorderThickness = 8,
|
||||
BorderColour = Color4.White,
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Triangles
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourLight = Color4.White,
|
||||
ColourDark = Color4.White.Darken(0.1f)
|
||||
}
|
||||
},
|
||||
SymbolContainer = new Container
|
||||
{
|
||||
Name = "Symbol",
|
||||
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
|
||||
}
|
||||
}
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Name = "Symbol",
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
// Add the overshoot to compensate for corner radius
|
||||
innerLayer.Width = DrawWidth + DrawHeight;
|
||||
if (isStrong)
|
||||
{
|
||||
Size *= strong_scale;
|
||||
|
||||
//for symbols etc.
|
||||
Content.Scale *= strong_scale;
|
||||
}
|
||||
}
|
||||
|
||||
private void resetEdgeEffects()
|
||||
|
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Modes.Taiko.UI;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
|
||||
{
|
||||
public class ElongatedCirclePiece : CirclePiece
|
||||
{
|
||||
/// <summary>
|
||||
/// As we are being used to define the absolute size of hits, we need to be given a relative reference of our containing <see cref="TaikoPlayfield"/>.
|
||||
/// </summary>
|
||||
public Func<float> PlayfieldLengthReference;
|
||||
|
||||
/// <summary>
|
||||
/// The length of this piece as a multiple of the value returned by <see cref="PlayfieldLengthReference"/>
|
||||
/// </summary>
|
||||
public float Length;
|
||||
|
||||
public ElongatedCirclePiece(bool isStrong = false) : base(isStrong)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
var contentPadding = DrawHeight / 2 * Content.Scale.X;
|
||||
|
||||
Content.Padding = new MarginPadding
|
||||
{
|
||||
Left = contentPadding,
|
||||
Right = contentPadding,
|
||||
};
|
||||
|
||||
Width = (PlayfieldLengthReference?.Invoke() ?? 0) * Length + DrawHeight;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +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.Drawables.Pieces
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of circle piece which is drawn at a higher scale to represent a "strong" piece.
|
||||
/// </summary>
|
||||
public class StrongCirclePiece : CirclePiece
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount to scale up the base circle to show it as a "strong" piece.
|
||||
/// </summary>
|
||||
private const float strong_scale = 1.5f;
|
||||
|
||||
public StrongCirclePiece()
|
||||
{
|
||||
SymbolContainer.Scale = new Vector2(strong_scale);
|
||||
}
|
||||
|
||||
public override Vector2 Size => new Vector2(base.Size.X, base.Size.Y * strong_scale);
|
||||
}
|
||||
}
|
45
osu.Game.Modes.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
Normal file
45
osu.Game.Modes.Taiko/Objects/Drawables/Pieces/TaikoPiece.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// 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.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
|
||||
{
|
||||
public class TaikoPiece : Container, IHasAccentColour
|
||||
{
|
||||
private Color4 accentColour;
|
||||
/// <summary>
|
||||
/// The colour of the inner circle and outer glows.
|
||||
/// </summary>
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour; }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool kiaiMode;
|
||||
/// <summary>
|
||||
/// Whether Kiai mode effects are enabled for this circle piece.
|
||||
/// </summary>
|
||||
public virtual bool KiaiMode
|
||||
{
|
||||
get { return kiaiMode; }
|
||||
set
|
||||
{
|
||||
kiaiMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TaikoPiece()
|
||||
{
|
||||
//just a default
|
||||
Size = new Vector2(TaikoHitObject.CIRCLE_RADIUS * 2);
|
||||
}
|
||||
}
|
||||
}
|
60
osu.Game.Modes.Taiko/Objects/Drawables/Pieces/TickPiece.cs
Normal file
60
osu.Game.Modes.Taiko/Objects/Drawables/Pieces/TickPiece.cs
Normal file
@ -0,0 +1,60 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects.Drawables.Pieces
|
||||
{
|
||||
public class TickPiece : TaikoPiece
|
||||
{
|
||||
/// <summary>
|
||||
/// Any tick that is not the first for a drumroll is not filled, but is instead displayed
|
||||
/// as a hollow circle. This is what controls the border width of that circle.
|
||||
/// </summary>
|
||||
private const float tick_border_width = TaikoHitObject.CIRCLE_RADIUS / 2 / 4;
|
||||
|
||||
/// <summary>
|
||||
/// The size of a tick.
|
||||
/// </summary>
|
||||
private const float tick_size = TaikoHitObject.CIRCLE_RADIUS / 2;
|
||||
|
||||
private bool filled;
|
||||
public bool Filled
|
||||
{
|
||||
get { return filled; }
|
||||
set
|
||||
{
|
||||
filled = value;
|
||||
fillBox.Alpha = filled ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Box fillBox;
|
||||
|
||||
public TickPiece()
|
||||
{
|
||||
Size = new Vector2(tick_size);
|
||||
|
||||
Add(new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = tick_border_width,
|
||||
BorderColour = Color4.White,
|
||||
Children = new[]
|
||||
{
|
||||
fillBox = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user