2019-01-24 16:43:03 +08: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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-08-25 20:40:40 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-04 11:06:41 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2019-06-18 13:51:48 +08:00
|
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-08-25 20:40:40 +08:00
|
|
|
|
namespace osu.Game.Tournament.Screens.Drawings.Components
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class Group : Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public readonly string GroupName;
|
|
|
|
|
|
|
|
|
|
public int TeamsCount { get; private set; }
|
|
|
|
|
|
|
|
|
|
private readonly FlowContainer<GroupTeam> teams;
|
|
|
|
|
|
|
|
|
|
private readonly List<GroupTeam> allTeams = new List<GroupTeam>();
|
|
|
|
|
|
|
|
|
|
public Group(string name)
|
|
|
|
|
{
|
|
|
|
|
GroupName = name;
|
|
|
|
|
|
|
|
|
|
Size = new Vector2(176, 128);
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = 4;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = new Color4(54, 54, 54, 255)
|
|
|
|
|
},
|
|
|
|
|
// Group name
|
2020-03-03 18:14:44 +08:00
|
|
|
|
new TournamentSpriteText
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, 7f),
|
|
|
|
|
|
2018-07-24 20:42:06 +08:00
|
|
|
|
Text = $"GROUP {name.ToUpperInvariant()}",
|
2020-03-03 18:14:44 +08:00
|
|
|
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 8),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Colour = new Color4(255, 204, 34, 255),
|
|
|
|
|
},
|
|
|
|
|
teams = new FillFlowContainer<GroupTeam>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
|
|
|
|
|
Spacing = new Vector2(6f, 22),
|
|
|
|
|
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = 21f,
|
|
|
|
|
Bottom = 7f,
|
|
|
|
|
Left = 7f,
|
|
|
|
|
Right = 7f
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-25 20:40:40 +08:00
|
|
|
|
public void AddTeam(TournamentTeam team)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
GroupTeam gt = new GroupTeam(team);
|
|
|
|
|
|
|
|
|
|
if (TeamsCount < 8)
|
|
|
|
|
{
|
|
|
|
|
teams.Add(gt);
|
|
|
|
|
allTeams.Add(gt);
|
|
|
|
|
|
|
|
|
|
TeamsCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsTeam(string fullName)
|
|
|
|
|
{
|
2023-07-25 19:50:55 +08:00
|
|
|
|
return allTeams.Any(t => t.Team?.FullName.Value == fullName);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-25 20:40:40 +08:00
|
|
|
|
public bool RemoveTeam(TournamentTeam team)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
allTeams.RemoveAll(gt => gt.Team == team);
|
|
|
|
|
|
2022-08-26 14:19:05 +08:00
|
|
|
|
if (teams.RemoveAll(gt => gt.Team == team, true) > 0)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
TeamsCount--;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearTeams()
|
|
|
|
|
{
|
|
|
|
|
allTeams.Clear();
|
|
|
|
|
teams.Clear();
|
|
|
|
|
|
|
|
|
|
TeamsCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (GroupTeam gt in allTeams)
|
2023-07-25 19:50:55 +08:00
|
|
|
|
sb.AppendLine(gt.Team?.FullName.Value);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|