1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 10:32:55 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyDrumRoll.cs

99 lines
2.9 KiB
C#
Raw Normal View History

2020-04-15 16:50:57 +08: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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
2020-04-15 16:50:57 +08:00
using osu.Framework.Graphics.Sprites;
2022-08-02 18:50:57 +08:00
using osu.Framework.Graphics.Textures;
2020-04-15 16:50:57 +08:00
using osu.Game.Graphics;
using osu.Game.Skinning;
using osuTK.Graphics;
2020-12-07 11:30:25 +08:00
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
2020-04-15 16:50:57 +08:00
{
2022-11-24 13:32:20 +08:00
public partial class LegacyDrumRoll : CompositeDrawable, IHasAccentColour
2020-04-15 16:50:57 +08:00
{
public override Quad ScreenSpaceDrawQuad
{
get
{
var headDrawQuad = headCircle.ScreenSpaceDrawQuad;
var tailDrawQuad = tailCircle.ScreenSpaceDrawQuad;
return new Quad(headDrawQuad.TopLeft, tailDrawQuad.TopRight, headDrawQuad.BottomLeft, tailDrawQuad.BottomRight);
}
}
2022-11-02 16:07:19 +08:00
private LegacyCirclePiece headCircle = null!;
2020-04-15 16:50:57 +08:00
2022-11-02 16:07:19 +08:00
private Sprite body = null!;
2020-04-15 16:50:57 +08:00
2022-11-02 16:07:19 +08:00
private Sprite tailCircle = null!;
2020-04-15 16:50:57 +08:00
public LegacyDrumRoll()
{
2020-04-15 17:44:12 +08:00
RelativeSizeAxes = Axes.Both;
2020-04-15 16:50:57 +08:00
}
[BackgroundDependencyLoader]
2020-04-15 17:44:12 +08:00
private void load(ISkinSource skin, OsuColour colours)
2020-04-15 16:50:57 +08:00
{
InternalChildren = new Drawable[]
{
tailCircle = new Sprite
2020-04-15 17:44:12 +08:00
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-end", WrapMode.ClampToEdge, WrapMode.ClampToEdge),
2020-04-15 17:44:12 +08:00
FillMode = FillMode.Fit,
},
body = new Sprite
2020-04-15 16:50:57 +08:00
{
RelativeSizeAxes = Axes.Both,
Texture = skin.GetTexture("taiko-roll-middle", WrapMode.ClampToEdge, WrapMode.ClampToEdge),
2020-04-15 17:44:12 +08:00
},
headCircle = new LegacyCirclePiece
{
RelativeSizeAxes = Axes.Y,
2020-04-15 16:50:57 +08:00
},
};
2020-04-15 17:44:12 +08:00
AccentColour = colours.YellowDark;
2020-04-15 16:50:57 +08: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 13:24:04 +08:00
var colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour);
headCircle.AccentColour = colour;
body.Colour = colour;
tailCircle.Colour = colour;
2020-04-15 16:50:57 +08:00
}
}
}