mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Add win screen
This commit is contained in:
34
osu.Game.Tournament.Tests/TeamWinTestCase.cs
Normal file
34
osu.Game.Tournament.Tests/TeamWinTestCase.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
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.TeamWin;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Tests
|
||||||
|
{
|
||||||
|
public class TestCaseTeamWin : LadderTestCase
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
Add(new TeamWinScreen
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
FillAspectRatio = 16 / 9f
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
232
osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
Normal file
232
osu.Game.Tournament/Screens/TeamWin/TeamWinScreen.cs
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Graphics.Video;
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Tournament.Components;
|
||||||
|
using osu.Game.Tournament.Screens.Ladder.Components;
|
||||||
|
using osu.Game.Tournament.Screens.Showcase;
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tournament.Screens.TeamWin
|
||||||
|
{
|
||||||
|
public class TeamWinScreen : TournamentScreen, IProvideVideo
|
||||||
|
{
|
||||||
|
private Container mainContainer;
|
||||||
|
|
||||||
|
private readonly Bindable<MatchPairing> currentMatch = new Bindable<MatchPairing>();
|
||||||
|
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
|
||||||
|
|
||||||
|
private VideoSprite blueWinVideo;
|
||||||
|
private VideoSprite redWinVideo;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures, LadderInfo ladder, Storage storage)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
blueWinVideo = new VideoSprite(storage.GetStream(@"BG Team - Win Blue.m4v"))
|
||||||
|
{
|
||||||
|
Alpha = 1,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Loop = true,
|
||||||
|
},
|
||||||
|
redWinVideo = new VideoSprite(storage.GetStream(@"BG Team - Win Red.m4v"))
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Loop = true,
|
||||||
|
},
|
||||||
|
new TournamentLogo()
|
||||||
|
{
|
||||||
|
Y = 40,
|
||||||
|
},
|
||||||
|
mainContainer = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
currentMatch.BindValueChanged(matchChanged);
|
||||||
|
currentMatch.BindTo(ladder.CurrentMatch);
|
||||||
|
|
||||||
|
currentCompleted.BindValueChanged(_ => update());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void matchChanged(MatchPairing pairing)
|
||||||
|
{
|
||||||
|
currentCompleted.UnbindBindings();
|
||||||
|
currentCompleted.BindTo(pairing.Completed);
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update()
|
||||||
|
{
|
||||||
|
var pairing = currentMatch.Value;
|
||||||
|
|
||||||
|
if (pairing.Winner == null)
|
||||||
|
{
|
||||||
|
mainContainer.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool redWin = pairing.Winner == pairing.Team1.Value;
|
||||||
|
redWinVideo.Alpha = redWin ? 1 : 0;
|
||||||
|
blueWinVideo.Alpha = redWin ? 0 : 1;
|
||||||
|
|
||||||
|
mainContainer.Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new TeamWithPlayers(pairing.Winner, redWin)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Width = 0.5f,
|
||||||
|
Height = 0.6f,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
},
|
||||||
|
new RoundDisplay(pairing)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.25f,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RoundDisplay : CompositeDrawable
|
||||||
|
{
|
||||||
|
public RoundDisplay(MatchPairing pairing)
|
||||||
|
{
|
||||||
|
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",
|
||||||
|
Font = "Aquatico-Regular",
|
||||||
|
TextSize = 15,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Colour = col,
|
||||||
|
Text = pairing.Grouping.Value?.Name.Value ?? "Unknown Grouping",
|
||||||
|
Font = "Aquatico-Light",
|
||||||
|
Spacing = new Vector2(10, 0),
|
||||||
|
TextSize = 50,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Font = "Aquatico-Light",
|
||||||
|
Colour = col,
|
||||||
|
Text = pairing.Date.Value.ToUniversalTime().ToString("dd MMMM HH:mm UTC"),
|
||||||
|
TextSize = 20,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
FillFlowContainer players;
|
||||||
|
var colour = left ? red : blue;
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new TeamDisplay(team, left ? "Team Red" : "Team Blue", colour)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
},
|
||||||
|
players = new FillFlowContainer
|
||||||
|
{
|
||||||
|
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.ToUpper() ?? "???",
|
||||||
|
TextSize = 40,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
Font = "Aquatico-Light",
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = teamName.ToUpper(),
|
||||||
|
TextSize = 20,
|
||||||
|
Colour = colour,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ using osu.Game.Tournament.Screens.MapPool;
|
|||||||
using osu.Game.Tournament.Screens.Schedule;
|
using osu.Game.Tournament.Screens.Schedule;
|
||||||
using osu.Game.Tournament.Screens.Showcase;
|
using osu.Game.Tournament.Screens.Showcase;
|
||||||
using osu.Game.Tournament.Screens.TeamIntro;
|
using osu.Game.Tournament.Screens.TeamIntro;
|
||||||
|
using osu.Game.Tournament.Screens.TeamWin;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
private LadderManager bracket;
|
private LadderManager bracket;
|
||||||
private MapPoolScreen mapPool;
|
private MapPoolScreen mapPool;
|
||||||
private GameplayScreen gameplay;
|
private GameplayScreen gameplay;
|
||||||
|
private TeamWinScreen winner;
|
||||||
private TeamIntroScreen teamIntro;
|
private TeamIntroScreen teamIntro;
|
||||||
private DrawingsScreen drawings;
|
private DrawingsScreen drawings;
|
||||||
private Container screens;
|
private Container screens;
|
||||||
@ -64,6 +66,8 @@ namespace osu.Game.Tournament.Screens
|
|||||||
new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) },
|
new OsuButton { RelativeSizeAxes = Axes.X, Text = "TeamIntro", Action = () => setScreen(teamIntro) },
|
||||||
new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => setScreen(mapPool) },
|
new OsuButton { RelativeSizeAxes = Axes.X, Text = "MapPool", Action = () => setScreen(mapPool) },
|
||||||
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => setScreen(gameplay) },
|
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Gameplay", Action = () => setScreen(gameplay) },
|
||||||
|
new Container { RelativeSizeAxes = Axes.X, Height = 50 },
|
||||||
|
new OsuButton { RelativeSizeAxes = Axes.X, Text = "Win", Action = () => setScreen(winner) },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -97,7 +101,8 @@ namespace osu.Game.Tournament.Screens
|
|||||||
mapPool = new MapPoolScreen(),
|
mapPool = new MapPoolScreen(),
|
||||||
teamIntro = new TeamIntroScreen(),
|
teamIntro = new TeamIntroScreen(),
|
||||||
drawings = new DrawingsScreen(),
|
drawings = new DrawingsScreen(),
|
||||||
gameplay = new GameplayScreen()
|
gameplay = new GameplayScreen(),
|
||||||
|
winner = new TeamWinScreen()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user