1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:07:25 +08:00

Add a checkbox to toggle line breaking for each mod in mappool screen

This commit is contained in:
yhsphd 2023-06-11 22:43:06 +09:00
parent 659a042065
commit 82b7e570cd

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components; using osu.Game.Tournament.Components;
using osu.Game.Tournament.IPC; using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
@ -25,6 +26,7 @@ namespace osu.Game.Tournament.Screens.MapPool
public partial class MapPoolScreen : TournamentMatchScreen public partial class MapPoolScreen : TournamentMatchScreen
{ {
private readonly FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows; private readonly FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
private TournamentMatch currentMatch;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; } private TournamentSceneManager sceneManager { get; set; }
@ -37,6 +39,8 @@ namespace osu.Game.Tournament.Screens.MapPool
private readonly OsuButton buttonRedPick; private readonly OsuButton buttonRedPick;
private readonly OsuButton buttonBluePick; private readonly OsuButton buttonBluePick;
private readonly SettingsCheckbox chkBoxLineBreak;
public MapPoolScreen() public MapPoolScreen()
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
@ -98,6 +102,15 @@ namespace osu.Game.Tournament.Screens.MapPool
Action = reset Action = reset
}, },
new ControlPanel.Spacer(), 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) private void load(MatchIPCInfo ipc)
{ {
ipc.Beatmap.BindValueChanged(beatmapChanged); ipc.Beatmap.BindValueChanged(beatmapChanged);
chkBoxLineBreak.Current.Value = true;
chkBoxLineBreak.Current.BindValueChanged(_ => rearrangeMappool());
} }
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap) private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
@ -213,24 +228,29 @@ namespace osu.Game.Tournament.Screens.MapPool
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match) protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{ {
base.CurrentMatchChanged(match); base.CurrentMatchChanged(match);
currentMatch = match.NewValue;
rearrangeMappool();
}
private void rearrangeMappool()
{
mapFlows.Clear(); mapFlows.Clear();
if (match.NewValue == null) if (currentMatch == null)
return; return;
int totalRows = 0; int totalRows = 0;
if (match.NewValue.Round.Value != null) if (currentMatch.Round.Value != null)
{ {
FillFlowContainer<TournamentBeatmapPanel> currentFlow = null; FillFlowContainer<TournamentBeatmapPanel> currentFlow = null;
string currentMod = null; string currentMod = null;
int flowCount = 0; 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) if (currentFlow == null || currentMod != b.Mods)
{
if (chkBoxLineBreak.Current.Value || currentFlow == null)
{ {
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel> mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>
{ {
@ -240,11 +260,11 @@ namespace osu.Game.Tournament.Screens.MapPool
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y
}); });
currentMod = b.Mods;
totalRows++; totalRows++;
flowCount = 0; flowCount = 0;
} }
currentMod = b.Mods;
}
if (++flowCount > 2) if (++flowCount > 2)
{ {