diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 7e1bd37c03..4faac9b153 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -1548,16 +1548,17 @@ void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImag CStr attr_name (pFile->getAttributeString(attr.Name)); CStr attr_value (attr.Value); -#define COLOR(xml, mem) \ +#define COLOR(xml, mem, alpha) \ if (attr_name == xml) \ { \ CColor color; \ - if (!GUI::ParseString(attr_value, color)) \ + if (!GUI::ParseColor(attr_value, color, alpha)) \ ReportParseError("Error parsing '%s' (\"%s\")", attr_name.c_str(), attr_value.c_str()); \ else effects.m_##mem = color; \ } \ else + #define BOOL(xml, mem) \ if (attr_name == xml) \ { \ @@ -1565,8 +1566,8 @@ void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImag } \ else - COLOR("add_color", AddColor) - COLOR("multiply_color", MultiplyColor) + COLOR("add_color", AddColor, 0.f) + COLOR("multiply_color", MultiplyColor, 255.f) BOOL("grayscale", Greyscale) { diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index 9be79335d1..171af0732e 100755 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -76,7 +76,7 @@ bool __ParseString(const CStr& Value, CClientArea &Output) } template <> -bool __ParseString(const CStr& Value, CColor &Output) +bool GUI::ParseColor(const CStr& Value, CColor &Output, float DefaultAlpha) { // Use the parser to parse the values CParser& parser (CParserCache::Get("_[-$arg(_minus)]$value_[-$arg(_minus)]$value_[-$arg(_minus)]$value_[[-$arg(_minus)]$value_]")); @@ -91,7 +91,7 @@ bool __ParseString(const CStr& Value, CColor &Output) return false; } float values[4]; - values[3] = 255.f; // default + values[3] = DefaultAlpha; for (int i=0; i<(int)line.GetArgCount(); ++i) { if (!line.GetArgFloat(i, values[i])) @@ -105,10 +105,17 @@ bool __ParseString(const CStr& Value, CColor &Output) Output.g = values[1]/255.f; Output.b = values[2]/255.f; Output.a = values[3]/255.f; - + return true; } + +template <> +bool __ParseString(const CStr& Value, CColor &Output) +{ + return GUI::ParseColor(Value, Output, 255.f); +} + template <> bool __ParseString(const CStr& Value, CSize &Output) { diff --git a/source/gui/GUIutil.h b/source/gui/GUIutil.h index cc92c3a2eb..26a757e715 100755 --- a/source/gui/GUIutil.h +++ b/source/gui/GUIutil.h @@ -303,6 +303,8 @@ public: return __ParseString(Value, tOutput); } + static bool ParseColor(const CStr& Value, CColor &tOutput, float DefaultAlpha); + private: // templated typedef of function pointer