diff --git a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs index 845f5638a0..6fab1fd875 100644 --- a/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs +++ b/osu.Game.Tournament.Tests/TestCaseTeamIntro.cs @@ -3,22 +3,28 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Game.Tournament.Screens.Ladder.Components; using osu.Game.Tournament.Screens.TeamIntro; namespace osu.Game.Tournament.Tests { public class TestCaseTeamIntro : LadderTestCase { + [Cached] + private readonly Bindable currentMatch = new Bindable(); + [BackgroundDependencyLoader] private void load() { - var team1 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA"); - var team2 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN"); + var pairing = new MatchPairing(); + pairing.Team1.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA"); + pairing.Team2.Value = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN"); + pairing.Grouping.Value = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals"); + currentMatch.Value = pairing; - var round = Ladder.Groupings.FirstOrDefault(g => g.Name == "Finals"); - - Add(new TeamIntroScreen(team1, team2, round) + Add(new TeamIntroScreen() { FillMode = FillMode.Fit, FillAspectRatio = 16 / 9f diff --git a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs index 2c50970624..4b5e9aaf09 100644 --- a/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs +++ b/osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs @@ -3,6 +3,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Video; @@ -19,30 +20,34 @@ namespace osu.Game.Tournament.Screens.TeamIntro { public class TeamIntroScreen : OsuScreen { - private readonly TournamentTeam team1; - private readonly TournamentTeam team2; - private readonly TournamentGrouping round; + private VideoSprite background; - public TeamIntroScreen(TournamentTeam team1, TournamentTeam team2, TournamentGrouping round) - { - this.team1 = team1; - this.team2 = team2; - this.round = round; - } + [Resolved] + private Bindable currentMatch { get; set; } [BackgroundDependencyLoader] private void load(Storage storage) { RelativeSizeAxes = Axes.Both; + background = new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v")) + { + RelativeSizeAxes = Axes.Both, + Loop = true, + }; + + currentMatch.BindValueChanged(matchChanged, true); + } + + private void matchChanged(MatchPairing pairing) + { + if (pairing == null) + return; + InternalChildren = new Drawable[] { - new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v")) - { - RelativeSizeAxes = Axes.Both, - Loop = true, - }, - new TeamWithPlayers(team1, true) + background, + new TeamWithPlayers(pairing.Team1, true) { RelativeSizeAxes = Axes.Both, Width = 0.5f, @@ -50,7 +55,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.Centre, Origin = Anchor.CentreRight }, - new TeamWithPlayers(team2) + new TeamWithPlayers(pairing.Team2) { RelativeSizeAxes = Axes.Both, Width = 0.5f, @@ -58,7 +63,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro Anchor = Anchor.Centre, Origin = Anchor.CentreLeft }, - new RoundDisplay(round) + new RoundDisplay(pairing.Grouping) { RelativeSizeAxes = Axes.Both, Height = 0.25f, diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index cbb7a9fd35..9e9ed58297 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -3,6 +3,7 @@ using System.Drawing; using System.IO; +using System.Linq; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -28,6 +29,9 @@ namespace osu.Game.Tournament [Cached] private readonly Bindable ruleset = new Bindable(); + [Cached] + private readonly Bindable currentMatch = new Bindable(); + private Bindable windowSize; protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) @@ -51,6 +55,10 @@ 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;