From e856abe59ae9b2e9165ccf2793c3f8304a20c3cf Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 13:02:14 +0900 Subject: [PATCH 01/11] Let's not use Country for drawings-specific stuff... --- .../Tests/TestCaseDrawings.cs | 21 +++++++++---------- osu.Game/Screens/Tournament/Drawings.cs | 10 ++++----- osu.Game/Screens/Tournament/Group.cs | 10 ++++----- osu.Game/Screens/Tournament/GroupContainer.cs | 4 ++-- .../Tournament/ScrollingTeamContainer.cs | 20 +++++++++--------- .../Screens/Tournament/Teams/ITeamList.cs | 3 +-- .../Tournament/Teams/StorageBackedTeamList.cs | 9 ++++---- osu.Game/Screens/Tournament/Teams/Team.cs | 15 +++++++++++++ osu.Game/Users/Country.cs | 5 ----- osu.Game/Users/Team.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 11 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 osu.Game/Screens/Tournament/Teams/Team.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index a0463516de..c4771a2913 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using osu.Framework.Testing; using osu.Game.Screens.Tournament; using osu.Game.Screens.Tournament.Teams; -using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests { @@ -25,57 +24,57 @@ namespace osu.Desktop.VisualTests.Tests private class TestTeamList : ITeamList { - public IEnumerable Teams { get; } = new[] + public IEnumerable Teams { get; } = new[] { - new Country + new Team { FlagName = "GB", FullName = "United Kingdom", Acronym = "UK" }, - new Country + new Team { FlagName = "FR", FullName = "France", Acronym = "FRA" }, - new Country + new Team { FlagName = "CN", FullName = "China", Acronym = "CHN" }, - new Country + new Team { FlagName = "AU", FullName = "Australia", Acronym = "AUS" }, - new Country + new Team { FlagName = "JP", FullName = "Japan", Acronym = "JPN" }, - new Country + new Team { FlagName = "RO", FullName = "Romania", Acronym = "ROM" }, - new Country + new Team { FlagName = "IT", FullName = "Italy", Acronym = "PIZZA" }, - new Country + new Team { FlagName = "VE", FullName = "Venezuela", Acronym = "VNZ" }, - new Country + new Team { FlagName = "US", FullName = "United States of America", diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 9798b4e479..263319d4e5 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -21,7 +21,7 @@ using osu.Game.Screens.Tournament.Components; using osu.Game.Screens.Tournament.Teams; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Framework.IO.Stores; namespace osu.Game.Screens.Tournament { @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament private GroupContainer groupsContainer; private OsuSpriteText fullTeamNameText; - private readonly List allTeams = new List(); + private readonly List allTeams = new List(); private DrawingsConfigManager drawingsConfig; @@ -239,7 +239,7 @@ namespace osu.Game.Screens.Tournament reset(true); } - private void onTeamSelected(Country team) + private void onTeamSelected(Team team) { groupsContainer.AddTeam(team); @@ -276,7 +276,7 @@ namespace osu.Game.Screens.Tournament teamsContainer.ClearTeams(); allTeams.Clear(); - foreach (Country t in TeamList.Teams) + foreach (Team t in TeamList.Teams) { if (groupsContainer.ContainsTeam(t.FullName)) continue; @@ -312,7 +312,7 @@ namespace osu.Game.Screens.Tournament if (line.ToUpper().StartsWith("GROUP")) continue; - Country teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); + Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); if (teamToAdd == null) continue; diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 6847c97be8..697ae17e95 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -13,7 +13,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Country team) + public void AddTeam(Team team) { GroupTeam gt = new GroupTeam(team); @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Tournament return allTeams.Any(t => t.Team.FullName == fullName); } - public bool RemoveTeam(Country team) + public bool RemoveTeam(Team team) { allTeams.RemoveAll(gt => gt.Team == team); @@ -122,12 +122,12 @@ namespace osu.Game.Screens.Tournament private class GroupTeam : Container { - public readonly Country Team; + public readonly Team Team; private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Country team) + public GroupTeam(Team team) { Team = team; diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index a3c53f2076..bc4c3b71c3 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -8,7 +8,7 @@ using System.Text; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Country team) + public void AddTeam(Team team) { if (groups[currentGroup].TeamsCount == maxTeams) return; diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 5783893b3d..4ae26d3a67 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -15,16 +15,16 @@ using osu.Framework.Graphics.Transforms; using osu.Framework.Threading; using OpenTK; using OpenTK.Graphics; -using osu.Game.Users; +using osu.Game.Screens.Tournament.Teams; namespace osu.Game.Screens.Tournament { public class ScrollingTeamContainer : Container { public event Action OnScrollStarted; - public event Action OnSelected; + public event Action OnSelected; - private readonly List availableTeams = new List(); + private readonly List availableTeams = new List(); private readonly Container tracker; @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Country team) + public void AddTeam(Team team) { if (availableTeams.Contains(team)) return; @@ -169,12 +169,12 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void AddTeams(IEnumerable teams) + public void AddTeams(IEnumerable teams) { if (teams == null) return; - foreach (Country t in teams) + foreach (Team t in teams) AddTeam(t); } @@ -185,7 +185,7 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void RemoveTeam(Country team) + public void RemoveTeam(Team team) { availableTeams.Remove(team); @@ -270,7 +270,7 @@ namespace osu.Game.Screens.Tournament private void addFlags() { - foreach (Country t in availableTeams) + foreach (Team t in availableTeams) { Add(new ScrollingTeam(t) { @@ -320,7 +320,7 @@ namespace osu.Game.Screens.Tournament public const float WIDTH = 58; public const float HEIGHT = 41; - public Country Team; + public Team Team; private readonly Sprite flagSprite; private readonly Box outline; @@ -340,7 +340,7 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Country team) + public ScrollingTeam(Team team) { Team = team; diff --git a/osu.Game/Screens/Tournament/Teams/ITeamList.cs b/osu.Game/Screens/Tournament/Teams/ITeamList.cs index d4b644e2aa..a4476b64c6 100644 --- a/osu.Game/Screens/Tournament/Teams/ITeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/ITeamList.cs @@ -2,12 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { public interface ITeamList { - IEnumerable Teams { get; } + IEnumerable Teams { get; } } } diff --git a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs index 7dd333cdbc..3bca7f2937 100644 --- a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using osu.Framework.Logging; using osu.Framework.Platform; -using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { @@ -21,16 +20,16 @@ namespace osu.Game.Screens.Tournament.Teams this.storage = storage; } - public IEnumerable Teams + public IEnumerable Teams { get { - var teams = new List(); + var teams = new List(); try { using (Stream stream = storage.GetStream(teams_filename, FileAccess.Read, FileMode.Open)) - using (StreamReader sr = new StreamReader(stream)) + using (var sr = new StreamReader(stream)) { while (sr.Peek() != -1) { @@ -53,7 +52,7 @@ namespace osu.Game.Screens.Tournament.Teams string acronym = split.Length >= 3 ? split[2].Trim() : teamName; acronym = acronym.Substring(0, Math.Min(3, acronym.Length)); - teams.Add(new Country + teams.Add(new Team { FlagName = flagName, FullName = teamName, diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs new file mode 100644 index 0000000000..8da5cfa69e --- /dev/null +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Users; + +namespace osu.Game.Screens.Tournament.Teams +{ + public class Team : Country + { + /// + /// Short acronym which appears in the group boxes post-selection. + /// + public string Acronym; + } +} diff --git a/osu.Game/Users/Country.cs b/osu.Game/Users/Country.cs index 729629bdb8..ac95d22329 100644 --- a/osu.Game/Users/Country.cs +++ b/osu.Game/Users/Country.cs @@ -18,11 +18,6 @@ namespace osu.Game.Users [JsonProperty(@"name")] public string FullName; - /// - /// Short acronym which appears in the group boxes post-selection. - /// - public string Acronym; - /// /// Two-letter flag acronym (ISO 3166 standard) /// diff --git a/osu.Game/Users/Team.cs b/osu.Game/Users/Team.cs index 7d5c0322fe..fe94f26931 100644 --- a/osu.Game/Users/Team.cs +++ b/osu.Game/Users/Team.cs @@ -3,7 +3,7 @@ namespace osu.Game.Users { - public class Team + public class Team : Country { public string Name; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..0c41ec91bb 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -325,6 +325,7 @@ + From f17046abaf3e72ccd2d04cb066eceb951c4203f3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 13:23:09 +0900 Subject: [PATCH 02/11] Add ability to load Drawings flags from osu/Drawings/Flags. --- osu-framework | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 10 ++++++++-- osu.Game/Screens/Tournament/Group.cs | 14 +++++++++----- osu.Game/Screens/Tournament/GroupContainer.cs | 9 +++++++-- .../Tournament/ScrollingTeamContainer.cs | 18 +++++++++++++----- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/osu-framework b/osu-framework index b25ed4291b..a093c6cb70 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413 +Subproject commit a093c6cb70c145168ac359193e72176bf00ee20a diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 263319d4e5..4ef3face07 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -52,6 +52,12 @@ namespace osu.Game.Screens.Tournament { this.storage = storage; + // Todo: The way this is done is a haaaaaaaaaaaaaaack. + // Currently this store is being passed down all the way to ScrollingTeam/GroupTeam + // but it should replace the TextureStore DI item instead. This is pending some significant DI improvements. + TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + flagStore.AddStore(textures); + if (TeamList == null) TeamList = new StorageBackedTeamList(storage); @@ -104,7 +110,7 @@ namespace osu.Game.Screens.Tournament Lines = 6 }, // Groups - groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup)) + groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup), flagStore) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -119,7 +125,7 @@ namespace osu.Game.Screens.Tournament } }, // Scrolling teams - teamsContainer = new ScrollingTeamContainer + teamsContainer = new ScrollingTeamContainer(flagStore) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 697ae17e95..36b8b29e26 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,9 +73,9 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team) + public void AddTeam(Team team, TextureStore flagStore) { - GroupTeam gt = new GroupTeam(team); + GroupTeam gt = new GroupTeam(team, flagStore); if (TeamsCount < 8) { @@ -127,8 +127,12 @@ namespace osu.Game.Screens.Tournament private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Team team) + private readonly TextureStore flagStore; + + public GroupTeam(Team team, TextureStore flagStore) { + this.flagStore = flagStore; + Team = team; Width = 36; @@ -178,9 +182,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load() { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index bc4c3b71c3..e789c871b7 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Screens.Tournament.Teams; +using osu.Framework.Graphics.Textures; namespace osu.Game.Screens.Tournament { @@ -19,8 +20,12 @@ namespace osu.Game.Screens.Tournament private readonly int maxTeams; private int currentGroup; - public GroupContainer(int numGroups, int teamsPerGroup) + private readonly TextureStore flagStore; + + public GroupContainer(int numGroups, int teamsPerGroup, TextureStore flagStore) { + this.flagStore = flagStore; + FlowContainer bottomGroups; FlowContainer topGroups; @@ -69,7 +74,7 @@ namespace osu.Game.Screens.Tournament if (groups[currentGroup].TeamsCount == maxTeams) return; - groups[currentGroup].AddTeam(team); + groups[currentGroup].AddTeam(team, flagStore); currentGroup = (currentGroup + 1) % groups.Count; } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 4ae26d3a67..d46edd48f1 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -39,8 +39,12 @@ namespace osu.Game.Screens.Tournament private ScheduledDelegate delayedStateChangeDelegate; - public ScrollingTeamContainer() + private TextureStore flagStore; + + public ScrollingTeamContainer(TextureStore flagStore) { + this.flagStore = flagStore; + AutoSizeAxes = Axes.Y; Children = new Drawable[] @@ -272,7 +276,7 @@ namespace osu.Game.Screens.Tournament { foreach (Team t in availableTeams) { - Add(new ScrollingTeam(t) + Add(new ScrollingTeam(t, flagStore) { X = leftPos + DrawWidth }); @@ -340,8 +344,12 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Team team) + private TextureStore flagStore; + + public ScrollingTeam(Team team, TextureStore flagStore) { + this.flagStore = flagStore; + Team = team; Anchor = Anchor.CentreLeft; @@ -371,9 +379,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load(TextureStore textures) + private void load() { - flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); } } } From 91e000fd44d128d74a1d3ecd7ff1bd2fc9d228b2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 14:21:22 +0900 Subject: [PATCH 03/11] Back to sanity. --- osu-framework | 2 +- osu.Game/Screens/Tournament/Drawings.cs | 13 +++++++------ osu.Game/Screens/Tournament/Group.cs | 14 +++++--------- osu.Game/Screens/Tournament/GroupContainer.cs | 8 ++------ .../Tournament/ScrollingTeamContainer.cs | 18 +++++------------- 5 files changed, 20 insertions(+), 35 deletions(-) diff --git a/osu-framework b/osu-framework index a093c6cb70..cc69416da0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a093c6cb70c145168ac359193e72176bf00ee20a +Subproject commit cc69416da0e6b04c9a372ac821bfe201cec0d174 diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 4ef3face07..da36e8b5c7 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -47,17 +47,18 @@ namespace osu.Game.Screens.Tournament public ITeamList TeamList; + protected override DependencyContainer CreateLocalDependencies(DependencyContainer parent) => new DependencyContainer(parent); + [BackgroundDependencyLoader] - private void load(TextureStore textures, Storage storage) + private void load(TextureStore textures, Storage storage, DependencyContainer dependencies) { this.storage = storage; - // Todo: The way this is done is a haaaaaaaaaaaaaaack. - // Currently this store is being passed down all the way to ScrollingTeam/GroupTeam - // but it should replace the TextureStore DI item instead. This is pending some significant DI improvements. TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); flagStore.AddStore(textures); + dependencies.Cache(flagStore); + if (TeamList == null) TeamList = new StorageBackedTeamList(storage); @@ -110,7 +111,7 @@ namespace osu.Game.Screens.Tournament Lines = 6 }, // Groups - groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup), flagStore) + groupsContainer = new GroupContainer(drawingsConfig.Get(DrawingsConfig.Groups), drawingsConfig.Get(DrawingsConfig.TeamsPerGroup)) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -125,7 +126,7 @@ namespace osu.Game.Screens.Tournament } }, // Scrolling teams - teamsContainer = new ScrollingTeamContainer(flagStore) + teamsContainer = new ScrollingTeamContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 36b8b29e26..697ae17e95 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,9 +73,9 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team, TextureStore flagStore) + public void AddTeam(Team team) { - GroupTeam gt = new GroupTeam(team, flagStore); + GroupTeam gt = new GroupTeam(team); if (TeamsCount < 8) { @@ -127,12 +127,8 @@ namespace osu.Game.Screens.Tournament private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - private readonly TextureStore flagStore; - - public GroupTeam(Team team, TextureStore flagStore) + public GroupTeam(Team team) { - this.flagStore = flagStore; - Team = team; Width = 36; @@ -182,9 +178,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load() + private void load(TextureStore textures) { - flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index e789c871b7..52ae53e24f 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -20,12 +20,8 @@ namespace osu.Game.Screens.Tournament private readonly int maxTeams; private int currentGroup; - private readonly TextureStore flagStore; - - public GroupContainer(int numGroups, int teamsPerGroup, TextureStore flagStore) + public GroupContainer(int numGroups, int teamsPerGroup) { - this.flagStore = flagStore; - FlowContainer bottomGroups; FlowContainer topGroups; @@ -74,7 +70,7 @@ namespace osu.Game.Screens.Tournament if (groups[currentGroup].TeamsCount == maxTeams) return; - groups[currentGroup].AddTeam(team, flagStore); + groups[currentGroup].AddTeam(team); currentGroup = (currentGroup + 1) % groups.Count; } diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index d46edd48f1..4ae26d3a67 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -39,12 +39,8 @@ namespace osu.Game.Screens.Tournament private ScheduledDelegate delayedStateChangeDelegate; - private TextureStore flagStore; - - public ScrollingTeamContainer(TextureStore flagStore) + public ScrollingTeamContainer() { - this.flagStore = flagStore; - AutoSizeAxes = Axes.Y; Children = new Drawable[] @@ -276,7 +272,7 @@ namespace osu.Game.Screens.Tournament { foreach (Team t in availableTeams) { - Add(new ScrollingTeam(t, flagStore) + Add(new ScrollingTeam(t) { X = leftPos + DrawWidth }); @@ -344,12 +340,8 @@ namespace osu.Game.Screens.Tournament } } - private TextureStore flagStore; - - public ScrollingTeam(Team team, TextureStore flagStore) + public ScrollingTeam(Team team) { - this.flagStore = flagStore; - Team = team; Anchor = Anchor.CentreLeft; @@ -379,9 +371,9 @@ namespace osu.Game.Screens.Tournament } [BackgroundDependencyLoader] - private void load() + private void load(TextureStore textures) { - flagSprite.Texture = flagStore.Get($@"Flags/{Team.FlagName}"); + flagSprite.Texture = textures.Get($@"Flags/{Team.FlagName}"); } } } From ee0a5409bbbf674a34836a9b9595669b2acb4607 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:33:48 +0900 Subject: [PATCH 04/11] CI fixes. --- osu.Game/Screens/Tournament/GroupContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index 52ae53e24f..bc4c3b71c3 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Screens.Tournament.Teams; -using osu.Framework.Graphics.Textures; namespace osu.Game.Screens.Tournament { From e2620e2840d33312be919b4be23d939f3f61737f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:54:43 +0900 Subject: [PATCH 05/11] Make Team not inherit Country. --- osu.Game/Screens/Tournament/Teams/Team.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs index 8da5cfa69e..cfb35d58f2 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -5,11 +5,21 @@ using osu.Game.Users; namespace osu.Game.Screens.Tournament.Teams { - public class Team : Country + public class Team { + /// + /// The name of this team. + /// + public string FullName; + /// /// Short acronym which appears in the group boxes post-selection. /// public string Acronym; + + /// + /// Name of the file containing the flag. + /// + public string FlagName; } } From 40d2fee1dc1f2412d2f658c134e0ad33b1915320 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 16:55:04 +0900 Subject: [PATCH 06/11] Split up adding of local store from the ctor. --- osu.Game/Screens/Tournament/Drawings.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index da36e8b5c7..ef32ce39cb 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -54,7 +54,10 @@ namespace osu.Game.Screens.Tournament { this.storage = storage; - TextureStore flagStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + TextureStore flagStore = new TextureStore(); + // Local flag store + flagStore.AddStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); + /// Default texture store flagStore.AddStore(textures); dependencies.Cache(flagStore); From 9ca82951499d5bba365e41af3c9543005b2ce741 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 17:09:16 +0900 Subject: [PATCH 07/11] Oops. --- osu.Game/Screens/Tournament/Drawings.cs | 2 +- osu.Game/Screens/Tournament/Teams/Team.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index ef32ce39cb..924e7adac4 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Tournament TextureStore flagStore = new TextureStore(); // Local flag store flagStore.AddStore(new RawTextureLoaderStore(new NamespacedResourceStore(new StorageBackedResourceStore(storage), "Drawings"))); - /// Default texture store + // Default texture store flagStore.AddStore(textures); dependencies.Cache(flagStore); diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/Team.cs index cfb35d58f2..5ffee1fc37 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/Team.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Game.Users; - namespace osu.Game.Screens.Tournament.Teams { public class Team From f1f7a26dbde356fe16e97f82311d1f41d0814f4f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 17:58:59 +0900 Subject: [PATCH 08/11] Fix incorrect inheritance. --- osu.Game/Users/Team.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Users/Team.cs b/osu.Game/Users/Team.cs index fe94f26931..7d5c0322fe 100644 --- a/osu.Game/Users/Team.cs +++ b/osu.Game/Users/Team.cs @@ -3,7 +3,7 @@ namespace osu.Game.Users { - public class Team : Country + public class Team { public string Name; } From 8e88d86639989520c65fceb34d01bb99a5175097 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 2 May 2017 18:00:37 +0900 Subject: [PATCH 09/11] Fix naming confusion. --- .../Tests/TestCaseDrawings.cs | 20 +++++++++---------- osu.Game/Screens/Tournament/Drawings.cs | 8 ++++---- osu.Game/Screens/Tournament/Group.cs | 8 ++++---- osu.Game/Screens/Tournament/GroupContainer.cs | 2 +- .../Tournament/ScrollingTeamContainer.cs | 18 ++++++++--------- .../Teams/{Team.cs => DrawingsTeam.cs} | 2 +- .../Screens/Tournament/Teams/ITeamList.cs | 2 +- .../Tournament/Teams/StorageBackedTeamList.cs | 6 +++--- osu.Game/osu.Game.csproj | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) rename osu.Game/Screens/Tournament/Teams/{Team.cs => DrawingsTeam.cs} (91%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index c4771a2913..ebc9930f93 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -24,57 +24,57 @@ namespace osu.Desktop.VisualTests.Tests private class TestTeamList : ITeamList { - public IEnumerable Teams { get; } = new[] + public IEnumerable Teams { get; } = new[] { - new Team + new DrawingsTeam { FlagName = "GB", FullName = "United Kingdom", Acronym = "UK" }, - new Team + new DrawingsTeam { FlagName = "FR", FullName = "France", Acronym = "FRA" }, - new Team + new DrawingsTeam { FlagName = "CN", FullName = "China", Acronym = "CHN" }, - new Team + new DrawingsTeam { FlagName = "AU", FullName = "Australia", Acronym = "AUS" }, - new Team + new DrawingsTeam { FlagName = "JP", FullName = "Japan", Acronym = "JPN" }, - new Team + new DrawingsTeam { FlagName = "RO", FullName = "Romania", Acronym = "ROM" }, - new Team + new DrawingsTeam { FlagName = "IT", FullName = "Italy", Acronym = "PIZZA" }, - new Team + new DrawingsTeam { FlagName = "VE", FullName = "Venezuela", Acronym = "VNZ" }, - new Team + new DrawingsTeam { FlagName = "US", FullName = "United States of America", diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 924e7adac4..eada42a53e 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Tournament private GroupContainer groupsContainer; private OsuSpriteText fullTeamNameText; - private readonly List allTeams = new List(); + private readonly List allTeams = new List(); private DrawingsConfigManager drawingsConfig; @@ -249,7 +249,7 @@ namespace osu.Game.Screens.Tournament reset(true); } - private void onTeamSelected(Team team) + private void onTeamSelected(DrawingsTeam team) { groupsContainer.AddTeam(team); @@ -286,7 +286,7 @@ namespace osu.Game.Screens.Tournament teamsContainer.ClearTeams(); allTeams.Clear(); - foreach (Team t in TeamList.Teams) + foreach (DrawingsTeam t in TeamList.Teams) { if (groupsContainer.ContainsTeam(t.FullName)) continue; @@ -322,7 +322,7 @@ namespace osu.Game.Screens.Tournament if (line.ToUpper().StartsWith("GROUP")) continue; - Team teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); + DrawingsTeam teamToAdd = allTeams.FirstOrDefault(t => t.FullName == line); if (teamToAdd == null) continue; diff --git a/osu.Game/Screens/Tournament/Group.cs b/osu.Game/Screens/Tournament/Group.cs index 697ae17e95..f5695ae1cb 100644 --- a/osu.Game/Screens/Tournament/Group.cs +++ b/osu.Game/Screens/Tournament/Group.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.Tournament }; } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { GroupTeam gt = new GroupTeam(team); @@ -91,7 +91,7 @@ namespace osu.Game.Screens.Tournament return allTeams.Any(t => t.Team.FullName == fullName); } - public bool RemoveTeam(Team team) + public bool RemoveTeam(DrawingsTeam team) { allTeams.RemoveAll(gt => gt.Team == team); @@ -122,12 +122,12 @@ namespace osu.Game.Screens.Tournament private class GroupTeam : Container { - public readonly Team Team; + public readonly DrawingsTeam Team; private readonly FillFlowContainer innerContainer; private readonly Sprite flagSprite; - public GroupTeam(Team team) + public GroupTeam(DrawingsTeam team) { Team = team; diff --git a/osu.Game/Screens/Tournament/GroupContainer.cs b/osu.Game/Screens/Tournament/GroupContainer.cs index bc4c3b71c3..ba73a61c92 100644 --- a/osu.Game/Screens/Tournament/GroupContainer.cs +++ b/osu.Game/Screens/Tournament/GroupContainer.cs @@ -64,7 +64,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { if (groups[currentGroup].TeamsCount == maxTeams) return; diff --git a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs index 4ae26d3a67..3eea239f55 100644 --- a/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs +++ b/osu.Game/Screens/Tournament/ScrollingTeamContainer.cs @@ -22,9 +22,9 @@ namespace osu.Game.Screens.Tournament public class ScrollingTeamContainer : Container { public event Action OnScrollStarted; - public event Action OnSelected; + public event Action OnSelected; - private readonly List availableTeams = new List(); + private readonly List availableTeams = new List(); private readonly Container tracker; @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Tournament } } - public void AddTeam(Team team) + public void AddTeam(DrawingsTeam team) { if (availableTeams.Contains(team)) return; @@ -169,12 +169,12 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void AddTeams(IEnumerable teams) + public void AddTeams(IEnumerable teams) { if (teams == null) return; - foreach (Team t in teams) + foreach (DrawingsTeam t in teams) AddTeam(t); } @@ -185,7 +185,7 @@ namespace osu.Game.Screens.Tournament scrollState = ScrollState.Idle; } - public void RemoveTeam(Team team) + public void RemoveTeam(DrawingsTeam team) { availableTeams.Remove(team); @@ -270,7 +270,7 @@ namespace osu.Game.Screens.Tournament private void addFlags() { - foreach (Team t in availableTeams) + foreach (DrawingsTeam t in availableTeams) { Add(new ScrollingTeam(t) { @@ -320,7 +320,7 @@ namespace osu.Game.Screens.Tournament public const float WIDTH = 58; public const float HEIGHT = 41; - public Team Team; + public DrawingsTeam Team; private readonly Sprite flagSprite; private readonly Box outline; @@ -340,7 +340,7 @@ namespace osu.Game.Screens.Tournament } } - public ScrollingTeam(Team team) + public ScrollingTeam(DrawingsTeam team) { Team = team; diff --git a/osu.Game/Screens/Tournament/Teams/Team.cs b/osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs similarity index 91% rename from osu.Game/Screens/Tournament/Teams/Team.cs rename to osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs index 5ffee1fc37..2739711c35 100644 --- a/osu.Game/Screens/Tournament/Teams/Team.cs +++ b/osu.Game/Screens/Tournament/Teams/DrawingsTeam.cs @@ -3,7 +3,7 @@ namespace osu.Game.Screens.Tournament.Teams { - public class Team + public class DrawingsTeam { /// /// The name of this team. diff --git a/osu.Game/Screens/Tournament/Teams/ITeamList.cs b/osu.Game/Screens/Tournament/Teams/ITeamList.cs index a4476b64c6..9427ebc7fb 100644 --- a/osu.Game/Screens/Tournament/Teams/ITeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/ITeamList.cs @@ -7,6 +7,6 @@ namespace osu.Game.Screens.Tournament.Teams { public interface ITeamList { - IEnumerable Teams { get; } + IEnumerable Teams { get; } } } diff --git a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs index 3bca7f2937..1b2d84a666 100644 --- a/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs +++ b/osu.Game/Screens/Tournament/Teams/StorageBackedTeamList.cs @@ -20,11 +20,11 @@ namespace osu.Game.Screens.Tournament.Teams this.storage = storage; } - public IEnumerable Teams + public IEnumerable Teams { get { - var teams = new List(); + var teams = new List(); try { @@ -52,7 +52,7 @@ namespace osu.Game.Screens.Tournament.Teams string acronym = split.Length >= 3 ? split[2].Trim() : teamName; acronym = acronym.Substring(0, Math.Min(3, acronym.Length)); - teams.Add(new Team + teams.Add(new DrawingsTeam { FlagName = flagName, FullName = teamName, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0c41ec91bb..907ba0cd95 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -325,7 +325,7 @@ - + From 60c2e2a90af53a2315cab5cc8a6603a03df7f8fd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 11:22:09 +0900 Subject: [PATCH 10/11] Fix taiko auto replay generation not working. --- osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs | 2 +- .../{TaikoAutoReplay.cs => TaikoAutoGenerator.cs} | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) rename osu.Game.Rulesets.Taiko/Replays/{TaikoAutoReplay.cs => TaikoAutoGenerator.cs} (90%) diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs index 44430fe6bc..8b7a099b9a 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoMod.cs @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Mods protected override Score CreateReplayScore(Beatmap beatmap) => new Score { User = new User { Username = "mekkadosu!" }, - Replay = new TaikoAutoReplay(beatmap).Generate(), + Replay = new TaikoAutoGenerator(beatmap).Generate(), }; } } diff --git a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs similarity index 90% rename from osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs rename to osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs index 0af8e2822b..eec614426f 100644 --- a/osu.Game.Rulesets.Taiko/Replays/TaikoAutoReplay.cs +++ b/osu.Game.Rulesets.Taiko/Replays/TaikoAutoGenerator.cs @@ -7,16 +7,24 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Replays; +using osu.Game.Users; namespace osu.Game.Rulesets.Taiko.Replays { - public class TaikoAutoReplay : AutoGenerator + public class TaikoAutoGenerator : AutoGenerator { private const double swell_hit_speed = 50; - public TaikoAutoReplay(Beatmap beatmap) + public TaikoAutoGenerator(Beatmap beatmap) : base(beatmap) { + Replay = new Replay + { + User = new User + { + Username = @"Autoplay", + } + }; } protected Replay Replay; From 4d27e0abb6140107f5a6710db082a37011d235f2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 11:25:54 +0900 Subject: [PATCH 11/11] Oops i didn't save the solution. --- osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj index f890e32f90..983dc72d9e 100644 --- a/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj +++ b/osu.Game.Rulesets.Taiko/osu.Game.Rulesets.Taiko.csproj @@ -79,7 +79,7 @@ - +