Added translation support for server orders.

This commit is contained in:
Matthias Mailänder
2021-12-18 20:12:28 +01:00
committed by teinarss
parent ee95d2591f
commit 0260884369
19 changed files with 834 additions and 149 deletions

View File

@@ -60,6 +60,13 @@ namespace OpenRA.Mods.Common.Traits
public Color Color;
[TranslationReference]
static readonly string PlayerColorTerrain = "player-color-terrain";
[TranslationReference]
static readonly string PlayerColorPlayer = "player-color-player";
[TranslationReference]
static readonly string InvalidPlayerColor = "invalid-player-color";
bool TryGetBlockingColor((float R, float G, float B) color, List<(float R, float G, float B)> candidateBlockers, out (float R, float G, float B) closestBlocker)
{
var closestDistance = SimilarityThreshold;
@@ -148,9 +155,9 @@ namespace OpenRA.Mods.Common.Traits
{
var linear = Color.FromAhsv(hue, sat, V).ToLinear();
if (TryGetBlockingColor(linear, terrainLinear, out var blocker))
errorMessage = "Color was adjusted to be less similar to the terrain.";
errorMessage = PlayerColorTerrain;
else if (TryGetBlockingColor(linear, playerLinear, out blocker))
errorMessage = "Color was adjusted to be less similar to another player.";
errorMessage = PlayerColorPlayer;
else
{
if (errorMessage != null)
@@ -169,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
}
// Failed to find a solution within a reasonable time: return a random color without any validation
onError?.Invoke("Unable to determine a valid player color. A random color has been selected.");
onError?.Invoke(InvalidPlayerColor);
return Color.FromAhsv(random.NextFloat(), float2.Lerp(HsvSaturationRange[0], HsvSaturationRange[1], random.NextFloat()), V);
}
}