mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-23 16:33:16 +00:00
Introduce CGUIColor type inheriting Color type and switch the GUI to exclusively use that.
The type differs from the Color type, because contrary to Color, it can
be created from a color predefined in the GUI page (such as "yellow").
Move this predefined color check to the new class instead of hardcoding
it in FromJSVal / ToJSVal, GUIUtil, JSInterface_IGUIObject and to
straighten the latter.
Delete fov_wedge_color from Minimap, unused since introduction in
5275dc862b.
This was SVN commit r22558.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "gui/CGUIColor.h"
|
||||
#include "gui/CGUIList.h"
|
||||
#include "gui/CGUISeries.h"
|
||||
#include "gui/GUIbase.h"
|
||||
@@ -144,6 +145,31 @@ JSVAL_VECTOR(CVector2D)
|
||||
JSVAL_VECTOR(std::vector<CVector2D>)
|
||||
JSVAL_VECTOR(CGUIString)
|
||||
|
||||
template<> void ScriptInterface::ToJSVal<CGUIColor>(JSContext* cx, JS::MutableHandleValue ret, const CGUIColor& val)
|
||||
{
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse as object
|
||||
return FromJSVal<CColor>(cx, v, out);
|
||||
}
|
||||
|
||||
template<> void ScriptInterface::ToJSVal<CClientArea>(JSContext* cx, JS::MutableHandleValue ret, const CClientArea& val)
|
||||
{
|
||||
val.ToJSVal(cx, ret);
|
||||
|
||||
Reference in New Issue
Block a user