mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 08:12:53 +08:00
Add winner text
This commit is contained in:
parent
c376e652a4
commit
430a0e496c
19
osu.Game/Localisation/MultiplayerResultsScreenStrings.cs
Normal file
19
osu.Game/Localisation/MultiplayerResultsScreenStrings.cs
Normal 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}";
|
||||||
|
}
|
||||||
|
}
|
@ -5,10 +5,18 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
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.Online.Rooms;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||||
{
|
{
|
||||||
@ -16,22 +24,78 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
private readonly SortedDictionary<int, BindableInt> teamScores;
|
private readonly SortedDictionary<int, BindableInt> teamScores;
|
||||||
|
|
||||||
|
private Drawable winnerText;
|
||||||
|
|
||||||
public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableInt> teamScores)
|
public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem, SortedDictionary<int, BindableInt> teamScores)
|
||||||
: base(score, roomId, playlistItem, false, false)
|
: base(score, roomId, playlistItem, false, false)
|
||||||
{
|
{
|
||||||
this.teamScores = teamScores;
|
this.teamScores = teamScores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
if (teamScores.Count == 2)
|
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 },
|
new FillFlowContainer
|
||||||
Team2Score = { BindTarget = teamScores.Last().Value },
|
{
|
||||||
}, AddInternal);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user