From a02caeef64d5fb12de8271be48e119193c01a532 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 14 Oct 2018 05:19:50 +0900 Subject: [PATCH] Add team intro screen Also adds dates to groups and matches (must be manually populated via json) --- .../TestCaseTeamOverview.cs | 18 ++ .../Screens/Ladder/Components/MatchPairing.cs | 3 + .../Ladder/Components/TournamentGrouping.cs | 3 + .../Screens/TeamIntro/TeamIntro.cs | 192 ++++++++++++++++++ 4 files changed, 216 insertions(+) create mode 100644 osu.Game.Tournament.Tests/TestCaseTeamOverview.cs create mode 100644 osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs diff --git a/osu.Game.Tournament.Tests/TestCaseTeamOverview.cs b/osu.Game.Tournament.Tests/TestCaseTeamOverview.cs new file mode 100644 index 0000000000..b853abb27c --- /dev/null +++ b/osu.Game.Tournament.Tests/TestCaseTeamOverview.cs @@ -0,0 +1,18 @@ +using System.Linq; +using osu.Game.Tournament.Screens.TeamIntro; + +namespace osu.Game.Tournament.Tests +{ + public class TestCaseTeamIntro : LadderTestCase + { + public TestCaseTeamIntro() + { + var team1 = Ladder.Teams.First(t => t.Acronym == "USA"); + var team2 = Ladder.Teams.First(t => t.Acronym == "JPN"); + + var round = Ladder.Groupings.First(g => g.Name == "Quarter Finals"); + + Add(new TeamIntroScreen(team1, team2, round)); + } + } +} diff --git a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs index 93d1b7085c..5dc2009c4d 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using Newtonsoft.Json; using osu.Framework.Configuration; using osu.Game.Tournament.Components; @@ -42,6 +43,8 @@ public class MatchPairing [JsonIgnore] public readonly Bindable LosersProgression = new Bindable(); + public readonly Bindable Date = new Bindable(); + public Point Position; public MatchPairing() diff --git a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs index d7c89cb006..d8680b7210 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/TournamentGrouping.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using osu.Framework.Configuration; @@ -13,6 +14,8 @@ public class TournamentGrouping public readonly BindableInt BestOf = new BindableInt(9) { Default = 9, MinValue = 3, MaxValue = 23 }; + public readonly Bindable StartDate = new Bindable(); + public List Pairings = new List(); } } diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs new file mode 100644 index 0000000000..fce29a2c89 --- /dev/null +++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntro.cs @@ -0,0 +1,192 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Screens; +using osu.Game.Tournament.Components; +using osu.Game.Tournament.Screens.Ladder.Components; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Tournament.Screens.TeamIntro +{ + public class TeamIntroScreen : OsuScreen + { + public TeamIntroScreen(TournamentTeam team1, TournamentTeam team2, TournamentGrouping round) + { + RelativeSizeAxes = Axes.Both; + + InternalChildren = new Drawable[] + { + new Box + { + Colour = Color4.White, + RelativeSizeAxes = Axes.Both + }, + new TeamWithPlayers(team1, true) + { + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding(40), + Width = 0.5f, + Height = 0.6f, + Anchor = Anchor.Centre, + Origin = Anchor.CentreRight + }, + new TeamWithPlayers(team2) + { + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding(40), + Width = 0.5f, + Height = 0.6f, + Anchor = Anchor.Centre, + Origin = Anchor.CentreLeft + }, + new RoundDisplay(round) + { + RelativeSizeAxes = Axes.Both, + Height = 0.3f, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + } + }; + } + + private class RoundDisplay : CompositeDrawable + { + public RoundDisplay(TournamentGrouping group) + { + var col = OsuColour.Gray(0.33f); + + InternalChildren = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 10), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Colour = col, + Text = "COMING UP NEXT", + Font = "Exo2.0-SemiBold", + TextSize = 15, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Colour = col, + Text = group.Name.Value, + Font = "Exo2.0-Light", + Spacing = new Vector2(10, 0), + TextSize = 50, + }, + new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Colour = col, + Text = group.StartDate.Value.ToString("dd MMMM HH:mm UTC"), + TextSize = 20, + }, + } + } + }; + } + } + + private class TeamWithPlayers : CompositeDrawable + { + private readonly Color4 red = new Color4(129, 68, 65, 255); + private readonly Color4 blue = new Color4(41, 91, 97, 255); + + public TeamWithPlayers(TournamentTeam team, bool left = false) + { + FillFlowContainer players; + var colour = left ? red : blue; + InternalChildren = new Drawable[] + { + new TeamDisplay(team, left ? "Team Red" : "Team Blue", colour) + { + Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = left ? Anchor.CentreRight : Anchor.CentreLeft, + }, + players = new FillFlowContainer + { + Direction = FillDirection.Vertical, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(0, 5), + Padding = new MarginPadding(20), + Anchor = !left ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = !left ? Anchor.CentreRight : Anchor.CentreLeft, + RelativePositionAxes = Axes.Both, + X = left ? 0.1f : -0.1f, + }, + }; + + foreach (var p in team.Players) + players.Add(new OsuSpriteText + { + Text = p.Username, + TextSize = 24, + Colour = colour, + Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft, + Origin = left ? Anchor.CentreRight : Anchor.CentreLeft, + }); + } + + private class TeamDisplay : DrawableTournamentTeam + { + public TeamDisplay(TournamentTeam team, string teamName, Color4 colour) + : base(team) + { + AutoSizeAxes = Axes.Both; + + Flag.Anchor = Flag.Origin = Anchor.TopCentre; + Flag.RelativeSizeAxes = Axes.None; + Flag.Size = new Vector2(300, 200); + Flag.Scale = new Vector2(0.4f); + Flag.Margin = new MarginPadding { Bottom = 20 }; + + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 5), + Children = new Drawable[] + { + Flag, + new OsuSpriteText + { + Text = team.FullName.ToUpper(), + TextSize = 40, + Colour = Color4.Black, + Font = "Exo2.0-Light", + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + }, + new OsuSpriteText + { + Text = teamName.ToUpper(), + TextSize = 20, + Colour = colour, + Origin = Anchor.TopCentre, + Anchor = Anchor.TopCentre, + } + } + }; + } + } + } + } +}