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: Patrick Boenzli |
---|
13 | |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD |
---|
17 | |
---|
18 | |
---|
19 | #include "simple_game_menu.h" |
---|
20 | |
---|
21 | #include "state.h" |
---|
22 | #include "class_list.h" |
---|
23 | |
---|
24 | #include "load_param.h" |
---|
25 | #include "fast_factory.h" |
---|
26 | #include "factory.h" |
---|
27 | |
---|
28 | #include "world_entity.h" |
---|
29 | #include "terrain.h" |
---|
30 | |
---|
31 | #include "cd_engine.h" |
---|
32 | |
---|
33 | |
---|
34 | using namespace std; |
---|
35 | |
---|
36 | |
---|
37 | //! This creates a Factory to fabricate a SimpleGameMenu |
---|
38 | CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU); |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) |
---|
43 | : GameWorld(root) |
---|
44 | { |
---|
45 | this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); |
---|
46 | this->setName("SimpleGameMenu uninitialized"); |
---|
47 | |
---|
48 | this->dataTank = new SimpleGameMenuData(); |
---|
49 | |
---|
50 | this->loadParams(root); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | /** |
---|
55 | * remove the SimpleGameMenu from memory |
---|
56 | * |
---|
57 | * delete everything explicitly, that isn't contained in the parenting tree! |
---|
58 | * things contained in the tree are deleted automaticaly |
---|
59 | */ |
---|
60 | SimpleGameMenu::~SimpleGameMenu () |
---|
61 | { |
---|
62 | PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n"); |
---|
63 | |
---|
64 | if( this->dataTank) |
---|
65 | delete this->dataTank; |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | /** |
---|
70 | * loads the parameters of a SimpleGameMenu from an XML-element |
---|
71 | * @param root the XML-element to load from |
---|
72 | */ |
---|
73 | void SimpleGameMenu::loadParams(const TiXmlElement* root) |
---|
74 | { |
---|
75 | /* skip the GameWorld, since it does not define any useful loadParams for this class */ |
---|
76 | static_cast<StoryEntity*>(this)->loadParams(root); |
---|
77 | |
---|
78 | PRINTF(4)("Loaded SimpleGameMenu specific stuff\n"); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | /** |
---|
83 | * no collision detection in the menu |
---|
84 | */ |
---|
85 | void SimpleGameMenu::collide() |
---|
86 | {} |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | /********************************************************************************************** |
---|
97 | SimpleGameMenuData |
---|
98 | **********************************************************************************************/ |
---|
99 | |
---|
100 | |
---|
101 | /** |
---|
102 | * SimpleGameMenuData constructor |
---|
103 | */ |
---|
104 | SimpleGameMenuData::SimpleGameMenuData() |
---|
105 | {} |
---|
106 | |
---|
107 | /** |
---|
108 | * SimpleGameMenuData decontructor |
---|
109 | */ |
---|
110 | SimpleGameMenuData::~SimpleGameMenuData() |
---|
111 | {} |
---|
112 | |
---|
113 | |
---|
114 | /** |
---|
115 | * initialize the GameWorldDataData |
---|
116 | */ |
---|
117 | ErrorMessage SimpleGameMenuData::init() |
---|
118 | { |
---|
119 | /* call underlying function */ |
---|
120 | GameWorldData::init(); |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | /** |
---|
125 | * loads the GUI data |
---|
126 | * @param root reference to the xml root element |
---|
127 | */ |
---|
128 | ErrorMessage SimpleGameMenuData::loadGUI(TiXmlElement* root) |
---|
129 | { |
---|
130 | /* call underlying function */ |
---|
131 | GameWorldData::loadGUI(root); |
---|
132 | } |
---|
133 | |
---|
134 | |
---|
135 | /** |
---|
136 | * unloads the GUI data |
---|
137 | */ |
---|
138 | ErrorMessage SimpleGameMenuData::unloadGUI() |
---|
139 | { |
---|
140 | /* call underlying function */ |
---|
141 | GameWorldData::unloadGUI(); |
---|
142 | } |
---|
143 | |
---|
144 | |
---|
145 | /** |
---|
146 | * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) |
---|
147 | * @param root reference to the xml root parameter |
---|
148 | */ |
---|
149 | ErrorMessage SimpleGameMenuData::loadWorldEntities(TiXmlElement* root) |
---|
150 | { |
---|
151 | TiXmlElement* element = root->FirstChildElement("WorldEntities"); |
---|
152 | |
---|
153 | if( element != NULL) |
---|
154 | { |
---|
155 | element = element->FirstChildElement(); |
---|
156 | PRINTF(4)("Loading WorldEntities\n"); |
---|
157 | while( element != NULL) |
---|
158 | { |
---|
159 | BaseObject* created = Factory::fabricate(element); |
---|
160 | if( created != NULL ) |
---|
161 | printf("Created a %s: %s\n", created->getClassName(), created->getName()); |
---|
162 | |
---|
163 | if( element->Value() != NULL && !strcmp( element->Value(), "SkyBox")) |
---|
164 | this->sky = dynamic_cast<WorldEntity*>(created); |
---|
165 | if( element->Value() != NULL && !strcmp( element->Value(), "Terrain")) |
---|
166 | { |
---|
167 | this->terrain = dynamic_cast<Terrain*>(created); |
---|
168 | CDEngine::getInstance()->setTerrain(terrain); |
---|
169 | } |
---|
170 | element = element->NextSiblingElement(); |
---|
171 | } |
---|
172 | PRINTF(4)("Done loading WorldEntities\n"); |
---|
173 | } |
---|
174 | |
---|
175 | /* init the pnode tree */ |
---|
176 | PNode::getNullParent()->init(); |
---|
177 | } |
---|
178 | |
---|
179 | |
---|
180 | /** |
---|
181 | * unloads the world entities from the xml file |
---|
182 | */ |
---|
183 | ErrorMessage SimpleGameMenuData::unloadWorldEntities() |
---|
184 | { |
---|
185 | /* call underlying function */ |
---|
186 | GameWorldData::unloadWorldEntities(); |
---|
187 | } |
---|
188 | |
---|
189 | |
---|
190 | /** |
---|
191 | * loads the scene data |
---|
192 | * @param root reference to the xml root element |
---|
193 | */ |
---|
194 | ErrorMessage SimpleGameMenuData::loadScene(TiXmlElement* root) |
---|
195 | { |
---|
196 | /* call underlying function */ |
---|
197 | GameWorldData::loadScene(root); |
---|
198 | } |
---|
199 | |
---|
200 | |
---|
201 | /** |
---|
202 | * unloads the scene data |
---|
203 | */ |
---|
204 | ErrorMessage SimpleGameMenuData::unloadScene() |
---|
205 | { |
---|
206 | /* call underlying function */ |
---|
207 | GameWorldData::unloadScene(); |
---|
208 | } |
---|
209 | |
---|
210 | |
---|
211 | |
---|