mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-14 00:55:42 +00:00
# Add on-screen health bars
This was SVN commit r8241.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
#include "maths/Fixed.h"
|
||||
#include "maths/FixedVector2D.h"
|
||||
#include "maths/FixedVector3D.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Overlay.h"
|
||||
@@ -242,3 +243,24 @@ template<> jsval ScriptInterface::ToJSVal<CFixedVector3D>(JSContext* cx, const C
|
||||
|
||||
return OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
|
||||
template<> bool ScriptInterface::FromJSVal<CFixedVector2D>(JSContext* cx, jsval v, CFixedVector2D& out)
|
||||
{
|
||||
ScriptInterface::LocalRootScope scope(cx);
|
||||
if (!scope.OK())
|
||||
return false;
|
||||
|
||||
if (!JSVAL_IS_OBJECT(v))
|
||||
return false; // TODO: report type error
|
||||
JSObject* obj = JSVAL_TO_OBJECT(v);
|
||||
|
||||
jsval p;
|
||||
|
||||
if (!JS_GetProperty(cx, obj, "x", &p)) return false; // TODO: report type errors
|
||||
if (!FromJSVal(cx, p, out.X)) return false;
|
||||
|
||||
if (!JS_GetProperty(cx, obj, "y", &p)) return false;
|
||||
if (!FromJSVal(cx, p, out.Y)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user