From 53ec01d51f972c7117f56d8c9b0577f86ad89beb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Nov 2018 20:18:11 +0900 Subject: [PATCH] Perform mappings earlier in execution --- .../TestCaseTeamIntro.cs | 2 +- .../Screens/Ladder/LadderManager.cs | 29 --------------- osu.Game.Tournament/TournamentGameBase.cs | 35 +++++++++++++++++-- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs index 6fab1fd875..004009f269 100644 --- a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs +++ b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tournament.Tests pairing.Grouping.Value = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals"); currentMatch.Value = pairing; - Add(new TeamIntroScreen() + Add(new TeamIntroScreen { FillMode = FillMode.Fit, FillAspectRatio = 16 / 9f diff --git a/osu.Game.Tournament/Screens/Ladder/LadderManager.cs b/osu.Game.Tournament/Screens/Ladder/LadderManager.cs index ebac91c4f7..2ad296dd77 100644 --- a/osu.Game.Tournament/Screens/Ladder/LadderManager.cs +++ b/osu.Game.Tournament/Screens/Ladder/LadderManager.cs @@ -1,7 +1,6 @@ // 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 System.Linq; using osu.Framework.Allocation; @@ -67,37 +66,9 @@ namespace osu.Game.Tournament.Screens.Ladder } }; - // assign teams - foreach (var pairing in info.Pairings) - { - pairing.Team1.Value = info.Teams.FirstOrDefault(t => t.Acronym == pairing.Team1Acronym); - pairing.Team2.Value = info.Teams.FirstOrDefault(t => t.Acronym == pairing.Team2Acronym); - } - - // assign progressions - foreach (var pair in info.Progressions) - { - var src = info.Pairings.FirstOrDefault(p => p.ID == pair.Item1); - var dest = info.Pairings.FirstOrDefault(p => p.ID == pair.Item2); - - if (src == null) throw new InvalidOperationException(); - - if (dest != null) - { - if (pair.Losers) - src.LosersProgression.Value = dest; - else - src.Progression.Value = dest; - } - } - foreach (var pairing in info.Pairings) addPairing(pairing); - foreach (var group in info.Groupings) - foreach (var id in group.Pairings) - info.Pairings.Single(p => p.ID == id).Grouping.Value = group; - // todo: fix this Scheduler.AddDelayed(() => layout.Invalidate(), 100, true); } diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index 9e9ed58297..f7b829b4c7 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.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.Drawing; using System.IO; using System.Linq; @@ -56,13 +57,38 @@ namespace osu.Game.Tournament Ladder = content != null ? JsonConvert.DeserializeObject(content) : new LadderInfo(); - //todo: temp - currentMatch.Value = Ladder.Pairings.FirstOrDefault(); - dependencies.Cache(Ladder); bool addedInfo = false; + // assign teams + foreach (var pairing in Ladder.Pairings) + { + pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team1Acronym); + pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == pairing.Team2Acronym); + } + + // assign progressions + foreach (var pair in Ladder.Progressions) + { + var src = Ladder.Pairings.FirstOrDefault(p => p.ID == pair.Item1); + var dest = Ladder.Pairings.FirstOrDefault(p => p.ID == pair.Item2); + + if (src == null) throw new InvalidOperationException(); + + if (dest != null) + { + if (pair.Losers) + src.LosersProgression.Value = dest; + else + src.Progression.Value = dest; + } + } + + foreach (var group in Ladder.Groupings) + foreach (var id in group.Pairings) + Ladder.Pairings.Single(p => p.ID == id).Grouping.Value = group; + foreach (var g in Ladder.Groupings) foreach (var b in g.Beatmaps) if (b.BeatmapInfo == null) @@ -74,6 +100,9 @@ namespace osu.Game.Tournament addedInfo = true; } + //todo: temp + currentMatch.Value = Ladder.Pairings.FirstOrDefault(); + if (addedInfo) SaveChanges();