1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +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.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<FillFlowContainer<TournamentBeatmapPanel>> 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<TournamentBeatmap> beatmap)
@ -213,24 +228,29 @@ namespace osu.Game.Tournament.Screens.MapPool
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> 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<TournamentBeatmapPanel> 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)
{
if (chkBoxLineBreak.Current.Value || currentFlow == null)
{
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>
{
@ -240,11 +260,11 @@ namespace osu.Game.Tournament.Screens.MapPool
AutoSizeAxes = Axes.Y
});
currentMod = b.Mods;
totalRows++;
flowCount = 0;
}
currentMod = b.Mods;
}
if (++flowCount > 2)
{