Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem/src/ceguilua-0.5.0/ceguilua/CEGUILua.h @ 2138

Last change on this file since 2138 was 1980, checked in by adrfried, 16 years ago

using ceguilua-0.5.0

  • Property svn:eol-style set to native
File size: 8.4 KB
RevLine 
[1803]1/***********************************************************************
2        filename: CEGUILua.h
3        created:  16/3/2005
4        author:   Tomas Lindquist Olsen
5       
6        purpose:  Defines interface for LuaScriptModule class
7*************************************************************************/
8/***************************************************************************
9 *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10 *
11 *   Permission is hereby granted, free of charge, to any person obtaining
12 *   a copy of this software and associated documentation files (the
13 *   "Software"), to deal in the Software without restriction, including
14 *   without limitation the rights to use, copy, modify, merge, publish,
15 *   distribute, sublicense, and/or sell copies of the Software, and to
16 *   permit persons to whom the Software is furnished to do so, subject to
17 *   the following conditions:
18 *
19 *   The above copyright notice and this permission notice shall be
20 *   included in all copies or substantial portions of the Software.
21 *
22 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 *   OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30#ifndef _CEGUILua_h_
31#define _CEGUILua_h_
32
33
34/*************************************************************************
35        Import / Export control macros
36*************************************************************************/
[1980]37#if defined( __WIN32__ ) || defined( _WIN32 )
[1803]38#   ifdef CEGUILUA_EXPORTS
39#       define CEGUILUA_API __declspec(dllexport)
40#   else
[1980]41#       define CEGUILUA_API __declspec(dllimport)
[1803]42#   endif
43#else
44#   define CEGUILUA_API
45#endif
46
47
48#include "CEGUIScriptModule.h"
49
50struct lua_State;
51
52// Start of CEGUI namespace section
53namespace CEGUI
54{
55
56/*!
57\brief
58        Interface for the LuaScriptModule class
59*/
60class CEGUILUA_API LuaScriptModule : public CEGUI::ScriptModule
61{
62public:
63        /*************************************************************************
64                Construction and Destruction
65        *************************************************************************/
66        /*!
67        \brief
68                Constructor for LuaScriptModule class which create a lua_State
69        */
70        LuaScriptModule();
71
72
73        /*!
74        \brief
75                Constructor for LuaScriptModule class which takes a lua_State
76
77        \param state
78                Pointer to the lua_State that the script module should attach to.
79        */
80        LuaScriptModule(lua_State* state);
81
82
83        /*!
84        \brief
85                Destructor for LuaScriptModule class.
86        */
87        ~LuaScriptModule();
88
89
90        /*************************************************************************
91                Script Execution Functions
92        *************************************************************************/
93        /*!
94        \brief
95                Execute a script file.
96
97        \param filename
98                String object holding the filename of the script file that is to be executed
99               
100        \param resourceGroup
101                Resource group idendifier to be passed to the ResourceProvider when loading the script file.
102        */
103        void executeScriptFile(const String& filename, const String& resourceGroup);
104
105
106        /*!
107        \brief
108                Execute a scripted global function.  The function should not take any parameters and should return an integer.
109
110        \param function_name
111                String object holding the name of the function, in the global script environment, that
112                is to be executed.
113
114        \return
115                The integer value returned from the script function.
116        */
117        int executeScriptGlobal(const String& function_name);
118
119
120    /*!
121    \brief
122        Execute a scripted global 'event handler' function by looking it up by name.
123
124    \param handler_name
125        String object holding the name of the scripted handler function.
126        If this string contains dots '.' it will be parsed as tables containing a function field.
127        For example: 'mytable.subtable.func'
128
129    \param e
130        EventArgs based object that should be passed, by any appropriate means, to the scripted function.
131
132    \return
133        - true if the event was handled.
134        - false if the event was not handled.
135    */
136    bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e);
137
138
139    /*!
140    \brief
141        Execute script code contained in the given CEGUI::String object.
142
143    \param str
144        String object holding the valid script code that should be executed.
145
146    \return
147        Nothing.
148    */
149    void executeString(const String& str);
150
151    /*************************************************************************
152        Event subscription
153    *************************************************************************/
154    /*!
155    \brief
156            Subscribes the named Event to a scripted funtion
157
158    \param target
159            The target EventSet for the subscription.
160
161    \param name
162            String object containing the name of the Event to subscribe to.
163
164    \param subscriber_name
165            String object containing the name of the script funtion that is to be subscribed to the Event.
166
167    \return
168            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
169
170    \exception UnknownObjectException   Thrown if an Event named \a name is not in the EventSet
171    */
172    Event::Connection   subscribeEvent(EventSet* target, const String& name, const String& subscriber_name);
173
174    /*!
175    \brief
176            Subscribes the specified group of the named Event to a scripted funtion.
177
178    \param target
179            The target EventSet for the subscription.
180
181    \param name
182            String object containing the name of the Event to subscribe to.
183
184    \param group
185            Group which is to be subscribed to.  Subscription groups are called in ascending order.
186
187    \param subscriber_name
188            String object containing the name of the script funtion that is to be subscribed to the Event.
189
190    \return
191            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
192
193    \exception UnknownObjectException   Thrown if an Event named \a name is not in the EventSet
194    */
195    Event::Connection   subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name);
196
197    /*************************************************************************
198        Bindings creation / destruction
199    *************************************************************************/
200    /*!
201    \brief
202        Method called during system initialisation, prior to running any scripts via the ScriptModule, to enable the ScriptModule
203        to perform any operations required to complete initialisation or binding of the script language to the gui system objects.
204
205    \return
206        Nothing.
207    */
208    void createBindings(void);
209
210
211    /*!
212    \brief
213        Method called during system destruction, after all scripts have been run via the ScriptModule, to enable the ScriptModule
214        to perform any operations required to cleanup bindings of the script language to the gui system objects, as set-up in the
215        earlier createBindings call.
216
217    \return
218        Nothing.
219    */
220    void destroyBindings(void);
221
222    /*************************************************************************
223        Accessor type functions
224    *************************************************************************/
225    /*!
226    \brief
227        Method used to get a pointer to the lua_State that the script module is attached to.
228
229    \return
230        A pointer to the lua_State that the script module is attached to.
231    */
232    lua_State* getLuaState(void) const {return d_state;}
233
234private:
235    /*************************************************************************
236        Implementation Functions
237    *************************************************************************/
238    void setModuleIdentifierString();
239
240    /*************************************************************************
241        Implementation Data
242    *************************************************************************/
243    bool d_ownsState;      //!< true when the attached lua_State was created by this script module
244    lua_State* d_state;    //!< The lua_State that this script module uses.
245};
246
247} // namespace CEGUI
248
249#endif // end of guard _CEGUILua_h_
Note: See TracBrowser for help on using the repository browser.