1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Merge pull request #25398 from peppy/tournament-split-players-better

Split tournament player lists more equally
This commit is contained in:
Bartłomiej Dach 2023-11-09 14:39:01 +01:00 committed by GitHub
commit 8d47c64325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
@ -17,6 +19,11 @@ namespace osu.Game.Tournament.Components
{
AutoSizeAxes = Axes.Both;
var players = team?.Players ?? new BindableList<TournamentUser>();
// split the players into two even columns, favouring the first column if odd.
int split = (int)Math.Ceiling(players.Count / 2f);
InternalChildren = new Drawable[]
{
new FillFlowContainer
@ -39,13 +46,13 @@ namespace osu.Game.Tournament.Components
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
ChildrenEnumerable = team?.Players.Select(createPlayerText).Take(5) ?? Enumerable.Empty<Drawable>()
ChildrenEnumerable = players.Take(split).Select(createPlayerText),
},
new FillFlowContainer
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
ChildrenEnumerable = team?.Players.Select(createPlayerText).Skip(5) ?? Enumerable.Empty<Drawable>()
ChildrenEnumerable = players.Skip(split).Select(createPlayerText),
},
}
},