From 4a109fcc5528812f2a0bc445a0d16568c8cac785 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 3 Mar 2017 20:21:11 +0900 Subject: [PATCH] Remvoe ctor argument and fallback to storage-based TeamList if no custom list has been provided. --- .../Tests/TestCaseDrawings.cs | 133 +++++++++--------- osu.Game/Screens/Menu/MainMenu.cs | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 78 +++++----- osu.Game/Screens/Tournament/FileTeamList.cs | 5 +- osu.Game/Screens/Tournament/ITeamList.cs | 4 - 5 files changed, 100 insertions(+), 122 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index f42c708cac..5c4fb50374 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -1,13 +1,11 @@ -using osu.Framework.Allocation; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Framework.Screens.Testing; using osu.Game.Screens.Tournament; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Desktop.VisualTests.Tests { @@ -25,74 +23,71 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Drawings(new TestTeamList())); + Add(new Drawings + { + TeamList = new TestTeamList(), + }); } class TestTeamList : ITeamList { - public IEnumerable Teams + public IEnumerable Teams { get; } = new[] { - get + new Team { - return new Team[] - { - new Team() - { - FlagName = "GB", - FullName = "United Kingdom", - Acronym = "UK" - }, - new Team() - { - FlagName = "FR", - FullName = "France", - Acronym = "FRA" - }, - new Team() - { - FlagName = "CN", - FullName = "China", - Acronym = "CHN" - }, - new Team() - { - FlagName = "AU", - FullName = "Australia", - Acronym = "AUS" - }, - new Team() - { - FlagName = "JP", - FullName = "Japan", - Acronym = "JPN" - }, - new Team() - { - FlagName = "RO", - FullName = "Romania", - Acronym = "ROM" - }, - new Team() - { - FlagName = "IT", - FullName = "Italy", - Acronym = "PIZZA" - }, - new Team() - { - FlagName = "VE", - FullName = "Venezuela", - Acronym = "VNZ" - }, - new Team() - { - FlagName = "US", - FullName = "United States of America", - Acronym = "USA" - } - }; - } - } + FlagName = "GB", + FullName = "United Kingdom", + Acronym = "UK" + }, + new Team + { + FlagName = "FR", + FullName = "France", + Acronym = "FRA" + }, + new Team + { + FlagName = "CN", + FullName = "China", + Acronym = "CHN" + }, + new Team + { + FlagName = "AU", + FullName = "Australia", + Acronym = "AUS" + }, + new Team + { + FlagName = "JP", + FullName = "Japan", + Acronym = "JPN" + }, + new Team + { + FlagName = "RO", + FullName = "Romania", + Acronym = "ROM" + }, + new Team + { + FlagName = "IT", + FullName = "Italy", + Acronym = "PIZZA" + }, + new Team + { + FlagName = "VE", + FullName = "Venezuela", + Acronym = "VNZ" + }, + new Team + { + FlagName = "US", + FullName = "United States of America", + Acronym = "USA" + }, + }; } } } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index ef38458eb1..ec9f3bc7cf 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -105,7 +105,7 @@ namespace osu.Game.Screens.Menu { if (!args.Repeat && state.Keyboard.ControlPressed && state.Keyboard.ShiftPressed && args.Key == Key.D) { - Push(new Drawings(new FileTeamList(Game.Host.Storage))); + Push(new Drawings()); return true; } diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index f61a99cada..41ff7713c8 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -1,30 +1,24 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; -using osu.Framework.MathUtils; +using osu.Framework.Graphics.Textures; +using osu.Framework.Logging; +using osu.Framework.Platform; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Tournament.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Input; -using System.IO; -using osu.Framework.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Graphics.Textures; -using osu.Framework.IO.Stores; -using osu.Framework.Platform; -using osu.Framework.Logging; +using OpenTK; +using OpenTK.Graphics; namespace osu.Game.Screens.Tournament { @@ -48,19 +42,17 @@ namespace osu.Game.Screens.Tournament private Storage storage; - private ITeamList teamList; - - public Drawings(ITeamList teamList) - { - this.teamList = teamList; - } + public ITeamList TeamList; [BackgroundDependencyLoader] private void load(TextureStore textures, Storage storage) { this.storage = storage; - if (teamList.Teams.Count() == 0) + if (TeamList == null) + TeamList = new FileTeamList(storage); + + if (!TeamList.Teams.Any()) { Exit(); return; @@ -70,17 +62,17 @@ namespace osu.Game.Screens.Tournament Children = new Drawable[] { - new Box() + new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(77, 77, 77, 255) }, - new Sprite() + new Sprite { FillMode = FillMode.Fill, Texture = textures.Get(@"Backgrounds/Drawings/background.png") }, - new FillFlowContainer() + new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Right, @@ -88,7 +80,7 @@ namespace osu.Game.Screens.Tournament Children = new Drawable[] { // Main container - new Container() + new Container { RelativeSizeAxes = Axes.Both, Width = 0.85f, @@ -96,7 +88,7 @@ namespace osu.Game.Screens.Tournament Children = new Drawable[] { // Visualiser - new VisualiserContainer() + new VisualiserContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -117,14 +109,14 @@ namespace osu.Game.Screens.Tournament RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Padding = new MarginPadding() + Padding = new MarginPadding { Top = 35f, Bottom = 35f } }, // Scrolling teams - teamsContainer = new ScrollingTeamContainer() + teamsContainer = new ScrollingTeamContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -132,7 +124,7 @@ namespace osu.Game.Screens.Tournament RelativeSizeAxes = Axes.X, }, // Scrolling team name - fullTeamNameText = new SpriteText() + fullTeamNameText = new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.TopCentre, @@ -147,19 +139,19 @@ namespace osu.Game.Screens.Tournament } }, // Control panel container - new Container() + new Container { RelativeSizeAxes = Axes.Both, Width = 0.15f, Children = new Drawable[] { - new Box() + new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(54, 54, 54, 255) }, - new SpriteText() + new SpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -168,7 +160,7 @@ namespace osu.Game.Screens.Tournament TextSize = 22f, Font = "Exo2.0-Boldd" }, - new FillFlowContainer() + new FillFlowContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -184,21 +176,21 @@ namespace osu.Game.Screens.Tournament Children = new Drawable[] { - new OsuButton() + new OsuButton { RelativeSizeAxes = Axes.X, Text = "Begin random", Action = teamsContainer.StartScrolling, }, - new OsuButton() + new OsuButton { RelativeSizeAxes = Axes.X, Text = "Stop random", Action = teamsContainer.StopScrolling, }, - new OsuButton() + new OsuButton { RelativeSizeAxes = Axes.X, @@ -207,7 +199,7 @@ namespace osu.Game.Screens.Tournament } } }, - new FillFlowContainer() + new FillFlowContainer { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, @@ -223,7 +215,7 @@ namespace osu.Game.Screens.Tournament Children = new Drawable[] { - new OsuButton() + new OsuButton { RelativeSizeAxes = Axes.X, @@ -284,9 +276,7 @@ namespace osu.Game.Screens.Tournament teamsContainer.ClearTeams(); allTeams.Clear(); - List newTeams = teamList.Teams.ToList(); - - foreach (Team t in newTeams) + foreach (Team t in TeamList.Teams) { if (groupsContainer.ContainsTeam(t.FullName)) continue; diff --git a/osu.Game/Screens/Tournament/FileTeamList.cs b/osu.Game/Screens/Tournament/FileTeamList.cs index 84401f2cec..3eadec5114 100644 --- a/osu.Game/Screens/Tournament/FileTeamList.cs +++ b/osu.Game/Screens/Tournament/FileTeamList.cs @@ -6,9 +6,6 @@ using osu.Framework.Platform; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Screens.Tournament { @@ -27,7 +24,7 @@ namespace osu.Game.Screens.Tournament { get { - List teams = new List(); + var teams = new List(); try { diff --git a/osu.Game/Screens/Tournament/ITeamList.cs b/osu.Game/Screens/Tournament/ITeamList.cs index 0afb5d0512..b450b2fbb6 100644 --- a/osu.Game/Screens/Tournament/ITeamList.cs +++ b/osu.Game/Screens/Tournament/ITeamList.cs @@ -1,11 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Screens.Tournament {