1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 10:52:54 +08:00
osu-lazer/osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs

226 lines
8.4 KiB
C#
Raw Normal View History

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.Graphics.Sprites;
using osu.Game.Tournament.Components;
2019-06-18 13:51:48 +08:00
using osu.Game.Tournament.Models;
2018-11-11 09:39:04 +08:00
using osu.Game.Tournament.Screens.Showcase;
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>();
private TourneyVideo blueWinVideo;
private TourneyVideo redWinVideo;
2018-11-11 09:39:04 +08:00
[BackgroundDependencyLoader]
private void load(LadderInfo ladder, Storage storage)
2018-11-11 09:39:04 +08:00
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
blueWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Blue.m4v"))
2018-11-11 09:39:04 +08:00
{
Alpha = 1,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
redWinVideo = new TourneyVideo(storage.GetStream(@"BG Team - Win Red.m4v"))
2018-11-11 09:39:04 +08:00
{
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Loop = true,
},
new TournamentLogo(false)
2018-11-11 09:39:04 +08:00
{
Y = 40,
},
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[]
{
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,
Origin = Anchor.Centre
},
2019-06-18 13:57:05 +08:00
new RoundDisplay(match)
2018-11-11 09:39:04 +08:00
{
RelativeSizeAxes = Axes.Both,
Height = 0.25f,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
}
};
}
private class RoundDisplay : CompositeDrawable
{
2019-06-18 13:57:05 +08:00
public RoundDisplay(TournamentMatch match)
2018-11-11 09:39:04 +08:00
{
var col = OsuColour.Gray(0.33f);
InternalChildren = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Colour = col,
Text = "WINNER",
2019-06-13 18:41:01 +08:00
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 15, FontWeight.Regular),
2018-11-11 09:39:04 +08:00
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Colour = col,
2019-06-18 13:57:05 +08:00
Text = match.Round.Value?.Name.Value ?? "Unknown Round",
2019-06-13 18:41:01 +08:00
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 50, FontWeight.Light),
2018-11-11 09:39:04 +08:00
Spacing = new Vector2(10, 0),
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Colour = col,
2019-06-18 13:57:05 +08:00
Text = match.Date.Value.ToUniversalTime().ToString("dd MMMM HH:mm UTC"),
2019-06-13 18:41:01 +08:00
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 20, FontWeight.Light),
2018-11-11 09:39:04 +08:00
},
}
}
};
}
}
private class TeamWithPlayers : CompositeDrawable
{
private readonly Color4 red = new Color4(129, 68, 65, 255);
private readonly Color4 blue = new Color4(41, 91, 97, 255);
public TeamWithPlayers(TournamentTeam team, bool left = false)
{
var colour = left ? red : blue;
InternalChildren = new Drawable[]
{
new TeamDisplay(team, left ? "Team Red" : "Team Blue", colour)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
2018-11-15 13:12:41 +08:00
new FillFlowContainer
2018-11-11 09:39:04 +08:00
{
Direction = FillDirection.Vertical,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(0, 5),
Padding = new MarginPadding(20),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
},
};
}
private class TeamDisplay : DrawableTournamentTeam
{
public TeamDisplay(TournamentTeam team, string teamName, Color4 colour)
: base(team)
{
AutoSizeAxes = Axes.Both;
Flag.Anchor = Flag.Origin = Anchor.TopCentre;
Flag.RelativeSizeAxes = Axes.None;
Flag.Size = new Vector2(300, 200);
Flag.Scale = new Vector2(0.4f);
Flag.Margin = new MarginPadding { Bottom = 20 };
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
Flag,
new OsuSpriteText
{
Text = team?.FullName.Value.ToUpper() ?? "???",
2019-06-13 18:41:01 +08:00
Font = TournamentFont.GetFont(TournamentTypeface.Aquatico, 40, FontWeight.Light),
2018-11-11 09:39:04 +08:00
Colour = Color4.Black,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
},
new OsuSpriteText
{
Text = teamName.ToUpper(),
2019-03-04 11:06:41 +08:00
Font = OsuFont.GetFont(size: 20),
2018-11-11 09:39:04 +08:00
Colour = colour,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
}
}
};
}
}
}
}
}