fix player color remap to handle RemapIndex: with any number of entries, not only 16 colors

This commit is contained in:
evgeniysergeev
2015-10-17 22:47:03 +03:00
parent e0e31d89b1
commit 0830e4a2c0
2 changed files with 6 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ Also thanks to:
* Dmitri Suvorov (suvjunmd) * Dmitri Suvorov (suvjunmd)
* Erasmus Schroder (rasco) * Erasmus Schroder (rasco)
* Eric Bajumpaa (SteelPhase) * Eric Bajumpaa (SteelPhase)
* Evgeniy Sergeev (evgeniysergeev)
* Fahrradkette * Fahrradkette
* Frank Razenberg (zzattack) * Frank Razenberg (zzattack)
* Gareth Needham (Ripley`) * Gareth Needham (Ripley`)

View File

@@ -33,13 +33,14 @@ namespace OpenRA.Graphics
var c2 = new HSLColor(c.H, c.S, (byte)Math.Max(0, c.L - rampRange)).RGB; var c2 = new HSLColor(c.H, c.S, (byte)Math.Max(0, c.L - rampRange)).RGB;
var baseIndex = ramp[0]; var baseIndex = ramp[0];
var remapRamp = ramp.Select(r => r - ramp[0]); var remapRamp = ramp.Select(r => r - ramp[0]);
var rampMaxIndex = ramp.Length - 1;
// reversed remapping // reversed remapping
if (ramp[0] > ramp[15]) if (ramp[0] > ramp[rampMaxIndex])
{ {
baseIndex = ramp[15]; baseIndex = ramp[rampMaxIndex];
for (var i = 15; i > 0; i--) for (var i = rampMaxIndex; i > 0; i--)
remapRamp = ramp.Select(r => r - ramp[15]); remapRamp = ramp.Select(r => r - ramp[rampMaxIndex]);
} }
remapColors = remapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2))) remapColors = remapRamp.Select((x, i) => Pair.New(baseIndex + i, Exts.ColorLerp(x / 16f, c1, c2)))