1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:03:22 +08:00

Merge pull request #23877 from yhsphd/tournament-mappool-linebreak

Add a checkbox to toggle line breaking for each mod in tournament mappool screen
This commit is contained in:
Bartłomiej Dach 2023-06-14 22:10:37 +02:00 committed by GitHub
commit 3410880318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 19 deletions

View File

@ -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()
{
@ -92,7 +95,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 +121,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 +133,27 @@ namespace osu.Game.Tournament.Tests.Screens
assertThreeWide();
}
private void addBeatmap(string mods = "nm")
[Test]
public void TestSplitMapPoolByMods()
{
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 splitting map pool by mods", () => 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
{

View File

@ -42,5 +42,7 @@ namespace osu.Game.Tournament.Models
};
public Bindable<bool> AutoProgressScreens = new BindableBool(true);
public Bindable<bool> SplitMapPoolByMods = new BindableBool(true);
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tournament.Screens.MapPool
{
public partial class MapPoolScreen : TournamentMatchScreen
{
private readonly FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
private FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
@ -32,12 +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;
public MapPoolScreen()
[BackgroundDependencyLoader]
private void load(MatchIPCInfo ipc)
{
InternalChildren = new Drawable[]
{
@ -98,15 +99,26 @@ namespace osu.Game.Tournament.Screens.MapPool
Action = reset
},
new ControlPanel.Spacer(),
new OsuCheckbox
{
LabelText = "Split display by mods",
Current = LadderInfo.SplitMapPoolByMods,
},
},
}
};
ipc.Beatmap.BindValueChanged(beatmapChanged);
}
[BackgroundDependencyLoader]
private void load(MatchIPCInfo ipc)
private Bindable<bool> splitMapPoolByMods;
protected override void LoadComplete()
{
ipc.Beatmap.BindValueChanged(beatmapChanged);
base.LoadComplete();
splitMapPoolByMods = LadderInfo.SplitMapPoolByMods.GetBoundCopy();
splitMapPoolByMods.BindValueChanged(_ => updateDisplay());
}
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
@ -213,24 +225,27 @@ namespace osu.Game.Tournament.Screens.MapPool
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
updateDisplay();
}
private void updateDisplay()
{
mapFlows.Clear();
if (match.NewValue == null)
if (CurrentMatch.Value == null)
return;
int totalRows = 0;
if (match.NewValue.Round.Value != null)
if (CurrentMatch.Value.Round.Value != null)
{
FillFlowContainer<TournamentBeatmapPanel> currentFlow = null;
string currentMod = null;
string currentMods = null;
int flowCount = 0;
foreach (var b in match.NewValue.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))
{
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>
{
@ -240,7 +255,7 @@ namespace osu.Game.Tournament.Screens.MapPool
AutoSizeAxes = Axes.Y
});
currentMod = b.Mods;
currentMods = b.Mods;
totalRows++;
flowCount = 0;