mirror of
https://github.com/osukey/osukey.git
synced 2025-05-25 23:47:30 +09:00
Add slider ball animation support
This commit is contained in:
parent
539a27a557
commit
d0766fa1cd
@ -55,7 +55,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Child = new Container
|
Child = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
// TODO: support skin filename animation (sliderb0, sliderb1...)
|
|
||||||
Child = new SkinnableDrawable("Play/osu/sliderball", _ => new DefaultSliderBall()),
|
Child = new SkinnableDrawable("Play/osu/sliderball", _ => new DefaultSliderBall()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,9 +167,18 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
return action == OsuAction.LeftButton || action == OsuAction.RightButton;
|
return action == OsuAction.LeftButton || action == OsuAction.RightButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2? lastPosition;
|
||||||
|
|
||||||
public void UpdateProgress(double completionProgress)
|
public void UpdateProgress(double completionProgress)
|
||||||
{
|
{
|
||||||
Position = slider.CurvePositionAt(completionProgress);
|
var newPos = slider.CurvePositionAt(completionProgress);
|
||||||
|
|
||||||
|
var diff = lastPosition.HasValue ? lastPosition.Value - newPos : newPos - slider.CurvePositionAt(completionProgress + 0.01f);
|
||||||
|
|
||||||
|
Position = newPos;
|
||||||
|
Rotation = 90 + (float)(-Math.Atan2(diff.X, diff.Y) * 180 / Math.PI);
|
||||||
|
|
||||||
|
lastPosition = newPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FollowCircleContainer : Container
|
private class FollowCircleContainer : Container
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -92,8 +92,20 @@ namespace osu.Game.Skinning
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
case "Play/osu/sliderball":
|
case "Play/osu/sliderball":
|
||||||
if (GetTexture("sliderb") != null)
|
var sliderBallContent = getAnimation("sliderb", true, true, "");
|
||||||
return new LegacySliderBall();
|
|
||||||
|
if (sliderBallContent != null)
|
||||||
|
{
|
||||||
|
var size = sliderBallContent.Size;
|
||||||
|
|
||||||
|
sliderBallContent.RelativeSizeAxes = Axes.Both;
|
||||||
|
sliderBallContent.Size = Vector2.One;
|
||||||
|
|
||||||
|
return new LegacySliderBall(sliderBallContent)
|
||||||
|
{
|
||||||
|
Size = size
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -169,16 +181,6 @@ namespace osu.Game.Skinning
|
|||||||
return (texture = GetTexture(componentName)) == null ? null : new Sprite { Texture = texture };
|
return (texture = GetTexture(componentName)) == null ? null : new Sprite { Texture = texture };
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LegacySliderBall : Sprite
|
|
||||||
{
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(ISkinSource skin)
|
|
||||||
{
|
|
||||||
Texture = skin.GetTexture("sliderb");
|
|
||||||
Colour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Color4.White;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Texture GetTexture(string componentName)
|
public override Texture GetTexture(string componentName)
|
||||||
{
|
{
|
||||||
float ratio = 2;
|
float ratio = 2;
|
||||||
@ -333,6 +335,20 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LegacySliderBall : CompositeDrawable
|
||||||
|
{
|
||||||
|
public LegacySliderBall(Drawable content)
|
||||||
|
{
|
||||||
|
InternalChild = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(ISkinSource skin)
|
||||||
|
{
|
||||||
|
Colour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LegacyMainCirclePiece : CompositeDrawable
|
public class LegacyMainCirclePiece : CompositeDrawable
|
||||||
{
|
{
|
||||||
public LegacyMainCirclePiece()
|
public LegacyMainCirclePiece()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user