Add initial support for spinner disc skinning

This commit is contained in:
Dean Herbert
2020-07-29 16:25:10 +09:00
parent c3c60334ec
commit d01d1ce3f1
13 changed files with 31 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -175,8 +175,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Background.AccentColour = normalColour; Background.AccentColour = normalColour;
Ticks.AccentColour = normalColour; Ticks.AccentColour = normalColour;
Disc.AccentColour = fillColour; Disc.AccentColour = fillColour;
circle.Colour = colours.BlueDark; circle.Colour = colours.BlueDark;
glow.Colour = colours.BlueDark; glow.Colour = colours.BlueDark;

View File

@ -9,6 +9,7 @@ using osu.Game.Graphics;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
@ -16,13 +17,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{ {
private readonly Spinner spinner; private readonly Spinner spinner;
private Color4 accentColour;
public Color4 AccentColour public Color4 AccentColour
{ {
get => background.AccentColour; get => accentColour;
set => background.AccentColour = value; set
{
accentColour = value;
if (background.Drawable is IHasAccentColour accent)
accent.AccentColour = value;
}
} }
private readonly SpinnerBackground background; private readonly SkinnableDrawable background;
private const float idle_alpha = 0.2f; private const float idle_alpha = 0.2f;
private const float tracking_alpha = 0.4f; private const float tracking_alpha = 0.4f;
@ -37,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
Children = new Drawable[] Children = new Drawable[]
{ {
background = new SpinnerBackground { Alpha = idle_alpha }, background = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerDisc), _ => new SpinnerBackground { Alpha = idle_alpha }),
}; };
} }
@ -54,7 +62,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
tracking = value; tracking = value;
background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100); // todo: new default only
background.Drawable.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
} }
} }
@ -121,11 +130,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
if (Complete && updateCompleteTick()) if (Complete && updateCompleteTick())
{ {
background.FinishTransforms(false, nameof(Alpha)); // todo: new default only
background background.Drawable.FinishTransforms(false, nameof(Alpha));
.FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo) background.Drawable
.Then() .FadeTo(tracking_alpha + 0.2f, 60, Easing.OutExpo)
.FadeTo(tracking_alpha, 250, Easing.OutQuint); .Then()
.FadeTo(tracking_alpha, 250, Easing.OutQuint);
} }
Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1)); Rotation = (float)Interpolation.Lerp(Rotation, currentRotation / 2, Math.Clamp(Math.Abs(Time.Elapsed) / 40, 0, 1));

View File

@ -17,5 +17,6 @@ namespace osu.Game.Rulesets.Osu
SliderFollowCircle, SliderFollowCircle,
SliderBall, SliderBall,
SliderBody, SliderBody,
SpinnerDisc
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -102,6 +103,14 @@ namespace osu.Game.Rulesets.Osu.Skinning
Scale = new Vector2(0.8f), Scale = new Vector2(0.8f),
Spacing = new Vector2(-overlap, 0) Spacing = new Vector2(-overlap, 0)
}; };
case OsuSkinComponents.SpinnerDisc:
if (Source.GetTexture("spinner-background") != null)
return new Sprite { Texture = Source.GetTexture("spinner-circle") };
else if (Source.GetTexture("spinner-top") != null)
return new Sprite { Texture = Source.GetTexture("spinner-top") };
return null;
} }
return null; return null;