From 090601b485bdec297ef3d723f7254b54ca335d3b Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Nov 2023 18:12:39 -0700 Subject: [PATCH 01/22] Apply peppy's upright key counter attempt diff Co-Authored-By: Dean Herbert --- .../Visual/Gameplay/TestSceneKeyCounter.cs | 20 ++++++++- osu.Game/Screens/Play/ArgonKeyCounter.cs | 45 ++++++++++++------- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs index 5a66a5c7a6..7e66106264 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs @@ -43,7 +43,25 @@ namespace osu.Game.Tests.Visual.Gameplay { Origin = Anchor.Centre, Anchor = Anchor.Centre, - } + }, + new ArgonKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = -90, + }, + new ArgonKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = 90, + }, + new ArgonKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Scale = new Vector2(1, -1) + }, } } }; diff --git a/osu.Game/Screens/Play/ArgonKeyCounter.cs b/osu.Game/Screens/Play/ArgonKeyCounter.cs index 2d725898d8..ebf53abb30 100644 --- a/osu.Game/Screens/Play/ArgonKeyCounter.cs +++ b/osu.Game/Screens/Play/ArgonKeyCounter.cs @@ -3,8 +3,10 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Play.HUD; using osuTK; @@ -40,26 +42,39 @@ namespace osu.Game.Screens.Play { inputIndicator = new Circle { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X, Height = line_height * scale_factor, Alpha = 0.5f }, - keyNameText = new OsuSpriteText + new Container { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Position = new Vector2(0, -13) * scale_factor, - Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold), - Colour = colours.Blue0, - Text = Trigger.Name - }, - countText = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold), + RelativeSizeAxes = Axes.X, + Height = 40, + Children = new Drawable[] + { + new UprightAspectMaintainingContainer + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + keyNameText = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold), + Colour = colours.Blue0, + Text = Trigger.Name + }, + countText = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Position = new Vector2(0, 13) * scale_factor, + Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold), + }, + } + } + } }, }; From b3dfe19472a2a6a7f7d2b2d34570036df8f6b49c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Nov 2023 18:17:25 -0700 Subject: [PATCH 02/22] Fix `UprightAspectMaintainingContainer` not being centred --- osu.Game/Screens/Play/ArgonKeyCounter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/ArgonKeyCounter.cs b/osu.Game/Screens/Play/ArgonKeyCounter.cs index ebf53abb30..6ff60c68b7 100644 --- a/osu.Game/Screens/Play/ArgonKeyCounter.cs +++ b/osu.Game/Screens/Play/ArgonKeyCounter.cs @@ -55,6 +55,8 @@ namespace osu.Game.Screens.Play new UprightAspectMaintainingContainer { RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, Children = new Drawable[] { keyNameText = new OsuSpriteText From 16731ff85ff90b8c9e20b40b0358bc2c128782c2 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Nov 2023 18:20:15 -0700 Subject: [PATCH 03/22] Fix text positioning --- osu.Game/Screens/Play/ArgonKeyCounter.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/ArgonKeyCounter.cs b/osu.Game/Screens/Play/ArgonKeyCounter.cs index 6ff60c68b7..bb5fe0daf2 100644 --- a/osu.Game/Screens/Play/ArgonKeyCounter.cs +++ b/osu.Game/Screens/Play/ArgonKeyCounter.cs @@ -9,7 +9,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Play.HUD; -using osuTK; namespace osu.Game.Screens.Play { @@ -27,6 +26,8 @@ namespace osu.Game.Screens.Play // Make things look bigger without using Scale private const float scale_factor = 1.5f; + private const float indicator_press_offset = 4; + [Resolved] private OsuColour colours { get; set; } = null!; @@ -48,8 +49,8 @@ namespace osu.Game.Screens.Play }, new Container { - RelativeSizeAxes = Axes.X, - Height = 40, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = line_height * scale_factor + indicator_press_offset }, Children = new Drawable[] { new UprightAspectMaintainingContainer @@ -69,9 +70,8 @@ namespace osu.Game.Screens.Play }, countText = new OsuSpriteText { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Position = new Vector2(0, 13) * scale_factor, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold), }, } @@ -104,7 +104,7 @@ namespace osu.Game.Screens.Play .FadeIn(10, Easing.OutQuint) .MoveToY(0) .Then() - .MoveToY(4, 60, Easing.OutQuint); + .MoveToY(indicator_press_offset, 60, Easing.OutQuint); } protected override void Deactivate(bool forwardPlayback = true) From e3b3ce6c84102e34778c4fd25bb39e366dc0977f Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Nov 2023 18:44:56 -0700 Subject: [PATCH 04/22] Fix test overflowing on widescreen + add default (triangles) key counter testing --- .../Visual/Gameplay/TestSceneKeyCounter.cs | 49 +++++++++++++++---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs index 7e66106264..03302bae6a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs @@ -31,30 +31,24 @@ namespace osu.Game.Tests.Visual.Gameplay Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, - Spacing = new Vector2(72.7f), - Children = new KeyCounterDisplay[] + Spacing = new Vector2(20), + Children = new Drawable[] { new DefaultKeyCounterDisplay { Origin = Anchor.Centre, Anchor = Anchor.Centre, }, - new ArgonKeyCounterDisplay + new DefaultKeyCounterDisplay { Origin = Anchor.Centre, Anchor = Anchor.Centre, + Scale = new Vector2(1, -1) }, new ArgonKeyCounterDisplay { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Rotation = -90, - }, - new ArgonKeyCounterDisplay - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Rotation = 90, }, new ArgonKeyCounterDisplay { @@ -62,6 +56,41 @@ namespace osu.Game.Tests.Visual.Gameplay Anchor = Anchor.Centre, Scale = new Vector2(1, -1) }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Spacing = new Vector2(20), + Children = new Drawable[] + { + new DefaultKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = -90, + }, + new DefaultKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = 90, + }, + new ArgonKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = -90, + }, + new ArgonKeyCounterDisplay + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Rotation = 90, + }, + } + }, } } }; From 3f8baf913b46b884d9cbb5530721d58913403b5a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 Nov 2023 19:46:09 -0700 Subject: [PATCH 05/22] Add 100 and 1000 key press step to test overflow --- osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs index 03302bae6a..2d2b6c3bed 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneKeyCounter.cs @@ -124,8 +124,15 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Disable counting", () => controller.IsCounting.Value = false); addPressKeyStep(); AddAssert($"Check {testKey} count has not changed", () => testTrigger.ActivationCount.Value == 2); + AddStep("Enable counting", () => controller.IsCounting.Value = true); + addPressKeyStep(100); + addPressKeyStep(1000); - void addPressKeyStep() => AddStep($"Press {testKey} key", () => InputManager.Key(testKey)); + void addPressKeyStep(int repeat = 1) => AddStep($"Press {testKey} key {repeat} times", () => + { + for (int i = 0; i < repeat; i++) + InputManager.Key(testKey); + }); } } } From 48a75f6152705c5377b116f0dc2b6cf598036bb3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 5 Nov 2023 06:28:10 +0300 Subject: [PATCH 06/22] Fix resume cursor following gameplay cursor scale setting --- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 555610a3b6..bcfefe856d 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -5,7 +5,6 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -14,7 +13,6 @@ using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Screens.Play; -using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.UI @@ -25,7 +23,6 @@ namespace osu.Game.Rulesets.Osu.UI private OsuClickToResumeCursor clickToResumeCursor; private OsuCursorContainer localCursorContainer; - private IBindable localCursorScale; public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; @@ -49,13 +46,7 @@ namespace osu.Game.Rulesets.Osu.UI clickToResumeCursor.Appear(); if (localCursorContainer == null) - { Add(localCursorContainer = new OsuCursorContainer()); - - localCursorScale = new BindableFloat(); - localCursorScale.BindTo(localCursorContainer.CursorScale); - localCursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true); - } } protected override void PopOut() From 99405a2bbd38e999672d0fe89c83e56b845a0bdf Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 5 Nov 2023 06:28:34 +0300 Subject: [PATCH 07/22] Tidy up resume overlay test scene --- .../TestSceneResumeOverlay.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 0bb27cff0f..81dc64cda9 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -1,6 +1,7 @@ // 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.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -12,14 +13,15 @@ namespace osu.Game.Rulesets.Osu.Tests { public partial class TestSceneResumeOverlay : OsuManualInputManagerTestScene { - public TestSceneResumeOverlay() + private ManualOsuInputManager osuInputManager = null!; + private CursorContainer cursor = null!; + private ResumeOverlay resume = null!; + + private bool resumeFired; + + [SetUp] + public void SetUp() => Schedule(() => { - ManualOsuInputManager osuInputManager; - CursorContainer cursor; - ResumeOverlay resume; - - bool resumeFired = false; - Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) { Children = new Drawable[] @@ -32,8 +34,13 @@ namespace osu.Game.Rulesets.Osu.Tests } }; + resumeFired = false; resume.ResumeAction = () => resumeFired = true; + }); + [Test] + public void TestResume() + { AddStep("move mouse to center", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); AddStep("show", () => resume.Show()); From 9cb331641c39b9a1b54b192be3420e0db8b7ba68 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 5 Nov 2023 06:34:09 +0300 Subject: [PATCH 08/22] Rename container --- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index bcfefe856d..12506c83b9 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Osu.UI { public partial class OsuResumeOverlay : ResumeOverlay { - private Container cursorScaleContainer; + private Container resumeCursorContainer; private OsuClickToResumeCursor clickToResumeCursor; private OsuCursorContainer localCursorContainer; @@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.UI [BackgroundDependencyLoader] private void load() { - Add(cursorScaleContainer = new Container + Add(resumeCursorContainer = new Container { Child = clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume } }); @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.UI base.PopIn(); GameplayCursor.ActiveCursor.Hide(); - cursorScaleContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre); + resumeCursorContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre); clickToResumeCursor.Appear(); if (localCursorContainer == null) From e2b07628fb5719540ea3d1405de25a83b469b8da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 15:24:12 +0900 Subject: [PATCH 09/22] Add player name skin component 3 minute implementation. Addresses https://github.com/ppy/osu/discussions/25340. --- osu.Game/Skinning/Components/PlayerName.cs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 osu.Game/Skinning/Components/PlayerName.cs diff --git a/osu.Game/Skinning/Components/PlayerName.cs b/osu.Game/Skinning/Components/PlayerName.cs new file mode 100644 index 0000000000..34ace53d47 --- /dev/null +++ b/osu.Game/Skinning/Components/PlayerName.cs @@ -0,0 +1,40 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using JetBrains.Annotations; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens.Play; + +namespace osu.Game.Skinning.Components +{ + [UsedImplicitly] + public partial class PlayerName : FontAdjustableSkinComponent + { + private readonly OsuSpriteText text; + + public PlayerName() + { + AutoSizeAxes = Axes.Both; + + InternalChildren = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + } + }; + } + + [BackgroundDependencyLoader] + private void load(GameplayState gameplayState) + { + text.Text = gameplayState.Score.ScoreInfo.User.Username; + } + + protected override void SetFont(FontUsage font) => text.Font = font.With(size: 40); + } +} From 1f0b914251bc61d82bf9e3db207e75399a600806 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 16:18:33 +0900 Subject: [PATCH 10/22] Add skin editor dropdown items to reset rotation and scale --- .../Overlays/SkinEditor/SkinSelectionHandler.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs index c4e2c4c6bd..df73b15101 100644 --- a/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs +++ b/osu.Game/Overlays/SkinEditor/SkinSelectionHandler.cs @@ -198,12 +198,26 @@ namespace osu.Game.Overlays.SkinEditor Items = createAnchorItems((d, o) => ((Drawable)d).Origin == o, applyOrigins).ToArray() }; + yield return new EditorMenuItemSpacer(); + yield return new OsuMenuItem("Reset position", MenuItemType.Standard, () => { foreach (var blueprint in SelectedBlueprints) ((Drawable)blueprint.Item).Position = Vector2.Zero; }); + yield return new OsuMenuItem("Reset rotation", MenuItemType.Standard, () => + { + foreach (var blueprint in SelectedBlueprints) + ((Drawable)blueprint.Item).Rotation = 0; + }); + + yield return new OsuMenuItem("Reset scale", MenuItemType.Standard, () => + { + foreach (var blueprint in SelectedBlueprints) + ((Drawable)blueprint.Item).Scale = Vector2.One; + }); + yield return new EditorMenuItemSpacer(); yield return new OsuMenuItem("Bring to front", MenuItemType.Standard, () => skinEditor.BringSelectionToFront()); From 0915ac8891f1a5036a325d95b870d29c0daeb733 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 16:32:12 +0900 Subject: [PATCH 11/22] Use left aligned text for non-rotate key counter --- osu.Game/Screens/Play/ArgonKeyCounter.cs | 28 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/ArgonKeyCounter.cs b/osu.Game/Screens/Play/ArgonKeyCounter.cs index bb5fe0daf2..874fcde329 100644 --- a/osu.Game/Screens/Play/ArgonKeyCounter.cs +++ b/osu.Game/Screens/Play/ArgonKeyCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -18,6 +19,8 @@ namespace osu.Game.Screens.Play private OsuSpriteText keyNameText = null!; private OsuSpriteText countText = null!; + private UprightAspectMaintainingContainer uprightContainer = null!; + // These values were taken from Figma private const float line_height = 3; private const float name_font_size = 10; @@ -53,7 +56,7 @@ namespace osu.Game.Screens.Play Padding = new MarginPadding { Top = line_height * scale_factor + indicator_press_offset }, Children = new Drawable[] { - new UprightAspectMaintainingContainer + uprightContainer = new UprightAspectMaintainingContainer { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, @@ -62,16 +65,16 @@ namespace osu.Game.Screens.Play { keyNameText = new OsuSpriteText { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold), Colour = colours.Blue0, Text = Trigger.Name }, countText = new OsuSpriteText { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold), }, } @@ -93,6 +96,21 @@ namespace osu.Game.Screens.Play CountPresses.BindValueChanged(e => countText.Text = e.NewValue.ToString(@"#,0"), true); } + protected override void Update() + { + base.Update(); + + const float allowance = 6; + float absRotation = Math.Abs(uprightContainer.Rotation) % 180; + bool isRotated = absRotation > allowance && absRotation < (180 - allowance); + + keyNameText.Anchor = + keyNameText.Origin = isRotated ? Anchor.TopCentre : Anchor.TopLeft; + + countText.Anchor = + countText.Origin = isRotated ? Anchor.BottomCentre : Anchor.BottomLeft; + } + protected override void Activate(bool forwardPlayback = true) { base.Activate(forwardPlayback); From 69d6feb5a8b9137aaf74956945b897d7741fe3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Nov 2023 08:51:31 +0100 Subject: [PATCH 12/22] Add test coverage for player name skin component --- .../Archives/modified-argon-20231106.osk | Bin 0 -> 1397 bytes osu.Game.Tests/Skins/SkinDeserialisationTest.cs | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk diff --git a/osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk b/osu.Game.Tests/Resources/Archives/modified-argon-20231106.osk new file mode 100644 index 0000000000000000000000000000000000000000..70c4ff64d74b2efe0cd630812a41186f11f0467d GIT binary patch literal 1397 zcmWIWW@Zs#U|`^2`0JV$epO>m++rZ_AXtQfp*TA;PcJhsQ?+L!*C7W1*5ALomQQ8$ zRN?Tl(ze##D%fqh-IMQq+0!D$AGu<6llCVZ$xCSax#ym1WAgEgE7h`dx2y;i@;>BY zo8cj)v2)g*`ldCh-M58r@f+Vz{8uC{Cv{oK{FVC3rel?2Ts@D>x5@}wOkC=+bLX2# zi%I)u9S#Zke{oLIYNO+eVy33HxdyzJI$n0@t(Ea^#ZoElIZyPgx-5&|%=KzDx<5ld z0L3F)-r3fd0zJ_S#JoTZ@z} ze0N~b1p^}kqe~$dPMq~W>2uo0m(fVq$7E`WL)4t^AYt!M-445)K5zQ`>GWrXNAoI= zs&-bY&g@j3`Ll9fW#-R-;;(la%U-air$2j|`fTZI%ceC9A4^0MCV9ndWk7YG!T++N zdL{;jQ^E`kVnFx#CT8Y>|EA=N9DWrRJ3sgB|*Ix^Mn12Z6Ttf4I7hBN|o;ho4ex z-L`VowiPOST_$cdYu=l>w>j;)O4yP5_qQxMJ?}baG`(!MR5;IL{J8d;?B?ydr?dJy zV>de-V7EN}E&KJg8$G5%5(bIy^t-E9ZxP@3IfwJuWw)uf-bXThGf`n!`KB{rW^I|_ zw&MorD=#SfFv%opnFbu+#r;0weuId6<)zKt{>PDj^TEUY6Xrf< zdeZ6Bno%xiHDke}TPZuh)p_#HM-6-)cAcKz?=l;;-K z%xlUHocj7LJw}(e`%h%n?Mk~#%S9I2Fsqf=+!M(Sna}R|-TX=9TZM!t#}6!ykUsz5 z4MKBujhA8uxmWH z{Ed0fHl5y6TVDPT*sAo_zTad2^35DV6K;veG_6mT(_1pLTP^R$ikkwg%bq-Mu0ATt zzvF?G_R_tg5ghghr>=aySyZ5Vfu4>@DCeJ+i%ciNt+cPL*)OUb!SLwd_e1&Z^~u6z z<+GI!|KD9;zq^3R#NBHKPhwL{Rw)Pj$z}1$>{SzD3N(G)s#{J9ExqX_-RCf$+sAj_ zpZ@lG$&Fd;#Z!J|2I=fuZx(2I!20>Ft^XKNldR0tq$)LFQq=@vJ|GUrNvurEOwCC_ z57ZD2Ur>zzPW&%bg5eD4l4bWH!XarHP z(g$4^dgg}eVPI%H3DpJ9>gZb0^BqEKCL^v~h;9aYKp@PJVL=a;0B=?{kUR?zegx8a IKotxO0R77}LjV8( literal 0 HcmV?d00001 diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 98008a003d..67f9d20fce 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -54,7 +54,9 @@ namespace osu.Game.Tests.Skins // Covers key counters "Archives/modified-argon-pro-20230618.osk", // Covers "Argon" health display - "Archives/modified-argon-pro-20231001.osk" + "Archives/modified-argon-pro-20231001.osk", + // Covers player name text component. + "Archives/modified-argon-20231106.osk", }; /// From 51c891e2e4ff17432a01bf4f9ee75ad8c1498883 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 19:34:34 +0900 Subject: [PATCH 13/22] Automatically refresh the verify screen's issue list on re-entering it Addresses https://github.com/ppy/osu/discussions/25365. --- osu.Game/Screens/Edit/Verify/IssueList.cs | 10 +++++----- osu.Game/Screens/Edit/Verify/VerifyScreen.cs | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Verify/IssueList.cs b/osu.Game/Screens/Edit/Verify/IssueList.cs index 907949aee8..d07190fca0 100644 --- a/osu.Game/Screens/Edit/Verify/IssueList.cs +++ b/osu.Game/Screens/Edit/Verify/IssueList.cs @@ -72,7 +72,7 @@ namespace osu.Game.Screens.Edit.Verify new RoundedButton { Text = "Refresh", - Action = refresh, + Action = Refresh, Size = new Vector2(120, 40), Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -86,13 +86,13 @@ namespace osu.Game.Screens.Edit.Verify { base.LoadComplete(); - verify.InterpretedDifficulty.BindValueChanged(_ => refresh()); - verify.HiddenIssueTypes.BindCollectionChanged((_, _) => refresh()); + verify.InterpretedDifficulty.BindValueChanged(_ => Refresh()); + verify.HiddenIssueTypes.BindCollectionChanged((_, _) => Refresh()); - refresh(); + Refresh(); } - private void refresh() + public void Refresh() { var issues = generalVerifier.Run(context); diff --git a/osu.Game/Screens/Edit/Verify/VerifyScreen.cs b/osu.Game/Screens/Edit/Verify/VerifyScreen.cs index b17cf3379e..b6e0450e23 100644 --- a/osu.Game/Screens/Edit/Verify/VerifyScreen.cs +++ b/osu.Game/Screens/Edit/Verify/VerifyScreen.cs @@ -56,5 +56,11 @@ namespace osu.Game.Screens.Edit.Verify } }; } + + protected override void PopIn() + { + base.PopIn(); + IssueList.Refresh(); + } } } From 6deac9a5a45319d1536a9dc223a4efb07324a63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Nov 2023 11:24:56 +0100 Subject: [PATCH 14/22] Use better colours for system mods --- osu.Game/Graphics/OsuColour.cs | 2 +- osu.Game/Rulesets/UI/ModIcon.cs | 6 ++++-- osu.Game/Rulesets/UI/ModSwitchSmall.cs | 8 ++++++-- osu.Game/Rulesets/UI/ModSwitchTiny.cs | 6 +++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 75d313d98c..2e19eac572 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -162,7 +162,7 @@ namespace osu.Game.Graphics return Pink1; case ModType.System: - return Gray7; + return Gray5; default: throw new ArgumentOutOfRangeException(nameof(modType), modType, "Unknown mod type"); diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 5fd1507039..d09db37f2a 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -138,7 +138,6 @@ namespace osu.Game.Rulesets.UI { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Colour = OsuColour.Gray(84), Alpha = 0, Font = OsuFont.Numeric.With(null, 22f), UseFullGlyphHeight = false, @@ -148,7 +147,6 @@ namespace osu.Game.Rulesets.UI { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Colour = OsuColour.Gray(84), Size = new Vector2(45), Icon = FontAwesome.Solid.Question }, @@ -206,6 +204,10 @@ namespace osu.Game.Rulesets.UI private void updateColour() { + modAcronym.Colour = modIcon.Colour = mod.Type != ModType.System + ? OsuColour.Gray(84) + : colours.Yellow; + extendedText.Colour = background.Colour = Selected.Value ? backgroundColour.Lighten(0.2f) : backgroundColour; extendedBackground.Colour = Selected.Value ? backgroundColour.Darken(2.4f) : backgroundColour.Darken(2.8f); } diff --git a/osu.Game/Rulesets/UI/ModSwitchSmall.cs b/osu.Game/Rulesets/UI/ModSwitchSmall.cs index 927379c684..452a5599ba 100644 --- a/osu.Game/Rulesets/UI/ModSwitchSmall.cs +++ b/osu.Game/Rulesets/UI/ModSwitchSmall.cs @@ -85,11 +85,15 @@ namespace osu.Game.Rulesets.UI tinySwitch.Scale = new Vector2(0.3f); } + var modTypeColour = colours.ForModType(mod.Type); + inactiveForegroundColour = colourProvider?.Background5 ?? colours.Gray3; - activeForegroundColour = colours.ForModType(mod.Type); + activeForegroundColour = mod.Type != ModType.System ? modTypeColour : colours.Yellow; inactiveBackgroundColour = colourProvider?.Background2 ?? colours.Gray5; - activeBackgroundColour = Interpolation.ValueAt(0.1f, Colour4.Black, activeForegroundColour, 0, 1); + activeBackgroundColour = mod.Type != ModType.System + ? Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1) + : modTypeColour; } protected override void LoadComplete() diff --git a/osu.Game/Rulesets/UI/ModSwitchTiny.cs b/osu.Game/Rulesets/UI/ModSwitchTiny.cs index a3e325ace8..5bf501ead3 100644 --- a/osu.Game/Rulesets/UI/ModSwitchTiny.cs +++ b/osu.Game/Rulesets/UI/ModSwitchTiny.cs @@ -106,11 +106,15 @@ namespace osu.Game.Rulesets.UI [BackgroundDependencyLoader(true)] private void load(OsuColour colours, OverlayColourProvider? colourProvider) { + var modTypeColour = colours.ForModType(Mod.Type); + inactiveBackgroundColour = colourProvider?.Background5 ?? colours.Gray3; activeBackgroundColour = colours.ForModType(Mod.Type); inactiveForegroundColour = colourProvider?.Background2 ?? colours.Gray5; - activeForegroundColour = Interpolation.ValueAt(0.1f, Colour4.Black, activeForegroundColour, 0, 1); + activeForegroundColour = Mod.Type != ModType.System + ? Interpolation.ValueAt(0.1f, Colour4.Black, activeForegroundColour, 0, 1) + : colours.Yellow; } protected override void LoadComplete() From 4bc36a6c90dfd051cd6202be7e4fec48c1b05080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Nov 2023 12:18:02 +0100 Subject: [PATCH 15/22] Fix unused variable --- osu.Game/Rulesets/UI/ModSwitchTiny.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/ModSwitchTiny.cs b/osu.Game/Rulesets/UI/ModSwitchTiny.cs index 5bf501ead3..bb121c085c 100644 --- a/osu.Game/Rulesets/UI/ModSwitchTiny.cs +++ b/osu.Game/Rulesets/UI/ModSwitchTiny.cs @@ -109,11 +109,11 @@ namespace osu.Game.Rulesets.UI var modTypeColour = colours.ForModType(Mod.Type); inactiveBackgroundColour = colourProvider?.Background5 ?? colours.Gray3; - activeBackgroundColour = colours.ForModType(Mod.Type); + activeBackgroundColour = modTypeColour; inactiveForegroundColour = colourProvider?.Background2 ?? colours.Gray5; activeForegroundColour = Mod.Type != ModType.System - ? Interpolation.ValueAt(0.1f, Colour4.Black, activeForegroundColour, 0, 1) + ? Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1) : colours.Yellow; } From 915feeffb05389da36e9eb4e1c75f962202b3703 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 6 Nov 2023 17:37:25 +0300 Subject: [PATCH 16/22] Revert gameplay cursor scale changes --- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 12506c83b9..555610a3b6 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -5,6 +5,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -13,16 +14,18 @@ using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Screens.Play; +using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.UI { public partial class OsuResumeOverlay : ResumeOverlay { - private Container resumeCursorContainer; + private Container cursorScaleContainer; private OsuClickToResumeCursor clickToResumeCursor; private OsuCursorContainer localCursorContainer; + private IBindable localCursorScale; public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; @@ -31,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.UI [BackgroundDependencyLoader] private void load() { - Add(resumeCursorContainer = new Container + Add(cursorScaleContainer = new Container { Child = clickToResumeCursor = new OsuClickToResumeCursor { ResumeRequested = Resume } }); @@ -42,11 +45,17 @@ namespace osu.Game.Rulesets.Osu.UI base.PopIn(); GameplayCursor.ActiveCursor.Hide(); - resumeCursorContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre); + cursorScaleContainer.Position = ToLocalSpace(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre); clickToResumeCursor.Appear(); if (localCursorContainer == null) + { Add(localCursorContainer = new OsuCursorContainer()); + + localCursorScale = new BindableFloat(); + localCursorScale.BindTo(localCursorContainer.CursorScale); + localCursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true); + } } protected override void PopOut() From 75fbbb35ad2f88524670a19312dcb43569db8190 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 6 Nov 2023 18:28:51 +0300 Subject: [PATCH 17/22] Move cursor scale application within `OsuCursor` Doing so takes down two birds with one stone. 1. `ResumeOverlay` having to manually apply cursor scale to its "resume cursor". 2. Resume cursor input handling scaling up with the gameplay setting. Now, only the sprite itself gets scaled. --- osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs | 67 ++++++++++++++++--- .../UI/Cursor/OsuCursorContainer.cs | 61 ++--------------- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 12 +--- 3 files changed, 68 insertions(+), 72 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs index 66c86ee09d..ab1bb0cf5a 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs @@ -4,12 +4,16 @@ #nullable disable using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Rulesets.Osu.Skinning; +using osu.Game.Screens.Play; using osu.Game.Skinning; using osuTK; using osuTK.Graphics; @@ -20,12 +24,29 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { private const float size = 28; + private const float pressed_scale = 1.2f; + private const float released_scale = 1f; + private bool cursorExpand; private SkinnableDrawable cursorSprite; + private Container cursorScaleContainer = null!; private Drawable expandTarget => (cursorSprite.Drawable as OsuCursorSprite)?.ExpandTarget ?? cursorSprite; + public IBindable CursorScale => cursorScale; + + private readonly Bindable cursorScale = new BindableFloat(1); + + private Bindable userCursorScale = null!; + private Bindable autoCursorScale = null!; + + [Resolved(canBeNull: true)] + private GameplayState state { get; set; } + + [Resolved] + private OsuConfigManager config { get; set; } + public OsuCursor() { Origin = Anchor.Centre; @@ -33,15 +54,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Size = new Vector2(size); } - protected override void SkinChanged(ISkinSource skin) - { - cursorExpand = skin.GetConfig(OsuSkinConfiguration.CursorExpand)?.Value ?? true; - } - [BackgroundDependencyLoader] private void load() { - InternalChild = new Container + InternalChild = cursorScaleContainer = new Container { RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, @@ -52,10 +68,45 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Anchor = Anchor.Centre, } }; + + userCursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); + userCursorScale.ValueChanged += _ => calculateCursorScale(); + + autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize); + autoCursorScale.ValueChanged += _ => calculateCursorScale(); + + cursorScale.BindValueChanged(e => cursorScaleContainer.Scale = new Vector2(e.NewValue), true); } - private const float pressed_scale = 1.2f; - private const float released_scale = 1f; + protected override void LoadComplete() + { + base.LoadComplete(); + calculateCursorScale(); + } + + /// + /// Get the scale applicable to the ActiveCursor based on a beatmap's circle size. + /// + public static float GetScaleForCircleSize(float circleSize) => + 1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY; + + private void calculateCursorScale() + { + float scale = userCursorScale.Value; + + if (autoCursorScale.Value && state != null) + { + // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier. + scale *= GetScaleForCircleSize(state.Beatmap.Difficulty.CircleSize); + } + + cursorScale.Value = scale; + } + + protected override void SkinChanged(ISkinSource skin) + { + cursorExpand = skin.GetConfig(OsuSkinConfiguration.CursorExpand)?.Value ?? true; + } public void Expand() { diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs index bf1ff872dd..ba8a634ff7 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorContainer.cs @@ -11,11 +11,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; -using osu.Game.Beatmaps; -using osu.Game.Configuration; using osu.Game.Rulesets.Osu.Configuration; using osu.Game.Rulesets.UI; -using osu.Game.Screens.Play; using osu.Game.Skinning; using osuTK; @@ -23,6 +20,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { public partial class OsuCursorContainer : GameplayCursorContainer, IKeyBindingHandler { + public new OsuCursor ActiveCursor => (OsuCursor)base.ActiveCursor; + protected override Drawable CreateCursor() => new OsuCursor(); protected override Container Content => fadeContainer; @@ -33,13 +32,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private readonly Drawable cursorTrail; - public IBindable CursorScale => cursorScale; - - private readonly Bindable cursorScale = new BindableFloat(1); - - private Bindable userCursorScale; - private Bindable autoCursorScale; - private readonly CursorRippleVisualiser rippleVisualiser; public OsuCursorContainer() @@ -56,12 +48,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor }; } - [Resolved(canBeNull: true)] - private GameplayState state { get; set; } - - [Resolved] - private OsuConfigManager config { get; set; } - [BackgroundDependencyLoader(true)] private void load(OsuRulesetConfigManager rulesetConfig) { @@ -74,46 +60,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor showTrail.BindValueChanged(v => cursorTrail.FadeTo(v.NewValue ? 1 : 0, 200), true); - userCursorScale = config.GetBindable(OsuSetting.GameplayCursorSize); - userCursorScale.ValueChanged += _ => calculateScale(); - - autoCursorScale = config.GetBindable(OsuSetting.AutoCursorSize); - autoCursorScale.ValueChanged += _ => calculateScale(); - - CursorScale.BindValueChanged(e => + ActiveCursor.CursorScale.BindValueChanged(e => { var newScale = new Vector2(e.NewValue); - ActiveCursor.Scale = newScale; rippleVisualiser.CursorScale = newScale; cursorTrail.Scale = newScale; }, true); - - calculateScale(); - } - - /// - /// Get the scale applicable to the ActiveCursor based on a beatmap's circle size. - /// - public static float GetScaleForCircleSize(float circleSize) => - 1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY; - - private void calculateScale() - { - float scale = userCursorScale.Value; - - if (autoCursorScale.Value && state != null) - { - // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier. - scale *= GetScaleForCircleSize(state.Beatmap.Difficulty.CircleSize); - } - - cursorScale.Value = scale; - - var newScale = new Vector2(scale); - - ActiveCursor.ScaleTo(newScale, 400, Easing.OutQuint); - cursorTrail.Scale = newScale; } private int downCount; @@ -121,9 +74,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private void updateExpandedState() { if (downCount > 0) - (ActiveCursor as OsuCursor)?.Expand(); + ActiveCursor.Expand(); else - (ActiveCursor as OsuCursor)?.Contract(); + ActiveCursor.Contract(); } public bool OnPressed(KeyBindingPressEvent e) @@ -160,13 +113,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor protected override void PopIn() { fadeContainer.FadeTo(1, 300, Easing.OutQuint); - ActiveCursor.ScaleTo(CursorScale.Value, 400, Easing.OutQuint); + ActiveCursor.ScaleTo(1f, 400, Easing.OutQuint); } protected override void PopOut() { fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint); - ActiveCursor.ScaleTo(CursorScale.Value * 0.8f, 450, Easing.OutQuint); + ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint); } private partial class DefaultCursorTrail : CursorTrail diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 555610a3b6..ea49836772 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -5,7 +5,6 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -14,7 +13,6 @@ using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Screens.Play; -using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.UI @@ -25,7 +23,6 @@ namespace osu.Game.Rulesets.Osu.UI private OsuClickToResumeCursor clickToResumeCursor; private OsuCursorContainer localCursorContainer; - private IBindable localCursorScale; public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; @@ -49,13 +46,7 @@ namespace osu.Game.Rulesets.Osu.UI clickToResumeCursor.Appear(); if (localCursorContainer == null) - { Add(localCursorContainer = new OsuCursorContainer()); - - localCursorScale = new BindableFloat(); - localCursorScale.BindTo(localCursorContainer.CursorScale); - localCursorScale.BindValueChanged(scale => cursorScaleContainer.Scale = new Vector2(scale.NewValue), true); - } } protected override void PopOut() @@ -98,7 +89,8 @@ namespace osu.Game.Rulesets.Osu.UI { case OsuAction.LeftButton: case OsuAction.RightButton: - if (!IsHovered) return false; + if (!IsHovered) + return false; this.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint); From e12ee29a942279becf7ca4fd3816af1787b3fce8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 6 Nov 2023 18:35:30 +0300 Subject: [PATCH 18/22] Update existing test coverage --- osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs index c84a6ab70f..e6696032ae 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs @@ -94,16 +94,16 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("load content", loadContent); - AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.Scale.X == OsuCursorContainer.GetScaleForCircleSize(circleSize) * userScale); + AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.CursorScale.Value == OsuCursor.GetScaleForCircleSize(circleSize) * userScale); AddStep("set user scale to 1", () => config.SetValue(OsuSetting.GameplayCursorSize, 1f)); - AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.Scale.X == OsuCursorContainer.GetScaleForCircleSize(circleSize)); + AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.CursorScale.Value == OsuCursor.GetScaleForCircleSize(circleSize)); AddStep("turn off autosizing", () => config.SetValue(OsuSetting.AutoCursorSize, false)); - AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.Scale.X == 1); + AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.CursorScale.Value == 1); AddStep($"set user scale to {userScale}", () => config.SetValue(OsuSetting.GameplayCursorSize, userScale)); - AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.Scale.X == userScale); + AddUntilStep("cursor size correct", () => lastContainer.ActiveCursor.CursorScale.Value == userScale); } [Test] From 073249dafb3605a36bb8482f73f2dac1b7733b9f Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 6 Nov 2023 18:35:46 +0300 Subject: [PATCH 19/22] Allow tinkering with cursor-related settings in resume overlay test scene --- .../TestSceneResumeOverlay.cs | 58 +++++++++++++------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 81dc64cda9..49a8254f53 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -2,11 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; +using osu.Game.Configuration; using osu.Game.Rulesets.Osu.UI; using osu.Game.Screens.Play; +using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Osu.Tests @@ -19,24 +22,37 @@ namespace osu.Game.Rulesets.Osu.Tests private bool resumeFired; - [SetUp] - public void SetUp() => Schedule(() => - { - Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) - { - Children = new Drawable[] - { - cursor = new CursorContainer(), - resume = new OsuResumeOverlay - { - GameplayCursor = cursor - }, - } - }; + private OsuConfigManager localConfig = null!; - resumeFired = false; - resume.ResumeAction = () => resumeFired = true; - }); + [Cached] + private GameplayState gameplayState; + + public TestSceneResumeOverlay() + { + gameplayState = TestGameplayState.Create(new OsuRuleset()); + } + + [BackgroundDependencyLoader] + private void load() + { + Dependencies.Cache(localConfig = new OsuConfigManager(LocalStorage)); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + AddSliderStep("cursor size", 0.1f, 2f, 1f, v => localConfig.SetValue(OsuSetting.GameplayCursorSize, v)); + AddSliderStep("circle size", 0f, 10f, 0f, val => + { + gameplayState.Beatmap.Difficulty.CircleSize = val; + SetUp(); + }); + + AddToggleStep("auto size", v => localConfig.SetValue(OsuSetting.AutoCursorSize, v)); + } + + [SetUp] + public void SetUp() => Schedule(loadContent); [Test] public void TestResume() @@ -53,6 +69,14 @@ namespace osu.Game.Rulesets.Osu.Tests AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden); } + private void loadContent() + { + Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) { Children = new Drawable[] { cursor = new CursorContainer(), resume = new OsuResumeOverlay { GameplayCursor = cursor }, } }; + + resumeFired = false; + resume.ResumeAction = () => resumeFired = true; + } + private partial class ManualOsuInputManager : OsuInputManager { public ManualOsuInputManager(RulesetInfo ruleset) From a136f272cf78ec3572bc13bdcf0de47b74789a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 6 Nov 2023 16:40:57 +0100 Subject: [PATCH 20/22] Just use yellow for system mods --- osu.Game/Graphics/OsuColour.cs | 2 +- osu.Game/Rulesets/UI/ModIcon.cs | 4 +--- osu.Game/Rulesets/UI/ModSwitchSmall.cs | 6 ++---- osu.Game/Rulesets/UI/ModSwitchTiny.cs | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 2e19eac572..a417164e27 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -162,7 +162,7 @@ namespace osu.Game.Graphics return Pink1; case ModType.System: - return Gray5; + return Yellow; default: throw new ArgumentOutOfRangeException(nameof(modType), modType, "Unknown mod type"); diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index d09db37f2a..d1776c5c0b 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -204,9 +204,7 @@ namespace osu.Game.Rulesets.UI private void updateColour() { - modAcronym.Colour = modIcon.Colour = mod.Type != ModType.System - ? OsuColour.Gray(84) - : colours.Yellow; + modAcronym.Colour = modIcon.Colour = OsuColour.Gray(84); extendedText.Colour = background.Colour = Selected.Value ? backgroundColour.Lighten(0.2f) : backgroundColour; extendedBackground.Colour = Selected.Value ? backgroundColour.Darken(2.4f) : backgroundColour.Darken(2.8f); diff --git a/osu.Game/Rulesets/UI/ModSwitchSmall.cs b/osu.Game/Rulesets/UI/ModSwitchSmall.cs index 452a5599ba..6e96cc8e6f 100644 --- a/osu.Game/Rulesets/UI/ModSwitchSmall.cs +++ b/osu.Game/Rulesets/UI/ModSwitchSmall.cs @@ -88,12 +88,10 @@ namespace osu.Game.Rulesets.UI var modTypeColour = colours.ForModType(mod.Type); inactiveForegroundColour = colourProvider?.Background5 ?? colours.Gray3; - activeForegroundColour = mod.Type != ModType.System ? modTypeColour : colours.Yellow; + activeForegroundColour = modTypeColour; inactiveBackgroundColour = colourProvider?.Background2 ?? colours.Gray5; - activeBackgroundColour = mod.Type != ModType.System - ? Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1) - : modTypeColour; + activeBackgroundColour = Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1); } protected override void LoadComplete() diff --git a/osu.Game/Rulesets/UI/ModSwitchTiny.cs b/osu.Game/Rulesets/UI/ModSwitchTiny.cs index bb121c085c..4d50e702af 100644 --- a/osu.Game/Rulesets/UI/ModSwitchTiny.cs +++ b/osu.Game/Rulesets/UI/ModSwitchTiny.cs @@ -112,9 +112,7 @@ namespace osu.Game.Rulesets.UI activeBackgroundColour = modTypeColour; inactiveForegroundColour = colourProvider?.Background2 ?? colours.Gray5; - activeForegroundColour = Mod.Type != ModType.System - ? Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1) - : colours.Yellow; + activeForegroundColour = Interpolation.ValueAt(0.1f, Colour4.Black, modTypeColour, 0, 1); } protected override void LoadComplete() From 38c9a98e67e421a965d5979425ace752517e63e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Nov 2023 10:52:48 +0900 Subject: [PATCH 21/22] Add failing test coverage --- .../TestSceneResumeOverlay.cs | 34 +++++++++++++++++-- osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs | 8 ++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 49a8254f53..25d0b0a3d3 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -1,16 +1,20 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; +using osu.Framework.Testing; using osu.Game.Configuration; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Screens.Play; using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Rulesets.Osu.Tests { @@ -54,9 +58,13 @@ namespace osu.Game.Rulesets.Osu.Tests [SetUp] public void SetUp() => Schedule(loadContent); - [Test] - public void TestResume() + [TestCase(1)] + [TestCase(0.5f)] + [TestCase(2)] + public void TestResume(float cursorSize) { + AddStep($"set cursor size to {cursorSize}", () => localConfig.SetValue(OsuSetting.GameplayCursorSize, cursorSize)); + AddStep("move mouse to center", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); AddStep("show", () => resume.Show()); @@ -64,7 +72,27 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("click", () => osuInputManager.GameClick()); AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible); - AddStep("move mouse back", () => InputManager.MoveMouseTo(ScreenSpaceDrawQuad.Centre)); + AddStep("move mouse just out of range", () => + { + var resumeOverlay = this.ChildrenOfType().Single(); + var resumeOverlayCursor = resumeOverlay.ChildrenOfType().Single(); + + Vector2 offset = resumeOverlay.ToScreenSpace(new Vector2(OsuCursor.SIZE / 2)) - resumeOverlay.ToScreenSpace(Vector2.Zero); + InputManager.MoveMouseTo(resumeOverlayCursor.ScreenSpaceDrawQuad.Centre - offset - new Vector2(1)); + }); + + AddStep("click", () => osuInputManager.GameClick()); + AddAssert("not dismissed", () => !resumeFired && resume.State.Value == Visibility.Visible); + + AddStep("move mouse just within range", () => + { + var resumeOverlay = this.ChildrenOfType().Single(); + var resumeOverlayCursor = resumeOverlay.ChildrenOfType().Single(); + + Vector2 offset = resumeOverlay.ToScreenSpace(new Vector2(OsuCursor.SIZE / 2)) - resumeOverlay.ToScreenSpace(Vector2.Zero); + InputManager.MoveMouseTo(resumeOverlayCursor.ScreenSpaceDrawQuad.Centre - offset + new Vector2(1)); + }); + AddStep("click", () => osuInputManager.GameClick()); AddAssert("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden); } diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs index ab1bb0cf5a..8215201d43 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { public partial class OsuCursor : SkinReloadableDrawable { - private const float size = 28; + public const float SIZE = 28; private const float pressed_scale = 1.2f; private const float released_scale = 1f; @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { Origin = Anchor.Centre; - Size = new Vector2(size); + Size = new Vector2(SIZE); } [BackgroundDependencyLoader] @@ -134,7 +134,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Masking = true, - BorderThickness = size / 6, + BorderThickness = SIZE / 6, BorderColour = Color4.White, EdgeEffect = new EdgeEffectParameters { @@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Anchor = Anchor.Centre, RelativeSizeAxes = Axes.Both, Masking = true, - BorderThickness = size / 3, + BorderThickness = SIZE / 3, BorderColour = Color4.White.Opacity(0.5f), Children = new Drawable[] { From 7bedf7cf165e1a9a125eb74af636dca957e8fc0d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 7 Nov 2023 21:08:49 +0900 Subject: [PATCH 22/22] Move static method to end of file --- osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs index 8215201d43..ba9fda25e4 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs @@ -84,12 +84,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor calculateCursorScale(); } - /// - /// Get the scale applicable to the ActiveCursor based on a beatmap's circle size. - /// - public static float GetScaleForCircleSize(float circleSize) => - 1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY; - private void calculateCursorScale() { float scale = userCursorScale.Value; @@ -117,6 +111,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public void Contract() => expandTarget.ScaleTo(released_scale, 400, Easing.OutQuad); + /// + /// Get the scale applicable to the ActiveCursor based on a beatmap's circle size. + /// + public static float GetScaleForCircleSize(float circleSize) => + 1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY; + private partial class DefaultCursor : OsuCursorSprite { public DefaultCursor()