1 | #include <string> |
---|
2 | #include <list> |
---|
3 | |
---|
4 | #include "script.h" |
---|
5 | #include "script_manager.h" |
---|
6 | #include "lunar.h" |
---|
7 | |
---|
8 | |
---|
9 | ScriptManager::ScriptManager() |
---|
10 | { |
---|
11 | this->init(); |
---|
12 | } |
---|
13 | |
---|
14 | ScriptManager::~ScriptManager() |
---|
15 | { |
---|
16 | |
---|
17 | |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | void ScriptManager::loadParams(const TiXmlElement* root) |
---|
22 | { |
---|
23 | //BaseObject::loadParams(root); |
---|
24 | |
---|
25 | const TiXmlElement* scripttrigger= root->FirstChildElement("ScriptTrigger"); |
---|
26 | |
---|
27 | while( scripttrigger != NULL) |
---|
28 | { |
---|
29 | //TODO: generate script trigger in factory and let them load their params. |
---|
30 | scripttrigger = scripttrigger->NextSiblingElement("ScriptTrigger"); |
---|
31 | } |
---|
32 | |
---|
33 | |
---|
34 | LoadParamXML(root, "Scripts", this, ScriptManager, createScriptList); |
---|
35 | } |
---|
36 | |
---|
37 | void ScriptManager::tick(float timestep) |
---|
38 | { |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | void ScriptManager::init() |
---|
43 | { |
---|
44 | |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | void ScriptManager::createScriptList(const TiXmlElement* scripts) |
---|
49 | { |
---|
50 | |
---|
51 | LOAD_PARAM_START_CYCLE(scripts, object); |
---|
52 | { |
---|
53 | new Script(object); |
---|
54 | } |
---|
55 | LOAD_PARAM_END_CYCLE(object); |
---|
56 | |
---|
57 | |
---|
58 | /* |
---|
59 | const TiXmlElement* script = scripts->FirstChildElement(); |
---|
60 | |
---|
61 | PRINTF(4)("Creating scriptlist\n"); |
---|
62 | |
---|
63 | while( script != NULL) |
---|
64 | { |
---|
65 | { // scope to make the LoadParam work |
---|
66 | LoadParam(script, "file", this, ScriptManager, setCurrentScriptFile) |
---|
67 | .describe("the fileName of the script, that should be loaded into this world") |
---|
68 | .defaultValues(""); |
---|
69 | } |
---|
70 | |
---|
71 | if(!currentScript.name.empty()) // if LoadParam didn't fail... fill the object list with the needed objects |
---|
72 | { |
---|
73 | |
---|
74 | LOAD_PARAM_START_CYCLE(script, object); |
---|
75 | { |
---|
76 | // LoadParam_CYCLE(object, "object", this, ScriptManager, addObjectToScript) |
---|
77 | // .describe("The name of an object that is needed by a script"); |
---|
78 | } |
---|
79 | LOAD_PARAM_END_CYCLE(object); |
---|
80 | |
---|
81 | scriptList.push_back(currentScript); |
---|
82 | } |
---|
83 | |
---|
84 | script = script->NextSiblingElement("Script"); |
---|
85 | |
---|
86 | }*/ |
---|
87 | |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | Script* ScriptManager::getScriptByFile(std::string& file) |
---|
93 | { |
---|
94 | |
---|
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; |
---|
103 | |
---|
104 | } |
---|
105 | |
---|