diff --git a/OpenRa.FileFormats/FieldLoader.cs b/OpenRa.FileFormats/FieldLoader.cs index cbce5dcd0f..4c7288be0b 100644 --- a/OpenRa.FileFormats/FieldLoader.cs +++ b/OpenRa.FileFormats/FieldLoader.cs @@ -48,7 +48,7 @@ namespace OpenRa.FileFormats } } - static object GetValue( Type fieldType, string x ) + public static object GetValue( Type fieldType, string x ) { if (x != null) x = x.Trim(); if( fieldType == typeof( int ) ) diff --git a/OpenRa.FileFormats/PlayerColorRemap.cs b/OpenRa.FileFormats/PlayerColorRemap.cs index c14ec5a37a..12c2f394e0 100644 --- a/OpenRa.FileFormats/PlayerColorRemap.cs +++ b/OpenRa.FileFormats/PlayerColorRemap.cs @@ -21,37 +21,30 @@ using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Linq; namespace OpenRa.FileFormats { public class PlayerColorRemap : IPaletteRemap { - int offset; - List remapColors = new List(); + Dictionary remapColors; public PlayerColorRemap(Stream s) { - using (BinaryReader reader = new BinaryReader(s)) - { - for (int i = 0; i < 16; i++) - { - byte r = reader.ReadByte(); - byte g = reader.ReadByte(); - byte b = reader.ReadByte(); - - remapColors.Add(Color.FromArgb(r, g, b)); - } - } - - offset = 80; + var yaml = MiniYaml.FromStream(s); + remapColors = yaml.ToDictionary( + y => int.Parse(y.Key), + y => ArrayToColor((int[])FieldLoader.GetValue( + typeof(int[]), y.Value.Value.Trim()))); } + static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2], x[3]); } + public Color GetRemappedColor(Color original, int index) { - if (index < offset || index >= offset + remapColors.Count) - return original; - - return remapColors[index - offset]; + Color c; + return remapColors.TryGetValue(index, out c) + ? c : original; } } } diff --git a/mods/ra/blue.rem b/mods/ra/blue.rem index 9589fb20cb..ac740c8490 100644 --- a/mods/ra/blue.rem +++ b/mods/ra/blue.rem @@ -1 +1,16 @@ -궾ޡʍ}iuYiDU8H}0@u(8m ,a,U D4 \ No newline at end of file +80: 255,226,230,246 +81: 255,206,210,234 +82: 255,182,190,222 +83: 255,161,170,202 +84: 255,141,149,186 +85: 255,125,133,174 +86: 255,105,117,161 +87: 255,89,105,149 +88: 255,68,85,137 +89: 255,56,72,125 +90: 255,48,64,117 +91: 255,40,56,109 +92: 255,32,44,97 +93: 255,24,44,85 +94: 255,12,32,68 +95: 255,8,20,52 diff --git a/mods/ra/gold.rem b/mods/ra/gold.rem index e35abd6942..ca5f7a2926 100644 --- a/mods/ra/gold.rem +++ b/mods/ra/gold.rem @@ -1 +1,16 @@ -yq־iƲaYULu@q8me8YU,UL$HD 844,(  \ No newline at end of file +80: 255,246,214,121 +81: 255,230,202,113 +82: 255,214,190,105 +83: 255,198,178,97 +84: 255,182,165,89 +85: 255,170,153,85 +86: 255,145,137,76 +87: 255,145,117,64 +88: 255,133,113,56 +89: 255,109,101,56 +90: 255,89,85,44 +91: 255,85,76,36 +92: 255,72,68,32 +93: 255,56,52,28 +94: 255,52,44,20 +95: 255,40,32,8 diff --git a/mods/ra/gray.rem b/mods/ra/gray.rem index e397db43d6..41f751f5ef 100644 --- a/mods/ra/gray.rem +++ b/mods/ra/gray.rem @@ -1 +1,16 @@ -κ}qqeqYP]H@P<4P<4<,(<,(,, \ No newline at end of file +80: 255,238,238,238 +81: 255,238,226,218 +82: 255,222,206,198 +83: 255,206,186,178 +84: 255,186,165,153 +85: 255,165,145,133 +86: 255,149,125,113 +87: 255,133,113,101 +88: 255,113,89,80 +89: 255,93,72,64 +90: 255,80,60,52 +91: 255,80,60,52 +92: 255,60,44,40 +93: 255,60,44,40 +94: 255,44,28,24 +95: 255,44,28,24 diff --git a/mods/ra/green.rem b/mods/ra/green.rem index b66e9436e3..c0a88595aa 100644 --- a/mods/ra/green.rem +++ b/mods/ra/green.rem @@ -1 +1,16 @@ -慲}umyei]YuLLe<