2017-02-27 05:19:07 +00:00
|
|
|
|
using OpenTK;
|
2017-02-27 06:02:38 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-02-27 06:02:38 +00:00
|
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-02-27 06:02:38 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.MathUtils;
|
2017-02-27 13:50:34 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2017-02-27 06:02:38 +00:00
|
|
|
|
using osu.Game.Screens.Tournament.Components;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-02-27 13:50:34 +00:00
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Configuration;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Tournament
|
|
|
|
|
{
|
|
|
|
|
public class Drawings : OsuScreen
|
|
|
|
|
{
|
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault();
|
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
private ScrollingTeamContainer teamsContainer;
|
|
|
|
|
private GroupsContainer groupsContainer;
|
|
|
|
|
|
2017-02-27 05:19:07 +00:00
|
|
|
|
public Drawings()
|
|
|
|
|
{
|
2017-02-27 13:50:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(Framework.Game game)
|
|
|
|
|
{
|
2017-02-27 06:02:38 +00:00
|
|
|
|
Container visualiserContainer;
|
2017-02-27 13:50:34 +00:00
|
|
|
|
SpriteText st;
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 06:02:38 +00:00
|
|
|
|
Children = new Drawable[]
|
2017-02-27 05:19:07 +00:00
|
|
|
|
{
|
2017-02-27 13:50:34 +00:00
|
|
|
|
new FlowContainer()
|
2017-02-27 06:02:38 +00:00
|
|
|
|
{
|
2017-02-27 13:50:34 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FlowDirections.Horizontal,
|
2017-02-27 06:02:38 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// Main container
|
|
|
|
|
new Container()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.85f,
|
2017-02-27 06:02:38 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// Visualiser
|
|
|
|
|
visualiserContainer = new Container()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Size = new Vector2(1, 10),
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
Colour = new Color4(255, 204, 34, 255)
|
|
|
|
|
},
|
|
|
|
|
// Groups
|
|
|
|
|
groupsContainer = new GroupsContainer(8)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Padding = new MarginPadding()
|
|
|
|
|
{
|
|
|
|
|
Top = 35f,
|
|
|
|
|
Bottom = 35f
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// Scrolling teams
|
|
|
|
|
teamsContainer = new ScrollingTeamContainer()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
// Scrolling team name
|
|
|
|
|
st = new SpriteText()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, 45f),
|
|
|
|
|
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
|
|
|
|
|
Font = "Exo2.0-Light",
|
|
|
|
|
TextSize = 42f
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// Control panel container
|
|
|
|
|
new Container()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Width = 0.15f,
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = new Color4(54, 54, 54, 255)
|
|
|
|
|
},
|
|
|
|
|
new SpriteText()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
Text = "Control Panel",
|
|
|
|
|
TextSize = 22f,
|
|
|
|
|
Font = "Exo2.0-Boldd"
|
|
|
|
|
},
|
|
|
|
|
new FlowContainer()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Width = 0.75f,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, 35f),
|
|
|
|
|
|
|
|
|
|
Direction = FlowDirections.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 5f),
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuButton()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-27 06:02:38 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
Text = "Begin random",
|
|
|
|
|
Action = teamsContainer.StartScrolling,
|
|
|
|
|
},
|
|
|
|
|
new OsuButton()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Text = "Stop random",
|
|
|
|
|
Action = teamsContainer.StopScrolling,
|
|
|
|
|
},
|
|
|
|
|
new OsuButton()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Text = "Reload",
|
|
|
|
|
Action = reloadTeams
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new FlowContainer()
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Width = 0.75f,
|
|
|
|
|
|
|
|
|
|
Position = new Vector2(0, -5f),
|
|
|
|
|
|
|
|
|
|
Direction = FlowDirections.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 5f),
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuButton()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
|
|
|
|
|
Text = "Reset",
|
|
|
|
|
Action = reset
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-27 05:19:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-02-27 06:02:38 +00:00
|
|
|
|
float offset = 0;
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
visualiserContainer.Add(new VisualiserLine(2 * (float)Math.PI, offset, RNG.Next(10000, 12000))
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
offset += (float)Math.PI / 6f;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
teamsContainer.OnSelected += t =>
|
2017-02-27 05:19:07 +00:00
|
|
|
|
{
|
2017-02-27 13:50:34 +00:00
|
|
|
|
groupsContainer.AddTeam(t.Team);
|
|
|
|
|
|
|
|
|
|
st.Text = t.Team.FullName;
|
|
|
|
|
st.FadeIn(200);
|
2017-02-27 05:19:07 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
teamsContainer.OnScrollStarted += () => st.FadeOut(200);
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
reloadTeams();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void reloadTeams()
|
|
|
|
|
{
|
|
|
|
|
teamsContainer.ClearTeams();
|
|
|
|
|
|
|
|
|
|
try
|
2017-02-27 05:19:07 +00:00
|
|
|
|
{
|
2017-02-27 13:50:34 +00:00
|
|
|
|
foreach (string s in File.ReadAllLines("drawings.txt"))
|
|
|
|
|
{
|
|
|
|
|
string[] split = s.Split(':');
|
|
|
|
|
string flagName = split[0].Trim();
|
|
|
|
|
string name = split[1].Trim();
|
|
|
|
|
|
|
|
|
|
string acronym = name.Substring(0, Math.Min(3, name.Length));
|
|
|
|
|
if (split.Length >= 3)
|
|
|
|
|
acronym = split[2].Trim();
|
|
|
|
|
|
|
|
|
|
if (groupsContainer.ContainsTeam(name))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
teamsContainer.AddTeam(new Team()
|
|
|
|
|
{
|
|
|
|
|
FlagName = flagName,
|
|
|
|
|
FullName = name,
|
|
|
|
|
Acronym = acronym
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-02-27 05:19:07 +00:00
|
|
|
|
}
|
2017-02-27 13:50:34 +00:00
|
|
|
|
catch { }
|
|
|
|
|
}
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
private void reset()
|
|
|
|
|
{
|
|
|
|
|
groupsContainer.ClearTeams();
|
|
|
|
|
teamsContainer.ClearTeams();
|
2017-02-27 05:19:07 +00:00
|
|
|
|
|
2017-02-27 13:50:34 +00:00
|
|
|
|
reloadTeams();
|
2017-02-27 05:19:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|