ScummVM API documentation
te_lua_gui.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_GUI_H
23 #define TETRAEDGE_TE_TE_LUA_GUI_H
24 
25 #include "common/str.h"
26 #include "common/hashmap.h"
27 #include "common/hash-str.h"
28 #include "tetraedge/te/te_button_layout.h"
29 #include "tetraedge/te/te_checkbox_layout.h"
30 #include "tetraedge/te/te_clip_layout.h"
31 #include "tetraedge/te/te_color.h"
32 #include "tetraedge/te/te_curve_anim2.h"
33 #include "tetraedge/te/te_extended_text_layout.h"
34 #include "tetraedge/te/te_i_3d_object2.h"
35 #include "tetraedge/te/te_i_layout.h"
36 #include "tetraedge/te/te_i_text_layout.h"
37 #include "tetraedge/te/te_layout.h"
38 #include "tetraedge/te/te_list_layout.h"
39 #include "tetraedge/te/te_lua_context.h"
40 #include "tetraedge/te/te_lua_script.h"
41 #include "tetraedge/te/te_object.h"
42 #include "tetraedge/te/te_quaternion.h"
43 #include "tetraedge/te/te_scrolling_layout.h"
44 #include "tetraedge/te/te_sprite_layout.h"
45 #include "tetraedge/te/te_text_layout.h"
46 #include "tetraedge/te/te_vector3f32.h"
47 #include "tetraedge/te/te_variant.h"
48 
49 namespace Tetraedge {
50 
51 class TeLuaGUI : public TeObject {
52 public:
53  TeLuaGUI();
54  virtual ~TeLuaGUI() {
55  unload();
56  };
57 
58  virtual void enter() {};
59  virtual void leave() {};
60 
61  TeLayout *layout(const Common::String &name);
62  TeButtonLayout *buttonLayout(const Common::String &name);
63  TeCheckboxLayout *checkboxLayout(const Common::String &name);
64  TeClipLayout *clipLayout(const Common::String &name);
65  TeCurveAnim2<Te3DObject2, TeColor> *colorLinearAnimation(const Common::String &name);
66  TeExtendedTextLayout *extendedTextLayout(const Common::String &name);
67  TeCurveAnim2<TeLayout, TeVector3f32> *layoutAnchorLinearAnimation(const Common::String &name);
68  TeCurveAnim2<TeLayout, TeVector3f32> *layoutPositionLinearAnimation(const Common::String &name);
69  TeListLayout *listLayout(const Common::String &name);
70  TeCurveAnim2<TeI3DObject2, TeQuaternion> *rotationLinearAnimation(const Common::String &name);
71  TeScrollingLayout *scrollingLayout(const Common::String &name);
72  TeSpriteLayout *spriteLayout(const Common::String &name);
73  TeITextLayout *textLayout(const Common::String &name);
74 
75  // Same as the above functions, but call error() if the result is null.
76  TeLayout *layoutChecked(const Common::String &name);
77  TeButtonLayout *buttonLayoutChecked(const Common::String &name);
78  TeSpriteLayout *spriteLayoutChecked(const Common::String &name);
79 
80  bool load(const Common::Path &subPath);
81  void unload();
82 
83  TeVariant value(const Common::String &key);
84 
85  template <typename T> using StringMap = Common::HashMap<Common::String, T>;
86 
87  StringMap<TeLayout *> &layouts() { return _layouts; }
88  StringMap<TeButtonLayout *> &buttonLayouts() { return _buttonLayouts; }
89  StringMap<TeCheckboxLayout *> &checkboxLayouts() { return _checkboxLayouts; }
90  StringMap<TeListLayout *> &listLayouts() { return _listLayouts; }
91  StringMap<TeSpriteLayout *> &spriteLayouts() { return _spriteLayouts; }
92  StringMap<TeTextLayout *> &textLayouts() { return _textLayouts; }
93  StringMap<TeScrollingLayout *> &scrollingLayouts() { return _scrollingLayouts; }
94  StringMap<TeClipLayout *> &clipLayouts() { return _clipLayouts; }
95  StringMap<TeExtendedTextLayout *> &extendedTextLayouts() { return _extendedTextLayouts; }
96  StringMap<TeCurveAnim2<TeLayout, TeVector3f32> *> &layoutAnchorLinearAnimations() { return _layoutAnchorLinearAnimations; }
97  StringMap<TeCurveAnim2<TeLayout, TeVector3f32> *> &layoutPositionLinearAnimations() { return _layoutPositionLinearAnimations; }
98  StringMap<TeCurveAnim2<Te3DObject2, TeColor> *> &colorLinearAnimations() { return _colorLinearAnimations; }
99 
100  bool loaded() const { return _loaded; }
101  const Common::Path &scriptPath() const { return _scriptPath; }
102 
103 protected:
104  bool _loaded;
105 
106 private:
107  Common::Path _scriptPath;
108 
109  TeLuaContext _luaContext;
110  TeLuaScript _luaScript;
111 
112  StringMap<TeLayout *> _layouts;
113  StringMap<TeButtonLayout *> _buttonLayouts;
114  StringMap<TeCheckboxLayout *> _checkboxLayouts;
115  StringMap<TeListLayout *> _listLayouts;
116  StringMap<TeSpriteLayout *> _spriteLayouts;
117  StringMap<TeTextLayout *> _textLayouts;
118  StringMap<TeScrollingLayout *> _scrollingLayouts;
119  StringMap<TeClipLayout *> _clipLayouts;
120  StringMap<TeExtendedTextLayout *> _extendedTextLayouts;
121  StringMap<TeCurveAnim2<TeLayout, TeVector3f32> *> _layoutAnchorLinearAnimations;
122  StringMap<TeCurveAnim2<TeLayout, TeVector3f32> *> _layoutPositionLinearAnimations;
123  StringMap<TeCurveAnim2<Te3DObject2, TeColor> *> _colorLinearAnimations;
124 };
125 
126 } // end namespace Tetraedge
127 
128 #endif // TETRAEDGE_TE_TE_LUA_GUI_H
Definition: te_i_text_layout.h:30
Definition: te_list_layout.h:29
Definition: str.h:59
Definition: detection.h:27
Definition: te_lua_gui.h:51
Definition: path.h:52
Definition: te_curve_anim2.h:36
Definition: te_button_layout.h:38
Definition: hashmap.h:85
Definition: te_object.h:29
Definition: te_lua_script.h:33
Definition: te_layout.h:35
Definition: te_extended_text_layout.h:32
Definition: te_variant.h:30
Definition: te_checkbox_layout.h:30
Definition: te_lua_context.h:42
Definition: te_scrolling_layout.h:33
Definition: te_clip_layout.h:30
Definition: te_sprite_layout.h:30