1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Add the concept of "current match"

This commit is contained in:
Dean Herbert 2018-11-06 20:13:04 +09:00
parent 3427127589
commit 4e87288049
3 changed files with 41 additions and 22 deletions

View File

@ -3,22 +3,28 @@
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Tournament.Screens.TeamIntro; using osu.Game.Tournament.Screens.TeamIntro;
namespace osu.Game.Tournament.Tests namespace osu.Game.Tournament.Tests
{ {
public class TestCaseTeamIntro : LadderTestCase public class TestCaseTeamIntro : LadderTestCase
{ {
[Cached]
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
var team1 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "USA"); var pairing = new MatchPairing();
var team2 = Ladder.Teams.FirstOrDefault(t => t.Acronym == "JPN"); 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()
Add(new TeamIntroScreen(team1, team2, round)
{ {
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
FillAspectRatio = 16 / 9f FillAspectRatio = 16 / 9f

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Video; using osu.Framework.Graphics.Video;
@ -19,30 +20,34 @@ namespace osu.Game.Tournament.Screens.TeamIntro
{ {
public class TeamIntroScreen : OsuScreen public class TeamIntroScreen : OsuScreen
{ {
private readonly TournamentTeam team1; private VideoSprite background;
private readonly TournamentTeam team2;
private readonly TournamentGrouping round;
public TeamIntroScreen(TournamentTeam team1, TournamentTeam team2, TournamentGrouping round) [Resolved]
{ private Bindable<MatchPairing> currentMatch { get; set; }
this.team1 = team1;
this.team2 = team2;
this.round = round;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(Storage storage) private void load(Storage storage)
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[] background = new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
{
new VideoSprite(storage.GetStream(@"BG Team - Both OWC.m4v"))
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Loop = true, Loop = true,
}, };
new TeamWithPlayers(team1, true)
currentMatch.BindValueChanged(matchChanged, true);
}
private void matchChanged(MatchPairing pairing)
{
if (pairing == null)
return;
InternalChildren = new Drawable[]
{
background,
new TeamWithPlayers(pairing.Team1, true)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Width = 0.5f, Width = 0.5f,
@ -50,7 +55,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.CentreRight Origin = Anchor.CentreRight
}, },
new TeamWithPlayers(team2) new TeamWithPlayers(pairing.Team2)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Width = 0.5f, Width = 0.5f,
@ -58,7 +63,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft Origin = Anchor.CentreLeft
}, },
new RoundDisplay(round) new RoundDisplay(pairing.Grouping)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Height = 0.25f, Height = 0.25f,

View File

@ -3,6 +3,7 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
@ -28,6 +29,9 @@ namespace osu.Game.Tournament
[Cached] [Cached]
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>(); private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
[Cached]
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
private Bindable<Size> windowSize; private Bindable<Size> windowSize;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -51,6 +55,10 @@ namespace osu.Game.Tournament
} }
Ladder = content != null ? JsonConvert.DeserializeObject<LadderInfo>(content) : new LadderInfo(); Ladder = content != null ? JsonConvert.DeserializeObject<LadderInfo>(content) : new LadderInfo();
//todo: temp
currentMatch.Value = Ladder.Pairings.FirstOrDefault();
dependencies.Cache(Ladder); dependencies.Cache(Ladder);
bool addedInfo = false; bool addedInfo = false;