Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

more integration into orxonox framework

Location:
branches/script_engine/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/Makefile.am

    r7810 r8239  
    2828                $(libORXlibs_a_LIBRARIES_) \
    2929                $(CURL_LIBS) \
    30                 @QT_LIBS@
     30                @QT_LIBS@ \
     31                -L../extern_libs @LUA_LIBS@
    3132
    3233orxonox_SOURCES = \
  • 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}
  • branches/script_engine/src/story_entities/game_world.cc

    r8037 r8239  
    181181  this->dataXML = (TiXmlElement*)root->Clone();
    182182
     183  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
     184
    183185  delete XMLDoc;
    184186  this->releaseLoadScreen();
     
    213215  this->bPaused = false;
    214216  this->bRunning = true;
     217
     218  State::setScripManager(&this->scriptManager);
    215219
    216220  this->run();
  • branches/script_engine/src/story_entities/game_world.h

    r7919 r8239  
    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
     
    102104    GameRules*          gameRules;                    //!< Pointer to the data structure containig the game rules
    103105
    104 
    105106  private:
    106107    /* external modules interfaces */
     108    ScriptManager       scriptManager;
    107109    OrxShell::Shell*    shell;
    108110};
  • branches/script_engine/src/util/state.cc

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

    r7039 r8239  
    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.
Note: See TracChangeset for help on using the changeset viewer.