1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +08:00

Add winner text

This commit is contained in:
Dean Herbert 2021-08-11 15:32:10 +09:00
parent c376e652a4
commit 430a0e496c
2 changed files with 87 additions and 4 deletions

View File

@ -0,0 +1,19 @@
// 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.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class MultiplayerResultsScreenStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.MultiplayerResultsScreen";
/// <summary>
/// "Team {0} wins!"
/// </summary>
public static LocalisableString TeamWins(string winner) => new TranslatableString(getKey(@"team_wins"), @"Team {0} wins!", winner);
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -5,10 +5,18 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
using osu.Game.Screens.OnlinePlay.Playlists;
using osu.Game.Screens.Play.HUD;
using osu.Game.Localisation;
using osuTK.Graphics;
namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
@ -16,22 +24,78 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
private readonly SortedDictionary<int, BindableInt> teamScores;
private Drawable winnerText;
public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableInt> teamScores)
: base(score, roomId, playlistItem, false, false)
{
this.teamScores = teamScores;
}
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader]
private void load()
{
if (teamScores.Count == 2)
{
LoadComponentAsync(new MatchScoreDisplay
var redScore = teamScores.First().Value;
var blueScore = teamScores.Last().Value;
// eventually this will be replaced by team names coming from the multiplayer match state.
string winner = redScore.Value > blueScore.Value ? @"Red" : @"Blue";
var winnerColour = redScore.Value > blueScore.Value ? colours.TeamColourRed : colours.TeamColourBlue;
AddRangeInternal(new Drawable[]
{
Team1Score = { BindTarget = teamScores.First().Value },
Team2Score = { BindTarget = teamScores.Last().Value },
}, AddInternal);
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new MatchScoreDisplay
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Team1Score = { BindTarget = redScore },
Team2Score = { BindTarget = blueScore },
},
(winnerText = new OsuSpriteText
{
Alpha = 0,
Font = OsuFont.Torus.With(size: 40, weight: FontWeight.Bold),
Text = MultiplayerResultsScreenStrings.TeamWins(winner)
}).WithEffect(new GlowEffect
{
Colour = winnerColour,
}).With(e =>
{
e.Anchor = Anchor.TopCentre;
e.Origin = Anchor.TopCentre;
})
}
},
});
}
}
protected override void LoadComplete()
{
base.LoadComplete();
using (BeginDelayedSequence(300))
{
winnerText.FadeInFromZero(600, Easing.InQuint);
winnerText
.ScaleTo(10)
.ScaleTo(1, 600, Easing.InQuad)
.Then()
.ScaleTo(1.02f, 1600, Easing.OutQuint);
}
}
}