GRIM: Incapsulate the lua opcodes in a class hierarchy.

This commit is contained in:
Giulio Camuffo 2011-10-12 17:42:40 +02:00
parent da552f96f8
commit 5ca9cae83c
14 changed files with 1739 additions and 1619 deletions

View File

@ -755,7 +755,7 @@ void Actor::sayLine(const char *msgId, bool background) {
assert(msgId);
char id[50];
Common::String msg = parseMsgText(msgId, id);
Common::String msg = LuaBase::instance()->parseMsgText(msgId, id);
if (msgId[0] == 0) {
error("Actor::sayLine: No message ID for text");

View File

@ -51,6 +51,8 @@
#include "engines/grim/debug.h"
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/lua_v1.h"
#include "engines/grim/lua_v2.h"
#include "engines/grim/actor.h"
#include "engines/grim/movie/movie.h"
#include "engines/grim/savegame.h"
@ -74,8 +76,6 @@
namespace Grim {
static bool g_lua_initialized = false;
// CHAR_KEY tests to see whether a keycode is for
// a "character" handler or a "button" handler
#define CHAR_KEY(k) ((k >= 'a' && k <= 'z') || (k >= 'A' && k <= 'Z') || (k >= '0' && k <= '9') || k == ' ')
@ -189,12 +189,7 @@ GrimEngine::~GrimEngine() {
ObjectState::getPool()->deleteObjects();
PoolColor::getPool()->deleteObjects();
if (g_lua_initialized) {
lua_removelibslists();
lua_close();
lua_iolibclose();
g_lua_initialized = false;
}
delete LuaBase::instance();
if (g_registry) {
g_registry->save();
delete g_registry;
@ -261,28 +256,23 @@ Common::Error GrimEngine::run() {
g_driver->flipBuffer();
lua_iolibopen();
lua_strlibopen();
lua_mathlibopen();
LuaBase *lua = NULL;
if (getGameType() == GType_GRIM) {
registerGrimOpcodes();
lua = new Lua_L1();
// FIXME/HACK: see PutActorInSet
const char *func = "function reset_doorman() doorman_in_hot_box = FALSE end";
lua_pushstring(func);
lua_call("dostring");
} else
registerMonkeyOpcodes();
} else {
lua = new Lua_L2();
}
registerLua();
g_lua_initialized = true;
lua->registerOpcodes();
lua->registerLua();
bundle_dofile("_system.lua");
lua_pushnil(); // resumeSave
lua_pushnil(); // bootParam - not used in scripts
lua_call("BOOT");
bundle_dofile("_system.lua"); // TODO: Move in LuaBase.
lua->boot();
_savegameLoadRequest = false;
_savegameSaveRequest = false;
@ -649,11 +639,11 @@ void GrimEngine::luaUpdate() {
}
lua_beginblock();
setFrameTime(_frameTime);
LuaBase::instance()->setFrameTime(_frameTime);
lua_endblock();
lua_beginblock();
setMovieTime(_movieTime);
LuaBase::instance()->setMovieTime(_movieTime);
lua_endblock();
// Run asynchronous tasks

433
engines/grim/lua.cpp Normal file
View File

@ -0,0 +1,433 @@
/* Residual - A 3D game interpreter
*
* Residual 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "common/endian.h"
#include "common/system.h"
#include "math/matrix3.h"
#include "engines/grim/debug.h"
#include "engines/grim/lua.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/costume.h"
#include "engines/grim/registry.h"
#include "engines/grim/localize.h"
#include "engines/grim/colormap.h"
#include "engines/grim/grim.h"
#include "engines/grim/savegame.h"
#include "engines/grim/resource.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
#include "engines/grim/set.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/model.h"
#include "engines/grim/primitives.h"
#include "engines/grim/lua/lauxlib.h"
#include "engines/grim/lua/luadebug.h"
#include "engines/grim/lua/lualib.h"
namespace Grim {
int refSystemTable;
int refTypeOverride;
int refOldConcatFallback;
int refTextObjectX;
int refTextObjectY;
int refTextObjectFont;
int refTextObjectWidth;
int refTextObjectHeight;
int refTextObjectFGColor;
int refTextObjectBGColor;
int refTextObjectFXColor;
int refTextObjectHIColor;
int refTextObjectDuration;
int refTextObjectCenter;
int refTextObjectLJustify;
int refTextObjectRJustify;
int refTextObjectVolume;
int refTextObjectBackground;
int refTextObjectPan;
LuaBase *LuaBase::s_instance = NULL;
LuaBase::LuaBase() :
_translationMode(0) {
s_instance = this;
lua_iolibopen();
lua_strlibopen();
lua_mathlibopen();
}
LuaBase::~LuaBase() {
s_instance = NULL;
lua_removelibslists();
lua_close();
lua_iolibclose();
}
// Entries in the system table
static struct {
const char *name;
int key;
} system_defaults[] = {
{ "frameTime", 0 },
{ "movieTime", 0 }
};
void LuaBase::registerLua() {
// Register system table
lua_Object system_table = lua_createtable();
lua_pushobject(system_table);
lua_setglobal("system");
lua_pushobject(system_table);
refSystemTable = lua_ref(1);
for (unsigned i = 0; i < ARRAYSIZE(system_defaults); i++) {
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring(system_defaults[i].name);
lua_pushnumber(system_defaults[i].key);
lua_settable();
}
// Create and populate system.controls table
lua_Object controls_table = lua_createtable();
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("controls");
lua_pushobject(controls_table);
lua_settable();
for (int i = 0; controls[i].name; i++) {
lua_pushobject(controls_table);
lua_pushstring(controls[i].name);
lua_pushnumber(controls[i].key);
lua_settable();
}
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("camChangeHandler");
lua_pushcfunction(LUA_OPCODE(LuaBase, dummyHandler));
lua_settable();
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("axisHandler");
lua_pushcfunction(LUA_OPCODE(LuaBase, dummyHandler));
lua_settable();
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("buttonHandler");
lua_pushcfunction(LUA_OPCODE(LuaBase, dummyHandler));
lua_settable();
lua_pushobject(lua_getglobal("type"));
refTypeOverride = lua_ref(true);
lua_pushCclosure(LUA_OPCODE(LuaBase, typeOverride), 0);
lua_setglobal("type");
// Register constants for box types
lua_pushnumber(Sector::NoneType);
lua_setglobal("NONE");
lua_pushnumber(Sector::WalkType);
lua_setglobal("WALK");
lua_pushnumber(Sector::CameraType);
lua_setglobal("CAMERA");
lua_pushnumber(Sector::SpecialType);
lua_setglobal("SPECIAL");
lua_pushnumber(Sector::HotType);
lua_setglobal("HOT");
lua_pushobject(lua_setfallback("concat", LUA_OPCODE(LuaBase, concatFallback)));
refOldConcatFallback = lua_ref(1);
// initialize Text globals
lua_pushstring("x");
refTextObjectX = lua_ref(true);
lua_pushstring("y");
refTextObjectY = lua_ref(true);
lua_pushstring("font");
refTextObjectFont = lua_ref(true);
lua_pushstring("width");
refTextObjectWidth = lua_ref(true);
lua_pushstring("height");
refTextObjectHeight = lua_ref(true);
lua_pushstring("fgcolor");
refTextObjectFGColor = lua_ref(true);
lua_pushstring("bgcolor");
refTextObjectBGColor = lua_ref(true);
lua_pushstring("fxcolor");
refTextObjectFXColor = lua_ref(true);
lua_pushstring("hicolor");
refTextObjectHIColor = lua_ref(true);
lua_pushstring("duration");
refTextObjectDuration = lua_ref(true);
lua_pushstring("center");
refTextObjectCenter = lua_ref(true);
lua_pushstring("ljustify");
refTextObjectLJustify = lua_ref(true);
lua_pushstring("rjustify");
refTextObjectRJustify = lua_ref(true);
lua_pushstring("volume");
refTextObjectVolume = lua_ref(true);
lua_pushstring("pan");
refTextObjectPan = lua_ref(true);
lua_pushstring("background");
refTextObjectBackground = lua_ref(true);
}
struct luaL_reg baseOpcodes[] = {
{ " concatfallback", LUA_OPCODE(LuaBase, concatFallback) },
{ " typeoverride", LUA_OPCODE(LuaBase, typeOverride) },
{ " dfltcamera", LUA_OPCODE(LuaBase, dummyHandler) },
{ " dfltcontrol", LUA_OPCODE(LuaBase, dummyHandler) },
};
void LuaBase::registerOpcodes() {
luaL_openlib(baseOpcodes, ARRAYSIZE(baseOpcodes));
}
void LuaBase::boot() {
lua_pushnil(); // resumeSave
lua_pushnil(); // bootParam - not used in scripts
lua_call("BOOT");
}
void LuaBase::setFrameTime(float frameTime) {
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("frameTime");
lua_pushnumber(frameTime);
lua_settable();
}
void LuaBase::setMovieTime(float movieTime) {
lua_pushobject(lua_getref(refSystemTable));
lua_pushstring("movieTime");
lua_pushnumber(movieTime);
lua_settable();
}
bool LuaBase::getbool(int num) {
return !lua_isnil(lua_getparam(num));
}
void LuaBase::pushbool(bool val) {
if (val)
lua_pushnumber(1);
else
lua_pushnil();
}
void LuaBase::pushobject(PoolObjectBase *o) {
lua_pushusertag(o->getId(), o->getTag());
}
Actor *LuaBase::getactor(lua_Object obj) {
return Actor::getPool()->getObject(lua_getuserdata(obj));
}
TextObject *LuaBase::gettextobject(lua_Object obj) {
return TextObject::getPool()->getObject(lua_getuserdata(obj));
}
Font *LuaBase::getfont(lua_Object obj) {
return Font::getPool()->getObject(lua_getuserdata(obj));
}
PoolColor *LuaBase::getcolor(lua_Object obj) {
return PoolColor::getPool()->getObject(lua_getuserdata(obj));
}
PrimitiveObject *LuaBase::getprimitive(lua_Object obj) {
return PrimitiveObject::getPool()->getObject(lua_getuserdata(obj));
}
ObjectState *LuaBase::getobjectstate(lua_Object obj) {
return ObjectState::getPool()->getObject(lua_getuserdata(obj));
}
void LuaBase::dummyHandler() {
}
bool LuaBase::findCostume(lua_Object costumeObj, Actor *actor, Costume **costume) {
*costume = actor->getCurrentCostume(); // should be root of list I think
if (lua_isnil(costumeObj))
return true;
if (lua_isnumber(costumeObj)) {
/* int num = (int)lua_getnumber(costumeObj);*/
error("findCostume: search by Id not implemented");
// TODO get costume by ID ?
}
if (lua_isstring(costumeObj)) {
*costume = actor->findCostume(lua_getstring(costumeObj));
return *costume != 0;
}
return false;
}
Common::String LuaBase::parseMsgText(const char *msg, char *msgId) {
Common::String translation = g_localizer->localize(msg);
const char *secondSlash = NULL;
if (msg[0] == '/' && msgId) {
secondSlash = strchr(msg + 1, '/');
if (secondSlash) {
strncpy(msgId, msg + 1, secondSlash - msg - 1);
msgId[secondSlash - msg - 1] = 0;
} else {
msgId[0] = 0;
}
}
if (_translationMode == 1)
return secondSlash;
if (_translationMode == 2)
return msg;
return translation;
}
void LuaBase::parseSayLineTable(lua_Object paramObj, bool *background, int *vol, int *pan, int *x, int *y) {
lua_Object tableObj;
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectX));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*x)
*x = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectY));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*y)
*y = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectBackground));
tableObj = lua_gettable();
if (tableObj) {
if (*background)
*background = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectVolume));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*vol)
*vol = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectPan));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*pan)
*pan = (int)lua_getnumber(tableObj);
}
}
void LuaBase::typeOverride() {
lua_Object data = lua_getparam(1);
if (lua_isuserdata(data)) {
switch (lua_tag(data)) {
case MKTAG('A','C','T','R'):
lua_pushstring("actor");
lua_pushnumber(lua_tag(data));
return;
case MKTAG('C','O','S','T'):
lua_pushstring("costume");
lua_pushnumber(lua_tag(data));
return;
case MKTAG('S','E','T',' '):
lua_pushstring("set");
lua_pushnumber(lua_tag(data));
return;
case MKTAG('K','E','Y','F'):
lua_pushstring("keyframe");
lua_pushnumber(lua_tag(data));
return;
default:
break;
}
}
lua_pushobject(data);
lua_callfunction(lua_getref(refTypeOverride));
lua_Object param1 = lua_getresult(1);
lua_Object param2 = lua_getresult(2);
lua_pushobject(param1);
lua_pushobject(param2);
}
void LuaBase::concatFallback() {
lua_Object params[2];
char result[200];
char *strPtr;
params[0] = lua_getparam(1);
params[1] = lua_getparam(2);
result[0] = 0;
for (int i = 0; i < 2; i++) {
if (!lua_isnil(params[i]) && !lua_isuserdata(params[i]) && !lua_isstring(params[i])) {
lua_pushobject(params[0]);
lua_pushobject(params[1]);
lua_callfunction(lua_getref(refOldConcatFallback));
lua_pushobject(lua_getresult(1));
return;
}
int pos = strlen(result);
strPtr = &result[pos];
if (lua_isnil(params[i]))
sprintf(strPtr, "(nil)");
else if (lua_isstring(params[i]))
sprintf(strPtr, "%s", lua_getstring(params[i]));
else if (lua_tag(params[i]) == MKTAG('A','C','T','R')) {
Actor *a = getactor(params[i]);
sprintf(strPtr, "(actor%p:%s)", (void *)a,
(a->getCurrentCostume() && a->getCurrentCostume()->getModelNodes()) ?
a->getCurrentCostume()->getModelNodes()->_name : "");
} else {
lua_pushobject(params[0]);
lua_pushobject(params[1]);
lua_callfunction(lua_getref(refOldConcatFallback));
lua_pushobject(lua_getresult(1));
return;
}
}
lua_pushstring(result);
}
}

View File

@ -58,243 +58,57 @@ extern int refTextObjectVolume;
extern int refTextObjectBackground;
extern int refTextObjectPan;
// Helpers
bool getbool(int num);
void pushbool(bool val);
void pushobject(PoolObjectBase *o);
int getobject(lua_Object obj);
Actor *getactor(lua_Object obj);
TextObject *gettextobject(lua_Object obj);
Font *getfont(lua_Object obj);
PoolColor *getcolor(lua_Object obj);
PrimitiveObject *getprimitive(lua_Object obj);
ObjectState *getobjectstate(lua_Object obj);
byte clamp_color(int c);
bool findCostume(lua_Object costumeObj, Actor *actor, Costume **costume);
#define DECLARE_LUA_OPCODE(func) \
inline static void static_##func() {\
static_cast<LuaClass *>(LuaBase::instance())->func();\
}\
virtual void func()
Common::String parseMsgText(const char *msg, char *msgId);
void parseSayLineTable(lua_Object paramObj, bool *background, int *vol, int *pan, int *x, int *y);
void setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj);
void dummyHandler();
#define LUA_OPCODE(class, func) \
class::static_##func
void setFrameTime(float frameTime);
void setMovieTime(float movieTime);
void registerGrimOpcodes();
void registerMonkeyOpcodes();
void registerLua();
class LuaBase {
public:
typedef LuaBase LuaClass;
// Opcodes
void L1_new_dofile();
void L1_PrintDebug();
void L1_PrintError();
void L1_PrintWarning();
void L1_FunctionName();
void L1_CheckForFile();
void L1_MakeColor();
void L1_GetColorComponents();
void L1_ReadRegistryValue();
void L1_WriteRegistryValue();
void L1_LoadActor();
void L1_GetActorTimeScale();
void L1_SetSelectedActor();
void L1_GetCameraActor();
void L1_SetSayLineDefaults();
void L1_SetActorTalkColor();
void L1_GetActorTalkColor();
void L1_SetActorRestChore();
void L1_SetActorWalkChore();
void L1_SetActorTurnChores();
void L1_SetActorTalkChore();
void L1_SetActorMumblechore();
void L1_SetActorVisibility();
void L1_SetActorScale();
void L1_SetActorTimeScale();
void L1_SetActorCollisionMode();
void L1_SetActorCollisionScale();
void L1_PutActorAt();
void L1_GetActorPos();
void L1_SetActorRot();
void L1_GetActorRot();
void L1_IsActorTurning();
void L1_GetAngleBetweenActors();
void L1_GetAngleBetweenVectors();
void L1_GetActorYawToPoint();
void L1_PutActorInSet();
void L1_SetActorWalkRate();
void L1_GetActorWalkRate();
void L1_SetActorTurnRate();
void L1_WalkActorForward();
void L1_SetActorReflection();
void L1_GetActorPuckVector();
void L1_ActorPuckOrient();
void L1_WalkActorTo();
void L1_ActorToClean();
void L1_IsActorMoving();
void L1_Is3DHardwareEnabled();
void L1_SetHardwareState();
void L1_SetVideoDevices();
void L1_GetVideoDevices();
void L1_EnumerateVideoDevices();
void L1_Enumerate3DDevices();
void L1_IsActorResting();
void L1_GetActorNodeLocation();
void L1_SetActorWalkDominate();
void L1_SetActorColormap();
void L1_TurnActor();
void L1_PushActorCostume();
void L1_SetActorCostume();
void L1_GetActorCostume();
void L1_PopActorCostume();
void L1_GetActorCostumeDepth();
void L1_PrintActorCostumes();
void L1_LoadCostume();
void L1_PlayActorChore();
void L1_CompleteActorChore();
void L1_PlayActorChoreLooping();
void L1_SetActorChoreLooping();
void L1_StopActorChore();
void L1_FadeOutChore();
void L1_FadeInChore();
void L1_IsActorChoring();
void L1_ActorLookAt();
void L1_TurnActorTo();
void L1_PointActorAt();
void L1_WalkActorVector();
void L1_RotateVector();
void L1_SetActorPitch();
void L1_SetActorLookRate();
void L1_GetActorLookRate();
void L1_SetActorHead();
void L1_PutActorAtInterest();
void L1_SetActorFollowBoxes();
void L1_SetActorConstrain();
void L1_GetVisibleThings();
void L1_SetShadowColor();
void L1_KillActorShadows();
void L1_SetActiveShadow();
void L1_SetActorShadowPoint();
void L1_SetActorShadowPlane();
void L1_AddShadowPlane();
void L1_ActivateActorShadow();
void L1_SetActorShadowValid();
void L1_TextFileGetLine();
void L1_TextFileGetLineCount();
void L1_LocalizeString();
void L1_SayLine();
void L1_PrintLine();
void L1_InputDialog();
void L1_IsMessageGoing();
void L1_ShutUpActor();
void L1_GetPointSector();
void L1_GetActorSector();
void L1_IsActorInSector();
void L1_IsPointInSector();
void L1_MakeSectorActive();
void L1_LockSet();
void L1_UnLockSet();
void L1_MakeCurrentSet();
void L1_MakeCurrentSetup();
void L1_GetCurrentSetup();
void L1_ShrinkBoxes();
void L1_UnShrinkBoxes();
void L1_GetShrinkPos();
void L1_ImStartSound();
void L1_ImStopSound();
void L1_ImStopAllSounds();
void L1_ImPause();
void L1_ImResume();
void L1_ImSetVoiceEffect();
void L1_ImSetMusicVol();
void L1_ImGetMusicVol();
void L1_ImSetVoiceVol();
void L1_ImGetVoiceVol();
void L1_ImSetSfxVol();
void L1_ImGetSfxVol();
void L1_ImSetParam();
void L1_ImGetParam();
void L1_ImFadeParam();
void L1_ImSetState();
void L1_ImSetSequence();
void L1_SaveIMuse();
void L1_RestoreIMuse();
void L1_SetSoundPosition();
void L1_IsSoundPlaying();
void L1_PlaySoundAt();
void L1_FileFindDispose();
void L1_FileFindNext();
void L1_FileFindFirst();
void L1_PerSecond();
void L1_EnableControl();
void L1_DisableControl();
void L1_GetControlState();
void L1_GetImage();
void L1_FreeImage();
void L1_BlastImage();
void L1_CleanBuffer();
void L1_Exit();
void L1_KillTextObject();
void L1_ChangeTextObject();
void L1_GetTextSpeed();
void L1_SetTextSpeed();
void L1_MakeTextObject();
void L1_GetTextObjectDimensions();
void L1_ExpireText();
void L1_GetTextCharPosition();
void L1_BlastText();
void L1_SetOffscreenTextPos();
void L1_SetSpeechMode();
void L1_GetSpeechMode();
void L1_StartFullscreenMovie();
void L1_StartMovie();
void L1_IsFullscreenMoviePlaying();
void L1_IsMoviePlaying();
void L1_StopMovie();
void L1_PauseMovie();
void L1_PurgePrimitiveQueue();
void L1_DrawPolygon();
void L1_DrawLine();
void L1_ChangePrimitive();
void L1_DrawRectangle();
void L1_BlastRect();
void L1_KillPrimitive();
void L1_DimScreen();
void L1_DimRegion();
void L1_GetDiskFreeSpace();
void L1_NewObjectState();
void L1_FreeObjectState();
void L1_SendObjectToBack();
void L1_SendObjectToFront();
void L1_SetObjectType();
void L1_GetCurrentScript();
void L1_ScreenShot();
void L1_GetSaveGameImage();
void L1_SubmitSaveGameData();
void L1_GetSaveGameData();
void L1_Load();
void L1_Save();
void L1_Remove();
void L1_LockFont();
void L1_EnableDebugKeys();
void L1_LightMgrSetChange();
void L1_SetAmbientLight();
void L1_SetLightIntensity();
void L1_SetLightPosition();
void L1_TurnLightOn();
void L1_RenderModeUser();
void L1_PreRender();
void L1_IrisUp();
void L1_IrisDown();
void L1_SetGamma();
void L1_Display();
void L1_EngineDisplay();
void L1_ForceRefresh();
void L1_JustLoaded();
void L1_PlaySound();
void L1_SetEmergencyFont();
void L1_LoadBundle();
void L1_LightMgrStartup();
void L1_typeOverride();
void L1_concatFallback();
LuaBase();
virtual ~LuaBase();
inline static LuaBase *instance() { return s_instance; }
bool getbool(int num);
void pushbool(bool val);
void pushobject(PoolObjectBase *o);
int getobject(lua_Object obj);
Actor *getactor(lua_Object obj);
TextObject *gettextobject(lua_Object obj);
Font *getfont(lua_Object obj);
PoolColor *getcolor(lua_Object obj);
PrimitiveObject *getprimitive(lua_Object obj);
ObjectState *getobjectstate(lua_Object obj);
virtual bool findCostume(lua_Object costumeObj, Actor *actor, Costume **costume);
virtual Common::String parseMsgText(const char *msg, char *msgId);
virtual void parseSayLineTable(lua_Object paramObj, bool *background, int *vol, int *pan, int *x, int *y);
virtual void setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj);
void setFrameTime(float frameTime);
void setMovieTime(float movieTime);
virtual void registerLua();
virtual void registerOpcodes();
virtual void boot();
DECLARE_LUA_OPCODE(dummyHandler);
DECLARE_LUA_OPCODE(typeOverride);
DECLARE_LUA_OPCODE(concatFallback);
private:
// 0 - translate from '/msgId/'
// 1 - don't translate - message after '/msgId'
// 2 - return '/msgId/'
int _translationMode;
static LuaBase *s_instance;
};
} // end of namespace Grim

File diff suppressed because it is too large Load Diff

281
engines/grim/lua_v1.h Normal file
View File

@ -0,0 +1,281 @@
/* Residual - A 3D game interpreter
*
* Residual 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#ifndef GRIM_LUA_L1
#define GRIM_LUA_L1
#include "engines/grim/lua.h"
namespace Grim {
class Lua_L1 : public LuaBase {
public:
typedef Lua_L1 LuaClass;
void registerOpcodes();
// Opcodes
DECLARE_LUA_OPCODE(new_dofile);
DECLARE_LUA_OPCODE(PrintDebug);
DECLARE_LUA_OPCODE(PrintError);
DECLARE_LUA_OPCODE(PrintWarning);
DECLARE_LUA_OPCODE(FunctionName);
DECLARE_LUA_OPCODE(CheckForFile);
DECLARE_LUA_OPCODE(MakeColor);
DECLARE_LUA_OPCODE(GetColorComponents);
DECLARE_LUA_OPCODE(ReadRegistryValue);
DECLARE_LUA_OPCODE(WriteRegistryValue);
DECLARE_LUA_OPCODE(LoadActor);
DECLARE_LUA_OPCODE(GetActorTimeScale);
DECLARE_LUA_OPCODE(SetSelectedActor);
DECLARE_LUA_OPCODE(GetCameraActor);
DECLARE_LUA_OPCODE(SetSayLineDefaults);
DECLARE_LUA_OPCODE(SetActorTalkColor);
DECLARE_LUA_OPCODE(GetActorTalkColor);
DECLARE_LUA_OPCODE(SetActorRestChore);
DECLARE_LUA_OPCODE(SetActorWalkChore);
DECLARE_LUA_OPCODE(SetActorTurnChores);
DECLARE_LUA_OPCODE(SetActorTalkChore);
DECLARE_LUA_OPCODE(SetActorMumblechore);
DECLARE_LUA_OPCODE(SetActorVisibility);
DECLARE_LUA_OPCODE(SetActorScale);
DECLARE_LUA_OPCODE(SetActorTimeScale);
DECLARE_LUA_OPCODE(SetActorCollisionMode);
DECLARE_LUA_OPCODE(SetActorCollisionScale);
DECLARE_LUA_OPCODE(PutActorAt);
DECLARE_LUA_OPCODE(GetActorPos);
DECLARE_LUA_OPCODE(SetActorRot);
DECLARE_LUA_OPCODE(GetActorRot);
DECLARE_LUA_OPCODE(IsActorTurning);
DECLARE_LUA_OPCODE(GetAngleBetweenActors);
DECLARE_LUA_OPCODE(GetAngleBetweenVectors);
DECLARE_LUA_OPCODE(GetActorYawToPoint);
DECLARE_LUA_OPCODE(PutActorInSet);
DECLARE_LUA_OPCODE(SetActorWalkRate);
DECLARE_LUA_OPCODE(GetActorWalkRate);
DECLARE_LUA_OPCODE(SetActorTurnRate);
DECLARE_LUA_OPCODE(WalkActorForward);
DECLARE_LUA_OPCODE(SetActorReflection);
DECLARE_LUA_OPCODE(GetActorPuckVector);
DECLARE_LUA_OPCODE(ActorPuckOrient);
DECLARE_LUA_OPCODE(WalkActorTo);
DECLARE_LUA_OPCODE(ActorToClean);
DECLARE_LUA_OPCODE(IsActorMoving);
DECLARE_LUA_OPCODE(Is3DHardwareEnabled);
DECLARE_LUA_OPCODE(SetHardwareState);
DECLARE_LUA_OPCODE(SetVideoDevices);
DECLARE_LUA_OPCODE(GetVideoDevices);
DECLARE_LUA_OPCODE(EnumerateVideoDevices);
DECLARE_LUA_OPCODE(Enumerate3DDevices);
DECLARE_LUA_OPCODE(IsActorResting);
DECLARE_LUA_OPCODE(GetActorNodeLocation);
DECLARE_LUA_OPCODE(SetActorWalkDominate);
DECLARE_LUA_OPCODE(SetActorColormap);
DECLARE_LUA_OPCODE(TurnActor);
DECLARE_LUA_OPCODE(PushActorCostume);
DECLARE_LUA_OPCODE(SetActorCostume);
DECLARE_LUA_OPCODE(GetActorCostume);
DECLARE_LUA_OPCODE(PopActorCostume);
DECLARE_LUA_OPCODE(GetActorCostumeDepth);
DECLARE_LUA_OPCODE(PrintActorCostumes);
DECLARE_LUA_OPCODE(LoadCostume);
DECLARE_LUA_OPCODE(PlayActorChore);
DECLARE_LUA_OPCODE(CompleteActorChore);
DECLARE_LUA_OPCODE(PlayActorChoreLooping);
DECLARE_LUA_OPCODE(SetActorChoreLooping);
DECLARE_LUA_OPCODE(StopActorChore);
DECLARE_LUA_OPCODE(FadeOutChore);
DECLARE_LUA_OPCODE(FadeInChore);
DECLARE_LUA_OPCODE(IsActorChoring);
DECLARE_LUA_OPCODE(ActorLookAt);
DECLARE_LUA_OPCODE(TurnActorTo);
DECLARE_LUA_OPCODE(PointActorAt);
DECLARE_LUA_OPCODE(WalkActorVector);
DECLARE_LUA_OPCODE(RotateVector);
DECLARE_LUA_OPCODE(SetActorPitch);
DECLARE_LUA_OPCODE(SetActorLookRate);
DECLARE_LUA_OPCODE(GetActorLookRate);
DECLARE_LUA_OPCODE(SetActorHead);
DECLARE_LUA_OPCODE(PutActorAtInterest);
DECLARE_LUA_OPCODE(SetActorFollowBoxes);
DECLARE_LUA_OPCODE(SetActorConstrain);
DECLARE_LUA_OPCODE(GetVisibleThings);
DECLARE_LUA_OPCODE(SetShadowColor);
DECLARE_LUA_OPCODE(KillActorShadows);
DECLARE_LUA_OPCODE(SetActiveShadow);
DECLARE_LUA_OPCODE(SetActorShadowPoint);
DECLARE_LUA_OPCODE(SetActorShadowPlane);
DECLARE_LUA_OPCODE(AddShadowPlane);
DECLARE_LUA_OPCODE(ActivateActorShadow);
DECLARE_LUA_OPCODE(SetActorShadowValid);
DECLARE_LUA_OPCODE(TextFileGetLine);
DECLARE_LUA_OPCODE(TextFileGetLineCount);
DECLARE_LUA_OPCODE(LocalizeString);
DECLARE_LUA_OPCODE(SayLine);
DECLARE_LUA_OPCODE(PrintLine);
DECLARE_LUA_OPCODE(InputDialog);
DECLARE_LUA_OPCODE(IsMessageGoing);
DECLARE_LUA_OPCODE(ShutUpActor);
DECLARE_LUA_OPCODE(GetPointSector);
DECLARE_LUA_OPCODE(GetActorSector);
DECLARE_LUA_OPCODE(IsActorInSector);
DECLARE_LUA_OPCODE(IsPointInSector);
DECLARE_LUA_OPCODE(MakeSectorActive);
DECLARE_LUA_OPCODE(LockSet);
DECLARE_LUA_OPCODE(UnLockSet);
DECLARE_LUA_OPCODE(MakeCurrentSet);
DECLARE_LUA_OPCODE(MakeCurrentSetup);
DECLARE_LUA_OPCODE(GetCurrentSetup);
DECLARE_LUA_OPCODE(ShrinkBoxes);
DECLARE_LUA_OPCODE(UnShrinkBoxes);
DECLARE_LUA_OPCODE(GetShrinkPos);
DECLARE_LUA_OPCODE(ImStartSound);
DECLARE_LUA_OPCODE(ImStopSound);
DECLARE_LUA_OPCODE(ImStopAllSounds);
DECLARE_LUA_OPCODE(ImPause);
DECLARE_LUA_OPCODE(ImResume);
DECLARE_LUA_OPCODE(ImSetVoiceEffect);
DECLARE_LUA_OPCODE(ImSetMusicVol);
DECLARE_LUA_OPCODE(ImGetMusicVol);
DECLARE_LUA_OPCODE(ImSetVoiceVol);
DECLARE_LUA_OPCODE(ImGetVoiceVol);
DECLARE_LUA_OPCODE(ImSetSfxVol);
DECLARE_LUA_OPCODE(ImGetSfxVol);
DECLARE_LUA_OPCODE(ImSetParam);
DECLARE_LUA_OPCODE(ImGetParam);
DECLARE_LUA_OPCODE(ImFadeParam);
DECLARE_LUA_OPCODE(ImSetState);
DECLARE_LUA_OPCODE(ImSetSequence);
DECLARE_LUA_OPCODE(SaveIMuse);
DECLARE_LUA_OPCODE(RestoreIMuse);
DECLARE_LUA_OPCODE(SetSoundPosition);
DECLARE_LUA_OPCODE(IsSoundPlaying);
DECLARE_LUA_OPCODE(PlaySoundAt);
DECLARE_LUA_OPCODE(FileFindDispose);
DECLARE_LUA_OPCODE(FileFindNext);
DECLARE_LUA_OPCODE(FileFindFirst);
DECLARE_LUA_OPCODE(PerSecond);
DECLARE_LUA_OPCODE(EnableControl);
DECLARE_LUA_OPCODE(DisableControl);
DECLARE_LUA_OPCODE(GetControlState);
DECLARE_LUA_OPCODE(GetImage);
DECLARE_LUA_OPCODE(FreeImage);
DECLARE_LUA_OPCODE(BlastImage);
DECLARE_LUA_OPCODE(CleanBuffer);
DECLARE_LUA_OPCODE(Exit);
DECLARE_LUA_OPCODE(KillTextObject);
DECLARE_LUA_OPCODE(ChangeTextObject);
DECLARE_LUA_OPCODE(GetTextSpeed);
DECLARE_LUA_OPCODE(SetTextSpeed);
DECLARE_LUA_OPCODE(MakeTextObject);
DECLARE_LUA_OPCODE(GetTextObjectDimensions);
DECLARE_LUA_OPCODE(ExpireText);
DECLARE_LUA_OPCODE(GetTextCharPosition);
DECLARE_LUA_OPCODE(BlastText);
DECLARE_LUA_OPCODE(SetOffscreenTextPos);
DECLARE_LUA_OPCODE(SetSpeechMode);
DECLARE_LUA_OPCODE(GetSpeechMode);
DECLARE_LUA_OPCODE(StartFullscreenMovie);
DECLARE_LUA_OPCODE(StartMovie);
DECLARE_LUA_OPCODE(IsFullscreenMoviePlaying);
DECLARE_LUA_OPCODE(IsMoviePlaying);
DECLARE_LUA_OPCODE(StopMovie);
DECLARE_LUA_OPCODE(PauseMovie);
DECLARE_LUA_OPCODE(PurgePrimitiveQueue);
DECLARE_LUA_OPCODE(DrawPolygon);
DECLARE_LUA_OPCODE(DrawLine);
DECLARE_LUA_OPCODE(ChangePrimitive);
DECLARE_LUA_OPCODE(DrawRectangle);
DECLARE_LUA_OPCODE(BlastRect);
DECLARE_LUA_OPCODE(KillPrimitive);
DECLARE_LUA_OPCODE(DimScreen);
DECLARE_LUA_OPCODE(DimRegion);
DECLARE_LUA_OPCODE(GetDiskFreeSpace);
DECLARE_LUA_OPCODE(NewObjectState);
DECLARE_LUA_OPCODE(FreeObjectState);
DECLARE_LUA_OPCODE(SendObjectToBack);
DECLARE_LUA_OPCODE(SendObjectToFront);
DECLARE_LUA_OPCODE(SetObjectType);
DECLARE_LUA_OPCODE(GetCurrentScript);
DECLARE_LUA_OPCODE(ScreenShot);
DECLARE_LUA_OPCODE(GetSaveGameImage);
DECLARE_LUA_OPCODE(SubmitSaveGameData);
DECLARE_LUA_OPCODE(GetSaveGameData);
DECLARE_LUA_OPCODE(Load);
DECLARE_LUA_OPCODE(Save);
DECLARE_LUA_OPCODE(Remove);
DECLARE_LUA_OPCODE(LockFont);
DECLARE_LUA_OPCODE(EnableDebugKeys);
DECLARE_LUA_OPCODE(LightMgrSetChange);
DECLARE_LUA_OPCODE(SetAmbientLight);
DECLARE_LUA_OPCODE(SetLightIntensity);
DECLARE_LUA_OPCODE(SetLightPosition);
DECLARE_LUA_OPCODE(TurnLightOn);
DECLARE_LUA_OPCODE(RenderModeUser);
DECLARE_LUA_OPCODE(PreRender);
DECLARE_LUA_OPCODE(IrisUp);
DECLARE_LUA_OPCODE(IrisDown);
DECLARE_LUA_OPCODE(SetGamma);
DECLARE_LUA_OPCODE(Display);
DECLARE_LUA_OPCODE(EngineDisplay);
DECLARE_LUA_OPCODE(ForceRefresh);
DECLARE_LUA_OPCODE(JustLoaded);
DECLARE_LUA_OPCODE(PlaySound);
DECLARE_LUA_OPCODE(SetEmergencyFont);
DECLARE_LUA_OPCODE(LoadBundle);
DECLARE_LUA_OPCODE(LightMgrStartup);
DECLARE_LUA_OPCODE(GetSectorOppositeEdge);
DECLARE_LUA_OPCODE(SetActorInvClipNode);
DECLARE_LUA_OPCODE(NukeResources);
DECLARE_LUA_OPCODE(ResetTextures);
DECLARE_LUA_OPCODE(AttachToResources);
DECLARE_LUA_OPCODE(DetachFromResources);
DECLARE_LUA_OPCODE(SetActorClipPlane);
DECLARE_LUA_OPCODE(SetActorClipActive);
DECLARE_LUA_OPCODE(FlushControls);
DECLARE_LUA_OPCODE(GetCameraLookVector);
DECLARE_LUA_OPCODE(SetCameraRoll);
DECLARE_LUA_OPCODE(SetCameraInterest);
DECLARE_LUA_OPCODE(GetCameraPosition);
DECLARE_LUA_OPCODE(SpewStartup);
DECLARE_LUA_OPCODE(PreviousSetup);
DECLARE_LUA_OPCODE(NextSetup);
DECLARE_LUA_OPCODE(WorldToScreen);
DECLARE_LUA_OPCODE(SetActorRoll);
DECLARE_LUA_OPCODE(SetActorFrustrumCull);
DECLARE_LUA_OPCODE(DriveActorTo);
DECLARE_LUA_OPCODE(GetActorRect);
DECLARE_LUA_OPCODE(GetTranslationMode);
DECLARE_LUA_OPCODE(SetTranslationMode);
DECLARE_LUA_OPCODE(WalkActorToAvoiding);
DECLARE_LUA_OPCODE(GetActorChores);
DECLARE_LUA_OPCODE(SetCameraPosition);
DECLARE_LUA_OPCODE(GetCameraFOV);
DECLARE_LUA_OPCODE(SetCameraFOV);
DECLARE_LUA_OPCODE(GetCameraRoll);
DECLARE_LUA_OPCODE(GetMemoryUsage);
DECLARE_LUA_OPCODE(GetFontDimensions);
DECLARE_LUA_OPCODE(PurgeText);
};
}
#endif

View File

@ -21,7 +21,7 @@
*/
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/lua_v1.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/costume.h"
@ -33,7 +33,7 @@
namespace Grim {
void L1_LoadActor() {
void Lua_L1::LoadActor() {
lua_Object nameObj = lua_getparam(1);
const char *name;
@ -45,7 +45,7 @@ void L1_LoadActor() {
lua_pushusertag(a->getId(), MKTAG('A','C','T','R'));
}
void L1_GetActorTimeScale() {
void Lua_L1::GetActorTimeScale() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -54,7 +54,7 @@ void L1_GetActorTimeScale() {
lua_pushnumber(actor->getTimeScale());
}
void L1_SetSelectedActor() {
void Lua_L1::SetSelectedActor() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -66,13 +66,13 @@ void L1_SetSelectedActor() {
* "Camera-Relative" mode to handle the appropriate
* actor for movement
*/
void L1_GetCameraActor() {
void Lua_L1::GetCameraActor() {
// TODO verify what is going on with selected actor
Actor *actor = g_grim->getSelectedActor();
lua_pushusertag(actor->getId(), MKTAG('A','C','T','R'));
}
void L1_SetActorTalkColor() {
void Lua_L1::SetActorTalkColor() {
lua_Object actorObj = lua_getparam(1);
lua_Object colorObj = lua_getparam(2);
@ -85,7 +85,7 @@ void L1_SetActorTalkColor() {
actor->setTalkColor(color);
}
void L1_GetActorTalkColor() {
void Lua_L1::GetActorTalkColor() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
lua_pushnil();
@ -95,7 +95,7 @@ void L1_GetActorTalkColor() {
lua_pushusertag(actor->getTalkColor()->getId(), MKTAG('C','O','L','R'));
}
void L1_SetActorRestChore() {
void Lua_L1::SetActorRestChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -120,7 +120,7 @@ void L1_SetActorRestChore() {
actor->setRestChore(chore, costume);
}
void L1_SetActorWalkChore() {
void Lua_L1::SetActorWalkChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -145,7 +145,7 @@ void L1_SetActorWalkChore() {
actor->setWalkChore(chore, costume);
}
void L1_SetActorTurnChores() {
void Lua_L1::SetActorTurnChores() {
lua_Object actorObj = lua_getparam(1);
lua_Object leftChoreObj = lua_getparam(2);
lua_Object rightChoreObj = lua_getparam(3);
@ -167,7 +167,7 @@ void L1_SetActorTurnChores() {
actor->setTurnChores(leftChore, rightChore, costume);
}
void L1_SetActorTalkChore() {
void Lua_L1::SetActorTalkChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object indexObj = lua_getparam(2);
lua_Object choreObj = lua_getparam(3);
@ -200,7 +200,7 @@ void L1_SetActorTalkChore() {
actor->setTalkChore(index, chore, costume);
}
void L1_SetActorMumblechore() {
void Lua_L1::SetActorMumblechore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -228,7 +228,7 @@ void L1_SetActorMumblechore() {
actor->setMumbleChore(chore, costume);
}
void L1_SetActorVisibility() {
void Lua_L1::SetActorVisibility() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -239,7 +239,7 @@ void L1_SetActorVisibility() {
actor->setVisibility(val);
}
void L1_SetActorScale() {
void Lua_L1::SetActorScale() {
lua_Object actorObj = lua_getparam(1);
lua_Object scaleObj = lua_getparam(2);
@ -255,7 +255,7 @@ void L1_SetActorScale() {
actor->setScale(scale);
}
void L1_SetActorTimeScale() {
void Lua_L1::SetActorTimeScale() {
lua_Object actorObj = lua_getparam(1);
lua_Object scaleObj = lua_getparam(2);
@ -271,7 +271,7 @@ void L1_SetActorTimeScale() {
actor->setTimeScale(scale);
}
void L1_SetActorCollisionMode() {
void Lua_L1::SetActorCollisionMode() {
lua_Object actorObj = lua_getparam(1);
lua_Object modeObj = lua_getparam(2);
@ -286,7 +286,7 @@ void L1_SetActorCollisionMode() {
actor->setCollisionMode(mode);
}
void L1_SetActorCollisionScale() {
void Lua_L1::SetActorCollisionScale() {
lua_Object actorObj = lua_getparam(1);
lua_Object scaleObj = lua_getparam(2);
@ -301,7 +301,7 @@ void L1_SetActorCollisionScale() {
actor->setCollisionScale(scale);
}
void L1_PutActorAt() {
void Lua_L1::PutActorAt() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -319,7 +319,7 @@ void L1_PutActorAt() {
actor->setPos(Math::Vector3d(x, y, z));
}
void L1_GetActorPos() {
void Lua_L1::GetActorPos() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -332,7 +332,7 @@ void L1_GetActorPos() {
lua_pushnumber(pos.z());
}
void L1_SetActorRot() {
void Lua_L1::SetActorRot() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -353,7 +353,7 @@ void L1_SetActorRot() {
actor->setRot(pitch, yaw, roll);
}
void L1_GetActorRot() {
void Lua_L1::GetActorRot() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -365,7 +365,7 @@ void L1_GetActorRot() {
lua_pushnumber(actor->getRoll().getDegrees());
}
void L1_IsActorTurning() {
void Lua_L1::IsActorTurning() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -375,7 +375,7 @@ void L1_IsActorTurning() {
pushbool(actor->isTurning());
}
void L1_GetAngleBetweenActors() {
void Lua_L1::GetAngleBetweenActors() {
lua_Object actor1Obj = lua_getparam(1);
lua_Object actor2Obj = lua_getparam(2);
@ -398,7 +398,7 @@ void L1_GetAngleBetweenActors() {
lua_pushnumber(actor1->getYawTo(actor2).getDegrees());
}
void L1_GetActorYawToPoint() {
void Lua_L1::GetActorYawToPoint() {
lua_Object actorObj = lua_getparam(1);
lua_Object pointObj = lua_getparam(2);
lua_Object xObj, yObj, zObj;
@ -437,7 +437,7 @@ void L1_GetActorYawToPoint() {
* by changing the set to "nil" an actor is disabled
* but should still not be destroyed.
*/
void L1_PutActorInSet() {
void Lua_L1::PutActorInSet() {
lua_Object actorObj = lua_getparam(1);
lua_Object setObj = lua_getparam(2);
@ -473,7 +473,7 @@ void L1_PutActorInSet() {
actor->putInSet(set);
}
void L1_SetActorWalkRate() {
void Lua_L1::SetActorWalkRate() {
lua_Object actorObj = lua_getparam(1);
lua_Object rateObj = lua_getparam(2);
@ -487,7 +487,7 @@ void L1_SetActorWalkRate() {
actor->setWalkRate(rate);
}
void L1_GetActorWalkRate() {
void Lua_L1::GetActorWalkRate() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -496,7 +496,7 @@ void L1_GetActorWalkRate() {
lua_pushnumber(actor->getWalkRate());
}
void L1_SetActorTurnRate() {
void Lua_L1::SetActorTurnRate() {
lua_Object actorObj = lua_getparam(1);
lua_Object rateObj = lua_getparam(2);
@ -510,7 +510,7 @@ void L1_SetActorTurnRate() {
actor->setTurnRate(rate);
}
void L1_WalkActorForward() {
void Lua_L1::WalkActorForward() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -518,7 +518,7 @@ void L1_WalkActorForward() {
actor->walkForward();
}
void L1_SetActorReflection() {
void Lua_L1::SetActorReflection() {
lua_Object actorObj = lua_getparam(1);
lua_Object angleObj = lua_getparam(2);
@ -530,7 +530,7 @@ void L1_SetActorReflection() {
actor->setReflection(angle);
}
void L1_GetActorPuckVector() {
void Lua_L1::GetActorPuckVector() {
lua_Object actorObj = lua_getparam(1);
lua_Object addObj = lua_getparam(2);
@ -554,7 +554,7 @@ void L1_GetActorPuckVector() {
lua_pushnumber(result.z());
}
void L1_ActorPuckOrient() {
void Lua_L1::ActorPuckOrient() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
@ -565,7 +565,7 @@ void L1_ActorPuckOrient() {
actor->setPuckOrient(getbool(2));
}
void L1_WalkActorTo() {
void Lua_L1::WalkActorTo() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -601,7 +601,7 @@ void L1_WalkActorTo() {
actor->walkTo(destVec);
}
void L1_ActorToClean() {
void Lua_L1::ActorToClean() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
@ -617,7 +617,7 @@ void L1_ActorToClean() {
actor->_toClean = true;
}
void L1_IsActorMoving() {
void Lua_L1::IsActorMoving() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -626,7 +626,7 @@ void L1_IsActorMoving() {
pushbool(actor->isWalking());
}
void L1_IsActorResting() {
void Lua_L1::IsActorResting() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -643,7 +643,7 @@ void L1_IsActorResting() {
* in Rubacava. It is also used for calculating many positions
* passed to ActorLookAt.
*/
void L1_GetActorNodeLocation() {
void Lua_L1::GetActorNodeLocation() {
lua_Object actorObj = lua_getparam(1);
lua_Object nodeObj = lua_getparam(2);
@ -679,7 +679,7 @@ void L1_GetActorNodeLocation() {
lua_pushnumber(pos.z());
}
void L1_SetActorWalkDominate() {
void Lua_L1::SetActorWalkDominate() {
lua_Object actorObj = lua_getparam(1);
lua_Object modeObj = lua_getparam(2);
@ -691,7 +691,7 @@ void L1_SetActorWalkDominate() {
actor->setRunning(mode);
}
void L1_SetActorColormap() {
void Lua_L1::SetActorColormap() {
lua_Object actorObj = lua_getparam(1);
lua_Object nameObj = lua_getparam(2);
@ -708,7 +708,7 @@ void L1_SetActorColormap() {
}
}
void L1_TurnActor() {
void Lua_L1::TurnActor() {
lua_Object actorObj = lua_getparam(1);
lua_Object dirObj = lua_getparam(2);
@ -724,7 +724,7 @@ void L1_TurnActor() {
actor->turn(dir);
}
void L1_PushActorCostume() {
void Lua_L1::PushActorCostume() {
lua_Object actorObj = lua_getparam(1);
lua_Object nameObj = lua_getparam(2);
@ -739,7 +739,7 @@ void L1_PushActorCostume() {
actor->pushCostume(costumeName);
}
void L1_SetActorCostume() {
void Lua_L1::SetActorCostume() {
lua_Object actorObj = lua_getparam(1);
lua_Object costumeObj = lua_getparam(2);
@ -762,7 +762,7 @@ void L1_SetActorCostume() {
pushbool(true);
}
void L1_GetActorCostume() {
void Lua_L1::GetActorCostume() {
lua_Object actorObj = lua_getparam(1);
lua_Object costumeObj = lua_getparam(2);
@ -787,7 +787,7 @@ void L1_GetActorCostume() {
lua_pushnil();
}
void L1_PopActorCostume() {
void Lua_L1::PopActorCostume() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
return;
@ -800,7 +800,7 @@ void L1_PopActorCostume() {
lua_pushnil();
}
void L1_GetActorCostumeDepth() {
void Lua_L1::GetActorCostumeDepth() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
lua_pushnil();
@ -811,11 +811,11 @@ void L1_GetActorCostumeDepth() {
lua_pushnumber(actor->getCostumeStackDepth());
}
void L1_PrintActorCostumes() {
void Lua_L1::PrintActorCostumes() {
// dummy
}
void L1_LoadCostume() {
void Lua_L1::LoadCostume() {
lua_Object nameObj = lua_getparam(1);
if (lua_isstring(nameObj)) {
// FIXME disable loading costume due creating issue with colormap, this opcode is unknown purpose
@ -825,7 +825,7 @@ void L1_LoadCostume() {
lua_pushnil();
}
void L1_PlayActorChore() {
void Lua_L1::PlayActorChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -854,7 +854,7 @@ void L1_PlayActorChore() {
pushbool(true);
}
void L1_CompleteActorChore() {
void Lua_L1::CompleteActorChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -883,7 +883,7 @@ void L1_CompleteActorChore() {
pushbool(true);
}
void L1_PlayActorChoreLooping() {
void Lua_L1::PlayActorChoreLooping() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -912,7 +912,7 @@ void L1_PlayActorChoreLooping() {
pushbool(true);
}
void L1_SetActorChoreLooping() {
void Lua_L1::SetActorChoreLooping() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(4);
@ -937,7 +937,7 @@ void L1_SetActorChoreLooping() {
}
}
void L1_StopActorChore() {
void Lua_L1::StopActorChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(3);
@ -962,7 +962,7 @@ void L1_StopActorChore() {
}
}
void L1_FadeOutChore() {
void Lua_L1::FadeOutChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object costumeObj = lua_getparam(2);
lua_Object choreObj = lua_getparam(3);
@ -988,7 +988,7 @@ void L1_FadeOutChore() {
}
}
void L1_FadeInChore() {
void Lua_L1::FadeInChore() {
lua_Object actorObj = lua_getparam(1);
lua_Object costumeObj = lua_getparam(2);
lua_Object choreObj = lua_getparam(3);
@ -1014,7 +1014,7 @@ void L1_FadeInChore() {
}
}
void L1_IsActorChoring() {
void Lua_L1::IsActorChoring() {
lua_Object actorObj = lua_getparam(1);
lua_Object choreObj = lua_getparam(2);
lua_Object costumeObj = lua_getparam(4);
@ -1067,7 +1067,7 @@ void L1_IsActorChoring() {
lua_pushnil();
}
void L1_ActorLookAt() {
void Lua_L1::ActorLookAt() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -1140,7 +1140,7 @@ void L1_ActorLookAt() {
* This function must use a yaw value around the unit
* circle and not just a difference in angles.
*/
void L1_TurnActorTo() {
void Lua_L1::TurnActorTo() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -1180,7 +1180,7 @@ void L1_TurnActorTo() {
pushbool(actor->getYaw() != yaw);
}
void L1_PointActorAt() {
void Lua_L1::PointActorAt() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -1219,7 +1219,7 @@ void L1_PointActorAt() {
pushbool(false);
}
void L1_WalkActorVector() {
void Lua_L1::WalkActorVector() {
lua_Object actorObj = lua_getparam(1);
lua_Object actor2Obj = lua_getparam(2);
// lua_Object xObj = lua_getparam(3);
@ -1268,7 +1268,7 @@ void L1_WalkActorVector() {
* This is used when Glottis runs over the signpost in
* the Petrified Forest
*/
void L1_SetActorPitch() {
void Lua_L1::SetActorPitch() {
lua_Object actorObj = lua_getparam(1);
lua_Object pitchObj = lua_getparam(2);
@ -1280,7 +1280,7 @@ void L1_SetActorPitch() {
actor->setRot(pitch, actor->getYaw(), actor->getRoll());
}
void L1_SetActorLookRate() {
void Lua_L1::SetActorLookRate() {
lua_Object actorObj = lua_getparam(1);
lua_Object rateObj = lua_getparam(2);
@ -1298,7 +1298,7 @@ void L1_SetActorLookRate() {
actor->setLookAtRate(rate);
}
void L1_GetActorLookRate() {
void Lua_L1::GetActorLookRate() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -1311,7 +1311,7 @@ void L1_GetActorLookRate() {
lua_pushnumber(actor->getLookAtRate());
}
void L1_SetActorHead() {
void Lua_L1::SetActorHead() {
lua_Object actorObj = lua_getparam(1);
lua_Object joint1Obj = lua_getparam(2);
lua_Object joint2Obj = lua_getparam(3);
@ -1337,7 +1337,7 @@ void L1_SetActorHead() {
actor->setHead(joint1, joint2, joint3, maxRoll, maxPitch, maxYaw);
}
void L1_PutActorAtInterest() {
void Lua_L1::PutActorAtInterest() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -1370,7 +1370,7 @@ void L1_PutActorAtInterest() {
actor->setPos(resultPt);
}
void L1_SetActorFollowBoxes() {
void Lua_L1::SetActorFollowBoxes() {
lua_Object actorObj = lua_getparam(1);
lua_Object modeObj = lua_getparam(2);
bool mode = true;
@ -1389,7 +1389,7 @@ void L1_SetActorFollowBoxes() {
actor->setConstrain(mode);
}
void L1_SetActorConstrain() {
void Lua_L1::SetActorConstrain() {
lua_Object actorObj = lua_getparam(1);
// lua_Object constrainObj = lua_getparam(2);
@ -1404,7 +1404,7 @@ void L1_SetActorConstrain() {
// actor->setConstrain(constrain);
}
void L1_GetVisibleThings() {
void Lua_L1::GetVisibleThings() {
lua_Object actorObj = lua_getparam(1);
Actor *actor = NULL;
if (lua_isnil(actorObj)) {
@ -1434,7 +1434,7 @@ void L1_GetVisibleThings() {
lua_pushobject(result);
}
void L1_SetShadowColor() {
void Lua_L1::SetShadowColor() {
int r = (int)lua_getnumber(lua_getparam(1));
int g = (int)lua_getnumber(lua_getparam(2));
int b = (int)lua_getnumber(lua_getparam(3));
@ -1442,7 +1442,7 @@ void L1_SetShadowColor() {
g_driver->setShadowColor(r, g, b);
}
void L1_KillActorShadows() {
void Lua_L1::KillActorShadows() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R')) {
@ -1453,7 +1453,7 @@ void L1_KillActorShadows() {
actor->clearShadowPlanes();
}
void L1_SetActiveShadow() {
void Lua_L1::SetActiveShadow() {
lua_Object actorObj = lua_getparam(1);
lua_Object shadowIdObj = lua_getparam(2);
@ -1466,7 +1466,7 @@ void L1_SetActiveShadow() {
actor->setActiveShadow(shadowId);
}
void L1_SetActorShadowPoint() {
void Lua_L1::SetActorShadowPoint() {
lua_Object actorObj = lua_getparam(1);
lua_Object xObj = lua_getparam(2);
lua_Object yObj = lua_getparam(3);
@ -1484,7 +1484,7 @@ void L1_SetActorShadowPoint() {
actor->setShadowPoint(Math::Vector3d(x, y, z));
}
void L1_SetActorShadowPlane() {
void Lua_L1::SetActorShadowPlane() {
lua_Object actorObj = lua_getparam(1);
lua_Object nameObj = lua_getparam(2);
@ -1498,7 +1498,7 @@ void L1_SetActorShadowPlane() {
actor->setShadowPlane(name);
}
void L1_AddShadowPlane() {
void Lua_L1::AddShadowPlane() {
lua_Object actorObj = lua_getparam(1);
lua_Object nameObj = lua_getparam(2);
@ -1512,7 +1512,7 @@ void L1_AddShadowPlane() {
actor->addShadowPlane(name);
}
void L1_ActivateActorShadow() {
void Lua_L1::ActivateActorShadow() {
lua_Object actorObj = lua_getparam(1);
lua_Object shadowIdObj = lua_getparam(2);
lua_Object stateObj = lua_getparam(3);
@ -1529,7 +1529,7 @@ void L1_ActivateActorShadow() {
g_grim->flagRefreshShadowMask(true);
}
void L1_SetActorShadowValid() {
void Lua_L1::SetActorShadowValid() {
lua_Object actorObj = lua_getparam(1);
lua_Object numObj = lua_getparam(2);

View File

@ -27,7 +27,7 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_unlink
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/lua_v1.h"
#include "engines/grim/resource.h"
#include "engines/grim/colormap.h"
#include "engines/grim/bitmap.h"
@ -51,7 +51,7 @@ void killBitmapPrimitives(Bitmap *bitmap) {
}
#endif
void L1_GetImage() {
void Lua_L1::GetImage() {
lua_Object nameObj = lua_getparam(1);
if (!lua_isstring(nameObj)) {
lua_pushnil();
@ -62,7 +62,7 @@ void L1_GetImage() {
lua_pushusertag(b->getId(), MKTAG('V','B','U','F'));
}
void L1_FreeImage() {
void Lua_L1::FreeImage() {
lua_Object param = lua_getparam(1);
if (!lua_isuserdata(param) || lua_tag(param) != MKTAG('V','B','U','F'))
return;
@ -70,7 +70,7 @@ void L1_FreeImage() {
delete bitmap;
}
void L1_BlastImage() {
void Lua_L1::BlastImage() {
lua_Object param = lua_getparam(1);
if (!lua_isuserdata(param) || lua_tag(param) != MKTAG('V','B','U','F'))
return;
@ -88,17 +88,17 @@ void L1_BlastImage() {
g_driver->drawBitmap(bitmap);
}
void L1_CleanBuffer() {
void Lua_L1::CleanBuffer() {
g_driver->copyStoredToDisplay();
}
void L1_StartFullscreenMovie() {
void Lua_L1::StartFullscreenMovie() {
lua_Object name = lua_getparam(1);
if (!lua_isstring(name)) {
lua_pushnil();
return;
}
L1_CleanBuffer();
Lua_L1::CleanBuffer();
GrimEngine::EngineMode prevEngineMode = g_grim->getMode();
g_grim->setMode(GrimEngine::SmushMode);
@ -109,7 +109,7 @@ void L1_StartFullscreenMovie() {
pushbool(result);
}
void L1_StartMovie() {
void Lua_L1::StartMovie() {
lua_Object name = lua_getparam(1);
if (!lua_isstring(name)) {
lua_pushnil();
@ -135,30 +135,30 @@ void L1_StartMovie() {
* query should actually detect correctly and not
* just return true whenever ANY movie is playing
*/
void L1_IsFullscreenMoviePlaying() {
void Lua_L1::IsFullscreenMoviePlaying() {
pushbool(g_movie->isPlaying());
}
void L1_IsMoviePlaying() {
void Lua_L1::IsMoviePlaying() {
// Previously, if the game was *not* the demo, this checked also if the mode
// was GrimEngine::NormalMode. This doesn't seem to be what original does, and causes
// bug #301 because the movie eldepot.snm is played before legslide.snm ends.
pushbool(g_movie->isPlaying());
}
void L1_StopMovie() {
void Lua_L1::StopMovie() {
g_movie->stop();
}
void L1_PauseMovie() {
void Lua_L1::PauseMovie() {
g_movie->pause(lua_isnil(lua_getparam(1)) == 0);
}
void L1_PurgePrimitiveQueue() {
void Lua_L1::PurgePrimitiveQueue() {
PrimitiveObject::getPool()->deleteObjects();
}
void L1_DrawPolygon() {
void Lua_L1::DrawPolygon() {
lua_Object pointObj;
Common::Point p1, p2, p3, p4;
PoolColor *color = NULL;
@ -225,7 +225,7 @@ void L1_DrawPolygon() {
lua_pushusertag(p->getId(), MKTAG('P','R','I','M'));
}
void L1_DrawLine() {
void Lua_L1::DrawLine() {
Common::Point p1, p2;
PoolColor *color = NULL;;
lua_Object x1Obj = lua_getparam(1);
@ -264,7 +264,7 @@ void L1_DrawLine() {
lua_pushusertag(p->getId(), MKTAG('P','R','I','M'));
}
void L1_ChangePrimitive() {
void Lua_L1::ChangePrimitive() {
PrimitiveObject *psearch, *pmodify = NULL;
PoolColor *color = NULL;
@ -373,7 +373,7 @@ void L1_ChangePrimitive() {
}
}
void L1_DrawRectangle() {
void Lua_L1::DrawRectangle() {
Common::Point p1, p2;
PoolColor *color = NULL;
lua_Object objX1 = lua_getparam(1);
@ -412,7 +412,7 @@ void L1_DrawRectangle() {
lua_pushusertag(p->getId(), MKTAG('P','R','I','M')); // FIXME: we use PRIM usetag here
}
void L1_BlastRect() {
void Lua_L1::BlastRect() {
Common::Point p1, p2;
PoolColor *color = NULL;
lua_Object objX1 = lua_getparam(1);
@ -452,7 +452,7 @@ void L1_BlastRect() {
delete p;
}
void L1_KillPrimitive() {
void Lua_L1::KillPrimitive() {
lua_Object primObj = lua_getparam(1);
if (!lua_isuserdata(primObj) || lua_tag(primObj) != MKTAG('P','R','I','M'))
@ -462,12 +462,12 @@ void L1_KillPrimitive() {
delete prim;
}
void L1_DimScreen() {
void Lua_L1::DimScreen() {
g_driver->storeDisplay();
g_driver->dimScreen();
}
void L1_DimRegion() {
void Lua_L1::DimRegion() {
int x = (int)lua_getnumber(lua_getparam(1));
int y = (int)lua_getnumber(lua_getparam(2));
int w = (int)lua_getnumber(lua_getparam(3));
@ -476,7 +476,7 @@ void L1_DimRegion() {
g_driver->dimRegion(x, y, w, h, level);
}
void L1_ScreenShot() {
void Lua_L1::ScreenShot() {
int width = (int)lua_getnumber(lua_getparam(1));
int height = (int)lua_getnumber(lua_getparam(2));
GrimEngine::EngineMode mode = g_grim->getMode();
@ -492,7 +492,7 @@ void L1_ScreenShot() {
}
}
void L1_SetGamma() {
void Lua_L1::SetGamma() {
lua_Object levelObj = lua_getparam(1);
if (!lua_isnumber(levelObj))
@ -500,16 +500,16 @@ void L1_SetGamma() {
int level = (int)lua_getnumber(levelObj);
// FIXME: func(level)
warning("L1_SetGamma, implement opcode, level: %d", level);
warning("Lua_L1::SetGamma, implement opcode, level: %d", level);
}
void L1_Display() {
void Lua_L1::Display() {
if (g_grim->getFlipEnable()) {
g_driver->flipBuffer();
}
}
void L1_EngineDisplay() {
void Lua_L1::EngineDisplay() {
// it enable/disable updating display
bool mode = (int)lua_getnumber(lua_getparam(1)) != 0;
if (mode) {
@ -519,11 +519,11 @@ void L1_EngineDisplay() {
}
}
void L1_ForceRefresh() {
void Lua_L1::ForceRefresh() {
g_grim->refreshDrawMode();
}
void L1_RenderModeUser() {
void Lua_L1::RenderModeUser() {
lua_Object param1 = lua_getparam(1);
if (!lua_isnil(param1) && g_grim->getMode() != GrimEngine::DrawMode) {
g_grim->setPreviousMode(g_grim->getMode());
@ -536,7 +536,7 @@ void L1_RenderModeUser() {
}
}
void L1_IrisUp() {
void Lua_L1::IrisUp() {
lua_Object xObj = lua_getparam(1);
lua_Object yObj = lua_getparam(2);
lua_Object timeObj = lua_getparam(3);
@ -544,7 +544,7 @@ void L1_IrisUp() {
g_grim->playIrisAnimation(Iris::Open, (int)lua_getnumber(xObj), (int)lua_getnumber(yObj), (int)lua_getnumber(timeObj));
}
void L1_IrisDown() {
void Lua_L1::IrisDown() {
lua_Object xObj = lua_getparam(1);
lua_Object yObj = lua_getparam(2);
lua_Object timeObj = lua_getparam(3);
@ -552,7 +552,7 @@ void L1_IrisDown() {
g_grim->playIrisAnimation(Iris::Close, (int)lua_getnumber(xObj), (int)lua_getnumber(yObj), (int)lua_getnumber(timeObj));
}
void L1_PreRender() {
void Lua_L1::PreRender() {
g_driver->renderBitmaps(getbool(1));
g_driver->renderZBitmaps(getbool(2));
}

View File

@ -22,7 +22,7 @@
#include "engines/grim/debug.h"
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/lua_v1.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/savegame.h"
@ -44,7 +44,7 @@ enum ImuseParam {
IM_SOUND_PAN = 0x700
};
void L1_ImStartSound() {
void Lua_L1::ImStartSound() {
lua_Object nameObj = lua_getparam(1);
lua_Object priorityObj = lua_getparam(2);
lua_Object groupObj = lua_getparam(3);
@ -65,7 +65,7 @@ void L1_ImStartSound() {
}
}
void L1_ImStopSound() {
void Lua_L1::ImStopSound() {
lua_Object nameObj = lua_getparam(1);
if (lua_isnumber(nameObj))
error("ImStopsound: name from value not supported");
@ -74,59 +74,59 @@ void L1_ImStopSound() {
g_imuse->stopSound(soundName);
}
void L1_ImStopAllSounds() {
void Lua_L1::ImStopAllSounds() {
g_imuse->stopAllSounds();
}
void L1_ImPause() {
void Lua_L1::ImPause() {
g_imuse->pause(true);
}
void L1_ImResume() {
void Lua_L1::ImResume() {
g_imuse->pause(false);
}
void L1_ImSetVoiceEffect() {
void Lua_L1::ImSetVoiceEffect() {
const char *effectName;
effectName = luaL_check_string(1);
Debug::warning(Debug::Imuse, "ImSetVoiceEffect(%s) Voice effects are not yet supported", effectName);
}
void L1_ImSetMusicVol() {
void Lua_L1::ImSetMusicVol() {
lua_Object volObj = lua_getparam(1);
if (!lua_isnumber(volObj))
return;
g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, (int)lua_getnumber(volObj));
}
void L1_ImGetMusicVol() {
void Lua_L1::ImGetMusicVol() {
lua_pushnumber(g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kMusicSoundType));
}
void L1_ImSetVoiceVol() {
void Lua_L1::ImSetVoiceVol() {
lua_Object volObj = lua_getparam(1);
if (!lua_isnumber(volObj))
return;
g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, (int)lua_getnumber(volObj));
}
void L1_ImGetVoiceVol() {
void Lua_L1::ImGetVoiceVol() {
lua_pushnumber(g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType));
}
void L1_ImSetSfxVol() {
void Lua_L1::ImSetSfxVol() {
lua_Object volObj = lua_getparam(1);
if (!lua_isnumber(volObj))
return;
g_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, (int)lua_getnumber(volObj));
}
void L1_ImGetSfxVol() {
void Lua_L1::ImGetSfxVol() {
lua_pushnumber(g_system->getMixer()->getVolumeForSoundType(Audio::Mixer::kSFXSoundType));
}
void L1_ImSetParam() {
void Lua_L1::ImSetParam() {
lua_Object nameObj = lua_getparam(1);
lua_Object paramObj = lua_getparam(2);
lua_Object valueObj = lua_getparam(3);
@ -155,7 +155,7 @@ void L1_ImSetParam() {
}
}
void L1_ImGetParam() {
void Lua_L1::ImGetParam() {
lua_Object nameObj = lua_getparam(1);
lua_Object paramObj = lua_getparam(2);
@ -180,7 +180,7 @@ void L1_ImGetParam() {
}
}
void L1_ImFadeParam() {
void Lua_L1::ImFadeParam() {
lua_Object nameObj = lua_getparam(1);
lua_Object opcodeObj = lua_getparam(2);
lua_Object valueObj = lua_getparam(3);
@ -212,7 +212,7 @@ void L1_ImFadeParam() {
}
}
void L1_ImSetState() {
void Lua_L1::ImSetState() {
lua_Object stateObj = lua_getparam(1);
if (!lua_isnumber(stateObj))
return;
@ -220,7 +220,7 @@ void L1_ImSetState() {
g_imuseState = (int)lua_getnumber(stateObj);
}
void L1_ImSetSequence() {
void Lua_L1::ImSetSequence() {
lua_Object stateObj = lua_getparam(1);
if (!lua_isnumber(stateObj))
return;
@ -229,7 +229,7 @@ void L1_ImSetSequence() {
lua_pushnumber(g_imuse->setMusicSequence(state));
}
void L1_SaveIMuse() {
void Lua_L1::SaveIMuse() {
SaveGame *savedIMuse = SaveGame::openForSaving("grim.tmp");
if (!savedIMuse)
return;
@ -237,7 +237,7 @@ void L1_SaveIMuse() {
delete savedIMuse;
}
void L1_RestoreIMuse() {
void Lua_L1::RestoreIMuse() {
SaveGame *savedIMuse = SaveGame::openForLoading("grim.tmp");
if (!savedIMuse)
return;
@ -248,7 +248,7 @@ void L1_RestoreIMuse() {
g_system->getSavefileManager()->removeSavefile("grim.tmp");
}
void L1_SetSoundPosition() {
void Lua_L1::SetSoundPosition() {
Math::Vector3d pos;
int minVolume = 10;
int maxVolume = 127;
@ -309,19 +309,19 @@ void L1_SetSoundPosition() {
}
}
void L1_IsSoundPlaying() {
void Lua_L1::IsSoundPlaying() {
// dummy
}
void L1_PlaySoundAt() {
void Lua_L1::PlaySoundAt() {
// dummy
}
void L1_LoadBundle() {
void Lua_L1::LoadBundle() {
// loading grimdemo.mus is allready handled
}
void L1_PlaySound() {
void Lua_L1::PlaySound() {
// dummy
}

View File

@ -26,7 +26,7 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_stdin
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/lua_v1.h"
#include "engines/grim/localize.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
@ -45,7 +45,7 @@ namespace Grim {
* note that the menu creates more objects than it needs,
* so it deletes some objects right after creating them
*/
void L1_KillTextObject() {
void Lua_L1::KillTextObject() {
lua_Object textObj = lua_getparam(1);
if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
@ -56,7 +56,7 @@ void L1_KillTextObject() {
/* Make changes to a text object based on the parameters passed
* in the table in the LUA parameter 2.
*/
void L1_ChangeTextObject() {
void Lua_L1::ChangeTextObject() {
const char *line;
lua_Object textObj = lua_getparam(1);
int paramId = 2;
@ -88,11 +88,11 @@ void L1_ChangeTextObject() {
* to prevent errors in the "Options" menu even though
* we're not currently using the value
*/
void L1_GetTextSpeed() {
void Lua_L1::GetTextSpeed() {
lua_pushnumber(g_grim->getTextSpeed());
}
void L1_SetTextSpeed() {
void Lua_L1::SetTextSpeed() {
lua_Object speedObj = lua_getparam(1);
if (!lua_isnumber(speedObj))
return;
@ -101,7 +101,7 @@ void L1_SetTextSpeed() {
g_grim->setTextSpeed(speed);
}
void L1_MakeTextObject() {
void Lua_L1::MakeTextObject() {
lua_Object textObj = lua_getparam(1);
if (!lua_isstring(textObj)) {
return;
@ -125,7 +125,7 @@ void L1_MakeTextObject() {
}
}
void L1_GetTextObjectDimensions() {
void Lua_L1::GetTextObjectDimensions() {
lua_Object textObj = lua_getparam(1);
if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
@ -135,7 +135,7 @@ void L1_GetTextObjectDimensions() {
}
}
void L1_ExpireText() {
void Lua_L1::ExpireText() {
// Expire all the text objects
for (TextObject::Pool::Iterator i = TextObject::getPool()->getBegin();
i != TextObject::getPool()->getEnd(); ++i)
@ -146,7 +146,7 @@ void L1_ExpireText() {
i->_value->lineCleanup();
}
void L1_GetTextCharPosition() {
void Lua_L1::GetTextCharPosition() {
lua_Object textObj = lua_getparam(1);
if (lua_isuserdata(textObj) && lua_tag(textObj) == MKTAG('T', 'E', 'X', 'T')) {
TextObject *textObject = gettextobject(textObj);
@ -155,7 +155,7 @@ void L1_GetTextCharPosition() {
}
}
void L1_BlastText() {
void Lua_L1::BlastText() {
lua_Object textObj = lua_getparam(1);
if (!lua_isstring(textObj)) {
return;
@ -176,12 +176,12 @@ void L1_BlastText() {
delete textObject;
}
void L1_SetOffscreenTextPos() {
warning("L1_SetOffscreenTextPos: implement opcode");
void Lua_L1::SetOffscreenTextPos() {
warning("Lua_L1::SetOffscreenTextPos: implement opcode");
// this sets where we shouldn't put dialog maybe?
}
void setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj) {
void LuaBase::setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj) {
lua_Object keyObj;
lua_pushobject(tableObj);
@ -305,35 +305,7 @@ void setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj) {
}
}
// 0 - translate from '/msgId/'
// 1 - don't translate - message after '/msgId'
// 2 - return '/msgId/'
int translationMode = 0;
Common::String parseMsgText(const char *msg, char *msgId) {
Common::String translation = g_localizer->localize(msg);
const char *secondSlash = NULL;
if (msg[0] == '/' && msgId) {
secondSlash = strchr(msg + 1, '/');
if (secondSlash) {
strncpy(msgId, msg + 1, secondSlash - msg - 1);
msgId[secondSlash - msg - 1] = 0;
} else {
msgId[0] = 0;
}
}
if (translationMode == 1)
return secondSlash;
if (translationMode == 2)
return msg;
return translation;
}
void L1_TextFileGetLine() {
void Lua_L1::TextFileGetLine() {
char textBuf[1000];
lua_Object nameObj = lua_getparam(1);
lua_Object posObj = lua_getparam(2);
@ -361,7 +333,7 @@ void L1_TextFileGetLine() {
lua_pushstring(textBuf);
}
void L1_TextFileGetLineCount() {
void Lua_L1::TextFileGetLineCount() {
char textBuf[1000];
lua_Object nameObj = lua_getparam(1);
@ -403,7 +375,7 @@ void L1_TextFileGetLineCount() {
// Localization function
void L1_LocalizeString() {
void Lua_L1::LocalizeString() {
char msgId[50], buf[1000];
lua_Object strObj = lua_getparam(1);
@ -421,57 +393,13 @@ void L1_LocalizeString() {
}
}
void parseSayLineTable(lua_Object paramObj, bool *background, int *vol, int *pan, int *x, int *y) {
lua_Object tableObj;
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectX));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*x)
*x = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectY));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*y)
*y = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectBackground));
tableObj = lua_gettable();
if (tableObj) {
if (*background)
*background = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectVolume));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*vol)
*vol = (int)lua_getnumber(tableObj);
}
lua_pushobject(paramObj);
lua_pushobject(lua_getref(refTextObjectPan));
tableObj = lua_gettable();
if (lua_isnumber(tableObj)) {
if (*pan)
*pan = (int)lua_getnumber(tableObj);
}
}
void L1_SetSayLineDefaults() {
void Lua_L1::SetSayLineDefaults() {
lua_Object tableObj = lua_getparam(1);
if (tableObj && lua_istable(tableObj))
setTextObjectParams(&g_grim->_sayLineDefaults, tableObj);
}
void L1_SayLine() {
void Lua_L1::SayLine() {
int vol = 127, buffer = 64, paramId = 1, x = -1, y = -1;
bool background = true;
const char *msgId = NULL;;
@ -506,7 +434,7 @@ void L1_SayLine() {
}
}
void L1_ShutUpActor() {
void Lua_L1::ShutUpActor() {
lua_Object actorObj = lua_getparam(1);
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
@ -516,7 +444,7 @@ void L1_ShutUpActor() {
actor->shutUp();
}
void L1_PrintLine() {
void Lua_L1::PrintLine() {
int vol = 127, buffer = 64, /*paramId = 1, */x = -1, y = -1;
bool background = true;
char msgId[50];
@ -539,7 +467,7 @@ void L1_PrintLine() {
}
}
void L1_InputDialog() {
void Lua_L1::InputDialog() {
lua_Object titleObj = lua_getparam(1);
lua_Object messageObj = lua_getparam(2);
lua_Object defaultObj = lua_getparam(3);
@ -552,7 +480,7 @@ void L1_InputDialog() {
Common::String str = lua_getstring(titleObj);
str += ": ";
str += lua_getstring(messageObj);
InputDialog d(str, lua_getstring(defaultObj));
Grim::InputDialog d(str, lua_getstring(defaultObj));
int res = d.runModal();
// The KeyUp event for CTRL has been eat by the gui loop, so we
// need to reset it manually.
@ -564,7 +492,7 @@ void L1_InputDialog() {
}
}
void L1_IsMessageGoing() {
void Lua_L1::IsMessageGoing() {
lua_Object actorObj = lua_getparam(1);
if (!actorObj || (lua_isuserdata(actorObj) && lua_tag(actorObj) == MKTAG('A','C','T','R')) || lua_isnil(actorObj)) {

File diff suppressed because it is too large Load Diff

156
engines/grim/lua_v2.h Normal file
View File

@ -0,0 +1,156 @@
/* Residual - A 3D game interpreter
*
* Residual 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 library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#ifndef GRIM_LUA_V2
#define GRIM_LUA_V2
#include "engines/grim/lua_v1.h"
namespace Grim {
class Lua_L2 : public Lua_L1 {
public:
typedef Lua_L2 LuaClass;
void registerOpcodes();
DECLARE_LUA_OPCODE(UndimAll);
DECLARE_LUA_OPCODE(SetActorLocalAlpha);
DECLARE_LUA_OPCODE(UndimRegion);
DECLARE_LUA_OPCODE(SleepFor);
DECLARE_LUA_OPCODE(DimScreen);
DECLARE_LUA_OPCODE(MakeCurrentSetup);
DECLARE_LUA_OPCODE(SetActorGlobalAlpha);
DECLARE_LUA_OPCODE(ImGetMillisecondPosition);
DECLARE_LUA_OPCODE(RemoveActorFromOverworld);
DECLARE_LUA_OPCODE(UnloadActor);
DECLARE_LUA_OPCODE(SetActorWalkRate);
DECLARE_LUA_OPCODE(GetActorWalkRate);
DECLARE_LUA_OPCODE(SetReverb);
DECLARE_LUA_OPCODE(LockBackground);
DECLARE_LUA_OPCODE(UnLockBackground);
DECLARE_LUA_OPCODE(LockChore);
DECLARE_LUA_OPCODE(IsChoreValid);
DECLARE_LUA_OPCODE(IsChorePlaying);
DECLARE_LUA_OPCODE(StopChore);
DECLARE_LUA_OPCODE(AdvanceChore);
DECLARE_LUA_OPCODE(SetActorSortOrder);
DECLARE_LUA_OPCODE(ActorActivateShadow);
DECLARE_LUA_OPCODE(ActorStopMoving);
DECLARE_LUA_OPCODE(PutActorInOverworld);
DECLARE_LUA_OPCODE(GetActorWorldPos);
DECLARE_LUA_OPCODE(MakeScreenTextures);
DECLARE_LUA_OPCODE(PutActorInSet);
DECLARE_LUA_OPCODE(LoadBundle);
DECLARE_LUA_OPCODE(AreWeInternational);
DECLARE_LUA_OPCODE(ImSetState);
DECLARE_LUA_OPCODE(EnableVoiceFX);
DECLARE_LUA_OPCODE(SetGroupVolume);
DECLARE_LUA_OPCODE(EnableAudioGroup);
DECLARE_LUA_OPCODE(ImSelectSet);
DECLARE_LUA_OPCODE(PlayActorChore);
DECLARE_LUA_OPCODE(StopActorChores);
DECLARE_LUA_OPCODE(SetActorLighting);
DECLARE_LUA_OPCODE(SetActorCollisionMode);
DECLARE_LUA_OPCODE(SetActorCollisionScale);
DECLARE_LUA_OPCODE(GetActorPuckVector);
DECLARE_LUA_OPCODE(SetActorHeadLimits);
DECLARE_LUA_OPCODE(SetActorFOV);
DECLARE_LUA_OPCODE(AttachActor);
DECLARE_LUA_OPCODE(DetachActor);
DECLARE_LUA_OPCODE(GetCPUSpeed);
DECLARE_LUA_OPCODE(StartMovie);
DECLARE_LUA_OPCODE(IsMoviePlaying);
DECLARE_LUA_OPCODE(SetActiveCD);
DECLARE_LUA_OPCODE(GetActiveCD);
DECLARE_LUA_OPCODE(PurgeText);
DECLARE_LUA_OPCODE(ImFlushStack);
DECLARE_LUA_OPCODE(LoadSound);
DECLARE_LUA_OPCODE(ImSetMusicVol);
DECLARE_LUA_OPCODE(ImSetSfxVol);
DECLARE_LUA_OPCODE(ImSetVoiceVol);
DECLARE_LUA_OPCODE(ImSetVoiceEffect);
DECLARE_LUA_OPCODE(ToggleOverworld);
DECLARE_LUA_OPCODE(ScreenshotForSavegame);
DECLARE_LUA_OPCODE(EngineDisplay);
DECLARE_LUA_OPCODE(SetAmbientLight);
DECLARE_LUA_OPCODE(Display);
DECLARE_LUA_OPCODE(ThumbnailFromFile);
DECLARE_LUA_OPCODE(ClearSpecialtyTexture);
DECLARE_LUA_OPCODE(ClearOverworld);
DECLARE_LUA_OPCODE(EnableActorPuck);
DECLARE_LUA_OPCODE(GetActorSortOrder);
DECLARE_LUA_OPCODE(IsChoreLooping);
DECLARE_LUA_OPCODE(PlayChore);
DECLARE_LUA_OPCODE(PauseChore);
DECLARE_LUA_OPCODE(CompleteChore);
DECLARE_LUA_OPCODE(UnlockChore);
DECLARE_LUA_OPCODE(LockChoreSet);
DECLARE_LUA_OPCODE(UnlockChoreSet);
DECLARE_LUA_OPCODE(EscapeMovie);
DECLARE_LUA_OPCODE(StopAllSounds);
DECLARE_LUA_OPCODE(FreeSound);
DECLARE_LUA_OPCODE(PlayLoadedSound);
DECLARE_LUA_OPCODE(GetSoundVolume);
DECLARE_LUA_OPCODE(SetSoundVolume);
DECLARE_LUA_OPCODE(PlaySoundFrom);
DECLARE_LUA_OPCODE(PlayLoadedSoundFrom);
DECLARE_LUA_OPCODE(UpdateSoundPosition);
DECLARE_LUA_OPCODE(ImStateHasLooped);
DECLARE_LUA_OPCODE(ImStateHasEnded);
DECLARE_LUA_OPCODE(ImPushState);
DECLARE_LUA_OPCODE(ImPopState);
DECLARE_LUA_OPCODE(GetSectorName);
DECLARE_LUA_OPCODE(GetCameraYaw);
DECLARE_LUA_OPCODE(YawCamera);
DECLARE_LUA_OPCODE(GetCameraPitch);
DECLARE_LUA_OPCODE(PitchCamera);
DECLARE_LUA_OPCODE(RollCamera);
DECLARE_LUA_OPCODE(NewLayer);
DECLARE_LUA_OPCODE(FreeLayer);
DECLARE_LUA_OPCODE(SetLayerSortOrder);
DECLARE_LUA_OPCODE(SetLayerFrame);
DECLARE_LUA_OPCODE(AdvanceLayerFrame);
DECLARE_LUA_OPCODE(PushText);
DECLARE_LUA_OPCODE(PopText);
DECLARE_LUA_OPCODE(NukeAllScriptLocks);
DECLARE_LUA_OPCODE(ToggleDebugDraw);
DECLARE_LUA_OPCODE(ToggleDrawCameras);
DECLARE_LUA_OPCODE(ToggleDrawLights);
DECLARE_LUA_OPCODE(ToggleDrawSectors);
DECLARE_LUA_OPCODE(ToggleDrawBBoxes);
DECLARE_LUA_OPCODE(ToggleDrawFPS);
DECLARE_LUA_OPCODE(ToggleDrawPerformance);
DECLARE_LUA_OPCODE(ToggleDrawActorStats);
DECLARE_LUA_OPCODE(SectEditSelect);
DECLARE_LUA_OPCODE(SectEditPlace);
DECLARE_LUA_OPCODE(SectEditDelete);
DECLARE_LUA_OPCODE(SectEditInsert);
DECLARE_LUA_OPCODE(SectEditSortAdd);
DECLARE_LUA_OPCODE(SectEditForgetIt);
DECLARE_LUA_OPCODE(FRUTEY_Begin);
DECLARE_LUA_OPCODE(FRUTEY_End);
};
}
#endif

View File

@ -60,6 +60,7 @@ MODULE_OBJS := \
lab.o \
lipsync.o \
localize.o \
lua.o \
lua_v1.o \
lua_v1_actor.o \
lua_v1_graphics.o \

View File

@ -31,8 +31,6 @@
namespace Grim {
Common::String parseMsgText(const char *msg, char *msgId);
TextObjectCommon::TextObjectCommon() :
_x(0), _y(0), _fgColor(0), _justify(0), _width(0), _height(0),
_disabled(false), _font(NULL), _duration(0) {
@ -133,7 +131,7 @@ int TextObject::getBitmapHeight() {
int TextObject::getTextCharPosition(int pos) {
int width = 0;
Common::String msg = parseMsgText(_textID.c_str(), NULL);
Common::String msg = LuaBase::instance()->parseMsgText(_textID.c_str(), NULL);
for (int i = 0; (msg[i] != '\0') && (i < pos); ++i) {
width += _font->getCharWidth(msg[i]);
}
@ -148,7 +146,7 @@ void TextObject::destroy() {
}
void TextObject::setupText() {
Common::String msg = parseMsgText(_textID.c_str(), NULL);
Common::String msg = LuaBase::instance()->parseMsgText(_textID.c_str(), NULL);
Common::String message;
// remove spaces (NULL_TEXT) from the end of the string,