From 82b7e570cddc271e36360de10ee447d129733114 Mon Sep 17 00:00:00 2001 From: yhsphd Date: Sun, 11 Jun 2023 22:43:06 +0900 Subject: [PATCH 1/5] Add a checkbox to toggle line breaking for each mod in mappool screen --- .../Screens/MapPool/MapPoolScreen.cs | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index f0e34d78c3..fcb0c4d70b 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Framework.Threading; using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Tournament.IPC; using osu.Game.Tournament.Models; @@ -25,6 +26,7 @@ namespace osu.Game.Tournament.Screens.MapPool public partial class MapPoolScreen : TournamentMatchScreen { private readonly FillFlowContainer> mapFlows; + private TournamentMatch currentMatch; [Resolved(canBeNull: true)] private TournamentSceneManager sceneManager { get; set; } @@ -37,6 +39,8 @@ namespace osu.Game.Tournament.Screens.MapPool private readonly OsuButton buttonRedPick; private readonly OsuButton buttonBluePick; + private readonly SettingsCheckbox chkBoxLineBreak; + public MapPoolScreen() { InternalChildren = new Drawable[] @@ -98,6 +102,15 @@ namespace osu.Game.Tournament.Screens.MapPool Action = reset }, new ControlPanel.Spacer(), + new TournamentSpriteText + { + Text = "Each modpool takes" + }, + new TournamentSpriteText + { + Text = "different row" + }, + chkBoxLineBreak = new SettingsCheckbox() }, } }; @@ -107,6 +120,8 @@ namespace osu.Game.Tournament.Screens.MapPool private void load(MatchIPCInfo ipc) { ipc.Beatmap.BindValueChanged(beatmapChanged); + chkBoxLineBreak.Current.Value = true; + chkBoxLineBreak.Current.BindValueChanged(_ => rearrangeMappool()); } private void beatmapChanged(ValueChangedEvent beatmap) @@ -213,37 +228,42 @@ namespace osu.Game.Tournament.Screens.MapPool protected override void CurrentMatchChanged(ValueChangedEvent match) { base.CurrentMatchChanged(match); + currentMatch = match.NewValue; + rearrangeMappool(); + } + private void rearrangeMappool() + { mapFlows.Clear(); - if (match.NewValue == null) + if (currentMatch == null) return; - int totalRows = 0; - if (match.NewValue.Round.Value != null) + if (currentMatch.Round.Value != null) { FillFlowContainer currentFlow = null; string currentMod = null; - int flowCount = 0; - foreach (var b in match.NewValue.Round.Value.Beatmaps) + foreach (var b in currentMatch.Round.Value.Beatmaps) { if (currentFlow == null || currentMod != b.Mods) { - mapFlows.Add(currentFlow = new FillFlowContainer + if (chkBoxLineBreak.Current.Value || currentFlow == null) { - Spacing = new Vector2(10, 5), - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - }); + mapFlows.Add(currentFlow = new FillFlowContainer + { + Spacing = new Vector2(10, 5), + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); + totalRows++; + flowCount = 0; + } currentMod = b.Mods; - - totalRows++; - flowCount = 0; } if (++flowCount > 2) From 6543c720efcf154f0d29b8e839aa076e5a8359d0 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 14 Jun 2023 09:58:39 +0300 Subject: [PATCH 2/5] Fix map pool test scene using invalid mod acronyms --- osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index 5695cb5574..48375c2cbd 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -92,7 +92,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); for (int i = 0; i < 11; i++) - addBeatmap(i > 4 ? $"M{i}" : "NM"); + addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); }); AddStep("reset match", () => @@ -118,7 +118,7 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); for (int i = 0; i < 12; i++) - addBeatmap(i > 4 ? $"M{i}" : "NM"); + addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); }); AddStep("reset match", () => @@ -130,7 +130,7 @@ namespace osu.Game.Tournament.Tests.Screens assertThreeWide(); } - private void addBeatmap(string mods = "nm") + private void addBeatmap(string mods = "NM") { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Add(new RoundBeatmap { From 90a5c75474275cd56bfd8031bd35b6a94d7c3e4c Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 14 Jun 2023 10:01:01 +0300 Subject: [PATCH 3/5] Add setting to ladder info and simplify changes --- osu.Game.Tournament/Models/LadderInfo.cs | 2 + .../Screens/MapPool/MapPoolScreen.cs | 79 +++++++++---------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/osu.Game.Tournament/Models/LadderInfo.cs b/osu.Game.Tournament/Models/LadderInfo.cs index 6b64a1156e..cb4e8bc16a 100644 --- a/osu.Game.Tournament/Models/LadderInfo.cs +++ b/osu.Game.Tournament/Models/LadderInfo.cs @@ -42,5 +42,7 @@ namespace osu.Game.Tournament.Models }; public Bindable AutoProgressScreens = new BindableBool(true); + + public Bindable SplitMapPoolByMods = new BindableBool(true); } } diff --git a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs index fcb0c4d70b..cb6c5902ec 100644 --- a/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs +++ b/osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; using osu.Framework.Threading; using osu.Game.Graphics.UserInterface; -using osu.Game.Overlays.Settings; using osu.Game.Tournament.Components; using osu.Game.Tournament.IPC; using osu.Game.Tournament.Models; @@ -25,8 +24,7 @@ namespace osu.Game.Tournament.Screens.MapPool { public partial class MapPoolScreen : TournamentMatchScreen { - private readonly FillFlowContainer> mapFlows; - private TournamentMatch currentMatch; + private FillFlowContainer> mapFlows; [Resolved(canBeNull: true)] private TournamentSceneManager sceneManager { get; set; } @@ -34,14 +32,13 @@ namespace osu.Game.Tournament.Screens.MapPool private TeamColour pickColour; private ChoiceType pickType; - private readonly OsuButton buttonRedBan; - private readonly OsuButton buttonBlueBan; - private readonly OsuButton buttonRedPick; - private readonly OsuButton buttonBluePick; + private OsuButton buttonRedBan; + private OsuButton buttonBlueBan; + private OsuButton buttonRedPick; + private OsuButton buttonBluePick; - private readonly SettingsCheckbox chkBoxLineBreak; - - public MapPoolScreen() + [BackgroundDependencyLoader] + private void load(MatchIPCInfo ipc) { InternalChildren = new Drawable[] { @@ -102,26 +99,26 @@ namespace osu.Game.Tournament.Screens.MapPool Action = reset }, new ControlPanel.Spacer(), - new TournamentSpriteText + new OsuCheckbox { - Text = "Each modpool takes" + LabelText = "Split display by mods", + Current = LadderInfo.SplitMapPoolByMods, }, - new TournamentSpriteText - { - Text = "different row" - }, - chkBoxLineBreak = new SettingsCheckbox() }, } }; + + ipc.Beatmap.BindValueChanged(beatmapChanged); } - [BackgroundDependencyLoader] - private void load(MatchIPCInfo ipc) + private Bindable splitMapPoolByMods; + + protected override void LoadComplete() { - ipc.Beatmap.BindValueChanged(beatmapChanged); - chkBoxLineBreak.Current.Value = true; - chkBoxLineBreak.Current.BindValueChanged(_ => rearrangeMappool()); + base.LoadComplete(); + + splitMapPoolByMods = LadderInfo.SplitMapPoolByMods.GetBoundCopy(); + splitMapPoolByMods.BindValueChanged(_ => updateDisplay()); } private void beatmapChanged(ValueChangedEvent beatmap) @@ -228,42 +225,40 @@ namespace osu.Game.Tournament.Screens.MapPool protected override void CurrentMatchChanged(ValueChangedEvent match) { base.CurrentMatchChanged(match); - currentMatch = match.NewValue; - rearrangeMappool(); + updateDisplay(); } - private void rearrangeMappool() + private void updateDisplay() { mapFlows.Clear(); - if (currentMatch == null) + if (CurrentMatch.Value == null) return; + int totalRows = 0; - if (currentMatch.Round.Value != null) + if (CurrentMatch.Value.Round.Value != null) { FillFlowContainer currentFlow = null; - string currentMod = null; + string currentMods = null; int flowCount = 0; - foreach (var b in currentMatch.Round.Value.Beatmaps) + foreach (var b in CurrentMatch.Value.Round.Value.Beatmaps) { - if (currentFlow == null || currentMod != b.Mods) + if (currentFlow == null || (LadderInfo.SplitMapPoolByMods.Value && currentMods != b.Mods)) { - if (chkBoxLineBreak.Current.Value || currentFlow == null) + mapFlows.Add(currentFlow = new FillFlowContainer { - mapFlows.Add(currentFlow = new FillFlowContainer - { - Spacing = new Vector2(10, 5), - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - }); + Spacing = new Vector2(10, 5), + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); - totalRows++; - flowCount = 0; - } - currentMod = b.Mods; + currentMods = b.Mods; + + totalRows++; + flowCount = 0; } if (++flowCount > 2) From 78fe71182430e145a4d647b40c15a6118b448550 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 14 Jun 2023 10:01:52 +0300 Subject: [PATCH 4/5] Add visual test case --- .../Screens/TestSceneMapPoolScreen.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index 48375c2cbd..0ffbeeb491 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -24,6 +24,9 @@ namespace osu.Game.Tournament.Tests.Screens Add(screen = new MapPoolScreen { Width = 0.7f }); } + [SetUp] + public void SetUp() => Schedule(() => Ladder.SplitMapPoolByMods.Value = true); + [Test] public void TestFewMaps() { @@ -130,6 +133,26 @@ namespace osu.Game.Tournament.Tests.Screens assertThreeWide(); } + [Test] + public void TestDisableMapsPerMod() + { + AddStep("load many maps", () => + { + Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Clear(); + + for (int i = 0; i < 12; i++) + addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); + }); + + AddStep("disable maps per mod", () => Ladder.SplitMapPoolByMods.Value = false); + + AddStep("reset match", () => + { + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + }); + } + private void addBeatmap(string mods = "NM") { Ladder.CurrentMatch.Value.Round.Value.Beatmaps.Add(new RoundBeatmap From 4cc2bb0c7db35e4b52ac230e81cb5f50a08dfbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 14 Jun 2023 21:33:11 +0200 Subject: [PATCH 5/5] Rename things in test to match --- osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index 0ffbeeb491..94086f10f2 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -134,7 +134,7 @@ namespace osu.Game.Tournament.Tests.Screens } [Test] - public void TestDisableMapsPerMod() + public void TestSplitMapPoolByMods() { AddStep("load many maps", () => { @@ -144,7 +144,7 @@ namespace osu.Game.Tournament.Tests.Screens addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); }); - AddStep("disable maps per mod", () => Ladder.SplitMapPoolByMods.Value = false); + AddStep("disable splitting map pool by mods", () => Ladder.SplitMapPoolByMods.Value = false); AddStep("reset match", () => {