Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/ceguilua-0.5.0b/ceguilua/CEGUILua.h @ 2207

Last change on this file since 2207 was 1849, checked in by rgrieder, 16 years ago

MINGW32 fix again for other CEGUILua version.

  • Property svn:eol-style set to native
File size: 8.5 KB
Line 
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/*** CHANGES BY ORXONOX TEAM FOR MINGW32 ***/
35/*************************************************************************
36        Import / Export control macros
37*************************************************************************/
38#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
39#   ifdef CEGUILUA_EXPORTS
40#       define CEGUILUA_API __declspec(dllexport)
41#   else
42#      if defined( __MINGW32__ )
43#          define CEGUILUA_API
44#      else
45#          define CEGUILUA_API __declspec(dllimport)
46#      endif
47#   endif
48#else
49#   define CEGUILUA_API
50#endif
51
52
53#include "CEGUIScriptModule.h"
54
55struct lua_State;
56
57// Start of CEGUI namespace section
58namespace CEGUI
59{
60
61/*!
62\brief
63        Interface for the LuaScriptModule class
64*/
65class CEGUILUA_API LuaScriptModule : public CEGUI::ScriptModule
66{
67public:
68        /*************************************************************************
69                Construction and Destruction
70        *************************************************************************/
71        /*!
72        \brief
73                Constructor for LuaScriptModule class which create a lua_State
74        */
75        LuaScriptModule();
76
77
78        /*!
79        \brief
80                Constructor for LuaScriptModule class which takes a lua_State
81
82        \param state
83                Pointer to the lua_State that the script module should attach to.
84        */
85        LuaScriptModule(lua_State* state);
86
87
88        /*!
89        \brief
90                Destructor for LuaScriptModule class.
91        */
92        ~LuaScriptModule();
93
94
95        /*************************************************************************
96                Script Execution Functions
97        *************************************************************************/
98        /*!
99        \brief
100                Execute a script file.
101
102        \param filename
103                String object holding the filename of the script file that is to be executed
104               
105        \param resourceGroup
106                Resource group idendifier to be passed to the ResourceProvider when loading the script file.
107        */
108        void executeScriptFile(const String& filename, const String& resourceGroup);
109
110
111        /*!
112        \brief
113                Execute a scripted global function.  The function should not take any parameters and should return an integer.
114
115        \param function_name
116                String object holding the name of the function, in the global script environment, that
117                is to be executed.
118
119        \return
120                The integer value returned from the script function.
121        */
122        int executeScriptGlobal(const String& function_name);
123
124
125    /*!
126    \brief
127        Execute a scripted global 'event handler' function by looking it up by name.
128
129    \param handler_name
130        String object holding the name of the scripted handler function.
131        If this string contains dots '.' it will be parsed as tables containing a function field.
132        For example: 'mytable.subtable.func'
133
134    \param e
135        EventArgs based object that should be passed, by any appropriate means, to the scripted function.
136
137    \return
138        - true if the event was handled.
139        - false if the event was not handled.
140    */
141    bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e);
142
143
144    /*!
145    \brief
146        Execute script code contained in the given CEGUI::String object.
147
148    \param str
149        String object holding the valid script code that should be executed.
150
151    \return
152        Nothing.
153    */
154    void executeString(const String& str);
155
156    /*************************************************************************
157        Event subscription
158    *************************************************************************/
159    /*!
160    \brief
161            Subscribes the named Event to a scripted funtion
162
163    \param target
164            The target EventSet for the subscription.
165
166    \param name
167            String object containing the name of the Event to subscribe to.
168
169    \param subscriber_name
170            String object containing the name of the script funtion that is to be subscribed to the Event.
171
172    \return
173            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
174
175    \exception UnknownObjectException   Thrown if an Event named \a name is not in the EventSet
176    */
177    Event::Connection   subscribeEvent(EventSet* target, const String& name, const String& subscriber_name);
178
179    /*!
180    \brief
181            Subscribes the specified group of the named Event to a scripted funtion.
182
183    \param target
184            The target EventSet for the subscription.
185
186    \param name
187            String object containing the name of the Event to subscribe to.
188
189    \param group
190            Group which is to be subscribed to.  Subscription groups are called in ascending order.
191
192    \param subscriber_name
193            String object containing the name of the script funtion that is to be subscribed to the Event.
194
195    \return
196            Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
197
198    \exception UnknownObjectException   Thrown if an Event named \a name is not in the EventSet
199    */
200    Event::Connection   subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name);
201
202    /*************************************************************************
203        Bindings creation / destruction
204    *************************************************************************/
205    /*!
206    \brief
207        Method called during system initialisation, prior to running any scripts via the ScriptModule, to enable the ScriptModule
208        to perform any operations required to complete initialisation or binding of the script language to the gui system objects.
209
210    \return
211        Nothing.
212    */
213    void createBindings(void);
214
215
216    /*!
217    \brief
218        Method called during system destruction, after all scripts have been run via the ScriptModule, to enable the ScriptModule
219        to perform any operations required to cleanup bindings of the script language to the gui system objects, as set-up in the
220        earlier createBindings call.
221
222    \return
223        Nothing.
224    */
225    void destroyBindings(void);
226
227    /*************************************************************************
228        Accessor type functions
229    *************************************************************************/
230    /*!
231    \brief
232        Method used to get a pointer to the lua_State that the script module is attached to.
233
234    \return
235        A pointer to the lua_State that the script module is attached to.
236    */
237    lua_State* getLuaState(void) const {return d_state;}
238
239private:
240    /*************************************************************************
241        Implementation Functions
242    *************************************************************************/
243    void setModuleIdentifierString();
244
245    /*************************************************************************
246        Implementation Data
247    *************************************************************************/
248    bool d_ownsState;      //!< true when the attached lua_State was created by this script module
249    lua_State* d_state;    //!< The lua_State that this script module uses.
250};
251
252} // namespace CEGUI
253
254#endif // end of guard _CEGUILua_h_
Note: See TracBrowser for help on using the repository browser.