Make Color use uint for ARGB.

This is a more natural representation than int that allows removal of casts in many places that require uint. Additionally, we can change the internal representation from long to uint, making the Color struct smaller. Since arrays of colors are common, this can save on memory.
This commit is contained in:
RoosterDragon
2024-03-02 12:02:06 +00:00
committed by Gustas
parent 7b82d85b27
commit 5f97e2de5a
15 changed files with 35 additions and 40 deletions

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
public void LoadPalettes(WorldRenderer wr)
{
var c = info.Fog ? Fog : Shroud;
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (uint)c[i % 8].ToArgb())));
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => c[i % 8].ToArgb())));
}
static readonly Color[] Fog = new[]

View File

@@ -77,8 +77,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
static int ColorDistance(uint a, uint b)
{
var ca = Color.FromArgb((int)a);
var cb = Color.FromArgb((int)b);
var ca = Color.FromArgb(a);
var cb = Color.FromArgb(b);
return Math.Abs(ca.R - cb.R) +
Math.Abs(ca.G - cb.G) +