From 20c631a7f9d2eae37126daa619f38942df8c50c4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 5 Feb 2010 12:36:47 +1300 Subject: [PATCH] Forgot a file --- OpenRa.Game/Traits/PlayerColorPalette.cs | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 OpenRa.Game/Traits/PlayerColorPalette.cs diff --git a/OpenRa.Game/Traits/PlayerColorPalette.cs b/OpenRa.Game/Traits/PlayerColorPalette.cs new file mode 100644 index 0000000000..9758b5bb37 --- /dev/null +++ b/OpenRa.Game/Traits/PlayerColorPalette.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Drawing; +using OpenRa.FileFormats; + +namespace OpenRa.Traits +{ + class PlayerColorPaletteInfo : ITraitInfo + { + public readonly string Name = null; + public readonly string DisplayName = null; + public readonly string BasePalette = null; + public readonly string Remap = null; + public readonly int[] DisplayColor = null; + public object Create(Actor self) { return new PlayerColorPalette(self, this); } + } + + class PlayerColorPalette + { + public PlayerColorPalette(Actor self, PlayerColorPaletteInfo info) + { + var wr = self.World.WorldRenderer; + var pal = wr.GetPalette(info.BasePalette); + var newpal = (info.Remap == null) ? pal : new Palette(pal, new PlayerColorRemap(FileSystem.Open(info.Remap))); + wr.AddPalette(info.Name, newpal); + Player.RegisterPlayerColor(info.Name, info.DisplayName, Color.FromArgb(info.DisplayColor[0], info.DisplayColor[1], info.DisplayColor[2])); + } + } +}