mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Initial groups implementation.
This commit is contained in:
123
osu.Game/Screens/Tournament/Drawings.cs
Normal file
123
osu.Game/Screens/Tournament/Drawings.cs
Normal file
@ -0,0 +1,123 @@
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Screens.Tournament
|
||||
{
|
||||
public class Drawings : OsuScreen
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||
|
||||
public Drawings()
|
||||
{
|
||||
GroupContainer gc;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
gc = new GroupContainer(8)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
|
||||
Padding = new MarginPadding()
|
||||
{
|
||||
Top = 35f,
|
||||
Bottom = 35f
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Team t = new Team()
|
||||
{
|
||||
FullName = "Australia",
|
||||
Acronym = "AUS",
|
||||
FlagName = "AU"
|
||||
};
|
||||
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
gc.AddTeam(t);
|
||||
}
|
||||
|
||||
class GroupContainer : Container
|
||||
{
|
||||
private FlowContainer<Group> topGroups;
|
||||
private FlowContainer<Group> bottomGroups;
|
||||
|
||||
private List<Group> allGroups = new List<Group>();
|
||||
|
||||
public GroupContainer(int numGroups)
|
||||
{
|
||||
char nextGroupName = 'A';
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
topGroups = new FlowContainer<Group>()
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
|
||||
AutoSizeAxes = Axes.Both,
|
||||
|
||||
Spacing = new Vector2(7f, 0)
|
||||
},
|
||||
bottomGroups = new FlowContainer<Group>()
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
|
||||
AutoSizeAxes = Axes.Both,
|
||||
|
||||
Spacing = new Vector2(7f, 0)
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < numGroups; i++)
|
||||
{
|
||||
Group g = new Group(nextGroupName.ToString());
|
||||
|
||||
allGroups.Add(g);
|
||||
nextGroupName++;
|
||||
|
||||
if (i < (int)Math.Ceiling(numGroups / 2f))
|
||||
topGroups.Add(g);
|
||||
else
|
||||
bottomGroups.Add(g);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTeam(Team team)
|
||||
{
|
||||
for (int i = 0; i < allGroups.Count; i++)
|
||||
{
|
||||
if (allGroups[i].TeamsCount == 8)
|
||||
continue;
|
||||
|
||||
allGroups[i].AddTeam(team);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
162
osu.Game/Screens/Tournament/Group.cs
Normal file
162
osu.Game/Screens/Tournament/Group.cs
Normal file
@ -0,0 +1,162 @@
|
||||
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;
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
if (topTeamsCount < 4)
|
||||
{
|
||||
topTeams.Add(new GroupTeam(team));
|
||||
topTeamsCount++;
|
||||
}
|
||||
else if (bottomTeamsCount < 4)
|
||||
{
|
||||
bottomTeams.Add(new GroupTeam(team));
|
||||
bottomTeamsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveTeam(Team team)
|
||||
{
|
||||
if (topTeams.RemoveAll(gt => gt.Team == team) > 0)
|
||||
topTeamsCount--;
|
||||
else if (bottomTeams.RemoveAll(gt => gt.Team == team) > 0)
|
||||
bottomTeamsCount--;
|
||||
}
|
||||
|
||||
class GroupTeam : FlowContainer
|
||||
{
|
||||
public Team Team;
|
||||
|
||||
private Sprite flagSprite;
|
||||
|
||||
public GroupTeam(Team team)
|
||||
{
|
||||
Team = team;
|
||||
|
||||
Size = new Vector2(36, 0);
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FlowDirections.Vertical;
|
||||
|
||||
Spacing = new Vector2(0, 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"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
osu.Game/Screens/Tournament/Team.cs
Normal file
16
osu.Game/Screens/Tournament/Team.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Screens.Tournament
|
||||
{
|
||||
public class Team
|
||||
{
|
||||
public string FullName;
|
||||
public string Acronym;
|
||||
|
||||
public string FlagName;
|
||||
}
|
||||
}
|
14
osu.Game/Screens/Tournament/Tournament.cs
Normal file
14
osu.Game/Screens/Tournament/Tournament.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.Screens.Tournament
|
||||
{
|
||||
public class Tournament : OsuScreen
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user