mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Apply velocity into legacy slider ball animation rate
This commit is contained in:
parent
3cdcdbaf52
commit
ac8c2a173b
@ -1,8 +1,10 @@
|
|||||||
// 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 osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -15,31 +17,41 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
{
|
{
|
||||||
public partial class LegacySliderBall : CompositeDrawable
|
public partial class LegacySliderBall : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly Drawable animationContent;
|
|
||||||
|
|
||||||
private readonly ISkin skin;
|
private readonly ISkin skin;
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private DrawableHitObject? parentObject { get; set; }
|
private DrawableHitObject? parentObject { get; set; }
|
||||||
|
|
||||||
public Color4 BallColour => animationContent.Colour;
|
|
||||||
|
|
||||||
private Sprite layerNd = null!;
|
private Sprite layerNd = null!;
|
||||||
|
private Drawable ball = null!;
|
||||||
private Sprite layerSpec = null!;
|
private Sprite layerSpec = null!;
|
||||||
|
|
||||||
public LegacySliderBall(Drawable animationContent, ISkin skin)
|
public Color4 BallColour => ball.Colour;
|
||||||
|
|
||||||
|
public LegacySliderBall(ISkin skin)
|
||||||
{
|
{
|
||||||
this.animationContent = animationContent;
|
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(DrawableHitObject drawableHitObject)
|
||||||
{
|
{
|
||||||
var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
|
var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
|
||||||
|
|
||||||
|
DrawableSlider drawableSlider = (DrawableSlider)drawableHitObject;
|
||||||
|
|
||||||
|
// stable apparently calculates slider velocity in units of seconds rather than milliseconds.
|
||||||
|
double stableSliderVelocity = drawableSlider.HitObject.Velocity * 1000;
|
||||||
|
|
||||||
|
double ballAnimationRate = Math.Max(
|
||||||
|
150 / stableSliderVelocity * LegacySkinExtensions.SIXTY_FRAME_TIME,
|
||||||
|
LegacySkinExtensions.SIXTY_FRAME_TIME);
|
||||||
|
|
||||||
|
ball = skin.GetAnimation("sliderb", true, true, animationSeparator: "", frameLength: ballAnimationRate,
|
||||||
|
maxSize: OsuLegacySkinTransformer.MAX_FOLLOW_CIRCLE_AREA_SIZE).AsNonNull();
|
||||||
|
|
||||||
InternalChildren = new[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
layerNd = new Sprite
|
layerNd = new Sprite
|
||||||
@ -49,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
Texture = skin.GetTexture("sliderb-nd")?.WithMaximumSize(OsuLegacySkinTransformer.MAX_FOLLOW_CIRCLE_AREA_SIZE),
|
Texture = skin.GetTexture("sliderb-nd")?.WithMaximumSize(OsuLegacySkinTransformer.MAX_FOLLOW_CIRCLE_AREA_SIZE),
|
||||||
Colour = new Color4(5, 5, 5, 255),
|
Colour = new Color4(5, 5, 5, 255),
|
||||||
},
|
},
|
||||||
LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
|
LegacyColourCompatibility.ApplyWithDoubledAlpha(ball.With(d =>
|
||||||
{
|
{
|
||||||
d.Anchor = Anchor.Centre;
|
d.Anchor = Anchor.Centre;
|
||||||
d.Origin = Anchor.Centre;
|
d.Origin = Anchor.Centre;
|
||||||
@ -78,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
if (skin.GetConfig<SkinConfiguration.LegacySetting, bool>(SkinConfiguration.LegacySetting.AllowSliderBallTint)?.Value == true)
|
if (skin.GetConfig<SkinConfiguration.LegacySetting, bool>(SkinConfiguration.LegacySetting.AllowSliderBallTint)?.Value == true)
|
||||||
{
|
{
|
||||||
accentColour.BindTo(parentObject.AccentColour);
|
accentColour.BindTo(parentObject.AccentColour);
|
||||||
accentColour.BindValueChanged(a => animationContent.Colour = a.NewValue, true);
|
accentColour.BindValueChanged(a => ball.Colour = a.NewValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
case OsuSkinComponents.SliderBall:
|
case OsuSkinComponents.SliderBall:
|
||||||
var sliderBallContent = this.GetAnimation("sliderb", true, true, animationSeparator: "", maxSize: MAX_FOLLOW_CIRCLE_AREA_SIZE);
|
if (GetTexture("sliderb") != null || GetTexture("sliderb0") != null)
|
||||||
|
return new LegacySliderBall(this);
|
||||||
// todo: slider ball has a custom frame delay based on velocity
|
|
||||||
// Math.Max((150 / Velocity) * GameBase.SIXTY_FRAME_TIME, GameBase.SIXTY_FRAME_TIME);
|
|
||||||
|
|
||||||
if (sliderBallContent != null)
|
|
||||||
return new LegacySliderBall(sliderBallContent, this);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -200,7 +200,11 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const double default_frame_time = 1000 / 60d;
|
/// <summary>
|
||||||
|
/// The frame length of each frame at a 60 FPS rate.
|
||||||
|
/// Default frame rate for legacy skin animations.
|
||||||
|
/// </summary>
|
||||||
|
public const double SIXTY_FRAME_TIME = 1000 / 60d;
|
||||||
|
|
||||||
private static double getFrameLength(ISkin source, bool applyConfigFrameRate, Texture[] textures)
|
private static double getFrameLength(ISkin source, bool applyConfigFrameRate, Texture[] textures)
|
||||||
{
|
{
|
||||||
@ -214,7 +218,7 @@ namespace osu.Game.Skinning
|
|||||||
return 1000f / textures.Length;
|
return 1000f / textures.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_frame_time;
|
return SIXTY_FRAME_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user