2019-03-04 12:24:19 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-11-11 09:39:04 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-03-02 12:40:43 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-11-11 09:39:04 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Tournament.Components;
|
2019-06-18 13:51:48 +08:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-11-11 09:39:04 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Screens.TeamWin
|
|
|
|
{
|
|
|
|
public class TeamWinScreen : TournamentScreen, IProvideVideo
|
|
|
|
{
|
|
|
|
private Container mainContainer;
|
|
|
|
|
2019-06-18 13:57:05 +08:00
|
|
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
2018-11-11 09:39:04 +08:00
|
|
|
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
|
|
|
|
|
2019-06-17 20:07:30 +08:00
|
|
|
private TourneyVideo blueWinVideo;
|
|
|
|
private TourneyVideo redWinVideo;
|
2018-11-11 09:39:04 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-02-17 18:48:54 +08:00
|
|
|
private void load(LadderInfo ladder, Storage storage)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-03-03 18:10:29 +08:00
|
|
|
blueWinVideo = new TourneyVideo(storage.GetStream(@"videos/teamwin-blue.m4v"))
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
Alpha = 1,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Loop = true,
|
|
|
|
},
|
2020-03-03 18:10:29 +08:00
|
|
|
redWinVideo = new TourneyVideo(storage.GetStream(@"videos/teamwin-red.m4v"))
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
Alpha = 0,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Loop = true,
|
|
|
|
},
|
|
|
|
mainContainer = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
currentMatch.BindValueChanged(matchChanged);
|
|
|
|
currentMatch.BindTo(ladder.CurrentMatch);
|
|
|
|
|
|
|
|
currentCompleted.BindValueChanged(_ => update());
|
|
|
|
}
|
|
|
|
|
2019-06-18 13:57:05 +08:00
|
|
|
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
currentCompleted.UnbindBindings();
|
2019-06-18 13:57:05 +08:00
|
|
|
currentCompleted.BindTo(match.NewValue.Completed);
|
2018-11-11 09:39:04 +08:00
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void update()
|
|
|
|
{
|
2019-06-18 13:57:05 +08:00
|
|
|
var match = currentMatch.Value;
|
2018-11-11 09:39:04 +08:00
|
|
|
|
2019-06-18 13:57:05 +08:00
|
|
|
if (match.Winner == null)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
mainContainer.Clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-18 13:57:05 +08:00
|
|
|
bool redWin = match.Winner == match.Team1.Value;
|
2018-11-11 09:39:04 +08:00
|
|
|
redWinVideo.Alpha = redWin ? 1 : 0;
|
|
|
|
blueWinVideo.Alpha = redWin ? 0 : 1;
|
|
|
|
|
|
|
|
mainContainer.Children = new Drawable[]
|
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
new TeamFlagDisplay(match.Winner)
|
|
|
|
{
|
|
|
|
Size = new Vector2(300, 200),
|
|
|
|
Scale = new Vector2(0.5f),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
X = -387,
|
|
|
|
},
|
|
|
|
new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Position = new Vector2(78, -70),
|
|
|
|
Colour = OsuColour.Gray(0.33f),
|
|
|
|
Text = match.Round.Value?.Name.Value ?? "Unknown Round",
|
|
|
|
Font = OsuFont.Torus.With(size: 30, weight: FontWeight.Regular)
|
|
|
|
},
|
2019-06-18 13:57:05 +08:00
|
|
|
new TeamWithPlayers(match.Winner, redWin)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Width = 0.5f,
|
|
|
|
Height = 0.6f,
|
|
|
|
Anchor = Anchor.Centre,
|
2020-03-03 18:14:44 +08:00
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Position = new Vector2(78, 0),
|
2018-11-11 09:39:04 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-03-03 18:14:44 +08:00
|
|
|
private class TeamWithPlayers : CompositeDrawable
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
public TeamWithPlayers(TournamentTeam team, bool left = false)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
FillFlowContainer players;
|
2018-11-11 09:39:04 +08:00
|
|
|
|
2020-03-03 18:14:44 +08:00
|
|
|
var colour = left ? TournamentGame.COLOUR_RED : TournamentGame.COLOUR_BLUE;
|
2018-11-11 09:39:04 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
2020-03-03 18:14:44 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
2018-11-11 09:39:04 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
new TournamentSpriteText
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
Text = "WINNER",
|
2020-03-03 18:14:44 +08:00
|
|
|
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold),
|
|
|
|
Colour = Color4.Black,
|
2018-11-11 09:39:04 +08:00
|
|
|
},
|
2020-03-03 18:14:44 +08:00
|
|
|
new TournamentSpriteText
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
Text = team?.FullName.Value ?? "???",
|
|
|
|
Font = OsuFont.Torus.With(size: 30, weight: FontWeight.SemiBold),
|
|
|
|
Colour = Color4.Black,
|
2018-11-11 09:39:04 +08:00
|
|
|
},
|
2020-03-03 18:14:44 +08:00
|
|
|
players = new FillFlowContainer
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Top = 10 },
|
2018-11-11 09:39:04 +08:00
|
|
|
},
|
|
|
|
}
|
2020-03-03 18:14:44 +08:00
|
|
|
},
|
2018-11-11 09:39:04 +08:00
|
|
|
};
|
2020-03-03 18:14:44 +08:00
|
|
|
|
|
|
|
if (team != null)
|
|
|
|
{
|
|
|
|
foreach (var p in team.Players)
|
|
|
|
{
|
|
|
|
players.Add(new TournamentSpriteText
|
|
|
|
{
|
|
|
|
Text = p.Username,
|
|
|
|
Font = OsuFont.Torus.With(size: 24),
|
|
|
|
Colour = colour,
|
|
|
|
Anchor = left ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
|
|
Origin = left ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-11-11 09:39:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 18:14:44 +08:00
|
|
|
private class TeamFlagDisplay : DrawableTournamentTeam
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
public TeamFlagDisplay(TournamentTeam team)
|
|
|
|
: base(team)
|
2018-11-11 09:39:04 +08:00
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-03-03 18:14:44 +08:00
|
|
|
Flag
|
2018-11-11 09:39:04 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|