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 "event_handler.h" |
---|
22 | |
---|
23 | #include "state.h" |
---|
24 | #include "class_list.h" |
---|
25 | |
---|
26 | #include "util/loading/load_param.h" |
---|
27 | #include "fast_factory.h" |
---|
28 | #include "util/loading/factory.h" |
---|
29 | |
---|
30 | #include "world_entity.h" |
---|
31 | #include "elements/image_entity.h" |
---|
32 | #include "terrain.h" |
---|
33 | #include "camera.h" |
---|
34 | |
---|
35 | #include "graphics_engine.h" |
---|
36 | #include "object_manager.h" |
---|
37 | #include "sound_engine.h" |
---|
38 | #include "sound_source.h" |
---|
39 | |
---|
40 | #include "cd_engine.h" |
---|
41 | |
---|
42 | #include "glgui.h" |
---|
43 | |
---|
44 | //! This creates a Factory to fabricate a SimpleGameMenu |
---|
45 | CREATE_FACTORY(SimpleGameMenu, CL_SIMPLE_GAME_MENU); |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root) |
---|
50 | : GameWorld() |
---|
51 | { |
---|
52 | this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu"); |
---|
53 | this->setName("SimpleGameMenu uninitialized"); |
---|
54 | |
---|
55 | this->dataTank = new SimpleGameMenuData(); |
---|
56 | |
---|
57 | this->cameraVector = Vector(50.0, 0.0, 0.0); |
---|
58 | this->menuLayers.push_back(MenuLayer()); |
---|
59 | this->menuLayers.push_back(MenuLayer()); |
---|
60 | |
---|
61 | this->layerIndex = 0; |
---|
62 | this->menuSelectedIndex = 0; |
---|
63 | this->selectorSource = NULL; |
---|
64 | |
---|
65 | |
---|
66 | /// GUI |
---|
67 | ///(this is as modular as it is possible). |
---|
68 | /* |
---|
69 | OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME"); |
---|
70 | pb->show(); |
---|
71 | pb->setAbsCoor2D(50, 50); |
---|
72 | |
---|
73 | OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("DO NOT PUSH ME"); |
---|
74 | dnpb->show(); |
---|
75 | dnpb->setAbsCoor2D(350, 50); |
---|
76 | |
---|
77 | OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("REALLY DO NOT PUSH ME!!"); |
---|
78 | rdnpb->show(); |
---|
79 | rdnpb->setAbsCoor2D(200, 180); |
---|
80 | rdnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::quitMenu)); |
---|
81 | |
---|
82 | OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine(); |
---|
83 | input->setText("input some text here"); |
---|
84 | input->show(); |
---|
85 | input->setAbsCoor2D(200, 230); |
---|
86 | |
---|
87 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
88 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
89 | */ |
---|
90 | ///// |
---|
91 | |
---|
92 | if (root != NULL) |
---|
93 | this->loadParams(root); |
---|
94 | |
---|
95 | State::setMenuID(this->getNextStoryID()); |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief remove the SimpleGameMenu from memory |
---|
101 | * |
---|
102 | * delete everything explicitly, that isn't contained in the parenting tree! |
---|
103 | * things contained in the tree are deleted automaticaly |
---|
104 | */ |
---|
105 | SimpleGameMenu::~SimpleGameMenu () |
---|
106 | { |
---|
107 | PRINTF(3)("SimpleGameMenu::~SimpleGameMenu() - deleting current world\n"); |
---|
108 | |
---|
109 | if( this->dataTank) |
---|
110 | delete this->dataTank; |
---|
111 | //delete OrxGui::GLGuiHandler::getInstance( ); |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief loads the parameters of a SimpleGameMenu from an XML-element |
---|
117 | * @param root the XML-element to load from |
---|
118 | */ |
---|
119 | void SimpleGameMenu::loadParams(const TiXmlElement* root) |
---|
120 | { |
---|
121 | /* skip the GameWorld, since it does not define any useful loadParams for this class */ |
---|
122 | //static_cast<GameWorld*>(this)->loadParams(root); |
---|
123 | GameWorld::loadParams(root); |
---|
124 | |
---|
125 | PRINTF(4)("Loaded SimpleGameMenu specific stuff\n"); |
---|
126 | } |
---|
127 | |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief this is executed just before load |
---|
131 | * |
---|
132 | * since the load function sometimes needs data, that has been initialized |
---|
133 | * before the load and after the proceeding storyentity has finished |
---|
134 | */ |
---|
135 | ErrorMessage SimpleGameMenu::init() |
---|
136 | { |
---|
137 | /* call underlying init funciton */ |
---|
138 | GameWorld::init(); |
---|
139 | |
---|
140 | this->subscribeEvent(ES_MENU, SDLK_UP); |
---|
141 | this->subscribeEvent(ES_MENU, SDLK_DOWN); |
---|
142 | this->subscribeEvent(ES_MENU, SDLK_RETURN); |
---|
143 | this->subscribeEvent(ES_MENU, SDLK_SPACE); |
---|
144 | this->subscribeEvent(ES_MENU, SDLK_ESCAPE); |
---|
145 | |
---|
146 | this->dataTank->localCamera->setRelCoor(this->cameraVector); |
---|
147 | |
---|
148 | GraphicsEngine::getInstance()->displayFPS(false); |
---|
149 | |
---|
150 | this->layerIndex = 0; |
---|
151 | this->menuSelectedIndex = 0; |
---|
152 | } |
---|
153 | |
---|
154 | |
---|
155 | /** |
---|
156 | * @brief load the data |
---|
157 | */ |
---|
158 | ErrorMessage SimpleGameMenu::loadData() |
---|
159 | { |
---|
160 | GameWorld::loadData(); |
---|
161 | |
---|
162 | if (this->dataXML != NULL) |
---|
163 | { |
---|
164 | LoadParam(dataXML, "selector-sound", this, SimpleGameMenu, setSelectorSound); |
---|
165 | |
---|
166 | TiXmlElement* element = this->dataXML->FirstChildElement("Elements"); |
---|
167 | |
---|
168 | |
---|
169 | if( element == NULL) |
---|
170 | { |
---|
171 | PRINTF(1)("SimpleGameMenu is missing 'Elements'\n"); |
---|
172 | } |
---|
173 | else |
---|
174 | { |
---|
175 | element = element->FirstChildElement(); |
---|
176 | // load Players/Objects/Whatever |
---|
177 | PRINTF(4)("Loading Elements\n"); |
---|
178 | while( element != NULL) |
---|
179 | { |
---|
180 | BaseObject* created = Factory::fabricate(element); |
---|
181 | if( created != NULL ) |
---|
182 | { |
---|
183 | PRINTF(4)("Created a %s::%s\n", created->getClassName(), created->getName()); |
---|
184 | if (!created->isA(CL_ELEMENT_2D)) |
---|
185 | PRINTF(2)("Error the Created Entity is not an Element2D but an %s::%s\n", created->getClassName(), created->getName()); |
---|
186 | } |
---|
187 | element = element->NextSiblingElement(); |
---|
188 | } |
---|
189 | PRINTF(4)("Done loading Elements\n"); |
---|
190 | } |
---|
191 | } |
---|
192 | |
---|
193 | /* get the menu list */ |
---|
194 | const std::list<BaseObject*>* imageEntityList = ClassList::getList(CL_IMAGE_ENTITY); |
---|
195 | std::list<BaseObject*>::const_iterator entity; |
---|
196 | for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++) |
---|
197 | { |
---|
198 | |
---|
199 | if( !strcmp("Selector_Menu", (*entity)->getName())) |
---|
200 | { |
---|
201 | this->menuSelector = dynamic_cast<ImageEntity*>(*entity); |
---|
202 | this->menuSelector->setBindNode((const PNode*)NULL); |
---|
203 | } |
---|
204 | } |
---|
205 | |
---|
206 | imageEntityList = ClassList::getList(CL_TEXT_ELEMENT); |
---|
207 | for (entity = imageEntityList->begin(); entity != imageEntityList->end(); entity++) |
---|
208 | { |
---|
209 | if( !strcmp( "StartGame_Menu", (*entity)->getName())) |
---|
210 | { |
---|
211 | this->menuStartGame = dynamic_cast<TextElement*>(*entity); |
---|
212 | this->menuStartGame->setBindNode((const PNode*)NULL); |
---|
213 | this->menuStartGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
214 | State::getResY() / 2.0f - 60.0f); |
---|
215 | this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity)); |
---|
216 | |
---|
217 | } |
---|
218 | else if( !strcmp( "Multiplayer_Menu", (*entity)->getName())) |
---|
219 | { |
---|
220 | this->menuStartMultiplayerGame = dynamic_cast<TextElement*>(*entity); |
---|
221 | this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL); |
---|
222 | this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
223 | State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f)); |
---|
224 | this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity)); |
---|
225 | } |
---|
226 | else if( !strcmp( "Quit_Menu", (*entity)->getName())) |
---|
227 | { |
---|
228 | this->menuQuitGame = dynamic_cast<TextElement*>(*entity); |
---|
229 | this->menuQuitGame->setBindNode((const PNode*)NULL); |
---|
230 | this->menuQuitGame->setRelCoor2D(State::getResX() / 2.0f, |
---|
231 | State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 )* 60.0f)); |
---|
232 | this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity)); |
---|
233 | } |
---|
234 | } |
---|
235 | this->menuSelected->getNullElement()->update2D(0.1f); |
---|
236 | this->menuSelectedIndex = 0; |
---|
237 | this->menuSelected = this->menuLayers[0].menuList[this->menuSelectedIndex]; |
---|
238 | this->sliderTo(this->menuSelected, 0.0f); |
---|
239 | |
---|
240 | |
---|
241 | // loading the storyentities submenu (singleplayer) |
---|
242 | const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY); |
---|
243 | std::list<BaseObject*>::const_iterator it; |
---|
244 | for( it = storyEntities->begin(); it != storyEntities->end(); it++) |
---|
245 | { |
---|
246 | StoryEntity* se = dynamic_cast<StoryEntity*>(*it); |
---|
247 | if( se->isContainedInMenu()) |
---|
248 | { |
---|
249 | this->menuLayers[1].storyList.push_back(se); |
---|
250 | |
---|
251 | // generating menu item |
---|
252 | TextElement* te = new TextElement(); |
---|
253 | te->setVisibility(false); |
---|
254 | te->setText(se->getName()); |
---|
255 | te->setRelCoor2D(State::getResX() / 2.0f - 200.0f, State::getResY() / 2.0f + ((this->menuLayers[1].menuList.size() - 2.0f) * 60.0f)); |
---|
256 | this->menuLayers[1].menuList.push_back(te); |
---|
257 | |
---|
258 | // generating screenshoot item |
---|
259 | ImageEntity* ie = new ImageEntity(); |
---|
260 | ie->setVisibility(false); |
---|
261 | ie->setBindNode((const PNode*)NULL); |
---|
262 | ie->setTexture(se->getMenuScreenshoot()); |
---|
263 | ie->setRelCoor2D(State::getResX() / 2.0f + 250.0f, State::getResY() / 2.0f); |
---|
264 | ie->setSize2D(140.0f, 105.0f); |
---|
265 | this->menuLayers[1].screenshootList.push_back(ie); |
---|
266 | } |
---|
267 | } |
---|
268 | } |
---|
269 | |
---|
270 | /** |
---|
271 | * @brief set the Sound to play when switching menu entry. |
---|
272 | * @param selectorSound the sound to load. |
---|
273 | */ |
---|
274 | void SimpleGameMenu::setSelectorSound(const std::string& selectorSound) |
---|
275 | { |
---|
276 | this->selectorSource = OrxSound::SoundEngine::getInstance()->createSource(selectorSound, NULL); |
---|
277 | } |
---|
278 | |
---|
279 | ErrorMessage SimpleGameMenu::unloadData() |
---|
280 | { |
---|
281 | this->unsubscribeEvents(ES_MENU); |
---|
282 | |
---|
283 | std::vector<MenuLayer>::iterator mit; |
---|
284 | for(mit = this->menuLayers.begin(); mit != this->menuLayers.end(); mit++) |
---|
285 | { |
---|
286 | while(!(*mit).menuList.empty()) |
---|
287 | { |
---|
288 | delete (*mit).menuList.back(); |
---|
289 | (*mit).menuList.pop_back(); |
---|
290 | } |
---|
291 | |
---|
292 | (*mit).menuList.clear(); |
---|
293 | (*mit).storyList.clear(); |
---|
294 | (*mit).screenshootList.clear(); |
---|
295 | } |
---|
296 | |
---|
297 | // delete the SoundSource. |
---|
298 | if (this->selectorSource != NULL) |
---|
299 | delete this->selectorSource; |
---|
300 | this->selectorSource = NULL; |
---|
301 | |
---|
302 | GameWorld::unloadData(); |
---|
303 | } |
---|
304 | |
---|
305 | |
---|
306 | /** |
---|
307 | * @brief start the menu |
---|
308 | */ |
---|
309 | bool SimpleGameMenu::start() |
---|
310 | { |
---|
311 | EventHandler::getInstance()->pushState(ES_MENU); |
---|
312 | |
---|
313 | /* now call the underlying*/ |
---|
314 | GameWorld::start(); |
---|
315 | } |
---|
316 | |
---|
317 | |
---|
318 | |
---|
319 | /** |
---|
320 | * stop the menu |
---|
321 | */ |
---|
322 | bool SimpleGameMenu::stop() |
---|
323 | { |
---|
324 | EventHandler::getInstance()->popState(); |
---|
325 | |
---|
326 | /* now call the underlying*/ |
---|
327 | GameWorld::stop(); |
---|
328 | } |
---|
329 | |
---|
330 | |
---|
331 | /** |
---|
332 | * override the standard tick for more functionality |
---|
333 | */ |
---|
334 | void SimpleGameMenu::tick() |
---|
335 | { |
---|
336 | GameWorld::tick(); |
---|
337 | |
---|
338 | // Make the GLGui tick. |
---|
339 | OrxGui::GLGuiHandler::getInstance()->tick(this->dtS); |
---|
340 | |
---|
341 | this->animateScene(this->dtS); |
---|
342 | } |
---|
343 | |
---|
344 | |
---|
345 | /** |
---|
346 | * @brief no collision detection in the menu |
---|
347 | */ |
---|
348 | void SimpleGameMenu::collide() |
---|
349 | { |
---|
350 | // this->dataTank->localCamera-> |
---|
351 | } |
---|
352 | |
---|
353 | |
---|
354 | /** |
---|
355 | * @brief animate the scene |
---|
356 | */ |
---|
357 | void SimpleGameMenu::animateScene(float dt) |
---|
358 | { |
---|
359 | Quaternion q(/*0.00005*/ dt * .1, Vector(0.0, 1.0, 0.0)); |
---|
360 | this->cameraVector = q.apply(this->cameraVector); |
---|
361 | this->dataTank->localCamera->setRelCoor(this->cameraVector); |
---|
362 | this->dataTank->localCamera->getTarget()->setRelCoorSoft(0,0,0); |
---|
363 | } |
---|
364 | |
---|
365 | void SimpleGameMenu::quitMenu() |
---|
366 | { |
---|
367 | this->setNextStoryID(WORLD_ID_GAMEEND); |
---|
368 | this->stop(); |
---|
369 | } |
---|
370 | |
---|
371 | |
---|
372 | /** |
---|
373 | * @brief event dispatcher funciton |
---|
374 | * @param event the incoming event |
---|
375 | */ |
---|
376 | void SimpleGameMenu::process(const Event &event) |
---|
377 | { |
---|
378 | /* ----------------- LAYER 1 ---------------*/ |
---|
379 | if( this->layerIndex == 0) |
---|
380 | { |
---|
381 | if( event.type == SDLK_RETURN && event.bPressed == true) |
---|
382 | { |
---|
383 | if( this->menuSelected == this->menuQuitGame) |
---|
384 | { |
---|
385 | this->setNextStoryID(WORLD_ID_GAMEEND); |
---|
386 | this->stop(); |
---|
387 | } |
---|
388 | if( this->menuSelected == this->menuStartGame) |
---|
389 | { |
---|
390 | // switch to first submenu |
---|
391 | if( this->menuLayers[1].menuList.size() == 0) |
---|
392 | { |
---|
393 | PRINTF(1)("Haven't got any StoryEntities to play!\n"); |
---|
394 | return; |
---|
395 | } |
---|
396 | |
---|
397 | this->switchMenuLayer(this->layerIndex, 1); |
---|
398 | } |
---|
399 | } |
---|
400 | if( event.type == SDLK_ESCAPE && event.bPressed == true) |
---|
401 | { |
---|
402 | this->setNextStoryID(WORLD_ID_GAMEEND); |
---|
403 | this->stop(); |
---|
404 | } |
---|
405 | } /* ----------------- LAYER 2 ---------------*/ |
---|
406 | else if( this->layerIndex == 1) |
---|
407 | { |
---|
408 | if( event.type == SDLK_RETURN && event.bPressed == true) |
---|
409 | { |
---|
410 | this->setNextStoryID( this->menuLayers[1].storyList[this->menuSelectedIndex]->getStoryID()); |
---|
411 | this->stop(); |
---|
412 | } |
---|
413 | if( event.type == SDLK_ESCAPE && event.bPressed == true) |
---|
414 | { |
---|
415 | this->switchMenuLayer(this->layerIndex, 0); |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | |
---|
420 | |
---|
421 | // The menu selction cursor |
---|
422 | if( event.type == SDLK_DOWN && event.bPressed == true) |
---|
423 | { |
---|
424 | if(this->menuSelectedIndex < (this->menuLayers[this->layerIndex].menuList.size() - 1)) |
---|
425 | { |
---|
426 | this->menuSelected = this->menuLayers[this->layerIndex].menuList[++this->menuSelectedIndex]; |
---|
427 | this->sliderTo(this->menuSelected, 5.0f); |
---|
428 | if (this->selectorSource != NULL) |
---|
429 | this->selectorSource->play(); |
---|
430 | |
---|
431 | if( this->layerIndex == 1) |
---|
432 | { |
---|
433 | this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true); |
---|
434 | this->menuLayers[1].screenshootList[this->menuSelectedIndex-1]->setVisibility(false); |
---|
435 | } |
---|
436 | } |
---|
437 | } |
---|
438 | else if( event.type == SDLK_UP && event.bPressed == true) |
---|
439 | { |
---|
440 | if(this->menuSelectedIndex > 0) |
---|
441 | { |
---|
442 | this->menuSelected = this->menuLayers[this->layerIndex].menuList[--this->menuSelectedIndex]; |
---|
443 | this->sliderTo(this->menuSelected, 5.0f); |
---|
444 | if (this->selectorSource != NULL) |
---|
445 | this->selectorSource->play(); |
---|
446 | |
---|
447 | if( this->layerIndex == 1) |
---|
448 | { |
---|
449 | this->menuLayers[1].screenshootList[this->menuSelectedIndex]->setVisibility(true); |
---|
450 | this->menuLayers[1].screenshootList[this->menuSelectedIndex+1]->setVisibility(false); |
---|
451 | } |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | |
---|
457 | /** |
---|
458 | * @brief switches to from one meny layer to an other |
---|
459 | * @param layer1 from layer |
---|
460 | * @param layer2 to layer |
---|
461 | */ |
---|
462 | void SimpleGameMenu::switchMenuLayer(int layer1, int layer2) |
---|
463 | { |
---|
464 | // wrong sizes |
---|
465 | if(layer1 >= this->menuLayers.size() || layer2 >= this->menuLayers.size()) |
---|
466 | return; |
---|
467 | |
---|
468 | |
---|
469 | PRINTF(0)("Removing layer %i\n", layer1); |
---|
470 | std::vector<TextElement*>::iterator te; |
---|
471 | // fade old menu |
---|
472 | for( te = this->menuLayers[layer1].menuList.begin(); te != this->menuLayers[layer1].menuList.end(); te++) |
---|
473 | { |
---|
474 | (*te)->setVisibility(false); |
---|
475 | } |
---|
476 | |
---|
477 | std::vector<ImageEntity*>::iterator it; |
---|
478 | |
---|
479 | //also fade the screenshots if in level choosement mode |
---|
480 | for( it = this->menuLayers[layer1].screenshootList.begin(); it != this->menuLayers[layer1].screenshootList.end(); it++) |
---|
481 | { |
---|
482 | (*it)->setVisibility(false); |
---|
483 | } |
---|
484 | |
---|
485 | |
---|
486 | PRINTF(0)("Showing layer %i\n", layer1); |
---|
487 | // beam here the new menu |
---|
488 | for( te = this->menuLayers[layer2].menuList.begin(); te != this->menuLayers[layer2].menuList.end(); te++ ) |
---|
489 | { |
---|
490 | (*te)->setVisibility(true); |
---|
491 | } |
---|
492 | |
---|
493 | |
---|
494 | this->layerIndex = layer2; |
---|
495 | this->menuSelected = this->menuLayers[layer2].menuList[0]; |
---|
496 | this->menuSelector->setAbsCoor2D(this->menuSelected->getAbsCoor2D() + Vector2D(0, this->menuSelected->getSizeY2D() *.5)); |
---|
497 | this->menuSelector->setSize2D(this->menuSelected->getSizeX2D()*.7, this->menuSelected->getSizeY2D()); |
---|
498 | this->menuSelectedIndex = 0; |
---|
499 | |
---|
500 | if( layer2 == 1) |
---|
501 | this->menuLayers[layer2].screenshootList[0]->setVisibility(true); |
---|
502 | } |
---|
503 | |
---|
504 | void SimpleGameMenu::sliderTo(const Element2D* element, float bias) |
---|
505 | { |
---|
506 | if (bias > 0.0) |
---|
507 | { |
---|
508 | this->menuSelector->setAbsCoorSoft2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5), bias); |
---|
509 | this->menuSelector->setSizeSoft2D(element->getSizeX2D()*.7, element->getSizeY2D(), bias); |
---|
510 | } |
---|
511 | else |
---|
512 | { |
---|
513 | this->menuSelector->setAbsCoor2D(element->getAbsCoor2D() + Vector2D(0, element->getSizeY2D() *.5)); |
---|
514 | this->menuSelector->setSize2D(element->getSizeX2D()*.7, element->getSizeY2D()); |
---|
515 | } |
---|
516 | } |
---|
517 | |
---|
518 | |
---|
519 | |
---|
520 | /********************************************************************************************** |
---|
521 | SimpleGameMenuData |
---|
522 | **********************************************************************************************/ |
---|
523 | |
---|
524 | |
---|
525 | /** |
---|
526 | * SimpleGameMenuData constructor |
---|
527 | */ |
---|
528 | SimpleGameMenuData::SimpleGameMenuData() |
---|
529 | {} |
---|
530 | |
---|
531 | /** |
---|
532 | * SimpleGameMenuData decontructor |
---|
533 | */ |
---|
534 | SimpleGameMenuData::~SimpleGameMenuData() |
---|
535 | {} |
---|
536 | |
---|
537 | |
---|
538 | /** |
---|
539 | * initialize the GameWorldDataData |
---|
540 | */ |
---|
541 | ErrorMessage SimpleGameMenuData::init() |
---|
542 | { |
---|
543 | /* call underlying function */ |
---|
544 | GameWorldData::init(); |
---|
545 | } |
---|
546 | |
---|
547 | |
---|
548 | /** |
---|
549 | * loads the GUI data |
---|
550 | * @param root reference to the xml root element |
---|
551 | */ |
---|
552 | ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root) |
---|
553 | { |
---|
554 | /* call underlying function */ |
---|
555 | GameWorldData::loadGUI(root); |
---|
556 | } |
---|
557 | |
---|
558 | |
---|
559 | /** |
---|
560 | * unloads the GUI data |
---|
561 | */ |
---|
562 | ErrorMessage SimpleGameMenuData::unloadGUI() |
---|
563 | { |
---|
564 | /* call underlying function */ |
---|
565 | GameWorldData::unloadGUI(); |
---|
566 | } |
---|
567 | |
---|
568 | |
---|
569 | /** |
---|
570 | * overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff) |
---|
571 | * @param root reference to the xml root parameter |
---|
572 | */ |
---|
573 | ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root) |
---|
574 | { |
---|
575 | GameWorldData::loadWorldEntities(root); |
---|
576 | /* |
---|
577 | const TiXmlElement* element = root->FirstChildElement("WorldEntities"); |
---|
578 | |
---|
579 | if( element != NULL) |
---|
580 | { |
---|
581 | element = element->FirstChildElement(); |
---|
582 | PRINTF(4)("Loading WorldEntities\n"); |
---|
583 | while(element != NULL) |
---|
584 | { |
---|
585 | BaseObject* created = Factory::fabricate(element); |
---|
586 | if( created != NULL ) |
---|
587 | printf("Created a %s: %s\n", created->getClassName(), created->getName()); |
---|
588 | |
---|
589 | if( element->Value() == "SkyBox") |
---|
590 | this->sky = dynamic_cast<WorldEntity*>(created); |
---|
591 | if( element->Value() == "Terrain") |
---|
592 | this->terrain = dynamic_cast<Terrain*>(created); |
---|
593 | element = element->NextSiblingElement(); |
---|
594 | } |
---|
595 | |
---|
596 | PRINTF(4)("Done loading WorldEntities\n"); |
---|
597 | } |
---|
598 | |
---|
599 | // init the pnode tree |
---|
600 | PNode::getNullParent()->init(); |
---|
601 | */ |
---|
602 | } |
---|
603 | |
---|
604 | |
---|
605 | /** |
---|
606 | * unloads the world entities from the xml file |
---|
607 | */ |
---|
608 | ErrorMessage SimpleGameMenuData::unloadWorldEntities() |
---|
609 | { |
---|
610 | /* call underlying function */ |
---|
611 | GameWorldData::unloadWorldEntities(); |
---|
612 | } |
---|
613 | |
---|
614 | |
---|
615 | /** |
---|
616 | * loads the scene data |
---|
617 | * @param root reference to the xml root element |
---|
618 | */ |
---|
619 | ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root) |
---|
620 | { |
---|
621 | /* call underlying function */ |
---|
622 | GameWorldData::loadScene(root); |
---|
623 | } |
---|
624 | |
---|
625 | |
---|
626 | /** |
---|
627 | * unloads the scene data |
---|
628 | */ |
---|
629 | ErrorMessage SimpleGameMenuData::unloadScene() |
---|
630 | { |
---|
631 | /* call underlying function */ |
---|
632 | GameWorldData::unloadScene(); |
---|
633 | } |
---|
634 | |
---|
635 | |
---|
636 | |
---|