1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:12:54 +08:00

Initial groups implementation.

This commit is contained in:
smoogipooo 2017-02-27 14:19:07 +09:00
parent 0c2089ddd7
commit 25a1c7a8ad
8 changed files with 344 additions and 1 deletions

@ -1 +1 @@
Subproject commit 51f2b9b37f38cd349a3dd728a78f8fffcb3a54f5
Subproject commit 29dda31250aedb71f76d1c6b98f0bf0eebc798b2

View File

@ -0,0 +1,23 @@
using osu.Framework.Screens.Testing;
using osu.Game.Screens.Tournament;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseDrawings : TestCase
{
public override string Name => @"Drawings";
public override string Description => "Tournament drawings";
public override void Reset()
{
base.Reset();
Add(new Drawings());
}
}
}

View File

@ -176,6 +176,7 @@
<Compile Include="Benchmark.cs" />
<Compile Include="Program.cs" />
<Compile Include="Tests\TestCaseChatDisplay.cs" />
<Compile Include="Tests\TestCaseDrawings.cs" />
<Compile Include="Tests\TestCaseGamefield.cs" />
<Compile Include="Tests\TestCaseMusicController.cs" />
<Compile Include="Tests\TestCaseNotificationManager.cs" />

View 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;
}
}
}
}
}

View 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}");
}
}
}
}

View 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;
}
}

View 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();
}
}

View File

@ -209,6 +209,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Screens\Select\BeatmapInfoWedge.cs" />
<Compile Include="Screens\Select\WedgeBackground.cs" />
<Compile Include="Screens\Tournament\Drawings.cs" />
<Compile Include="Screens\Tournament\Group.cs" />
<Compile Include="Screens\Tournament\Team.cs" />
<Compile Include="Screens\Tournament\Tournament.cs" />
<Compile Include="Users\User.cs" />
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
<Compile Include="Database\BeatmapDatabase.cs" />