2010-07-31 09:53:02 +00:00
|
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
|
*
|
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* $URL$
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
/*
|
2010-07-31 09:53:02 +00:00
|
|
|
|
* This code is based on Broken Sword 2.5 engine
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
|
|
|
|
|
*
|
|
|
|
|
* Licensed under GNU GPL v2
|
|
|
|
|
*
|
|
|
|
|
*/
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-07-30 09:02:39 +00:00
|
|
|
|
#include "sword25/kernel/common.h"
|
|
|
|
|
#include "sword25/kernel/kernel.h"
|
|
|
|
|
#include "sword25/kernel/callbackregistry.h"
|
|
|
|
|
#include "sword25/script/script.h"
|
|
|
|
|
#include "sword25/script/luabindhelper.h"
|
|
|
|
|
#include "sword25/script/luacallback.h"
|
|
|
|
|
#include "sword25/math/vertex.h"
|
|
|
|
|
|
|
|
|
|
#include "sword25/gfx/graphicengine.h"
|
|
|
|
|
#include "sword25/gfx/renderobject.h"
|
|
|
|
|
#include "sword25/gfx/bitmap.h"
|
|
|
|
|
#include "sword25/gfx/animation.h"
|
|
|
|
|
#include "sword25/gfx/panel.h"
|
|
|
|
|
#include "sword25/gfx/text.h"
|
|
|
|
|
#include "sword25/gfx/animationtemplate.h"
|
|
|
|
|
#include "sword25/gfx/animationtemplateregistry.h"
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-08-05 12:48:19 +00:00
|
|
|
|
namespace Sword25 {
|
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
#define BS_LOG_PREFIX "GRAPHICENGINE"
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static bool animationDeleteCallback(uint Data);
|
|
|
|
|
static bool animationActionCallback(uint Data);
|
|
|
|
|
static bool animationLoopPointCallback(uint Data);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
namespace {
|
2010-08-18 12:57:47 +00:00
|
|
|
|
class ActionCallback : public LuaCallback {
|
2010-08-06 13:13:25 +00:00
|
|
|
|
public:
|
2010-10-13 20:04:50 +00:00
|
|
|
|
ActionCallback(lua_State *L) : LuaCallback(L) {}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
Common::String Action;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
protected:
|
|
|
|
|
virtual int PreFunctionInvokation(lua_State *L) {
|
|
|
|
|
lua_pushstring(L, Action.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
};
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
Common::ScopedPtr<LuaCallback> loopPointCallbackPtr;
|
|
|
|
|
Common::ScopedPtr<ActionCallback> actionCallbackPtr;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
struct CallbackfunctionRegisterer {
|
|
|
|
|
CallbackfunctionRegisterer() {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
CallbackRegistry::instance().registerCallbackFunction("LuaLoopPointCB", (void ( *)(int))animationLoopPointCallback);
|
|
|
|
|
CallbackRegistry::instance().registerCallbackFunction("LuaActionCB", (void ( *)(int))animationActionCallback);
|
|
|
|
|
CallbackRegistry::instance().registerCallbackFunction("LuaDeleteCB", (void ( *)(int))animationDeleteCallback);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
static CallbackfunctionRegisterer Instance;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Die Strings werden als #defines definiert um Stringkomposition zur Compilezeit zu erm<72>glichen.
|
|
|
|
|
#define RENDEROBJECT_CLASS_NAME "Gfx.RenderObject"
|
|
|
|
|
#define BITMAP_CLASS_NAME "Gfx.Bitmap"
|
|
|
|
|
#define PANEL_CLASS_NAME "Gfx.Panel"
|
|
|
|
|
#define TEXT_CLASS_NAME "Gfx.Text"
|
|
|
|
|
#define ANIMATION_CLASS_NAME "Gfx.Animation"
|
|
|
|
|
#define ANIMATION_TEMPLATE_CLASS_NAME "Gfx.AnimationTemplate"
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const char *GFX_LIBRARY_NAME = "Gfx";
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
// Wie luaL_checkudata, nur ohne dass kein Fehler erzeugt wird.
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static void *my_checkudata(lua_State *L, int ud, const char *tname) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
int top = lua_gettop(L);
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
void *p = lua_touserdata(L, ud);
|
|
|
|
|
if (p != NULL) { /* value is a userdata? */
|
|
|
|
|
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, tname);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_settop(L, top);
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lua_settop(L, top);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static void newUintUserData(lua_State *L, uint value) {
|
|
|
|
|
void *userData = lua_newuserdata(L, sizeof(value));
|
|
|
|
|
memcpy(userData, &value, sizeof(value));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static AnimationTemplate *checkAnimationTemplate(lua_State *L, int idx = 1) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.AnimationTemplate
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint animationTemplateHandle;
|
|
|
|
|
if ((animationTemplateHandle = *reinterpret_cast<uint *>(my_checkudata(L, idx, ANIMATION_TEMPLATE_CLASS_NAME))) != 0) {
|
|
|
|
|
AnimationTemplate *animationTemplatePtr = AnimationTemplateRegistry::instance().resolveHandle(animationTemplateHandle);
|
|
|
|
|
if (!animationTemplatePtr)
|
|
|
|
|
luaL_error(L, "The animation template with the handle %d does no longer exist.", animationTemplateHandle);
|
|
|
|
|
return animationTemplatePtr;
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, idx, "'" ANIMATION_TEMPLATE_CLASS_NAME "' expected");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int newAnimationTemplate(lua_State *L) {
|
|
|
|
|
uint animationTemplateHandle = AnimationTemplate::create(luaL_checkstring(L, 1));
|
|
|
|
|
AnimationTemplate *animationTemplatePtr = AnimationTemplateRegistry::instance().resolveHandle(animationTemplateHandle);
|
|
|
|
|
if (animationTemplatePtr && animationTemplatePtr->isValid()) {
|
|
|
|
|
newUintUserData(L, animationTemplateHandle);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
//luaL_getmetatable(L, ANIMATION_TEMPLATE_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, ANIMATION_TEMPLATE_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int at_addFrame(lua_State *L) {
|
|
|
|
|
AnimationTemplate *pAT = checkAnimationTemplate(L);
|
2010-10-12 19:38:40 +00:00
|
|
|
|
pAT->addFrame(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int at_setFrame(lua_State *L) {
|
|
|
|
|
AnimationTemplate *pAT = checkAnimationTemplate(L);
|
2010-10-12 19:38:40 +00:00
|
|
|
|
pAT->setFrame(static_cast<int>(luaL_checknumber(L, 2)), static_cast<int>(luaL_checknumber(L, 3)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static bool animationTypeStringToNumber(const char *typeString, Animation::ANIMATION_TYPES &result) {
|
|
|
|
|
if (strcmp(typeString, "jojo") == 0) {
|
|
|
|
|
result = Animation::AT_JOJO;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return true;
|
2010-10-19 20:51:21 +00:00
|
|
|
|
} else if (strcmp(typeString, "loop") == 0) {
|
|
|
|
|
result = Animation::AT_LOOP;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return true;
|
2010-10-19 20:51:21 +00:00
|
|
|
|
} else if (strcmp(typeString, "oneshot") == 0) {
|
|
|
|
|
result = Animation::AT_ONESHOT;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return true;
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int at_setAnimationType(lua_State *L) {
|
|
|
|
|
AnimationTemplate *pAT = checkAnimationTemplate(L);
|
|
|
|
|
Animation::ANIMATION_TYPES animationType;
|
|
|
|
|
if (animationTypeStringToNumber(luaL_checkstring(L, 2), animationType)) {
|
|
|
|
|
pAT->setAnimationType(animationType);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 2, "Invalid animation type");
|
|
|
|
|
}
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int at_setFPS(lua_State *L) {
|
|
|
|
|
AnimationTemplate *pAT = checkAnimationTemplate(L);
|
2010-10-12 19:38:40 +00:00
|
|
|
|
pAT->setFPS(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int at_finalize(lua_State *L) {
|
|
|
|
|
AnimationTemplate *pAT = checkAnimationTemplate(L);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
delete pAT;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg ANIMATION_TEMPLATE_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"AddFrame", at_addFrame},
|
|
|
|
|
{"SetFrame", at_setFrame},
|
|
|
|
|
{"SetAnimationType", at_setAnimationType},
|
|
|
|
|
{"SetFPS", at_setFPS},
|
|
|
|
|
{"__gc", at_finalize},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static GraphicEngine *getGE() {
|
2010-10-19 21:03:33 +00:00
|
|
|
|
Kernel *pKernel = Kernel::getInstance();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(pKernel);
|
2010-10-19 21:03:33 +00:00
|
|
|
|
GraphicEngine *pGE = pKernel->getGfx();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(pGE);
|
|
|
|
|
return pGE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int init(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
|
|
|
|
switch (lua_gettop(L)) {
|
|
|
|
|
case 0:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1))));
|
2010-08-06 13:13:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2))));
|
2010-08-06 13:13:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static_cast<int>(luaL_checknumber(L, 3))));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4))));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4)),
|
|
|
|
|
lua_tobooleancpp(L, 5)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
int __startStackDepth = lua_gettop(L);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Main-Panel zum Gfx-Modul hinzuf<75>gen
|
2010-10-19 20:51:21 +00:00
|
|
|
|
RenderObjectPtr<Panel> mainPanelPtr(getGE()->getMainPanel());
|
|
|
|
|
BS_ASSERT(mainPanelPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
lua_pushstring(L, GFX_LIBRARY_NAME);
|
|
|
|
|
lua_gettable(L, LUA_GLOBALSINDEX);
|
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
newUintUserData(L, mainPanelPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
// luaL_getmetatable(L, PANEL_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, PANEL_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
lua_pushstring(L, "MainPanel");
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_insert(L, -2);
|
|
|
|
|
lua_settable(L, -3);
|
|
|
|
|
|
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
BS_ASSERT(__startStackDepth == lua_gettop(L));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int startFrame(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
if (lua_gettop(L) == 0)
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->startFrame());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
else
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->startFrame(lua_tobooleancpp(L, 1)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int endFrame(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->endFrame());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int drawDebugLine(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
Vertex start;
|
|
|
|
|
Vertex end;
|
|
|
|
|
Vertex::luaVertexToVertex(L, 1, start);
|
|
|
|
|
Vertex::luaVertexToVertex(L, 2, end);
|
|
|
|
|
pGE->drawDebugLine(start, end, GraphicEngine::luaColorToARGBColor(L, 3));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getDisplayWidth(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getDisplayWidth());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getDisplayHeight(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getDisplayHeight());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getBitDepth(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getBitDepth());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int setVsync(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
pGE->setVsync(lua_tobooleancpp(L, 1));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int isVsync(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->getVsync());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int isWindowed(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushbooleancpp(L, pGE->isWindowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getFPSCount(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getFPSCount());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getLastFrameDuration(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getLastFrameDuration());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int stopMainTimer(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
|
|
|
|
pGE->stopMainTimer();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int resumeMainTimer(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
|
|
|
|
pGE->resumeMainTimer();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getSecondaryFrameDuration(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
lua_pushnumber(L, pGE->getSecondaryFrameDuration());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int saveScreenshot(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
|
|
|
|
lua_pushbooleancpp(L, pGE->saveScreenshot(luaL_checkstring(L, 1)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int saveThumbnailScreenshot(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
|
|
|
|
lua_pushbooleancpp(L, pGE->saveThumbnailScreenshot(luaL_checkstring(L, 1)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int getRepaintedPixels(lua_State *L) {
|
|
|
|
|
GraphicEngine *pGE = getGE();
|
|
|
|
|
lua_pushnumber(L, static_cast<lua_Number>(pGE->getRepaintedPixels()));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg GFX_FUNCTIONS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"Init", init},
|
|
|
|
|
{"StartFrame", startFrame},
|
|
|
|
|
{"EndFrame", endFrame},
|
|
|
|
|
{"DrawDebugLine", drawDebugLine},
|
|
|
|
|
{"SetVsync", setVsync},
|
|
|
|
|
{"GetDisplayWidth", getDisplayWidth},
|
|
|
|
|
{"GetDisplayHeight", getDisplayHeight},
|
|
|
|
|
{"GetBitDepth", getBitDepth},
|
|
|
|
|
{"IsVsync", isVsync},
|
|
|
|
|
{"IsWindowed", isWindowed},
|
|
|
|
|
{"GetFPSCount", getFPSCount},
|
|
|
|
|
{"GetLastFrameDuration", getLastFrameDuration},
|
|
|
|
|
{"StopMainTimer", stopMainTimer},
|
|
|
|
|
{"ResumeMainTimer", resumeMainTimer},
|
|
|
|
|
{"GetSecondaryFrameDuration", getSecondaryFrameDuration},
|
|
|
|
|
{"SaveScreenshot", saveScreenshot},
|
|
|
|
|
{"NewAnimationTemplate", newAnimationTemplate},
|
|
|
|
|
{"GetRepaintedPixels", getRepaintedPixels},
|
|
|
|
|
{"SaveThumbnailScreenshot", saveThumbnailScreenshot},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static RenderObjectPtr<RenderObject> checkRenderObject(lua_State *L, bool errorIfRemoved = true) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable einer Klasse haben, die von Gfx.RenderObject "erbt".
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint *userDataPtr;
|
|
|
|
|
if ((userDataPtr = (uint *) my_checkudata(L, 1, BITMAP_CLASS_NAME)) != 0 ||
|
|
|
|
|
(userDataPtr = (uint *) my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0 ||
|
|
|
|
|
(userDataPtr = (uint *) my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0 ||
|
|
|
|
|
(userDataPtr = (uint *) my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr(*userDataPtr);
|
|
|
|
|
if (roPtr.isValid())
|
|
|
|
|
return roPtr;
|
2010-08-06 13:13:25 +00:00
|
|
|
|
else {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
if (errorIfRemoved)
|
|
|
|
|
luaL_error(L, "The renderobject with the handle %d does no longer exist.", *userDataPtr);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 1, "'" RENDEROBJECT_CLASS_NAME "' expected");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 10:52:24 +00:00
|
|
|
|
return RenderObjectPtr<RenderObject>();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_setPos(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
Vertex pos;
|
|
|
|
|
Vertex::luaVertexToVertex(L, 2, pos);
|
|
|
|
|
roPtr->setPos(pos.x, pos.y);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_setX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr->setX(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_setY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr->setY(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_setZ(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr->setZ(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_setVisible(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr->setVisible(lua_tobooleancpp(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getX());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getY());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getZ(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getZ());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getAbsoluteX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getAbsoluteX());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getAbsoluteY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getAbsoluteY());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getWidth(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getWidth());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_getHeight(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, roPtr->getHeight());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_isVisible(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, roPtr->isVisible());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_addPanel(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
RenderObjectPtr<Panel> panelPtr = roPtr->addPanel(static_cast<int>(luaL_checknumber(L, 2)),
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static_cast<int>(luaL_checknumber(L, 3)),
|
2010-10-19 20:51:21 +00:00
|
|
|
|
GraphicEngine::luaColorToARGBColor(L, 4));
|
|
|
|
|
if (panelPtr.isValid()) {
|
|
|
|
|
newUintUserData(L, panelPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// luaL_getmetatable(L, PANEL_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, PANEL_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_addBitmap(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmaPtr = roPtr->addBitmap(luaL_checkstring(L, 2));
|
|
|
|
|
if (bitmaPtr.isValid()) {
|
|
|
|
|
newUintUserData(L, bitmaPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// luaL_getmetatable(L, BITMAP_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, BITMAP_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_addText(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
RenderObjectPtr<Text> textPtr;
|
|
|
|
|
if (lua_gettop(L) >= 3)
|
|
|
|
|
textPtr = roPtr->addText(luaL_checkstring(L, 2), luaL_checkstring(L, 3));
|
|
|
|
|
else
|
|
|
|
|
textPtr = roPtr->addText(luaL_checkstring(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
if (textPtr.isValid()) {
|
|
|
|
|
newUintUserData(L, textPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// luaL_getmetatable(L, TEXT_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, TEXT_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int ro_addAnimation(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
RenderObjectPtr<Animation> animationPtr;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
if (lua_type(L, 2) == LUA_TUSERDATA)
|
2010-10-19 20:51:21 +00:00
|
|
|
|
animationPtr = roPtr->addAnimation(*checkAnimationTemplate(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
else
|
2010-10-19 20:51:21 +00:00
|
|
|
|
animationPtr = roPtr->addAnimation(luaL_checkstring(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
if (animationPtr.isValid()) {
|
|
|
|
|
newUintUserData(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// luaL_getmetatable(L, ANIMATION_CLASS_NAME);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
LuaBindhelper::getMetatable(L, ANIMATION_CLASS_NAME);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(!lua_isnil(L, -1));
|
|
|
|
|
lua_setmetatable(L, -2);
|
|
|
|
|
|
|
|
|
|
// Alle Animationscallbacks registrieren.
|
2010-10-19 20:51:21 +00:00
|
|
|
|
animationPtr->registerDeleteCallback(animationDeleteCallback, animationPtr->getHandle());
|
|
|
|
|
animationPtr->registerLoopPointCallback(animationLoopPointCallback, animationPtr->getHandle());
|
|
|
|
|
animationPtr->registerActionCallback(animationActionCallback, animationPtr->getHandle());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-07-29 19:53:02 +00:00
|
|
|
|
lua_pushnil(L);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg RENDEROBJECT_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"AddAnimation", ro_addAnimation},
|
|
|
|
|
{"AddText", ro_addText},
|
|
|
|
|
{"AddBitmap", ro_addBitmap},
|
|
|
|
|
{"AddPanel", ro_addPanel},
|
|
|
|
|
{"SetPos", ro_setPos},
|
|
|
|
|
{"SetX", ro_setX},
|
|
|
|
|
{"SetY", ro_setY},
|
|
|
|
|
{"SetZ", ro_setZ},
|
|
|
|
|
{"SetVisible", ro_setVisible},
|
|
|
|
|
{"GetX", ro_getX},
|
|
|
|
|
{"GetY", ro_getY},
|
|
|
|
|
{"GetZ", ro_getZ},
|
|
|
|
|
{"GetAbsoluteX", ro_getAbsoluteX},
|
|
|
|
|
{"GetAbsoluteY", ro_getAbsoluteY},
|
|
|
|
|
{"GetWidth", ro_getWidth},
|
|
|
|
|
{"GetHeight", ro_getHeight},
|
|
|
|
|
{"IsVisible", ro_isVisible},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static RenderObjectPtr<Panel> checkPanel(lua_State *L) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Panel
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint *userDataPtr;
|
|
|
|
|
if ((userDataPtr = (uint *)my_checkudata(L, 1, PANEL_CLASS_NAME)) != 0) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr(*userDataPtr);
|
|
|
|
|
if (roPtr.isValid()) {
|
|
|
|
|
return roPtr->toPanel();
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-10-19 20:51:21 +00:00
|
|
|
|
luaL_error(L, "The panel with the handle %d does no longer exist.", *userDataPtr);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 1, "'" PANEL_CLASS_NAME "' expected");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 10:52:24 +00:00
|
|
|
|
return RenderObjectPtr<Panel>();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int p_getColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Panel> PanelPtr = checkPanel(L);
|
2010-09-02 17:11:45 +00:00
|
|
|
|
BS_ASSERT(PanelPtr.isValid());
|
|
|
|
|
GraphicEngine::ARGBColorToLuaColor(L, PanelPtr->getColor());
|
2010-08-06 13:13:25 +00:00
|
|
|
|
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int p_setColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Panel> PanelPtr = checkPanel(L);
|
2010-09-02 17:11:45 +00:00
|
|
|
|
BS_ASSERT(PanelPtr.isValid());
|
2010-10-19 20:51:21 +00:00
|
|
|
|
PanelPtr->setColor(GraphicEngine::luaColorToARGBColor(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int p_remove(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr.erase();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg PANEL_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"GetColor", p_getColor},
|
|
|
|
|
{"SetColor", p_setColor},
|
|
|
|
|
{"Remove", p_remove},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static RenderObjectPtr<Bitmap> checkBitmap(lua_State *L) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Bitmap
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint *userDataPtr;
|
|
|
|
|
if ((userDataPtr = (uint *)my_checkudata(L, 1, BITMAP_CLASS_NAME)) != 0) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr(*userDataPtr);
|
|
|
|
|
if (roPtr.isValid()) {
|
|
|
|
|
return roPtr->toBitmap();
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else
|
2010-10-19 20:51:21 +00:00
|
|
|
|
luaL_error(L, "The bitmap with the handle %d does no longer exist.", *userDataPtr);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 1, "'" BITMAP_CLASS_NAME "' expected");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 10:52:24 +00:00
|
|
|
|
return RenderObjectPtr<Bitmap>();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setAlpha(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setAlpha(static_cast<uint>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setTintColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setModulationColor(GraphicEngine::luaColorToARGBColor(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setScaleFactor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setScaleFactor(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setScaleFactorX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setScaleFactorX(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setScaleFactorY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setScaleFactorY(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setFlipH(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setFlipH(lua_tobooleancpp(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_setFlipV(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
bitmapPtr->setFlipV(lua_tobooleancpp(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_getAlpha(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, bitmapPtr->getAlpha());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_getTintColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
GraphicEngine::ARGBColorToLuaColor(L, bitmapPtr->getModulationColor());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_getScaleFactorX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, bitmapPtr->getScaleFactorX());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_getScaleFactorY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, bitmapPtr->getScaleFactorY());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_isFlipH(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, bitmapPtr->isFlipH());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_isFlipV(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, bitmapPtr->isFlipV());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_getPixel(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
2010-08-18 12:57:47 +00:00
|
|
|
|
Vertex Pos;
|
2010-10-03 13:25:36 +00:00
|
|
|
|
Vertex::luaVertexToVertex(L, 2, Pos);
|
2010-10-19 20:51:21 +00:00
|
|
|
|
GraphicEngine::ARGBColorToLuaColor(L, bitmapPtr->getPixel(Pos.x, Pos.y));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_isScalingAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, bitmapPtr->isScalingAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_isAlphaAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, bitmapPtr->isAlphaAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_isTintingAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
|
|
|
|
|
BS_ASSERT(bitmapPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, bitmapPtr->isColorModulationAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int b_remove(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
|
|
|
|
|
BS_ASSERT(roPtr.isValid());
|
|
|
|
|
roPtr.erase();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg BITMAP_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"SetAlpha", b_setAlpha},
|
|
|
|
|
{"SetTintColor", b_setTintColor},
|
|
|
|
|
{"SetScaleFactor", b_setScaleFactor},
|
|
|
|
|
{"SetScaleFactorX", b_setScaleFactorX},
|
|
|
|
|
{"SetScaleFactorY", b_setScaleFactorY},
|
|
|
|
|
{"SetFlipH", b_setFlipH},
|
|
|
|
|
{"SetFlipV", b_setFlipV},
|
|
|
|
|
{"GetAlpha", b_getAlpha},
|
|
|
|
|
{"GetTintColor", b_getTintColor},
|
|
|
|
|
{"GetScaleFactorX", b_getScaleFactorX},
|
|
|
|
|
{"GetScaleFactorY", b_getScaleFactorY},
|
|
|
|
|
{"IsFlipH", b_isFlipH},
|
|
|
|
|
{"IsFlipV", b_isFlipV},
|
|
|
|
|
{"GetPixel", b_getPixel},
|
|
|
|
|
{"IsScalingAllowed", b_isScalingAllowed},
|
|
|
|
|
{"IsAlphaAllowed", b_isAlphaAllowed},
|
|
|
|
|
{"IsTintingAllowed", b_isTintingAllowed},
|
|
|
|
|
{"Remove", b_remove},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static RenderObjectPtr<Animation> checkAnimation(lua_State *L) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Animation
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint *userDataPtr;
|
|
|
|
|
if ((userDataPtr = (uint *)my_checkudata(L, 1, ANIMATION_CLASS_NAME)) != 0) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr(*userDataPtr);
|
|
|
|
|
if (roPtr.isValid())
|
|
|
|
|
return roPtr->toAnimation();
|
2010-08-06 13:13:25 +00:00
|
|
|
|
else {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
luaL_error(L, "The animation with the handle %d does no longer exist.", *userDataPtr);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 1, "'" ANIMATION_CLASS_NAME "' expected");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 10:52:24 +00:00
|
|
|
|
return RenderObjectPtr<Animation>();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_play(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->play();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_pause(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->pause();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_stop(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->stop();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setFrame(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setFrame(static_cast<uint>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setAlpha(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setAlpha(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setTintColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setModulationColor(GraphicEngine::luaColorToARGBColor(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setScaleFactor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setScaleFactor(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setScaleFactorX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setScaleFactorX(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_setScaleFactorY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr->setScaleFactorY(static_cast<float>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getScaleFactorX(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, animationPtr->getScaleFactorX());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getScaleFactorY(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, animationPtr->getScaleFactorY());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getAnimationType(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
switch (animationPtr->getAnimationType()) {
|
2010-08-18 10:52:24 +00:00
|
|
|
|
case Animation::AT_JOJO:
|
2010-08-06 13:13:25 +00:00
|
|
|
|
lua_pushstring(L, "jojo");
|
|
|
|
|
break;
|
2010-08-18 10:52:24 +00:00
|
|
|
|
case Animation::AT_LOOP:
|
2010-08-06 13:13:25 +00:00
|
|
|
|
lua_pushstring(L, "loop");
|
|
|
|
|
break;
|
2010-08-18 10:52:24 +00:00
|
|
|
|
case Animation::AT_ONESHOT:
|
2010-08-06 13:13:25 +00:00
|
|
|
|
lua_pushstring(L, "oneshot");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
BS_ASSERT(false);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getFPS(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, animationPtr->getFPS());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getFrameCount(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, animationPtr->getFrameCount());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_isScalingAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, animationPtr->isScalingAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_isAlphaAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, animationPtr->isAlphaAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_isTintingAllowed(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, animationPtr->isColorModulationAllowed());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getCurrentFrame(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, animationPtr->getCurrentFrame());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_getCurrentAction(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushstring(L, animationPtr->getCurrentAction().c_str());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_isPlaying(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
lua_pushbooleancpp(L, animationPtr->isRunning());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static bool animationLoopPointCallback(uint handle) {
|
2010-10-19 21:03:33 +00:00
|
|
|
|
lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject());
|
2010-10-19 20:51:21 +00:00
|
|
|
|
loopPointCallbackPtr->invokeCallbackFunctions(L, handle);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_registerLoopPointCallback(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_checktype(L, 2, LUA_TFUNCTION);
|
|
|
|
|
|
|
|
|
|
lua_pushvalue(L, 2);
|
2010-10-19 20:51:21 +00:00
|
|
|
|
loopPointCallbackPtr->registerCallbackFunction(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_unregisterLoopPointCallback(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_checktype(L, 2, LUA_TFUNCTION);
|
|
|
|
|
|
|
|
|
|
lua_pushvalue(L, 2);
|
2010-10-19 20:51:21 +00:00
|
|
|
|
loopPointCallbackPtr->unregisterCallbackFunction(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static bool animationActionCallback(uint Handle) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr(Handle);
|
|
|
|
|
if (animationPtr.isValid()) {
|
|
|
|
|
actionCallbackPtr->Action = animationPtr->getCurrentAction();
|
2010-10-19 21:03:33 +00:00
|
|
|
|
lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject());
|
2010-10-19 20:51:21 +00:00
|
|
|
|
actionCallbackPtr->invokeCallbackFunctions(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_registerActionCallback(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_checktype(L, 2, LUA_TFUNCTION);
|
|
|
|
|
|
|
|
|
|
lua_pushvalue(L, 2);
|
2010-10-19 20:51:21 +00:00
|
|
|
|
actionCallbackPtr->registerCallbackFunction(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_unregisterActionCallback(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_checktype(L, 2, LUA_TFUNCTION);
|
|
|
|
|
|
|
|
|
|
lua_pushvalue(L, 2);
|
2010-10-19 20:51:21 +00:00
|
|
|
|
actionCallbackPtr->unregisterCallbackFunction(L, animationPtr->getHandle());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static bool animationDeleteCallback(uint Handle) {
|
2010-10-19 21:03:33 +00:00
|
|
|
|
lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject());
|
2010-10-19 20:51:21 +00:00
|
|
|
|
loopPointCallbackPtr->removeAllObjectCallbacks(L, Handle);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int a_remove(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Animation> animationPtr = checkAnimation(L);
|
|
|
|
|
BS_ASSERT(animationPtr.isValid());
|
|
|
|
|
animationPtr.erase();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg ANIMATION_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"Play", a_play},
|
|
|
|
|
{"Pause", a_pause},
|
|
|
|
|
{"Stop", a_stop},
|
|
|
|
|
{"SetFrame", a_setFrame},
|
|
|
|
|
{"SetAlpha", a_setAlpha},
|
|
|
|
|
{"SetTintColor", a_setTintColor},
|
|
|
|
|
{"SetScaleFactor", a_setScaleFactor},
|
|
|
|
|
{"SetScaleFactorX", a_setScaleFactorX},
|
|
|
|
|
{"SetScaleFactorY", a_setScaleFactorY},
|
|
|
|
|
{"GetScaleFactorX", a_getScaleFactorX},
|
|
|
|
|
{"GetScaleFactorY", a_getScaleFactorY},
|
|
|
|
|
{"GetAnimationType", a_getAnimationType},
|
|
|
|
|
{"GetFPS", a_getFPS},
|
|
|
|
|
{"GetFrameCount", a_getFrameCount},
|
|
|
|
|
{"IsScalingAllowed", a_isScalingAllowed},
|
|
|
|
|
{"IsAlphaAllowed", a_isAlphaAllowed},
|
|
|
|
|
{"IsTintingAllowed", a_isTintingAllowed},
|
|
|
|
|
{"GetCurrentFrame", a_getCurrentFrame},
|
|
|
|
|
{"GetCurrentAction", a_getCurrentAction},
|
|
|
|
|
{"IsPlaying", a_isPlaying},
|
|
|
|
|
{"RegisterLoopPointCallback", a_registerLoopPointCallback},
|
|
|
|
|
{"UnregisterLoopPointCallback", a_unregisterLoopPointCallback},
|
|
|
|
|
{"RegisterActionCallback", a_registerActionCallback},
|
|
|
|
|
{"UnregisterActionCallback", a_unregisterActionCallback},
|
|
|
|
|
{"Remove", a_remove},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static RenderObjectPtr<Text> checkText(lua_State *L) {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
// Der erste Parameter muss vom Typ userdata sein und die Metatable der Klasse Gfx.Text
|
2010-10-19 20:51:21 +00:00
|
|
|
|
uint *userDataPtr;
|
|
|
|
|
if ((userDataPtr = (uint *)my_checkudata(L, 1, TEXT_CLASS_NAME)) != 0) {
|
|
|
|
|
RenderObjectPtr<RenderObject> roPtr(*userDataPtr);
|
|
|
|
|
if (roPtr.isValid())
|
|
|
|
|
return roPtr->toText();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
else
|
2010-10-19 20:51:21 +00:00
|
|
|
|
luaL_error(L, "The text with the handle %d does no longer exist.", *userDataPtr);
|
2010-08-06 13:13:25 +00:00
|
|
|
|
} else {
|
2010-07-29 19:53:02 +00:00
|
|
|
|
luaL_argcheck(L, 0, 1, "'" TEXT_CLASS_NAME "' expected");
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 10:52:24 +00:00
|
|
|
|
return RenderObjectPtr<Text>();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setFont(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
textPtr->setFont(luaL_checkstring(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setText(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
textPtr->setText(luaL_checkstring(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setAlpha(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
|
|
|
|
textPtr->setAlpha(static_cast<int>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
|
|
|
|
textPtr->setColor(GraphicEngine::luaColorToARGBColor(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setAutoWrap(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
textPtr->setAutoWrap(lua_tobooleancpp(L, 2));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_setAutoWrapThreshold(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
textPtr->setAutoWrapThreshold(static_cast<uint>(luaL_checknumber(L, 2)));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_getText(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
lua_pushstring(L, textPtr->getText().c_str());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_getFont(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
lua_pushstring(L, textPtr->getFont().c_str());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_getAlpha(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, textPtr->getAlpha());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_getColor(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
|
|
|
|
lua_pushnumber(L, textPtr->getColor());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_isAutoWrap(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
lua_pushbooleancpp(L, textPtr->isAutoWrapActive());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_getAutoWrapThreshold(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
2010-10-19 20:54:30 +00:00
|
|
|
|
lua_pushnumber(L, textPtr->getAutoWrapThreshold());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
static int t_remove(lua_State *L) {
|
|
|
|
|
RenderObjectPtr<Text> textPtr = checkText(L);
|
|
|
|
|
BS_ASSERT(textPtr.isValid());
|
|
|
|
|
textPtr.erase();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
|
static const luaL_reg TEXT_METHODS[] = {
|
2010-10-19 20:51:21 +00:00
|
|
|
|
{"SetFont", t_setFont},
|
|
|
|
|
{"SetText", t_setText},
|
|
|
|
|
{"SetAlpha", t_setAlpha},
|
|
|
|
|
{"SetColor", t_setColor},
|
|
|
|
|
{"SetAutoWrap", t_setAutoWrap},
|
|
|
|
|
{"SetAutoWrapThreshold", t_setAutoWrapThreshold},
|
|
|
|
|
{"GetText", t_getText},
|
|
|
|
|
{"GetFont", t_getFont},
|
|
|
|
|
{"GetAlpha", t_getAlpha},
|
|
|
|
|
{"GetColor", t_getColor},
|
|
|
|
|
{"IsAutoWrap", t_isAutoWrap},
|
|
|
|
|
{"GetAutoWrapThreshold", t_getAutoWrapThreshold},
|
|
|
|
|
{"Remove", t_remove},
|
2010-08-06 10:59:50 +00:00
|
|
|
|
{0, 0}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
bool GraphicEngine::registerScriptBindings() {
|
2010-10-19 21:03:33 +00:00
|
|
|
|
Kernel *pKernel = Kernel::getInstance();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(pKernel);
|
2010-10-19 21:03:33 +00:00
|
|
|
|
ScriptEngine *pScript = pKernel->getScript();
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(pScript);
|
2010-10-03 13:25:22 +00:00
|
|
|
|
lua_State *L = static_cast<lua_State *>(pScript->getScriptObject());
|
2010-07-29 19:53:02 +00:00
|
|
|
|
BS_ASSERT(L);
|
|
|
|
|
|
2010-10-03 13:25:22 +00:00
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, BITMAP_CLASS_NAME, RENDEROBJECT_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, ANIMATION_CLASS_NAME, RENDEROBJECT_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, PANEL_CLASS_NAME, RENDEROBJECT_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, TEXT_CLASS_NAME, RENDEROBJECT_METHODS)) return false;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-03 13:25:22 +00:00
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, PANEL_CLASS_NAME, PANEL_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, BITMAP_CLASS_NAME, BITMAP_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, TEXT_CLASS_NAME, TEXT_METHODS)) return false;
|
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, ANIMATION_CLASS_NAME, ANIMATION_METHODS)) return false;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-03 13:25:22 +00:00
|
|
|
|
if (!LuaBindhelper::addMethodsToClass(L, ANIMATION_TEMPLATE_CLASS_NAME, ANIMATION_TEMPLATE_METHODS)) return false;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-03 13:25:22 +00:00
|
|
|
|
if (!LuaBindhelper::addFunctionsToLib(L, GFX_LIBRARY_NAME, GFX_FUNCTIONS)) return false;
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
2010-10-19 20:51:21 +00:00
|
|
|
|
loopPointCallbackPtr.reset(new LuaCallback(L));
|
|
|
|
|
actionCallbackPtr.reset(new ActionCallback(L));
|
2010-07-29 19:53:02 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-08-05 12:48:19 +00:00
|
|
|
|
|
|
|
|
|
} // End of namespace Sword25
|