2020-04-15 08:50:57 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2024-11-05 12:00:00 +00:00
|
|
|
using System;
|
2020-04-15 08:50:57 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-08-18 08:05:09 +00:00
|
|
|
using osu.Framework.Graphics.Primitives;
|
2020-04-15 08:50:57 +00:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-08-02 10:50:57 +00:00
|
|
|
using osu.Framework.Graphics.Textures;
|
2020-04-15 08:50:57 +00:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Skinning;
|
2024-11-05 12:00:00 +00:00
|
|
|
using osuTK;
|
2020-04-15 08:50:57 +00:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-07 03:30:25 +00:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
2020-04-15 08:50:57 +00:00
|
|
|
{
|
2020-04-15 09:44:12 +00:00
|
|
|
public partial class LegacyDrumRoll : CompositeDrawable, IHasAccentColour
|
2020-04-15 08:50:57 +00:00
|
|
|
{
|
2022-08-18 08:05:09 +00:00
|
|
|
public override Quad ScreenSpaceDrawQuad
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2024-11-05 12:00:00 +00:00
|
|
|
// the reason why this calculation is so involved is that the head & tail sprites have different sizes/radii.
|
|
|
|
// therefore naively taking the SSDQs of them and making a quad out of them results in a trapezoid shape and not a box.
|
|
|
|
var headCentre = headCircle.ScreenSpaceDrawQuad.Centre;
|
|
|
|
var tailCentre = (tailCircle.ScreenSpaceDrawQuad.TopLeft + tailCircle.ScreenSpaceDrawQuad.BottomLeft) / 2;
|
2022-08-18 08:05:09 +00:00
|
|
|
|
2024-11-05 12:00:00 +00:00
|
|
|
float headRadius = headCircle.ScreenSpaceDrawQuad.Height / 2;
|
|
|
|
float tailRadius = tailCircle.ScreenSpaceDrawQuad.Height / 2;
|
|
|
|
float radius = Math.Max(headRadius, tailRadius);
|
|
|
|
|
|
|
|
var rectangle = new RectangleF(headCentre.X, headCentre.Y, tailCentre.X - headCentre.X, 0).Inflate(radius);
|
|
|
|
return new Quad(rectangle.TopLeft, rectangle.TopRight, rectangle.BottomLeft, rectangle.BottomRight);
|
2022-08-18 08:05:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-05 12:00:00 +00:00
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => ScreenSpaceDrawQuad.Contains(screenSpacePos);
|
|
|
|
|
2022-11-02 08:07:19 +00:00
|
|
|
private LegacyCirclePiece headCircle = null!;
|
2020-04-15 08:50:57 +00:00
|
|
|
|
2022-11-02 08:07:19 +00:00
|
|
|
private Sprite body = null!;
|
2020-04-15 08:50:57 +00:00
|
|
|
|
2022-11-02 08:07:19 +00:00
|
|
|
private Sprite tailCircle = null!;
|
2020-04-15 08:50:57 +00:00
|
|
|
|
|
|
|
public LegacyDrumRoll()
|
|
|
|
{
|
2020-04-15 09:44:12 +00:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
2020-04-15 08:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-04-15 09:44:12 +00:00
|
|
|
private void load(ISkinSource skin, OsuColour colours)
|
2020-04-15 08:50:57 +00:00
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2022-08-18 08:05:09 +00:00
|
|
|
tailCircle = new Sprite
|
2020-04-15 09:44:12 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-17 07:55:01 +00:00
|
|
|
Texture = skin.GetTexture("taiko-roll-end", WrapMode.ClampToEdge, WrapMode.ClampToEdge),
|
2020-04-15 09:44:12 +00:00
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
},
|
|
|
|
body = new Sprite
|
2020-04-15 08:50:57 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-07-17 07:55:01 +00:00
|
|
|
Texture = skin.GetTexture("taiko-roll-middle", WrapMode.ClampToEdge, WrapMode.ClampToEdge),
|
2020-04-15 09:44:12 +00:00
|
|
|
},
|
|
|
|
headCircle = new LegacyCirclePiece
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2020-04-15 08:50:57 +00:00
|
|
|
},
|
|
|
|
};
|
2020-04-15 09:44:12 +00:00
|
|
|
|
|
|
|
AccentColour = colours.YellowDark;
|
2020-04-15 08:50:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
updateAccentColour();
|
|
|
|
}
|
|
|
|
|
|
|
|
private Color4 accentColour;
|
|
|
|
|
|
|
|
public Color4 AccentColour
|
|
|
|
{
|
|
|
|
get => accentColour;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == accentColour)
|
|
|
|
return;
|
|
|
|
|
|
|
|
accentColour = value;
|
|
|
|
if (IsLoaded)
|
|
|
|
updateAccentColour();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateAccentColour()
|
|
|
|
{
|
2020-08-26 05:24:04 +00:00
|
|
|
var colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
|
|
|
|
|
|
|
|
headCircle.AccentColour = colour;
|
|
|
|
body.Colour = colour;
|
2022-08-18 08:05:09 +00:00
|
|
|
tailCircle.Colour = colour;
|
2020-04-15 08:50:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|