From 3d3a7f714dc338b2d5ccf0a2eb55b563d5bb8fed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 26 Aug 2018 01:24:19 +0900 Subject: [PATCH] Move and use shared components --- osu.Game.Tournament.Tests/TestCaseDrawings.cs | 1 + .../TestCaseMatchPairings.cs | 2 +- .../Components/DrawableTournamentTeam.cs | 3 +- .../TournamentTeam.cs} | 2 +- .../Screens/Drawings/Components/Group.cs | 49 ++++++------------- .../Drawings/Components/GroupContainer.cs | 1 + .../Screens/Drawings/Components/ITeamList.cs | 1 + .../Components/ScrollingTeamContainer.cs | 32 ++++-------- .../Components/StorageBackedTeamList.cs | 1 + .../Screens/Drawings/DrawingsScreen.cs | 1 + .../Ladder/Components/DrawableMatchTeam.cs | 2 +- .../Screens/Ladder/Components/MatchPairing.cs | 2 +- 12 files changed, 35 insertions(+), 62 deletions(-) rename osu.Game.Tournament/{Screens/Ladder => }/Components/DrawableTournamentTeam.cs (91%) rename osu.Game.Tournament/{Screens/Drawings/Components/DrawingsTeam.cs => Components/TournamentTeam.cs} (92%) diff --git a/osu.Game.Tournament.Tests/TestCaseDrawings.cs b/osu.Game.Tournament.Tests/TestCaseDrawings.cs index 029668df73..511724e51a 100644 --- a/osu.Game.Tournament.Tests/TestCaseDrawings.cs +++ b/osu.Game.Tournament.Tests/TestCaseDrawings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using osu.Game.Tests.Visual; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Drawings; using osu.Game.Tournament.Screens.Drawings.Components; diff --git a/osu.Game.Tournament.Tests/TestCaseMatchPairings.cs b/osu.Game.Tournament.Tests/TestCaseMatchPairings.cs index 77cf3c97f1..d5835896a4 100644 --- a/osu.Game.Tournament.Tests/TestCaseMatchPairings.cs +++ b/osu.Game.Tournament.Tests/TestCaseMatchPairings.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Tests.Visual; -using osu.Game.Tournament.Screens.Drawings.Components; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Ladder.Components; namespace osu.Game.Tournament.Tests diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentTeam.cs b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs similarity index 91% rename from osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentTeam.cs rename to osu.Game.Tournament/Components/DrawableTournamentTeam.cs index dc5e2c9007..ec60d24c2c 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableTournamentTeam.cs +++ b/osu.Game.Tournament/Components/DrawableTournamentTeam.cs @@ -7,9 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; -using osu.Game.Tournament.Screens.Drawings.Components; -namespace osu.Game.Tournament.Screens.Ladder.Components +namespace osu.Game.Tournament.Components { public abstract class DrawableTournamentTeam : CompositeDrawable { diff --git a/osu.Game.Tournament/Screens/Drawings/Components/DrawingsTeam.cs b/osu.Game.Tournament/Components/TournamentTeam.cs similarity index 92% rename from osu.Game.Tournament/Screens/Drawings/Components/DrawingsTeam.cs rename to osu.Game.Tournament/Components/TournamentTeam.cs index 7e182d1b62..03d787af76 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/DrawingsTeam.cs +++ b/osu.Game.Tournament/Components/TournamentTeam.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Tournament.Screens.Drawings.Components +namespace osu.Game.Tournament.Components { public class TournamentTeam { diff --git a/osu.Game.Tournament/Screens/Drawings/Components/Group.cs b/osu.Game.Tournament/Screens/Drawings/Components/Group.cs index 01f13857fc..1600a19be8 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/Group.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/Group.cs @@ -4,13 +4,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; +using osu.Game.Tournament.Components; using OpenTK; using OpenTK.Graphics; @@ -119,21 +117,26 @@ namespace osu.Game.Tournament.Screens.Drawings.Components return sb.ToString(); } - private class GroupTeam : Container + private class GroupTeam : DrawableTournamentTeam { - public readonly TournamentTeam Team; - private readonly FillFlowContainer innerContainer; - private readonly Sprite flagSprite; - public GroupTeam(TournamentTeam team) + public GroupTeam(TournamentTeam team) : base(team) { - Team = team; - Width = 36; AutoSizeAxes = Axes.Y; - Children = new Drawable[] + + Flag.Anchor = Anchor.TopCentre; + Flag.Origin = Anchor.TopCentre; + + AcronymText.Anchor = Anchor.TopCentre; + AcronymText.Origin = Anchor.TopCentre; + AcronymText.Text = team.Acronym.ToUpperInvariant(); + AcronymText.TextSize = 10f; + AcronymText.Font = @"Exo2.0-Bold"; + + InternalChildren = new Drawable[] { innerContainer = new FillFlowContainer { @@ -148,22 +151,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components Children = new Drawable[] { - flagSprite = new Sprite - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - FillMode = FillMode.Fit - }, - new OsuSpriteText - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - - Text = team.Acronym.ToUpperInvariant(), - TextSize = 10f, - Font = @"Exo2.0-Bold" - } + Flag, + AcronymText } } }; @@ -175,12 +164,6 @@ namespace osu.Game.Tournament.Screens.Drawings.Components innerContainer.ScaleTo(1.5f); innerContainer.ScaleTo(1f, 200); } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); - } } } } diff --git a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs index 2914d28a00..236d19a3ad 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/GroupContainer.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Tournament.Components; using OpenTK; namespace osu.Game.Tournament.Screens.Drawings.Components diff --git a/osu.Game.Tournament/Screens/Drawings/Components/ITeamList.cs b/osu.Game.Tournament/Screens/Drawings/Components/ITeamList.cs index 37b321c85b..614507dc80 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/ITeamList.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/ITeamList.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Game.Tournament.Components; namespace osu.Game.Tournament.Screens.Drawings.Components { diff --git a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs index ec2e8afcb6..816a3ef958 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/ScrollingTeamContainer.cs @@ -5,14 +5,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; using osu.Framework.Threading; +using osu.Game.Tournament.Components; using OpenTK; using OpenTK.Graphics; @@ -315,14 +313,11 @@ namespace osu.Game.Tournament.Screens.Drawings.Components Scrolling } - public class ScrollingTeam : Container + public class ScrollingTeam : DrawableTournamentTeam { public const float WIDTH = 58; public const float HEIGHT = 41; - public TournamentTeam Team; - - private readonly Sprite flagSprite; private readonly Box outline; private bool selected; @@ -343,9 +338,8 @@ namespace osu.Game.Tournament.Screens.Drawings.Components } public ScrollingTeam(TournamentTeam team) + : base(team) { - Team = team; - Anchor = Anchor.CentreLeft; Origin = Anchor.CentreLeft; @@ -355,28 +349,20 @@ namespace osu.Game.Tournament.Screens.Drawings.Components Alpha = 0; - Children = new Drawable[] + Flag.Anchor = Anchor.Centre; + Flag.Origin = Anchor.Centre; + Flag.Scale = new Vector2(0.9f); + + InternalChildren = new Drawable[] { outline = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0 }, - flagSprite = new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - - Size = new Vector2(WIDTH, HEIGHT) - new Vector2(8) - } + Flag }; } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); - } } } } diff --git a/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs b/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs index 296a23339e..44ee9d64ca 100644 --- a/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs +++ b/osu.Game.Tournament/Screens/Drawings/Components/StorageBackedTeamList.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using osu.Framework.Logging; using osu.Framework.Platform; +using osu.Game.Tournament.Components; namespace osu.Game.Tournament.Screens.Drawings.Components { diff --git a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs index e3853dca6f..8e6738d8d6 100644 --- a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs +++ b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Screens; using osu.Game.Screens.Backgrounds; +using osu.Game.Tournament.Components; using osu.Game.Tournament.Screens.Drawings.Components; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs index 9d8ea00e31..1a190b4cc7 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/DrawableMatchTeam.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Tournament.Screens.Drawings.Components; +using osu.Game.Tournament.Components; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs index b8d8b77d74..26beb5c598 100644 --- a/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs +++ b/osu.Game.Tournament/Screens/Ladder/Components/MatchPairing.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Configuration; -using osu.Game.Tournament.Screens.Drawings.Components; +using osu.Game.Tournament.Components; namespace osu.Game.Tournament.Screens.Ladder.Components {