2017-02-27 13:19:07 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2017-02-27 21:50:34 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2017-02-27 13:19:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Tournament
|
|
|
|
|
{
|
|
|
|
|
public class Group : Container
|
|
|
|
|
{
|
|
|
|
|
public string GroupName;
|
|
|
|
|
|
|
|
|
|
public int TeamsCount => topTeamsCount + bottomTeamsCount;
|
|
|
|
|
|
|
|
|
|
private FlowContainer<GroupTeam> topTeams;
|
|
|
|
|
private FlowContainer<GroupTeam> bottomTeams;
|
|
|
|
|
|
2017-02-27 21:50:34 +08:00
|
|
|
|
private List<GroupTeam> allTeams = new List<GroupTeam>();
|
|
|
|
|
|
2017-02-27 13:19:07 +08:00
|
|
|
|
private int topTeamsCount;
|
|
|
|
|
private int bottomTeamsCount;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
new SpriteText()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, 7f),
|
|
|
|
|
|
|
|
|
|
Text = $"GROUP {name.ToUpper()}",
|
|
|
|
|
TextSize = 8f,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Colour = new Color4(255, 204, 34, 255),
|
|
|
|
|
},
|
|
|
|
|
topTeams = new FlowContainer<GroupTeam>()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, 21f),
|
|
|
|
|
Spacing = new Vector2(6f, 0),
|
|
|
|
|
|
|
|
|
|
Padding = new MarginPadding()
|
|
|
|
|
{
|
|
|
|
|
Left = 7f,
|
|
|
|
|
Right = 7f
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Direction = FlowDirections.Horizontal
|
|
|
|
|
},
|
|
|
|
|
bottomTeams = new FlowContainer<GroupTeam>()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, -7f),
|
|
|
|
|
Spacing = new Vector2(6f, 0),
|
|
|
|
|
|
|
|
|
|
Padding = new MarginPadding()
|
|
|
|
|
{
|
|
|
|
|
Left = 7f,
|
|
|
|
|
Right = 7f
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Direction = FlowDirections.Horizontal
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddTeam(Team team)
|
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
|
|
|
|
|
GroupTeam gt = new GroupTeam(team);
|
2017-02-27 13:19:07 +08:00
|
|
|
|
if (topTeamsCount < 4)
|
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
topTeams.Add(gt);
|
|
|
|
|
allTeams.Add(gt);
|
2017-02-27 13:19:07 +08:00
|
|
|
|
topTeamsCount++;
|
|
|
|
|
}
|
|
|
|
|
else if (bottomTeamsCount < 4)
|
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
bottomTeams.Add(gt);
|
|
|
|
|
allTeams.Add(gt);
|
2017-02-27 13:19:07 +08:00
|
|
|
|
bottomTeamsCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 21:50:34 +08:00
|
|
|
|
public bool ContainsTeam(string fullName)
|
|
|
|
|
{
|
|
|
|
|
return allTeams.Any(t => t.Team.FullName == fullName);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 14:02:38 +08:00
|
|
|
|
public bool RemoveTeam(Team team)
|
2017-02-27 13:19:07 +08:00
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
allTeams.RemoveAll(gt => gt.Team == team);
|
|
|
|
|
|
2017-02-27 13:19:07 +08:00
|
|
|
|
if (topTeams.RemoveAll(gt => gt.Team == team) > 0)
|
2017-02-27 14:02:38 +08:00
|
|
|
|
{
|
2017-02-27 13:19:07 +08:00
|
|
|
|
topTeamsCount--;
|
2017-02-27 14:02:38 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-02-27 13:19:07 +08:00
|
|
|
|
else if (bottomTeams.RemoveAll(gt => gt.Team == team) > 0)
|
2017-02-27 14:02:38 +08:00
|
|
|
|
{
|
2017-02-27 13:19:07 +08:00
|
|
|
|
bottomTeamsCount--;
|
2017-02-27 14:02:38 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearTeams()
|
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
allTeams.Clear();
|
2017-02-27 14:02:38 +08:00
|
|
|
|
topTeams.Clear();
|
|
|
|
|
bottomTeams.Clear();
|
|
|
|
|
|
|
|
|
|
topTeamsCount = 0;
|
|
|
|
|
bottomTeamsCount = 0;
|
2017-02-27 13:19:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 11:02:50 +08:00
|
|
|
|
public string ToStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (GroupTeam gt in allTeams)
|
|
|
|
|
sb.AppendLine(gt.Team.FullName);
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 21:50:34 +08:00
|
|
|
|
class GroupTeam : Container
|
2017-02-27 13:19:07 +08:00
|
|
|
|
{
|
|
|
|
|
public Team Team;
|
|
|
|
|
|
2017-02-27 21:50:34 +08:00
|
|
|
|
private FlowContainer innerContainer;
|
2017-02-27 13:19:07 +08:00
|
|
|
|
private Sprite flagSprite;
|
|
|
|
|
|
|
|
|
|
public GroupTeam(Team team)
|
|
|
|
|
{
|
|
|
|
|
Team = team;
|
|
|
|
|
|
|
|
|
|
Size = new Vector2(36, 0);
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
innerContainer = new FlowContainer()
|
2017-02-27 13:19:07 +08:00
|
|
|
|
{
|
2017-02-27 21:50:34 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
|
|
|
|
|
Direction = FlowDirections.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 5f),
|
|
|
|
|
|
|
|
|
|
Scale = new Vector2(1.5f),
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
flagSprite = new Sprite()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
FillMode = FillMode.Fit
|
|
|
|
|
},
|
|
|
|
|
new SpriteText()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
Text = team.Acronym.ToUpper(),
|
|
|
|
|
TextSize = 10f,
|
|
|
|
|
Font = @"Exo2.0-Bold"
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-27 13:19:07 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 21:50:34 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
innerContainer.ScaleTo(1f, 200);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 13:19:07 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|