Changeset 8239 in orxonox.OLD for branches/script_engine/src
- Timestamp:
- Jun 8, 2006, 1:53:06 PM (18 years ago)
- Location:
- branches/script_engine/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/Makefile.am
r7810 r8239 28 28 $(libORXlibs_a_LIBRARIES_) \ 29 29 $(CURL_LIBS) \ 30 @QT_LIBS@ 30 @QT_LIBS@ \ 31 -L../extern_libs @LUA_LIBS@ 31 32 32 33 orxonox_SOURCES = \ -
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 } -
branches/script_engine/src/story_entities/game_world.cc
r8037 r8239 181 181 this->dataXML = (TiXmlElement*)root->Clone(); 182 182 183 LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams); 184 183 185 delete XMLDoc; 184 186 this->releaseLoadScreen(); … … 213 215 this->bPaused = false; 214 216 this->bRunning = true; 217 218 State::setScripManager(&this->scriptManager); 215 219 216 220 this->run(); -
branches/script_engine/src/story_entities/game_world.h
r7919 r8239 11 11 #include "game_world_data.h" 12 12 #include "playable.h" 13 #include "script_manager.h" 13 14 14 15 namespace OrxShell { class Shell; }; 15 16 class WorldEntity; 16 17 class GameRules; 18 17 19 18 20 /** How many frames time values to keep … … 102 104 GameRules* gameRules; //!< Pointer to the data structure containig the game rules 103 105 104 105 106 private: 106 107 /* external modules interfaces */ 108 ScriptManager scriptManager; 107 109 OrxShell::Shell* shell; 108 110 }; -
branches/script_engine/src/util/state.cc
r7039 r8239 38 38 39 39 ObjectManager* State::objectManager = NULL; 40 40 ScriptManager* State::scriptManager = NULL; 41 41 42 42 unsigned int State::resX = 1; -
branches/script_engine/src/util/state.h
r7039 r8239 18 18 class ObjectManager; 19 19 class GameRules; 20 21 class ScriptManager; 20 22 21 23 … … 92 94 93 95 96 97 //////////////////// 98 /// SCRIP_ENGINE /// 99 //////////////////// 100 static void setScripManager(ScriptManager* scriptManager) { State::scriptManager = scriptManager; }; 101 static ScriptManager* getScriptManager() { return State::scriptManager; }; 102 94 103 //////////// 95 104 /// Menu /// … … 116 125 117 126 static SkyBox* skyBox; //!< The SkyBox used in the current world. 127 128 static ScriptManager* scriptManager; //!< The ScriptManager. 129 118 130 static unsigned int resX; //!< The X Resolution of the screen. 119 131 static unsigned int resY; //!< The Y Resolution of the screen.
Note: See TracChangeset
for help on using the changeset viewer.