Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8239 in orxonox.OLD for branches/script_engine/src/lib


Ignore:
Timestamp:
Jun 8, 2006, 1:53:06 PM (19 years ago)
Author:
bensch
Message:

more integration into orxonox framework

Location:
branches/script_engine/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/BuildLibs.am

    r8093 r8239  
    66                $(LIB_PREFIX)/gui/gl_gui/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 \
     
    2223                $(LIB_PREFIX)/shell/libORXshell.a \
    2324                $(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  
    1616
    1717
    18 ScriptManager::ScriptManager()
     18ScriptManager::ScriptManager(const TiXmlElement* root)
    1919{
    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);
    2127}
     28
     29
    2230
    2331ScriptManager::~ScriptManager()
    2432{
    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();
    3234}
    3335
     
    3537void ScriptManager::loadParams(const TiXmlElement* root)
    3638{
    37   this->reset();
    3839  //BaseObject::loadParams(root);
    3940  {
    40   LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
     41    LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
    4142
    42   LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);
     43    LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);
    4344  } // make shure that the loading process is finished
    4445
     
    4647  getTriggers();
    4748  getScripts();
     49}
    4850
    4951
    50 }
    5152
    52 void  ScriptManager::reset()
     53void  ScriptManager::flush()
    5354{
    5455  //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();
    6359}
    64 
    65 void ScriptManager::init()
    66 {
    67   //this->setClassID("");
    68   this->setName("ScriptManager");
    69 
    70   this->scripts = NULL;
    71   this->triggers = NULL;
    72 }
    73 
    7460
    7561void  ScriptManager::createScripts(const TiXmlElement* scripts)
     
    9884{
    9985  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++ )
    10187    {
    10288      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    }
    10793
    10894  return NULL;
  • branches/script_engine/src/lib/script_engine/script_manager.h

    r8212 r8239  
    1414{
    1515 public:
    16    ScriptManager();
     16   ScriptManager(const TiXmlElement* root = NULL);
    1717   ~ScriptManager();
    18 
    19   inline static ScriptManager* getInstance() { if (!ScriptManager::singletonRef)ScriptManager::singletonRef = new ScriptManager(); return ScriptManager::singletonRef; }
    2018
    2119  /// LOADING
     
    2826
    2927 private:
    30 
    31    void  reset();                                   //!< Resets the script manager
    32    void  init();
     28   void  flush();                                   //!< Resets the script manager
    3329   void  createScripts(const TiXmlElement* scripts);
    3430   void  createTriggers(const TiXmlElement* triggers);
  • branches/script_engine/src/lib/script_engine/script_trigger.cc

    r8214 r8239  
    33#include "script.h"
    44
     5#include "state.h"
    56
    67ScriptTrigger::ScriptTrigger(const TiXmlElement* root)
     
    112113void ScriptTrigger::setScript(const std::string& file)
    113114{
    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  }
    119122}
Note: See TracChangeset for help on using the changeset viewer.