Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/script_manager.cc @ 9971

Last change on this file since 9971 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.1 KB
RevLine 
[8711]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Silvan Nellen
13   co-programmer: Benjamin Grauer
14*/
15
16
[8093]17#include <string>
18#include <list>
[8085]19
[8408]20#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
[8202]21
[8408]22
[8085]23#include "script_manager.h"
[8155]24#include "lunar.h"
[8093]25
[8202]26#include "script.h"
27#include "script_trigger.h"
28#include "luaincl.h"
[9869]29#include "loading/load_param_xml.h"
[8202]30
31
32
[8239]33ScriptManager::ScriptManager(const TiXmlElement* root)
[8093]34{
[8239]35  this->setName("ScriptManager");
36
37  if (root != NULL)
38    this->loadParams(root);
[8093]39}
40
[8239]41
42
[8093]43ScriptManager::~ScriptManager()
44{
[8239]45  this->flush();
[8093]46}
47
[8138]48
[8155]49void ScriptManager::loadParams(const TiXmlElement* root)
50{
[8408]51  BaseObject::loadParams(root);
[8206]52  {
[8239]53    LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
[8211]54
[8239]55    LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);
[8206]56  } // make shure that the loading process is finished
[8210]57
[8206]58  // fill the scripts and triggers (doing that on runtime is very slow!)
[8239]59}
[8210]60
61
[8155]62
[8239]63void  ScriptManager::flush()
[8208]64{
[8210]65  //Delete all scripts as they aren't deleted automatically
[9869]66  while(!Script::objectList().empty())
67    delete Script::objectList().front();
[9003]68  //Delete all triggers
[9869]69  while(!ScriptTrigger::objectList().empty())
70    delete ScriptTrigger::objectList().front();
71
[8208]72}
73
[8202]74void  ScriptManager::createScripts(const TiXmlElement* scripts)
[8093]75{
[8210]76
[8193]77  LOAD_PARAM_START_CYCLE(scripts, object);
78  {
79    new Script(object);
80  }
81  LOAD_PARAM_END_CYCLE(object);
[8093]82
[8202]83}
[8131]84
[8202]85void ScriptManager::createTriggers(const TiXmlElement* triggers)
86{
87  LOAD_PARAM_START_CYCLE(triggers, object);
[8155]88  {
[8202]89    new ScriptTrigger(object);
90  }
91  LOAD_PARAM_END_CYCLE(object);
[8155]92
[8093]93}
94
[8171]95
[8212]96Script* ScriptManager::getScriptByFile(const std::string& file)
[8171]97{
[9869]98  for (ObjectList<Script>::const_iterator it = Script::objectList().begin();
99       it != Script::objectList().end();
100       ++it)
101    if( ((*it))->getFileName().compare(file) == 0)
102      return (*it);
[8210]103
[8206]104  return NULL;
[8171]105
106}
Note: See TracBrowser for help on using the repository browser.