mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 17:53:21 +08:00
Add skin component for the legacy cursor trail
This commit is contained in:
parent
be2d4d0d02
commit
55afcc1e04
@ -8,6 +8,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
HitCircle,
|
||||
FollowPoint,
|
||||
Cursor,
|
||||
CursorTrail,
|
||||
SliderScorePoint,
|
||||
ApproachCircle,
|
||||
ReverseArrow,
|
||||
|
24
osu.Game.Rulesets.Osu/Skinning/LegacyCursorTrail.cs
Normal file
24
osu.Game.Rulesets.Osu/Skinning/LegacyCursorTrail.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning
|
||||
{
|
||||
public class LegacyCursorTrail : CursorTrail
|
||||
{
|
||||
public LegacyCursorTrail()
|
||||
{
|
||||
Blending = BlendingParameters.Additive;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin)
|
||||
{
|
||||
Texture = skin.GetTexture("cursortrail");
|
||||
}
|
||||
}
|
||||
}
|
@ -78,6 +78,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
||||
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.CursorTrail:
|
||||
if (source.GetTexture("cursortrail") != null)
|
||||
return new LegacyCursorTrail();
|
||||
|
||||
return null;
|
||||
|
||||
case OsuSkinComponents.HitCircleText:
|
||||
var font = GetConfig<OsuSkinConfiguration, string>(OsuSkinConfiguration.HitCircleFont)?.Value ?? "default";
|
||||
var overlap = GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.HitCircleOverlap)?.Value ?? 0;
|
||||
|
@ -20,14 +20,28 @@ using osuTK.Graphics.ES30;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
internal class CursorTrail : Drawable, IRequireHighFrequencyMousePosition
|
||||
public class CursorTrail : Drawable, IRequireHighFrequencyMousePosition
|
||||
{
|
||||
private const int max_sprites = 2048;
|
||||
|
||||
private Texture texture = Texture.WhitePixel;
|
||||
|
||||
public Texture Texture
|
||||
{
|
||||
get => texture;
|
||||
set
|
||||
{
|
||||
if (texture == value)
|
||||
return;
|
||||
|
||||
texture = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
||||
private int currentIndex;
|
||||
private IShader shader;
|
||||
private Texture texture;
|
||||
private double timeOffset;
|
||||
private float time;
|
||||
|
||||
@ -47,11 +61,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders, TextureStore textures)
|
||||
private void load(ShaderManager shaders)
|
||||
{
|
||||
shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
texture = textures.Get(@"Cursor/cursortrail");
|
||||
Scale = new Vector2(1 / texture.ScaleAdjust);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -6,9 +6,12 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Osu.Configuration;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
@ -22,17 +25,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
private readonly Bindable<bool> showTrail = new Bindable<bool>(true);
|
||||
|
||||
private readonly CursorTrail cursorTrail;
|
||||
private readonly Drawable cursorTrail;
|
||||
|
||||
public OsuCursorContainer()
|
||||
{
|
||||
InternalChild = fadeContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursorTrail = new CursorTrail { Depth = 1 }
|
||||
}
|
||||
Child = cursorTrail = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.CursorTrail), _ => new DefaultCursorTrail())
|
||||
};
|
||||
}
|
||||
|
||||
@ -98,5 +98,15 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint);
|
||||
ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private class DefaultCursorTrail : CursorTrail
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Texture = textures.Get(@"Cursor/cursortrail");
|
||||
Scale = new Vector2(1 / Texture.ScaleAdjust);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user