diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursorSizeChange.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursorSizeChange.cs new file mode 100644 index 0000000000..c94e575032 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursorSizeChange.cs @@ -0,0 +1,52 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Testing; +using osu.Game.Configuration; +using osu.Game.Skinning; +using osu.Game.Tests.Visual; +using osuTK.Input; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public partial class TestSceneGameplayCursorSizeChange : PlayerTestScene + { + private const float initial_cursor_size = 1f; + protected override Ruleset CreatePlayerRuleset() => new OsuRuleset(); + + [Resolved] + private SkinManager? skins { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + if (skins != null) skins.CurrentSkinInfo.Value = skins.DefaultClassicSkin.SkinInfo; + } + + [SetUpSteps] + public override void SetUpSteps() + { + base.SetUpSteps(); + + AddStep("Set gameplay cursor size: 1", () => LocalConfig.SetValue(OsuSetting.GameplayCursorSize, initial_cursor_size)); + AddStep("resume player", () => Player.GameplayClockContainer.Start()); + AddUntilStep("clock running", () => Player.GameplayClockContainer.IsRunning); + } + + [Test] + public void TestPausedChangeCursorSize() + { + AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre)); + AddStep("move cursor to top left", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft)); + AddStep("move cursor to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre)); + AddStep("move cursor to top right", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopRight)); + AddStep("press escape", () => InputManager.Key(Key.Escape)); + + AddSliderStep("cursor size", 0.1f, 2f, 1f, v => LocalConfig.SetValue(OsuSetting.GameplayCursorSize, v)); + } + + protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(true, false); + } +} diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 1c2d69fa00..fc5ad2d955 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -49,6 +49,18 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor /// protected bool AllowPartRotation { get; set; } + private Vector2 cursorScale; + + public Vector2 CursorScale + { + get => cursorScale; + set + { + cursorScale = value; + Invalidate(Invalidation.DrawNode); + } + } + /// /// The trail part texture origin. /// @@ -233,6 +245,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private float time; private float fadeExponent; private float angle; + private Vector2 cursorScale; private readonly TrailPart[] parts = new TrailPart[max_sprites]; private Vector2 originPosition; @@ -253,6 +266,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor time = Source.time; fadeExponent = Source.FadeExponent; angle = Source.AllowPartRotation ? float.DegreesToRadians(Source.PartRotation) : 0; + cursorScale = Source.cursorScale; originPosition = Vector2.Zero; @@ -307,7 +321,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor vertexBatch.Add(new TexturedTrailVertex { Position = rotateAround( - new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y), + new Vector2( + part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X * cursorScale.X, + part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y * cursorScale.Y), part.Position, sin, cos), TexturePosition = textureRect.BottomLeft, TextureRect = new Vector4(0, 0, 1, 1), @@ -318,8 +334,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor vertexBatch.Add(new TexturedTrailVertex { Position = rotateAround( - new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X, - part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y), part.Position, sin, cos), + new Vector2( + part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X * cursorScale.X, + part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y * cursorScale.Y), + part.Position, sin, cos), TexturePosition = textureRect.BottomRight, TextureRect = new Vector4(0, 0, 1, 1), Colour = DrawColourInfo.Colour.BottomRight.Linear, @@ -329,7 +347,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor vertexBatch.Add(new TexturedTrailVertex { Position = rotateAround( - new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y), + new Vector2( + part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X * cursorScale.X, + part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y * cursorScale.Y), part.Position, sin, cos), TexturePosition = textureRect.TopRight, TextureRect = new Vector4(0, 0, 1, 1), @@ -340,7 +360,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor vertexBatch.Add(new TexturedTrailVertex { Position = rotateAround( - new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y), + new Vector2( + part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X * cursorScale.X, + part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y * cursorScale.Y), part.Position, sin, cos), TexturePosition = textureRect.TopLeft, TextureRect = new Vector4(0, 0, 1, 1), diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs index 974d99d7c8..e04382d194 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs @@ -64,8 +64,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor var newScale = new Vector2(e.NewValue); rippleVisualiser.CursorScale = newScale; - cursorTrail.Scale = newScale; + updateTrailScale(); }, true); + cursorTrail.OnSkinChanged += updateTrailScale; + } + + private void updateTrailScale() + { + if (cursorTrail.Drawable is CursorTrail trail) trail.CursorScale = new Vector2(ActiveCursor.CursorScale.Value); } private int downCount;