Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8271 in orxonox.OLD


Ignore:
Timestamp:
Jun 8, 2006, 4:50:50 PM (18 years ago)
Author:
bensch
Message:

merge

Location:
trunk/src
Files:
5 deleted
22 edited
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r7810 r8271  
    2828                $(libORXlibs_a_LIBRARIES_) \
    2929                $(CURL_LIBS) \
    30                 @QT_LIBS@
     30                @QT_LIBS@ \
     31                -L../extern_libs @LUA_LIBS@
    3132
    3233orxonox_SOURCES = \
  • trunk/src/defs/class_id.h

    r8190 r8271  
    8484
    8585  CL_WORLD_ENTITY               =    0x40000000,
    86 
    87   CL_RESOURCE                   =    0x80000000,
    8886
    8987  /// subsuper-classes
     
    223221  // Testing Entities
    224222  CL_TEST_ENTITY                =    0x00000409,
     223  CL_ACCOUNT                    =    0x00000410,
     224  CL_TEST_OBJECT                =    0x00000411,
    225225
    226226  // misc
     
    242242  CL_AMMO_CONTAINER             =    0x00000604,
    243243  CL_HUD                        =    0x00000620,
     244
     245
     246  CL_SCRIPT_MANAGER             =    0x00000650,
     247  CL_SCRIPT                     =    0x00000651,
     248  CL_SCRIPT_CLASS               =    0x00000652,
     249  CL_SCRIPT_TRIGGER             =    0x00000652,
    244250
    245251
  • trunk/src/defs/include_paths.am

    r8145 r8271  
    2626AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/newmat
    2727AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/sound
     28AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/script_engine
    2829AM_CXXFLAGS+=-I$(MAINSRCDIR)/defs
    2930AM_CXXFLAGS+=-I$(MAINSRCDIR)/font
     
    3536AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/track
    3637AM_CXXFLAGS+=-I$(MAINSRCDIR)/subprojects
     38AM_CXXFLAGS+=-I$(MAINSRCDIR)/../extern_libs
  • trunk/src/lib/BuildLibs.am

    r8190 r8271  
    66                $(LIB_PREFIX)/gui/gl/libORXglgui.a \
    77                $(LIB_PREFIX)/gui/libORXbasegui.a \
     8                $(LIB_PREFIX)/script_engine/libORXscript.a \
    89                $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
    910                $(LIB_PREFIX)/graphics/libORXgraphics.a \
  • trunk/src/lib/Makefile.am

    r8061 r8271  
    1616                util/executor/executor.cc \
    1717                util/executor/executor_functional.cc \
     18                util/executor/executor_lua.cc \
    1819                \
    1920                util/loading/resource_manager.cc \
     
    4546                util/executor/executor_functional.h \
    4647                util/executor/executor_xml.h \
     48                util/executor/executor_lua.h \
    4749                util/executor/functor_list.h \
     50                \
    4851                util/preferences.h \
    4952                util/threading.h \
  • trunk/src/lib/gui/gl/signal_connector.cc

    r8145 r8271  
    9292  {
    9393    if (this->isValid())
    94       (*this->exec)(this->object, 0, NULL);
     94    {
     95      static int count = 0;
     96      (*this->exec)(this->object, count, NULL);
     97    }
    9598  }
    9699
     
    102105  {
    103106    if (exec != NULL && object != NULL)
    104       (*this->exec)(this->object, 1, (void*)&value0);
     107    {
     108      static int count = 1;
     109      (*this->exec)(this->object, count, (void*)&value0);
     110    }
    105111  }
    106112
     
    114120    if (exec != NULL && object != NULL)
    115121    {
     122      static int count = 2;
    116123      MultiType mt[] = { value0, value1 };
    117       (*this->exec)(this->object, 2, mt);
     124      (*this->exec)(this->object, count, mt);
    118125    }
    119126  }
     
    129136    if (exec != NULL && object != NULL)
    130137    {
     138      static int count = 3;
    131139      MultiType mt[] = { value0, value1, value2 };
    132       (*this->exec)(this->object, 3, mt);
     140      (*this->exec)(this->object, count, mt);
    133141    }
    134142  }
     
    145153    if (exec != NULL && object != NULL)
    146154    {
     155      static int count = 4;
    147156      MultiType mt[] = { value0, value1, value2, value3 };
    148       (*this->exec)(this->object, 4, mt);
     157      (*this->exec)(this->object, count, mt);
    149158    }
    150159  }
     
    162171    if (exec != NULL && object != NULL)
    163172    {
     173      static int count = 5;
    164174      MultiType mt[] = { value0, value1, value2, value3, value4 };
    165       (*this->exec)(this->object, 5, mt);
     175      (*this->exec)(this->object, count, mt);
    166176    }
    167177  }
  • trunk/src/lib/lang/class_list.cc

    r8145 r8271  
    221221          return (*bo);
    222222    }
     223  }
     224  return NULL;
     225}
     226
     227
     228/**
     229 * @brief checks if the BaseObject* object exists.
     230 * @param objectName the name of the BaseObject to look for
     231 * @param classID if not CL_NULL it will only search through a specific type of Objects. Otherwise it will be searched everywhere.
     232 * @return true, if the Object Exists in the specified ClassID, false otherwise
     233 * @todo: speed this up!!
     234 */
     235BaseObject* ClassList::getObject(const std::string& objectName, const std::string& className)
     236{
     237  ClassList* cl = ClassList::getClassList(className);
     238  if (cl != NULL)
     239  {
     240    std::list<BaseObject*>::iterator bo;
     241    for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++)
     242      if ((*bo)->getName() != NULL && objectName == (*bo)->getName())
     243        return (*bo);
    223244  }
    224245  return NULL;
  • trunk/src/lib/lang/class_list.h

    r7429 r8271  
    4242    static const std::list<BaseObject*>*  getList(const std::string& className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL;  };
    4343    static const std::list<std::string>*  getClassNames();
    44     static BaseObject*                    getObject(const std::string& name, ClassID classID = CL_NULL);
     44    static BaseObject*                    getObject(const std::string& objectName, ClassID classID = CL_NULL);
     45    static BaseObject*                    getObject(const std::string& objectName, const std::string& className);
    4546    static bool                           exists(const BaseObject* object, ClassID classID = CL_NULL);
    4647    static bool                           exists(const std::string& className, const std::string& objectName);
  • trunk/src/lib/script_engine/Makefile.am

    r8061 r8271  
    11MAINSRCDIR=../..
    22include $(MAINSRCDIR)/defs/include_paths.am
     3
     4
     5LIB_PREFIX=$(MAINSRCDIR)/lib
     6include $(MAINSRCDIR)/lib/BuildLibs.am
     7
     8
    39
    410INCLUDES= -I../../../extern_libs
     
    612noinst_LIBRARIES = libORXscript.a
    713
    8 libORXscript_a_SOURCES =
     14libORXscript_a_SOURCES = \
     15                script.cc\
     16                script_manager.cc\
     17                script_class.cc\
     18                account.cc \
     19                object.cc
     20
    921
    1022AM_CPPFLAGS= @LUA_INCLUDES@
    1123
    12 bin_PROGRAMS = account
    13 account_SOURCES = \
    14                 account.cc\
    15                 Script.cc
     24noinst_HEADERS = \
     25                lunar.h\
     26                script.h\
     27                script_manager.h\
     28                script_class.h
    1629
    1730
    1831
    19 account_LDADD = libORXscript.a -L../../../extern_libs @LUA_LIBS@
    2032
    21 #main_LDFLAGS =
     33check_PROGRAMS = example
    2234
    2335
    24 noinst_HEADERS = \
    25                 lunar.h\
    26                 Script.h
     36
     37
     38
     39
     40
     41example_DEPENDENCIES = \
     42                $(MAINSRCDIR)/world_entities/libORXwe.a \
     43                $(libORXlibs_a_LIBRARIES_) \
     44                $(MAINSRCDIR)/util/libORXutils.a
     45
     46example_LDADD = \
     47                $(MAINSRCDIR)/util/libORXutils.a \
     48                $(libORXlibs_a_LIBRARIES_) \
     49                libORXscript.a -L../../../extern_libs @LUA_LIBS@ \
     50                $(MAINSRCDIR)/world_entities/libORXwe.a \
     51                $(libORXlibs_a_LIBRARIES_) \
     52                $(MAINSRCDIR)/util/libORXutils.a
     53
     54example_SOURCES= \
     55                example.cc \
     56                \
     57                ../util/executor/executor_lua.cc
  • trunk/src/lib/script_engine/lunar.h

    r8061 r8271  
    33
    44#include <string>
    5 #include "Script.h"
     5#include <cassert>
     6#include "script.h"
    67
    78#include "luaincl.h"
     9#include "executor/executor_lua.h"
    810
    911
     
    1214      typedef struct { T *pT; } userdataType;
    1315    public:
    14       typedef int (T::*mfp)(lua_State *L);
     16      typedef Executor* mfp;
    1517      typedef struct { const char *name; mfp mfunc; } RegType;
    1618
     
    139141      static int insertObject(Script* script, T* obj, const std::string& name, bool gc=false)
    140142      {
    141         if(script != NULL)
    142           return insertObject(script->getLuaState(), obj, name, gc);
    143 
    144 
     143        assert (script != NULL);
     144        return insertObject(script->getLuaState(), obj, name, gc);
    145145      }
    146146
     
    163163        // get member function from upvalue
    164164        RegType *l = static_cast<RegType*>(lua_touserdata(L, lua_upvalueindex(1)));
    165         return (obj->*(l->mfunc))(L);  // call member function
     165        int value;
     166        (*l->mfunc)(obj, value, L);  // call member function
     167        return value;
    166168      }
    167169
  • trunk/src/lib/script_engine/lunartest2.lua

    r8061 r8271  
    1515getmetatable(Account).__index = parent
    1616
     17
     18function test()
     19io.write("Hi i'm test\n")
     20end
     21
     22
    1723function main(arg)
     24  -- use parameter
    1825  io.write("main received ", arg)
    1926  io.write(" as parameter\n")
     27
     28  --call member of an inserted object
    2029  Obj:printName()
     30
     31  --create object of a registered type
     32  o = Object()
     33  o:printName()
     34
     35  --take returnvalue from c
     36  callCount = Obj:getCallCount()
     37  io.write("callCount is now ",callCount)
     38  io.write("\n")
     39
     40  --pass parameters to a c++ method
     41  Obj:takeParam(3)
     42
     43  --print object information
    2144  print('a =', a)
    2245  print('b =', b)
     
    2851  Obj:printName()
    2952
    30   return 2
     53  return 2,false,2.72
     54
    3155  --debug.debug()
    3256end
  • trunk/src/lib/util/executor/executor.h

    r8048 r8271  
    5353    // EXECUTE
    5454    /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    55     virtual void operator()(BaseObject* object, unsigned int count, void* values) const = 0;
     55    virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
    5656    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    5757    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
  • trunk/src/lib/util/executor/executor_functional.h

    r8048 r8271  
    123123
    124124  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    125   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     125  virtual void operator()(BaseObject* object, int& count, void* values) const
    126126  {
    127127    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     
    163163
    164164  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    165   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     165  virtual void operator()(BaseObject* object, int& count, void* values) const
    166166  {
    167167    const MultiType* mt = (const MultiType*)values;
     
    227227
    228228  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    229   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     229  virtual void operator()(BaseObject* object, int& count, void* values) const
    230230  {
    231231    const MultiType* mt = (const MultiType*)values;
     
    282282
    283283  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    284   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     284  virtual void operator()(BaseObject* object, int& count, void* values) const
    285285  {
    286286    const MultiType* mt = (const MultiType*)values;
     
    340340
    341341  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    342   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     342  virtual void operator()(BaseObject* object, int& count, void* values) const
    343343  {
    344344    const MultiType* mt = (const MultiType*)values;
     
    400400
    401401  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    402   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     402  virtual void operator()(BaseObject* object, int& count, void* values) const
    403403  {
    404404    const MultiType* mt = (const MultiType*)values;
  • trunk/src/lib/util/executor/executor_lua.cc

    r8057 r8271  
    1818#include "executor_lua.h"
    1919
    20 template<> bool fromLua<bool>(lua_state* state, int index) { return lua_toboolean(state, index); };
    21 template<> int fromLua<int>(lua_state* state, int index) { return (int)lua_toumber(state, index); };
    22 template<> unsigned int fromLua<unsigned int>(lua_state* state, int index) { return (unsigned int)lua_tonumber(state, index); };
    23 template<> float fromLua<float>(lua_state* state, int index) { return (float)lua_tonumber(state, index); };
    24 template<> char fromLua<char>(lua_state* state, int index) { reutnr (char)lua_tonumber(state, index); };
    25 template<> const std::string& fromLua<const std::string&>(lua_state* state, int index) { return lua_tostring(state, index); };
     20std::string temp;
     21
     22template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); };
     23template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); };
     24template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); };
     25template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); };
     26template<> char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); };
     27template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { temp = lua_tostring(state, index); return temp; };
    2628
    2729
    2830
    29 template<> void toLua<bool>(lua_state* state, bool value) { lua_pushboolean(state, (int) value); };
    30 template<> void toLua<int>(lua_state* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
    31 template<> void toLua<unsigned int>(lua_state* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
    32 template<> void toLua<float>(lua_state* state, float value) { lua_pushnumber(state, (lua_Number) value); };
    33 template<> void toLua<char>(lua_state* state, char value) { lua_pushnumber(state, (lua_Number) value); };
    34 template<> void toLua<const std::string&>(lua_state* state, const std::string& value) {lua_pushstring (state, value.c_str()); }
     31template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); };
     32template<> void toLua<int>(lua_State* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
     33template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
     34template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
     35template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
     36template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); }
  • trunk/src/lib/util/executor/executor_lua.h

    r8057 r8271  
    44 */
    55
    6 #ifndef _EXECUTOR_SPECIALS_H
    7 #define _EXECUTOR_SPECIALS_H
     6#ifndef _EXECUTOR_LUA_H
     7#define _EXECUTOR_LUA_H
    88
    99#include "executor.h"
    1010#include "compiler.h"
    11 
     11#include "debug.h"
    1212#include "luaincl.h"
    1313
    1414
    1515
    16 template<typename type> type fromLua(lua_state* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };
    17 template<> bool fromLua<bool>(lua_state* state, int index);
    18 template<> int fromLua<int>(lua_state* state, int index);
    19 template<> unsigned int fromLua<unsigned int>(lua_state* state, int index);
    20 template<> float fromLua<float>(lua_state* state, int index);
    21 template<> char fromLua<char>(lua_state* state, int index);
    22 template<> const std::string& fromLua<const std::string&>(lua_state* state, int index);
    23 
    24 
    25 template<typename type> void toLua(lua_state* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };
    26 template<> void toLua<bool>(lua_state* state, bool value);
    27 template<> void toLua<int>(lua_state* state, int value);
    28 template<> void toLua<unsigned int>(lua_state* state, unsigned int value);
    29 template<> void toLua<float>(lua_state* state, float value);
    30 template<> void toLua<char>(lua_state* state, char value);
    31 template<> void toLua<const std::string&>(lua_state* state, const std::string& value);
     16template<typename type> type fromLua(lua_State* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };
     17template<> bool fromLua<bool>(lua_State* state, int index);
     18template<> int fromLua<int>(lua_State* state, int index);
     19template<> unsigned int fromLua<unsigned int>(lua_State* state, int index);
     20template<> float fromLua<float>(lua_State* state, int index);
     21template<> char fromLua<char>(lua_State* state, int index);
     22template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
     23
     24
     25template<typename type> void toLua(lua_State* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };
     26template<> void toLua<bool>(lua_State* state, bool value);
     27template<> void toLua<int>(lua_State* state, int value);
     28template<> void toLua<unsigned int>(lua_State* state, unsigned int value);
     29template<> void toLua<float>(lua_State* state, float value);
     30template<> void toLua<char>(lua_State* state, char value);
     31template<> void toLua<const std::string&>(lua_State* state, const std::string& value);
    3232
    3333// FORWARD DECLARATION
    3434
     35///////////////////////
     36///// WITHOUT RET /////
     37///////////////////////
    3538
    3639///////////
    3740//// 0 ////
    3841///////////
    39 //! Executes a Function with a lua_state* parameter.
     42//! Executes a Function with a lua_State* parameter.
    4043template<class T> class ExecutorLua0 : public Executor
    4144{
     
    6265    }
    6366
    64     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     67    virtual void operator()(BaseObject* object, int& count, void* values) const
    6568    {
    6669      (dynamic_cast<T*>(object)->*(functionPointer))();
     70      count = 0;
    6771    }
    6872
     
    7276    virtual Executor* clone () const
    7377    {
    74       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
    75     }
     78      return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
     79    }
     80  private:
     81    void          (T::*functionPointer)();
    7682};
    7783
     
    8187//// 1 ////
    8288///////////
    83 //! Executes a Function with a lua_state* parameter.
     89//! Executes a Function with a lua_State* parameter.
    8490template<class T, typename type0> class ExecutorLua1 : public Executor
    8591{
     
    8995     * @param function a Function to call
    9096     */
    91     ExecutorLua0(void(T::*function)(type0))
     97    ExecutorLua1(void(T::*function)(type0))
    9298        : Executor(ExecutorParamType<type0>())
    9399    {
     
    106112    }
    107113
    108     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
    109     {
    110       lua_state* state = (lua_state*)values;
     114    virtual void operator()(BaseObject* object, int& count, void* values) const
     115    {
     116      lua_State* state = (lua_State*)values;
     117      count = 0;
    111118
    112119      (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1));
     
    118125    virtual Executor* clone () const
    119126    {
    120       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
    121     }
     127      return new ExecutorLua1<T, type0>((this->functionPointer));
     128    }
     129  private:
     130    void          (T::*functionPointer)(type0);
    122131};
    123132
     
    127136//// 2 ////
    128137///////////
    129 //! Executes a Function with a lua_state* parameter.
    130 template<class T, typename type0, typename type1> class ExecutorLua1 : public Executor
    131 {
    132   public:
    133     /**
    134      * @brief Constructor of a ExecutorXML
    135      * @param function a Function to call
    136      */
    137     ExecutorLua0(void(T::*function)(type0, type1))
     138//! Executes a Function with a lua_State* parameter.
     139template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor
     140{
     141  public:
     142    /**
     143     * @brief Constructor of a ExecutorXML
     144     * @param function a Function to call
     145     */
     146    ExecutorLua2(void(T::*function)(type0, type1))
    138147        : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
    139148    {
     
    152161    }
    153162
    154     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
    155     {
    156       lua_state* state = (lua_state*)values;
     163    virtual void operator()(BaseObject* object, int& count, void* values) const
     164    {
     165      lua_State* state = (lua_State*)values;
     166      count = 0;
    157167
    158168      (dynamic_cast<T*>(object)->*(functionPointer))(
     
    166176    virtual Executor* clone () const
    167177    {
    168       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
    169     }
    170 };
    171 
    172 
    173 
    174 #endif /* _EXECUTOR_SPECIALS_H */
     178      return new ExecutorLua2<T, type0, type1>(this->functionPointer);
     179    }
     180  private:
     181    void          (T::*functionPointer)(type0, type1);
     182};
     183
     184
     185
     186
     187
     188
     189
     190////////////////////
     191///// WITH RET /////
     192////////////////////
     193
     194
     195///////////
     196//// 0 ////
     197///////////
     198//! Executes a Function with a lua_State* parameter.
     199template<class T, typename ret> class ExecutorLua0ret : public Executor
     200{
     201  public:
     202    /**
     203     * @brief Constructor of a ExecutorXML
     204     * @param function a Function to call
     205     */
     206    ExecutorLua0ret(ret (T::*function)())
     207        : Executor()
     208    {
     209      this->functionPointer = function;
     210      this->functorType = Executor_Objective | Executor_NoLoadString;
     211    }
     212
     213    /**
     214     * @brief executes the Command on BaseObject
     215     * @param object the BaseObject to execute this Executor on
     216     * @param loadString ignored in this case
     217     */
     218    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     219    {
     220      PRINTF(1)("no usefull executor\n");
     221    }
     222
     223    virtual void operator()(BaseObject* object, int& count, void* values) const
     224    {
     225      lua_State* state = (lua_State*)values;
     226      count = 1;
     227
     228      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))());
     229    }
     230
     231    /**
     232                       * @returns a _new_ Copy of this Executor
     233     */
     234    virtual Executor* clone () const
     235    {
     236      return new ExecutorLua0ret<T, ret>(this->functionPointer);
     237    }
     238  private:
     239    ret           (T::*functionPointer)();
     240};
     241
     242
     243
     244///////////
     245//// 1 ////
     246///////////
     247//! Executes a Function with a lua_State* parameter.
     248template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor
     249{
     250  public:
     251    /**
     252     * @brief Constructor of a ExecutorXML
     253     * @param function a Function to call
     254     */
     255    ExecutorLua1ret(ret (T::*function)(type0))
     256        : Executor(ExecutorParamType<type0>())
     257    {
     258      this->functionPointer = function;
     259      this->functorType = Executor_Objective | Executor_NoLoadString;
     260    }
     261
     262    /**
     263     * @brief executes the Command on BaseObject
     264     * @param object the BaseObject to execute this Executor on
     265     * @param loadString ignored in this case
     266     */
     267    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     268    {
     269      PRINTF(1)("no usefull executor\n");
     270    }
     271
     272    virtual void operator()(BaseObject* object, int& count, void* values) const
     273    {
     274      lua_State* state = (lua_State*)values;
     275      count = 1;
     276
     277      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     278                   fromLua<type0>(state, 1)));
     279    }
     280
     281    /**
     282     * @returns a _new_ Copy of this Executor
     283     */
     284    virtual Executor* clone () const
     285    {
     286      return new ExecutorLua1ret<T, ret, type0>(this->functionPointer);
     287    }
     288  private:
     289    ret           (T::*functionPointer)(type0);
     290};
     291
     292///////////
     293//// 2 ////
     294///////////
     295//! Executes a Function with a lua_State* parameter.
     296template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor
     297{
     298  public:
     299    /**
     300     * @brief Constructor of a ExecutorXML
     301     * @param function a Function to call
     302     */
     303    ExecutorLua2ret(ret (T::*function)(type0, type1))
     304        : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
     305    {
     306      this->functionPointer = function;
     307      this->functorType = Executor_Objective | Executor_NoLoadString;
     308    }
     309
     310    /**
     311     * @brief executes the Command on BaseObject
     312     * @param object the BaseObject to execute this Executor on
     313     * @param loadString ignored in this case
     314     */
     315    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     316    {
     317      PRINTF(1)("no usefull executor\n");
     318    }
     319
     320    virtual void operator()(BaseObject* object, int& count, void* values) const
     321    {
     322      lua_State* state = (lua_State*)values;
     323      count = 1;
     324
     325      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     326                   fromLua<type0>(state, 1),
     327                   fromLua<type1>(state, 2) ));
     328    }
     329
     330    /**
     331     * @returns a _new_ Copy of this Executor
     332     */
     333    virtual Executor* clone () const
     334    {
     335      return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer);
     336    }
     337  private:
     338    ret           (T::*functionPointer)(type0, type1);
     339};
     340
     341
     342
     343
     344
     345
     346
     347#endif /* _EXECUTOR_LUA_H */
  • trunk/src/lib/util/executor/executor_xml.h

    r8051 r8271  
    11/*!
    2  * @file executor.h
     2 * @file executor_xml.h
    33 * Definition of a on-screen-shell
    44 */
    55
    6 #ifndef _EXECUTOR_SPECIALS_H
    7 #define _EXECUTOR_SPECIALS_H
     6#ifndef _EXECUTOR_XML_H
     7#define _EXECUTOR_XML_H
    88
    99#include "executor.h"
     
    6565    }
    6666
    67     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     67    virtual void operator()(BaseObject* object, int& count, void* values) const
    6868    {
    6969      PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n");
     
    8282};
    8383
    84 #endif /* _EXECUTOR_SPECIALS_H */
     84#endif /* _EXECUTOR_XML_H */
  • trunk/src/lib/util/loading/resource.cc

    r7195 r8271  
    2626Resource::Resource (const std::string& fileName)
    2727{
    28    this->setClassID(CL_RESOURCE, "Resource");
     28//   this->setClassID(CL_RESOURCE, "Resource");
    2929
    3030}
  • trunk/src/story_entities/game_world.cc

    r8255 r8271  
    139139}
    140140
    141 
     141#include "account.cc"
     142#include "object.cc"
    142143/**
    143144 *  loads the GameWorld by initializing all resources, and set their default values.
     
    181182  this->dataXML = (TiXmlElement*)root->Clone();
    182183
     184
     185  Object* obj= new Object();
     186  obj->setName("Obj");
     187  Account* a = new Account();
     188  a->setName("a");
     189  Account *b = new Account(30);
     190  b->setName("b");
     191 
     192  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
     193
    183194  delete XMLDoc;
    184195  this->releaseLoadScreen();
     
    191202ErrorMessage GameWorld::unloadData()
    192203{
     204
    193205  PRINTF(3)("GameWorld::~GameWorld() - unloading the current GameWorld\n");
     206  this->scriptManager.flush();
     207
    194208  delete this->shell;
    195209
     
    215229  this->bRunning = true;
    216230
     231  State::setScripManager(&this->scriptManager);
     232
    217233  this->run();
    218234}
     
    225241{
    226242  PRINTF(3)("GameWorld::stop() - got stop signal\n");
     243  State::setScripManager(NULL);
    227244  this->bRunning = false;
    228245}
  • trunk/src/story_entities/game_world.h

    r8190 r8271  
    1111#include "game_world_data.h"
    1212#include "playable.h"
     13#include "script_manager.h"
    1314
    1415namespace OrxShell { class Shell; };
    1516class WorldEntity;
    1617class GameRules;
     18
    1719
    1820/** How many frames time values to keep
     
    103105    GameRules*          gameRules;                    //!< Pointer to the data structure containig the game rules
    104106
    105 
    106107  private:
    107108    /* external modules interfaces */
     109    ScriptManager       scriptManager;
    108110    OrxShell::Shell*    shell;
    109111};
  • trunk/src/util/state.cc

    r7039 r8271  
    3838
    3939ObjectManager* State::objectManager = NULL;
    40 
     40ScriptManager* State::scriptManager = NULL;
    4141
    4242unsigned int State::resX = 1;
  • trunk/src/util/state.h

    r8148 r8271  
    1818class ObjectManager;
    1919class GameRules;
     20
     21class ScriptManager;
    2022
    2123
     
    9294
    9395
     96
     97  ////////////////////
     98  /// SCRIP_ENGINE ///
     99  ////////////////////
     100  static void setScripManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; };
     101  static ScriptManager* getScriptManager() { return State::scriptManager; };
     102
    94103  ////////////
    95104  /// Menu ///
     
    116125
    117126  static SkyBox*                skyBox;            //!< The SkyBox used in the current world.
     127
     128  static  ScriptManager*        scriptManager;     //!< The ScriptManager.
     129
    118130  static unsigned int           resX;              //!< The X Resolution of the screen.
    119131  static unsigned int           resY;              //!< The Y Resolution of the screen.
  • trunk/src/world_entities/WorldEntities.am

    r8186 r8271  
    5151                world_entities/elements/text_element.cc \
    5252                \
    53                 world_entities/effects/lightning_bolt.cc
     53                world_entities/effects/lightning_bolt.cc \
     54                \
     55                world_entities/script_trigger.cc
    5456
    5557
     
    103105                elements/text_element.h \
    104106                \
    105                 effects/lightning_bolt.h
     107                effects/lightning_bolt.h \
     108                \
     109                script_trigger.h
Note: See TracChangeset for help on using the changeset viewer.