Skip to content

Commit

Permalink
Don't hard-code the transparent background color.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender authored and pchote committed May 16, 2020
1 parent 1bf01bc commit 1d2d8ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion OpenRA.Game/Traits/Player/PlayerHighlightPalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class PlayerHighlightPaletteInfo : ITraitInfo
[Desc("The prefix for the resulting player palettes")]
public readonly string BaseName = "highlight";

[Desc("Index set to be fully transparent/invisible.")]
public readonly int TransparentIndex = 0;

public object Create(ActorInitializer init) { return new PlayerHighlightPalette(this); }
}

Expand All @@ -37,7 +40,7 @@ public PlayerHighlightPalette(PlayerHighlightPaletteInfo info)
public void LoadPlayerPalettes(WorldRenderer wr, string playerName, Color color, bool replaceExisting)
{
var argb = (uint)Color.FromArgb(128, color).ToArgb();
var pal = new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => i == 0 ? 0 : argb));
var pal = new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => i == info.TransparentIndex ? 0 : argb));
wr.AddPalette(info.BaseName + playerName, pal, false, replaceExisting);
}
}
Expand Down

0 comments on commit 1d2d8ed

Please sign in to comment.