1
0
forked from 0ad/0ad

Added exit() JS function

This was SVN commit r673.
This commit is contained in:
Ykkrosh 2004-07-09 12:44:12 +00:00
parent dc5e5dd774
commit fcb85a5968
3 changed files with 19 additions and 1 deletions

View File

@ -254,6 +254,12 @@ static void WriteScreenshot()
bool active = true;
static bool quit = false; // break out of main loop
// HACK: Let code from other files (i.e. the scripting system) quit
void kill_mainloop()
{
quit = true;
}
static int handler(const SDL_Event* ev)
{
int c;

View File

@ -30,6 +30,7 @@ JSFunctionSpec ScriptFunctionTable[] =
{"getEntityTemplate", getEntityTemplate, 1, 0, 0 },
{"getGUIObjectByName", JSI_IGUIObject::getByName, 1, 0, 0 },
{"getGlobal", getGlobal, 0, 0, 0 },
{"exit", exitProgram, 0, 0, 0 },
{0, 0, 0, 0, 0},
};
@ -129,3 +130,11 @@ JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc,
return( JS_TRUE );
}
extern void kill_mainloop(); // from main.cpp
JSBool exitProgram(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval)
{
kill_mainloop();
return JS_TRUE;
}

View File

@ -13,7 +13,10 @@ JSBool getEntityByHandle( JSContext* context, JSObject* globalObject, unsigned i
JSBool getEntityTemplate( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval );
// Returns the global object, e.g. for setting global variables.
JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval );
JSBool getGlobal(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval);
// Tells the main loop to stop looping
JSBool exitProgram(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval);
extern JSFunctionSpec ScriptFunctionTable[];