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