From 077c77d52459c92b3b4e4f1beb9f634a0585eada Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 8 May 2022 16:00:07 +0300 Subject: [PATCH 1/8] Add method for scaling results screen in tests --- .../Multiplayer/TestSceneMultiplayerTeamResults.cs | 12 ++++++++++++ .../Visual/Ranking/TestSceneResultsScreen.cs | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs index bcb36a585f..0237298fa1 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerTeamResults.cs @@ -8,11 +8,23 @@ using osu.Game.Online.Rooms; using osu.Game.Rulesets.Osu; using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Tests.Resources; +using osuTK; namespace osu.Game.Tests.Visual.Multiplayer { public class TestSceneMultiplayerTeamResults : ScreenTestScene { + [Test] + public void TestScaling() + { + // scheduling is needed as scaling the content immediately causes the entire scene to shake badly, for some odd reason. + AddSliderStep("scale", 0.5f, 1.6f, 1f, v => Schedule(() => + { + Stack.Scale = new Vector2(v); + Stack.Size = new Vector2(1f / v); + })); + } + [TestCase(7483253, 1048576)] [TestCase(1048576, 7483253)] [TestCase(1048576, 1048576)] diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs index 4eed2a25f5..a1d51683e4 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs @@ -56,6 +56,17 @@ namespace osu.Game.Tests.Visual.Ranking }); } + [Test] + public void TestScaling() + { + // scheduling is needed as scaling the content immediately causes the entire scene to shake badly, for some odd reason. + AddSliderStep("scale", 0.5f, 1.6f, 1f, v => Schedule(() => + { + Content.Scale = new Vector2(v); + Content.Size = new Vector2(1f / v); + })); + } + [Test] public void TestResultsWithoutPlayer() { From 298c2a1828bf628d59a5bd7ec1b671e925732ec9 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 8 May 2022 16:03:57 +0300 Subject: [PATCH 2/8] Replace vertical scrolling in results screen with size-preserving container --- .../MultiplayerTeamResultsScreen.cs | 6 ++--- osu.Game/Screens/Ranking/ResultsScreen.cs | 26 ++----------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs index 3f0f3e043c..117415ac8f 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs @@ -46,9 +46,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { const float winner_background_half_height = 250; - VerticalScrollContent.Anchor = VerticalScrollContent.Origin = Anchor.TopCentre; - VerticalScrollContent.Scale = new Vector2(0.9f); - VerticalScrollContent.Y = 75; + Content.Anchor = Content.Origin = Anchor.TopCentre; + Content.Scale = new Vector2(0.9f); + Content.Y = 75; var redScore = teamScores.First().Value; var blueScore = teamScores.Last().Value; diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 98514cd846..2c91b17917 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -14,7 +14,6 @@ using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Screens; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; using osu.Game.Online.API; @@ -41,7 +40,7 @@ namespace osu.Game.Screens.Ranking protected ScorePanelList ScorePanelList { get; private set; } - protected VerticalScrollContainer VerticalScrollContent { get; private set; } + protected Container Content { get; private set; } [Resolved(CanBeNull = true)] private Player player { get; set; } @@ -79,10 +78,9 @@ namespace osu.Game.Screens.Ranking { new Drawable[] { - VerticalScrollContent = new VerticalScrollContainer + Content = new DrawSizePreservingFillContainer { RelativeSizeAxes = Axes.Both, - ScrollbarVisible = false, Child = new Container { RelativeSizeAxes = Axes.Both, @@ -346,25 +344,5 @@ namespace osu.Game.Screens.Ranking public void OnReleased(KeyBindingReleaseEvent e) { } - - protected class VerticalScrollContainer : OsuScrollContainer - { - protected override Container Content => content; - - private readonly Container content; - - public VerticalScrollContainer() - { - Masking = false; - - base.Content.Add(content = new Container { RelativeSizeAxes = Axes.X }); - } - - protected override void Update() - { - base.Update(); - content.Height = Math.Max(screen_height, DrawHeight); - } - } } } From 7f1ad149d5775606497144af30d94e801222e8a7 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 8 May 2022 16:04:24 +0300 Subject: [PATCH 3/8] Remove no longer necessary horizontal scroll blocker --- osu.Game/Screens/Ranking/ScorePanelList.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs index c2ef5529e8..a5341242e2 100644 --- a/osu.Game/Screens/Ranking/ScorePanelList.cs +++ b/osu.Game/Screens/Ranking/ScorePanelList.cs @@ -85,7 +85,6 @@ namespace osu.Game.Screens.Ranking InternalChild = scroll = new Scroll { RelativeSizeAxes = Axes.Both, - HandleScroll = () => expandedPanel?.IsHovered != true, // handle horizontal scroll only when not hovering the expanded panel. Child = flow = new Flow { Anchor = Anchor.Centre, @@ -359,11 +358,6 @@ namespace osu.Game.Screens.Ranking /// public float? InstantScrollTarget; - /// - /// Whether this container should handle scroll trigger events. - /// - public Func HandleScroll; - protected override void UpdateAfterChildren() { if (InstantScrollTarget != null) @@ -374,10 +368,6 @@ namespace osu.Game.Screens.Ranking base.UpdateAfterChildren(); } - - public override bool HandlePositionalInput => HandleScroll(); - - public override bool HandleNonPositionalInput => HandleScroll(); } } } From 6f4cdccf6c5430991c8e4c87a6ad60698faff4ce Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 8 May 2022 16:20:26 +0300 Subject: [PATCH 4/8] Remove no longer required constant --- osu.Game/Screens/Ranking/ResultsScreen.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 2c91b17917..87e49fcc5e 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -27,7 +27,6 @@ namespace osu.Game.Screens.Ranking public abstract class ResultsScreen : ScreenWithBeatmapBackground, IKeyBindingHandler { protected const float BACKGROUND_BLUR = 20; - private static readonly float screen_height = 768 - TwoLayerButton.SIZE_EXTENDED.Y; public override bool DisallowExternalBeatmapRulesetChanges => true; From e4521b1fff489cc92164d8d5de8c16cb628bd675 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 9 May 2022 10:16:57 +0300 Subject: [PATCH 5/8] Revert scale locking changes for now --- osu.Game/Screens/Ranking/ResultsScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 87e49fcc5e..70a1b69bcf 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Ranking { new Drawable[] { - Content = new DrawSizePreservingFillContainer + Content = new Container { RelativeSizeAxes = Axes.Both, Child = new Container From 3407a299ef30657d040736d71c7e84687adf927f Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 9 May 2022 10:35:12 +0300 Subject: [PATCH 6/8] Revert "Revert scale locking changes for now" This reverts commit e4521b1fff489cc92164d8d5de8c16cb628bd675. --- osu.Game/Screens/Ranking/ResultsScreen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 70a1b69bcf..87e49fcc5e 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Ranking { new Drawable[] { - Content = new Container + Content = new DrawSizePreservingFillContainer { RelativeSizeAxes = Axes.Both, Child = new Container From 422531d8ec5cb7240b4948c9e426663982e2a973 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 9 May 2022 10:35:13 +0300 Subject: [PATCH 7/8] Revert "Remove no longer required constant" This reverts commit 6f4cdccf6c5430991c8e4c87a6ad60698faff4ce. --- osu.Game/Screens/Ranking/ResultsScreen.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 87e49fcc5e..2c91b17917 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -27,6 +27,7 @@ namespace osu.Game.Screens.Ranking public abstract class ResultsScreen : ScreenWithBeatmapBackground, IKeyBindingHandler { protected const float BACKGROUND_BLUR = 20; + private static readonly float screen_height = 768 - TwoLayerButton.SIZE_EXTENDED.Y; public override bool DisallowExternalBeatmapRulesetChanges => true; From 2f3ac61b479bae1e4ecef58ffef024809ac1f5b4 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 9 May 2022 10:35:14 +0300 Subject: [PATCH 8/8] Revert "Replace vertical scrolling in results screen with size-preserving container" This reverts commit 298c2a1828bf628d59a5bd7ec1b671e925732ec9. --- .../MultiplayerTeamResultsScreen.cs | 6 ++--- osu.Game/Screens/Ranking/ResultsScreen.cs | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs index 117415ac8f..3f0f3e043c 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerTeamResultsScreen.cs @@ -46,9 +46,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { const float winner_background_half_height = 250; - Content.Anchor = Content.Origin = Anchor.TopCentre; - Content.Scale = new Vector2(0.9f); - Content.Y = 75; + VerticalScrollContent.Anchor = VerticalScrollContent.Origin = Anchor.TopCentre; + VerticalScrollContent.Scale = new Vector2(0.9f); + VerticalScrollContent.Y = 75; var redScore = teamScores.First().Value; var blueScore = teamScores.Last().Value; diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 2c91b17917..98514cd846 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -14,6 +14,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Screens; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; using osu.Game.Online.API; @@ -40,7 +41,7 @@ namespace osu.Game.Screens.Ranking protected ScorePanelList ScorePanelList { get; private set; } - protected Container Content { get; private set; } + protected VerticalScrollContainer VerticalScrollContent { get; private set; } [Resolved(CanBeNull = true)] private Player player { get; set; } @@ -78,9 +79,10 @@ namespace osu.Game.Screens.Ranking { new Drawable[] { - Content = new DrawSizePreservingFillContainer + VerticalScrollContent = new VerticalScrollContainer { RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, Child = new Container { RelativeSizeAxes = Axes.Both, @@ -344,5 +346,25 @@ namespace osu.Game.Screens.Ranking public void OnReleased(KeyBindingReleaseEvent e) { } + + protected class VerticalScrollContainer : OsuScrollContainer + { + protected override Container Content => content; + + private readonly Container content; + + public VerticalScrollContainer() + { + Masking = false; + + base.Content.Add(content = new Container { RelativeSizeAxes = Axes.X }); + } + + protected override void Update() + { + base.Update(); + content.Height = Math.Max(screen_height, DrawHeight); + } + } } }