ScummVM API documentation
te_lua_context.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TETRAEDGE_TE_TE_LUA_CONTEXT_H
23 #define TETRAEDGE_TE_TE_LUA_CONTEXT_H
24 
25 #include "common/error.h"
26 #include "common/str.h"
27 #include "common/serializer.h"
28 
29 #include "tetraedge/te/te_variant.h"
30 
31 struct lua_State;
32 
33 namespace Tetraedge {
34 
35 class TeLuaGUI;
36 
37 /*
38  * The lua state holder. In the original Te engine this is split into an
39  * interface and Impl class, but it just ends up being a 1-line wrapper in
40  * each function so there's very little point.
41  */
42 class TeLuaContext {
43 public:
44  TeLuaContext();
45  ~TeLuaContext();
46 
47  void addBindings(void(*fn)(lua_State *));
48  void create();
49  void destroy();
50  TeVariant global(const Common::String &name);
51  void global(const Common::String &name, bool &outVal);
52  void global(const Common::String &name, Common::String &outVal);
53  void global(const Common::String &name, int &outVal);
54  void global(const Common::String &name, float &outVal);
55  bool isCreated() {
56  return _luaState != nullptr;
57  }
58 
59  //void load(TiXmlNode *node);
60  //void save(TiXmlNode *node);
61 
62  lua_State *luaState() { return _luaState; }
63 
64  void registerCFunction(const Common::String &name, int(*fn)(lua_State *));
65 
66  void removeGlobal(const Common::String &name);
67 
68  void setGlobal(const Common::String &name, int val);
69  void setGlobal(const Common::String &name, bool val);
70  void setGlobal(const Common::String &name, const Common::String &val);
71 
72  void setInRegistry(const Common::String &name, TeLuaGUI *gui);
73 
74  Common::Error syncState(Common::Serializer &s);
75 
76 private:
77  lua_State *_luaState;
78 };
79 
80 } // end namespace Tetraedge
81 
82 #endif // TETRAEDGE_TE_TE_LUA_CONTEXT_H
Definition: str.h:59
Definition: detection.h:27
Definition: error.h:84
Definition: te_lua_gui.h:51
Definition: lstate.h:100
Definition: serializer.h:79
Definition: te_variant.h:30
Definition: te_lua_context.h:42