lugre_scripting.h

Go to the documentation of this file.
00001 /*
00002 http://www.opensource.org/licenses/mit-license.php  (MIT-License)
00003 
00004 Copyright (c) 2007 Lugre-Team
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022 THE SOFTWARE.
00023 */
00024 #ifndef LUGRE_SCRIPTING_H
00025 #define LUGRE_SCRIPTING_H
00026 #include "lugre_input.h"
00027 #include <list>
00028 
00029 
00030 
00031 // Ogre exceptions in a scripting function called from lua
00032 // do not propage to the global catch all in lugre_main.
00033 // This is not normal. But i don't know how to fix this.
00034 // Therefore the try catch macros
00035 #define LUGRE_TRY       \
00036     try {\
00037     
00038 #define LUGRE_CATCH     \
00039     } catch ( Ogre::Exception& e ) {\
00040         MyShowError((std::string("Ogre::exception occurred, see console\n") + e.getFullDescription()).c_str(),__FILE__,__LINE__,__FUNCTION__);\
00041     }\
00042     
00043 
00044 
00045 
00046 
00047 class lua_State;
00048 
00049 namespace Lugre {
00050 
00051 class cScriptingPlugin { public:
00052     virtual void    RegisterLua_GlobalFunctions (lua_State* L) {}
00053     virtual void    RegisterLua_Classes         (lua_State* L) {}
00054 };
00055     
00056 class cScripting : public cInputListener { public:
00057     lua_State*  L;
00058     
00059     static void         RegisterPlugin  (cScriptingPlugin* pPlugin);
00060     
00061     static cScripting*  GetSingletonPtr (cScripting* p=0);
00062     cScripting  ();
00063     ~cScripting ();
00064     
00065     void    Init        ();
00066     int     GetGlobal   (const char* name);
00067     static void SetGlobal   (lua_State *L,const char* name,int value);
00068     bool    LuaCall     (const char *func, const char *sig = "", ...);
00069     
00070     
00071     void    InitLugreLuaEnvironment     (lua_State* L);
00072     
00073     // cInputListener methods
00074     virtual void    Notify_KeyPress     (const unsigned char iKey,const int iLetter);
00075     virtual void    Notify_KeyRepeat    (const unsigned char iKey,const int iLetter);
00076     virtual void    Notify_KeyRelease   (const unsigned char iKey);
00077     
00078     private:
00079     static  std::list<cScriptingPlugin*>    mlPlugins;
00080 };
00081 
00082 };
00083 
00084 #endif

Generated on Wed May 23 06:00:13 2012 for cpp by  doxygen 1.5.6