Changeset 8239 in orxonox.OLD for branches/script_engine/src/lib
- Timestamp:
- Jun 8, 2006, 1:53:06 PM (19 years ago)
- Location:
- branches/script_engine/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/BuildLibs.am
r8093 r8239 6 6 $(LIB_PREFIX)/gui/gl_gui/libORXglgui.a \ 7 7 $(LIB_PREFIX)/gui/libORXbasegui.a \ 8 $(LIB_PREFIX)/script_engine/libORXscript.a \ 8 9 $(LIB_PREFIX)/graphics/importer/libORXimporter.a \ 9 10 $(LIB_PREFIX)/graphics/libORXgraphics.a \ … … 22 23 $(LIB_PREFIX)/shell/libORXshell.a \ 23 24 $(LIB_PREFIX)/math/libORXmath.a \ 24 $(LIB_PREFIX)/libORXlibs.a \ 25 $(LIB_PREFIX)/script_engine/libORXscript.a 25 $(LIB_PREFIX)/libORXlibs.a -
branches/script_engine/src/lib/script_engine/script_manager.cc
r8212 r8239 16 16 17 17 18 ScriptManager::ScriptManager( )18 ScriptManager::ScriptManager(const TiXmlElement* root) 19 19 { 20 this->init(); 20 this->setName("ScriptManager"); 21 22 this->scripts = NULL; 23 this->triggers = NULL; 24 25 if (root != NULL) 26 this->loadParams(root); 21 27 } 28 29 22 30 23 31 ScriptManager::~ScriptManager() 24 32 { 25 // delete all scripts since they are useless without the manager 26 if(getScripts()) 27 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ ) 28 { 29 ClassList::removeFromClassList( (*it) ); 30 } 31 33 this->flush(); 32 34 } 33 35 … … 35 37 void ScriptManager::loadParams(const TiXmlElement* root) 36 38 { 37 this->reset();38 39 //BaseObject::loadParams(root); 39 40 { 40 LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);41 LoadParamXML(root, "Scripts", this, ScriptManager, createScripts); 41 42 42 LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);43 LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers); 43 44 } // make shure that the loading process is finished 44 45 … … 46 47 getTriggers(); 47 48 getScripts(); 49 } 48 50 49 51 50 }51 52 52 void ScriptManager:: reset()53 void ScriptManager::flush() 53 54 { 54 55 //Delete all scripts as they aren't deleted automatically 55 if(getScripts()) 56 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ ) 57 { 58 ClassList::removeFromClassList( (*it) ); 59 } 60 61 this->scripts = NULL; 62 this->triggers = NULL; 56 if(this->getScripts()) 57 while(!scripts->empty()) 58 delete scripts->front(); 63 59 } 64 65 void ScriptManager::init()66 {67 //this->setClassID("");68 this->setName("ScriptManager");69 70 this->scripts = NULL;71 this->triggers = NULL;72 }73 74 60 75 61 void ScriptManager::createScripts(const TiXmlElement* scripts) … … 98 84 { 99 85 if(getScripts()) 100 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )86 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ ) 101 87 { 102 88 if( (dynamic_cast<Script*>(*it))->getFileName().compare(file) == 0) 103 {104 return dynamic_cast<Script*>(*it);105 }106 }89 { 90 return dynamic_cast<Script*>(*it); 91 } 92 } 107 93 108 94 return NULL; -
branches/script_engine/src/lib/script_engine/script_manager.h
r8212 r8239 14 14 { 15 15 public: 16 ScriptManager( );16 ScriptManager(const TiXmlElement* root = NULL); 17 17 ~ScriptManager(); 18 19 inline static ScriptManager* getInstance() { if (!ScriptManager::singletonRef)ScriptManager::singletonRef = new ScriptManager(); return ScriptManager::singletonRef; }20 18 21 19 /// LOADING … … 28 26 29 27 private: 30 31 void reset(); //!< Resets the script manager 32 void init(); 28 void flush(); //!< Resets the script manager 33 29 void createScripts(const TiXmlElement* scripts); 34 30 void createTriggers(const TiXmlElement* triggers); -
branches/script_engine/src/lib/script_engine/script_trigger.cc
r8214 r8239 3 3 #include "script.h" 4 4 5 #include "state.h" 5 6 6 7 ScriptTrigger::ScriptTrigger(const TiXmlElement* root) … … 112 113 void ScriptTrigger::setScript(const std::string& file) 113 114 { 114 ScriptManager* scriptManager = ScriptManager::getInstance(); 115 script = scriptManager->getScriptByFile(file); 116 if(script != NULL) 117 scriptIsOk = true; 118 115 ScriptManager* scriptManager = State::getScriptManager(); 116 if (scriptManager != NULL) 117 { 118 script = scriptManager->getScriptByFile(file); 119 if(script != NULL) 120 scriptIsOk = true; 121 } 119 122 }
Note: See TracChangeset
for help on using the changeset viewer.