Load rgb[a] hex colors from MiniYaml (+ Lua)

This commit is contained in:
atlimit8
2015-10-03 14:35:52 -05:00
parent f69ab464af
commit dac15edce5
11 changed files with 337 additions and 57 deletions

View File

@@ -16,6 +16,7 @@ using System.Drawing.Imaging;
using System.Globalization;
using System.Linq;
using System.Reflection;
using OpenRA.Graphics;
namespace OpenRA
{
@@ -73,14 +74,16 @@ namespace OpenRA
var t = v.GetType();
// Color.ToString() does the wrong thing; force it to format as an array
// Color.ToString() does the wrong thing; force it to format as rgb[a] hex
if (t == typeof(Color))
{
var c = (Color)v;
return "{0},{1},{2},{3}".F(((int)c.A).Clamp(0, 255),
((int)c.R).Clamp(0, 255),
((int)c.G).Clamp(0, 255),
((int)c.B).Clamp(0, 255));
return HSLColor.ToHexString((Color)v);
}
// HSLColor.ToString() does the wrong thing; force it to format as rgb[a] hex
if (t == typeof(HSLColor))
{
return ((HSLColor)v).ToHexString();
}
if (t == typeof(ImageFormat))