2020-03-06 07:07:54 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
2023-11-09 12:35:37 +00:00
|
|
|
|
using System;
|
2020-03-06 07:07:54 +00:00
|
|
|
|
using System.Linq;
|
2023-11-09 12:35:37 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-03-06 07:07:54 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Tournament.Models;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
|
{
|
|
|
|
|
public partial class DrawableTeamWithPlayers : CompositeDrawable
|
|
|
|
|
{
|
2023-06-23 15:59:36 +00:00
|
|
|
|
public DrawableTeamWithPlayers(TournamentTeam? team, TeamColour colour)
|
2020-03-06 07:07:54 +00:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2023-11-09 12:35:37 +00:00
|
|
|
|
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);
|
|
|
|
|
|
2020-03-06 07:07:54 +00:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(30),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new DrawableTeamTitleWithHeader(team, colour),
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Padding = new MarginPadding { Left = 10 },
|
|
|
|
|
Spacing = new Vector2(30),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2023-11-09 12:35:37 +00:00
|
|
|
|
ChildrenEnumerable = players.Take(split).Select(createPlayerText),
|
2020-03-06 07:07:54 +00:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2023-11-09 12:35:37 +00:00
|
|
|
|
ChildrenEnumerable = players.Skip(split).Select(createPlayerText),
|
2020-03-06 07:07:54 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-17 23:33:26 +00:00
|
|
|
|
TournamentSpriteText createPlayerText(TournamentUser p) =>
|
2020-03-06 07:07:54 +00:00
|
|
|
|
new TournamentSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = p.Username,
|
|
|
|
|
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold),
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|