Preserve original brightness when remapping player colors.

This commit is contained in:
Paul Chote
2021-04-10 18:12:50 +01:00
committed by teinarss
parent 9d62ce214c
commit 4042d5b179
5 changed files with 34 additions and 43 deletions

View File

@@ -29,9 +29,6 @@ namespace OpenRA.Traits
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndex = { };
[Desc("Luminosity range to span.")]
public readonly float Ramp = 0.05f;
[Desc("Allow palette modifiers to change the palette.")]
public readonly bool AllowModifiers = true;
@@ -49,7 +46,9 @@ namespace OpenRA.Traits
public void LoadPlayerPalettes(WorldRenderer wr, string playerName, Color color, bool replaceExisting)
{
var remap = new PlayerColorRemap(info.RemapIndex, color, info.Ramp);
color.ToAhsv(out _, out var h, out var s, out _);
var remap = new PlayerColorRemap(info.RemapIndex, h, s);
var pal = new ImmutablePalette(wr.Palette(info.BasePalette).Palette, remap);
wr.AddPalette(info.BaseName + playerName, pal, info.AllowModifiers, replaceExisting);
}

View File

@@ -31,9 +31,6 @@ namespace OpenRA.Traits
[Desc("The fixed color to remap.")]
public readonly Color Color;
[Desc("Luminosity range to span.")]
public readonly float Ramp = 0.05f;
[Desc("Allow palette modifiers to change the palette.")]
public readonly bool AllowModifiers = true;
@@ -51,7 +48,9 @@ namespace OpenRA.Traits
public void LoadPalettes(WorldRenderer wr)
{
var remap = new PlayerColorRemap(info.RemapIndex, info.Color, info.Ramp);
info.Color.ToAhsv(out _, out var h, out var s, out _);
var remap = new PlayerColorRemap(info.RemapIndex, h, s);
wr.AddPalette(info.Name, new ImmutablePalette(wr.Palette(info.Base).Palette, remap), info.AllowModifiers);
}
}