/* Make changes to a text object based on the parameters passed * in the table in the LUA parameter 2. */ void Lua_V1::ChangeTextObject() { const char *line; lua_Object textObj = lua_getparam(1); int paramId = 2; if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) { TextObject *textObject = gettextobject(textObj); for (;;) { lua_Object paramObj = lua_getparam(paramId++); if (!paramObj) break; if (!lua_isstring(paramObj)) { if (!lua_istable(paramObj)) break; setTextObjectParams(textObject, paramObj); textObject->reposition(); textObject->destroy(); } else { line = lua_getstring(paramObj); textObject->setText(line); lua_getstring(paramObj); } lua_pushnumber(textObject->getBitmapWidth()); lua_pushnumber(textObject->getBitmapHeight()); } } }
/* Destroy a text object since we don't need it anymore * note that the menu creates more objects than it needs, * so it deletes some objects right after creating them */ void Lua_V1::KillTextObject() { lua_Object textObj = lua_getparam(1); if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) { delete gettextobject(textObj); } }
void Lua_V1::GetTextCharPosition() { lua_Object textObj = lua_getparam(1); if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) { TextObject *textObject = gettextobject(textObj); int pos = (int)lua_getnumber(lua_getparam(2)); lua_pushnumber(textObject->getTextCharPosition(pos)); } }
void Lua_V1::GetTextObjectDimensions() { lua_Object textObj = lua_getparam(1); if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) { TextObject *textObject = gettextobject(textObj); lua_pushnumber(textObject->getBitmapWidth()); lua_pushnumber(textObject->getBitmapHeight()); } }