Delete wrongful proxy CGUIManager::GetPreDefinedColor from f0d9806b3f.

It is wrong because the predefined colors should be loaded from the GUI
page that requests to have the color parsed, which may be different from
the topmost page.
Similar to FindObjectByName removed in f9b529f2fb.

Achieve this by implementing the CGUISetting<CGUIColor>::FromJSVal
specialization, moved from ScriptInterface::FromJSVal<CGUIColor>,
instead of adding a CGUI pointer to CGUIColor.
Mark ScriptInterface::FromJSVal<GUIColor> and inherited
CColor::ParseString explicitly as deleted, so that people get a compile
error if they forget to check for predefined colors when parsing a
color.

Refs #5387, D1746 > D1684 > this > f9b529f2fb, 9be8a560a9, 415939b59b,
2c47fbd66a, 85a622b13a.

Differential Revision: https://code.wildfiregames.com/D2108
Tested on: clang 8, VS2015

This was SVN commit r22663.
This commit is contained in:
elexis
2019-08-13 18:00:41 +00:00
parent 02d23d1ff0
commit 6ad90aa1b8
16 changed files with 132 additions and 103 deletions
+4 -19
View File
@@ -150,25 +150,10 @@ template<> void ScriptInterface::ToJSVal<CGUIColor>(JSContext* cx, JS::MutableHa
ToJSVal<CColor>(cx, ret, val);
}
template<> bool ScriptInterface::FromJSVal<CGUIColor>(JSContext* cx, JS::HandleValue v, CGUIColor& out)
{
if (v.isString())
{
CStr name;
if (!FromJSVal(cx, v, name))
return false;
if (!out.ParseString(name))
{
JS_ReportError(cx, "Invalid color '%s'", name.c_str());
return false;
}
return true;
}
// Parse as object
return FromJSVal<CColor>(cx, v, out);
}
/**
* The color depends on the predefined color database stored in the current GUI page.
*/
template<> bool ScriptInterface::FromJSVal<CGUIColor>(JSContext* cx, JS::HandleValue v, CGUIColor& out) = delete;
template<> void ScriptInterface::ToJSVal<CSize>(JSContext* cx, JS::MutableHandleValue ret, const CSize& val)
{