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
1 changed files with 34 additions and 14 deletions

View File

@ -11,6 +11,7 @@
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 @@ public partial class MapPoolScreen : TournamentMatchScreen
private readonly OsuButton buttonRedPick;
private readonly OsuButton buttonBluePick;
private readonly SettingsCheckbox chkBoxLineBreak;
public MapPoolScreen()
{
InternalChildren = new Drawable[]
@ -98,6 +102,15 @@ public MapPoolScreen()
Action = reset
},
new ControlPanel.Spacer(),
new TournamentSpriteText
{
Text = "Each modpool takes"
},
new TournamentSpriteText
{
Text = "different row"
},
chkBoxLineBreak = new SettingsCheckbox()
},
}
};
@ -107,6 +120,8 @@ public MapPoolScreen()
private void load(MatchIPCInfo ipc)
{
ipc.Beatmap.BindValueChanged(beatmapChanged);
chkBoxLineBreak.Current.Value = true;
chkBoxLineBreak.Current.BindValueChanged(_ => rearrangeMappool());
}
private void beatmapChanged(ValueChangedEvent<TournamentBeatmap> beatmap)
@ -213,37 +228,42 @@ private void addForBeatmap(int beatmapId)
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)
{
mapFlows.Add(currentFlow = new FillFlowContainer<TournamentBeatmapPanel>
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<TournamentBeatmapPanel>
{
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)