Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/loader/LevelLoader.cc @ 470

Last change on this file since 470 was 470, checked in by nicolape, 16 years ago

Did some changes to levelloader

File size: 2.7 KB
Line 
1#include <string.h>
2#include <iostream>
3
4#include "LevelLoader.h"
5#include "xml/xmlParser.h"
6
7using namespace std;
8
9namespace loader
10{
11
12LevelLoader::LevelLoader(string file, string dir)
13{
14        // Load XML level file
15        dir.append("/");
16        dir.append(file);       
17        rootNode = XMLNode::openFileHelper(dir.c_str(),"orxonoxworld");
18        // TODO: Error handling
19
20        // Assing general level infos to class variables
21       
22        this->name_ = rootNode.getAttribute("name");
23        this->image_ = rootNode.getAttribute("image");
24        this->description_ = rootNode.getChildNode("description").getText();
25 
26        loadingScreenNode = rootNode.getChildNode("loading");
27 
28        if (!loadingScreenNode.isEmpty())
29        {
30                this->showLoadingScreen();
31        }
32 
33  /*
34  // Assign sub-nodes
35  if (rootNode.nChildNode("LightManager")==1)
36  {
37        // Init Luightmanager...
38  }*/
39 
40  /*
41 
42        worldNode = rootNode.getChildNode("WorldEntities");
43        scriptNode = rootNode.getChildNode("ScriptManager");
44        cameraNode = rootNode.getChildNode("CameraMan");
45        lightNode = rootNode.getChildNode("LightManager");
46*/
47
48}
49
50LevelLoader::~LevelLoader()
51{
52
53
54}
55
56
57string LevelLoader::name()
58{
59        return this->name_;
60}
61
62string LevelLoader::description()
63{
64        return this->description_;
65}
66
67string LevelLoader::image()
68{
69        return this->image_;
70}
71
72void LevelLoader::showLoadingScreen()
73{
74        cout << "\n\n\nThis is Orxonox\nthe hottest 3D action shooter ever to exist\n\n\n";
75        cout << "Level: " << name() << "\nDescription:" << description() << "\nImage:"<<image()<<"\n\n\n";
76}
77
78/*
79
80
81void LevelLoader::loadWorld(WorldManager* wm)
82{
83        if (!worldNode.getChildNode("lights").isEmpty())
84        {
85               
86               
87        }
88}
89
90
91void LevelLoader::loadLights(LightManager* lm)
92{
93        if (!lightNode.getChildNode("lights").isEmpty())
94        {
95                int nLights = lightNode.getChildNode("lights").nChildNode("light");
96                for (int i=0; i<nLights;i++)
97                {
98                        XMLNode t = lightNode.getChildNode("lights").getChildNode("light",i);
99                        const char* diffuse = t.getAttribute("diffuse-color");
100                        const char* coor = t.getAttribute("abs-coor");
101                        lm->addLight(diffuse,coor);     
102                }
103        }
104        lm->setAmbient(lightNode.getChildNode("ambient").getAttribute("color"));       
105}
106
107void LevelLoader::loadCameras(CameraManager* cm)
108{
109        if (!cameraNode.getChildNode("cameras").isEmpty())
110        {
111                int nCameras = cameraNode.getChildNode("cameras").nChildNode("camera");
112                for (int i=0; i<nCameras;i++)
113                {
114                        XMLNode t = cameraNode.getChildNode("cameras").getChildNode("camera",i);
115                       
116                       
117                        cm->addCamera();
118                }
119        }
120}
121
122
123void LevelLoader::loadScripts(ScriptManager* sm)
124{
125        if (!scriptNode.getChildNode("scripts").isEmpty())
126        {
127                int nScripts = scriptNode.getChildNode("scripts").nChildNode("script");
128                for (int i=0; i<nScripts;i++)
129                {
130                        XMLNode t = scriptNode.getChildNode("scripts").getChildNode("script",i);
131                        sm->addScript(t.getAttribute("file"));
132                }
133       
134        }
135}
136*/
137
138
139}
140
Note: See TracBrowser for help on using the repository browser.