Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2006, 3:04:14 PM (18 years ago)
Author:
snellen
Message:

script_engine: swapping to integrate into the ORXONOX framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/script_manager.cc

    r8178 r8193  
    3131   }
    3232
    33   const TiXmlElement* scripts = root->FirstChildElement("Scripts");
    34 
    35   if( scripts == NULL)
    36   {
    37     PRINTF(1)("ScriptManager is missing 'Scripts'\n");
    38   }
    39   else
    40   {
    41     createScriptList(scripts);
    42   }
    43 
    44 
     33   
     34   LoadParamXML(root, "Scripts", this, ScriptManager, createScriptList);
    4535}
    4636
     
    5040
    5141
    52 void ScriptManager::initScripts()
    53 {
    54   for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
    55   {
    56     (*it).script.loadFile((*it).name);
    57   }
    58 }
    59 
    6042void ScriptManager::init()
    6143{
    62   currentWorld.assign("");
    6344
    6445}
     
    6748void  ScriptManager::createScriptList(const TiXmlElement* scripts)
    6849{
     50 
     51  LOAD_PARAM_START_CYCLE(scripts, object);
     52  {
     53    new Script(object);
     54  }
     55  LOAD_PARAM_END_CYCLE(object);
     56     
     57     
     58  /*
    6959  const TiXmlElement* script = scripts->FirstChildElement();
    7060
     
    9484    script = script->NextSiblingElement("Script");
    9585
    96   }
     86  }*/
    9787
    9888
     
    10393{
    10494
    105   for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
    106   {
    107     if( (*it).name.compare(file) == 0)
    108     {
    109       return &((*it).script);
    110     }
    111   }
    112   return NULL;
     95//   for(std::list<LuaScript>::iterator it = scriptList.begin(); it != scriptList.end(); it++ )
     96//   {
     97//     if( (*it).name.compare(file) == 0)
     98//     {
     99//       return &((*it).script);
     100//     }
     101//   }
     102//   return NULL;
    113103
    114104}
    115105
    116 void  ScriptManager::setCurrentScriptFile(const std::string& file)
    117  {
    118    if( !fileIsInScriptList(file) )
    119      currentScript.name = file;
    120    else
    121      currentScript.name.assign("");
    122  }
    123 
    124 void  ScriptManager::addObjectToScript(const std::string object)
    125 {
    126   if(!objectIsInObjectList(object,currentScript))
    127     currentScript.objectList.push_back(object);
    128 }
    129 
    130 
    131 bool ScriptManager::fileIsInScriptList(const std::string& file)
    132 {
    133   for(std::list<LuaScript>::const_iterator it = scriptList.begin(); it != scriptList.end(); it++ )
    134   {
    135     if( (*it).name.compare(file) == 0)
    136     {
    137       return true;
    138     }
    139   }
    140   return false;
    141 }
    142 
    143 
    144 bool ScriptManager::objectIsInObjectList(const std::string& object, const LuaScript& script)
    145 {
    146   for(std::list<std::string>::const_iterator it = script.objectList.begin(); it != script.objectList.end(); it++ )
    147   {
    148     if( (*it).compare(object) == 0)
    149     {
    150       return true;
    151     }
    152   }
    153   return false;
    154 }
    155 
    156 
Note: See TracChangeset for help on using the changeset viewer.