From 03b3ea0b2f881112f21951bb39460fbd49b58283 Mon Sep 17 00:00:00 2001 From: feos Date: Fri, 22 Jun 2018 23:15:35 +0300 Subject: [PATCH] triple cast, but we don't have to cast to string to fetch ARGB --- BizHawk.Client.Common/lua/LuaLibraryBase.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/BizHawk.Client.Common/lua/LuaLibraryBase.cs b/BizHawk.Client.Common/lua/LuaLibraryBase.cs index 391ce4330d..bcf0a6845e 100644 --- a/BizHawk.Client.Common/lua/LuaLibraryBase.cs +++ b/BizHawk.Client.Common/lua/LuaLibraryBase.cs @@ -63,24 +63,21 @@ namespace BizHawk.Client.Common return (uint)(double)luaArg; } - protected static Color? ToColor(object color) + protected static Color? ToColor(object o) { - if (color == null) + if (o == null) { return null; } - int tryNum; - var result = int.TryParse(color.ToString(), out tryNum); - - if (result) + if (o.GetType() == typeof(double)) { - return Color.FromArgb(tryNum); + return Color.FromArgb((int)(long)(double)o); } - if (!string.IsNullOrWhiteSpace(color.ToString())) + if (o.GetType() == typeof(string)) { - return Color.FromName(color.ToString()); + return Color.FromName(o.ToString()); } return null;