# Add on-screen health bars

This was SVN commit r8241.
This commit is contained in:
Ykkrosh
2010-10-02 12:41:29 +00:00
parent 5e9a968bd6
commit 7ea522a484
24 changed files with 480 additions and 121 deletions
@@ -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;
}