From 00d7dc19cc4932ac1af3ca1c6da315dbcd8b5ee1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Mar 2020 14:25:25 +0900 Subject: [PATCH] Update tests and logic --- .../Screens/TestSceneMapPoolScreen.cs | 46 +++++++++++++++++-- .../Screens/MapPool/MapPoolScreen.cs | 7 +-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index a73e4e53ba..cc5f66761e 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -41,6 +41,26 @@ namespace osu.Game.Tournament.Tests.Screens AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); } + [Test] + public void TestJustEnoughMaps() + { + AddStep("load just enough maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 18; i++) + addBeatmap(); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + } + [Test] public void TestManyMaps() { @@ -48,7 +68,7 @@ namespace osu.Game.Tournament.Tests.Screens { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); - for (int i = 0; i < 17; i++) + for (int i = 0; i < 19; i++) addBeatmap(); }); @@ -61,6 +81,26 @@ namespace osu.Game.Tournament.Tests.Screens AddAssert("ensure layout width is 3", () => screen.ChildrenOfType().ElementAt(2).Y == 0); } + [Test] + public void TestJustEnoughMods() + { + AddStep("load many maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 11; i++) + addBeatmap(i > 4 ? $"M{i}" : "NM"); + }); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + + AddAssert("ensure layout width is 2", () => screen.ChildrenOfType().ElementAt(2).Y > 0); + } + [Test] public void TestManyMods() { @@ -68,8 +108,8 @@ namespace osu.Game.Tournament.Tests.Screens { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); - for (int i = 0; i < 13; i++) - addBeatmap(i < 4 ? $"M{i}" : "NM"); + for (int i = 0; i < 12; i++) + addBeatmap(i > 4 ? $"M{i}" : "NM"); }); AddStep("reset match", () => diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index a9e1d1f226..da7e226103 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -211,7 +211,6 @@ namespace osu.Game.Tournament.Screens.MapPool private void matchChanged(ValueChangedEvent match) { mapFlows.Clear(); - mapFlows.Padding = new MarginPadding(5) { Horizontal = 100 }; int totalRows = 0; @@ -254,9 +253,11 @@ namespace osu.Game.Tournament.Screens.MapPool } } - if (totalRows > 9) + mapFlows.Padding = new MarginPadding(5) + { // remove horizontal padding to increase flow width to 3 panels - mapFlows.Padding = new MarginPadding(5); + Horizontal = totalRows > 9 ? 0 : 100 + }; } } }