ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

lua.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_LUABASE_H
00024 #define GRIM_LUABASE_H
00025 
00026 #include "common/str.h"
00027 #include "common/list.h"
00028 
00029 #include "engines/grim/color.h"
00030 
00031 namespace Grim {
00032 
00033 typedef uint32 lua_Object; // from lua/lua.h
00034 
00035 class Actor;
00036 class Bitmap;
00037 class Costume;
00038 class Font;
00039 class ObjectState;
00040 class PrimitiveObject;
00041 class TextObject;
00042 class TextObjectDefaults;
00043 class TextObjectCommon;
00044 class PoolObjectBase;
00045 
00049 #define DECLARE_LUA_OPCODE(func) \
00050     public:\
00051     inline static void static_##func() {\
00052         static_cast<LuaClass *>(LuaBase::instance())->func();\
00053     }\
00054     protected:\
00055     virtual void func()
00056 
00059 #define LUA_OPCODE(class, func) \
00060     class::static_##func
00061 
00068 class LuaObjects {
00069 public:
00070     void add(float number);
00071     void add(int number);
00072     void add(const PoolObjectBase *obj);
00073     void add(const char *str);
00074     void addNil();
00075 
00076 private:
00080     void pushObjects() const;
00081 
00085     struct Obj {
00086         enum {
00087             Nil,
00088             Number,
00089             Object,
00090             String
00091         } _type;
00092         union {
00093             float number;
00094             const PoolObjectBase *object;
00095             const char *string;
00096         } _value;
00097     };
00098     Common::List<Obj> _objects;
00099 
00100     friend class LuaBase;
00101 };
00102 
00103 class LuaBase {
00104 public:
00105     typedef LuaBase LuaClass;
00106 
00107     LuaBase();
00108     virtual ~LuaBase();
00109     inline static LuaBase *instance() { return s_instance; }
00110 
00111     int dofile(const char *filename);
00112 
00113     virtual bool findCostume(lua_Object costumeObj, Actor *actor, Costume **costume);
00114     virtual Common::String parseMsgText(const char *msg, char *msgId);
00115     virtual void parseSayLineTable(lua_Object paramObj, bool *background, int *vol, int *pan, float *x, float *y);
00116     virtual void setTextObjectParams(TextObjectCommon *textObject, lua_Object tableObj);
00117 
00118     void update(int frameTime, int movieTime);
00119     void setFrameTime(float frameTime);
00120     void setMovieTime(float movieTime);
00121     virtual void registerLua();
00122     virtual void registerOpcodes();
00123     virtual void loadSystemScript();
00124     virtual void boot();
00125     virtual void postRestoreHandle() { }
00126 
00127     // Force the demo flag
00128     virtual void forceDemo();
00129 
00135     bool callback(const char *name);
00142     bool callback(const char *name, const LuaObjects &objects);
00143 
00144 protected:
00145     bool getbool(int num);
00146     void pushbool(bool val);
00147     void pushobject(const PoolObjectBase *o);
00148     int getobject(lua_Object obj);
00149     Actor *getactor(lua_Object obj);
00150     Bitmap *getbitmap(lua_Object obj);
00151     TextObject *gettextobject(lua_Object obj);
00152     Font *getfont(lua_Object obj);
00153     Color getcolor(lua_Object obj);
00154     PrimitiveObject *getprimitive(lua_Object obj);
00155     ObjectState *getobjectstate(lua_Object obj);
00156 
00157     DECLARE_LUA_OPCODE(dummyHandler);
00158     DECLARE_LUA_OPCODE(typeOverride);
00159     DECLARE_LUA_OPCODE(concatFallback);
00160 
00161 private:
00162     // 0 - translate from '/msgId/'
00163     // 1 - don't translate - message after '/msgId'
00164     // 2 - return '/msgId/'
00165     int _translationMode;
00166     unsigned int _frameTimeCollection;
00167 
00168     int refSystemTable;
00169     int refTypeOverride;
00170     int refOldConcatFallback;
00171     int refTextObjectX;
00172     int refTextObjectY;
00173     int refTextObjectFont;
00174     int refTextObjectWidth;
00175     int refTextObjectHeight;
00176     int refTextObjectFGColor;
00177     int refTextObjectBGColor;
00178     int refTextObjectFXColor;
00179     int refTextObjectHIColor;
00180     int refTextObjectDuration;
00181     int refTextObjectCenter;
00182     int refTextObjectLJustify;
00183     int refTextObjectRJustify;
00184     int refTextObjectVolume;
00185     int refTextObjectBackground;
00186     int refTextObjectPan;
00187     int refTextObjectLayer;
00188 
00189     static LuaBase *s_instance;
00190 
00191     friend class LuaObjects;
00192 };
00193 
00194 } // end of namespace Grim
00195 
00196 #endif


Generated on Sat Oct 12 2019 05:00:51 for ResidualVM by doxygen 1.7.1
curved edge   curved edge