rewrote remap code to use yaml descriptions rather than my insane binary format
This commit is contained in:
@@ -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 ) )
|
||||
|
||||
@@ -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<Color> remapColors = new List<Color>();
|
||||
Dictionary<int, Color> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>궾ޡ<EFBFBD>ʍ<EFBFBD><EFBFBD>}<7D><>iu<69>Yi<59>DU<44>8H}0@u(8m ,a,U D4
|
||||
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
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
<EFBFBD><EFBFBD>y<EFBFBD><EFBFBD>q־iƲa<EFBFBD><EFBFBD>Y<EFBFBD><EFBFBD>U<EFBFBD><EFBFBD>L<EFBFBD>u@<40>q8me8YU,UL$HD 844,(
|
||||
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
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>}q<>qeqYP]H@P<4P<4<,(<,(,,
|
||||
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
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>慲<EFBFBD>}<7D><>u<EFBFBD><75>my<6D>ei<65>]YuLLe<<U00D$$4$4$
|
||||
80: 255,255,230,149
|
||||
81: 255,255,230,149
|
||||
82: 255,198,230,133
|
||||
83: 255,178,210,125
|
||||
84: 255,157,190,117
|
||||
85: 255,137,174,109
|
||||
86: 255,121,153,101
|
||||
87: 255,105,137,93
|
||||
88: 255,89,117,76
|
||||
89: 255,76,101,60
|
||||
90: 255,60,85,48
|
||||
91: 255,48,68,36
|
||||
92: 255,36,52,24
|
||||
93: 255,36,52,24
|
||||
94: 255,24,36,16
|
||||
95: 255,20,20,20
|
||||
|
||||
Binary file not shown.
BIN
mods/ra/red.rem
BIN
mods/ra/red.rem
Binary file not shown.
Binary file not shown.
BIN
mods/ra/teal.rem
BIN
mods/ra/teal.rem
Binary file not shown.
Reference in New Issue
Block a user