mirror of https://github.com/ppy/osu
Handle ties in team vs. results screen
This commit is contained in:
parent
d9190607e4
commit
53b4cdfb02
|
@ -17,6 +17,7 @@ public class TestSceneMultiplayerTeamResults : ScreenTestScene
|
|||
{
|
||||
[TestCase(7483253, 1048576)]
|
||||
[TestCase(1048576, 7483253)]
|
||||
[TestCase(1048576, 1048576)]
|
||||
public void TestDisplayWithTeams(int team1Score, int team2Score)
|
||||
{
|
||||
MultiplayerResultsScreen screen = null;
|
||||
|
|
|
@ -5,15 +5,20 @@
|
|||
|
||||
namespace osu.Game.Localisation
|
||||
{
|
||||
public static class MultiplayerResultsScreenStrings
|
||||
public static class MultiplayerTeamResultsScreenStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.MultiplayerResultsScreen";
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.MultiplayerTeamResultsScreen";
|
||||
|
||||
/// <summary>
|
||||
/// "Team {0} wins!"
|
||||
/// </summary>
|
||||
public static LocalisableString TeamWins(string winner) => new TranslatableString(getKey(@"team_wins"), @"Team {0} wins!", winner);
|
||||
|
||||
/// <summary>
|
||||
/// "The teams are tied!"
|
||||
/// </summary>
|
||||
public static LocalisableString TheTeamsAreTied => new TranslatableString(getKey(@"the_teams_are_tied"), @"The teams are tied!");
|
||||
|
||||
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Localisation;
|
||||
|
@ -52,10 +53,28 @@ private void load()
|
|||
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";
|
||||
LocalisableString winner;
|
||||
Colour4 winnerColour;
|
||||
|
||||
var winnerColour = redScore.Value > blueScore.Value ? colours.TeamColourRed : colours.TeamColourBlue;
|
||||
int comparison = redScore.Value.CompareTo(blueScore.Value);
|
||||
|
||||
if (comparison < 0)
|
||||
{
|
||||
// team name should eventually be coming from the multiplayer match state.
|
||||
winner = MultiplayerTeamResultsScreenStrings.TeamWins(@"Blue");
|
||||
winnerColour = colours.TeamColourBlue;
|
||||
}
|
||||
else if (comparison > 0)
|
||||
{
|
||||
// team name should eventually be coming from the multiplayer match state.
|
||||
winner = MultiplayerTeamResultsScreenStrings.TeamWins(@"Red");
|
||||
winnerColour = colours.TeamColourRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
winner = MultiplayerTeamResultsScreenStrings.TheTeamsAreTied;
|
||||
winnerColour = Colour4.White.Opacity(0.5f);
|
||||
}
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
|
@ -96,7 +115,7 @@ private void load()
|
|||
{
|
||||
Alpha = 0,
|
||||
Font = OsuFont.Torus.With(size: 80, weight: FontWeight.Bold),
|
||||
Text = MultiplayerResultsScreenStrings.TeamWins(winner),
|
||||
Text = winner,
|
||||
Blending = BlendingParameters.Additive
|
||||
}).WithEffect(new GlowEffect
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue