Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/world_entities/questGUI/quest_gui.cc @ 10031

Last change on this file since 10031 was 10031, checked in by hejja, 17 years ago

Quest-Dialog mit Weissem Bild gecodet

File size: 4.0 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Andreas Hejj
15
16*/
17
18
19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
20
21#include "debug.h"
22#include "quest_gui.h"
23
24#include "event_handler.h"
25
26#include "state.h"
27
28#include "util/loading/load_param.h"
29#include "util/loading/factory.h"
30
31#include "graphics_engine.h"
32#include "camera.h"
33#include "sound_engine.h"
34
35#include "sound_source.h"
36
37#include "glgui.h"
38#include "menu/glgui_imagebutton.h"
39#include "glgui_text.h"
40
41
42#include "shell_command.h"
43
44
45
46
47ObjectListDefinition(QuestGUI);
48
49CREATE_FACTORY(QuestGUI);
50SHELL_COMMAND(gui, QuestGUI, guiInit);
51
52
53QuestGUI::QuestGUI(const TiXmlElement* root)
54{
55  this->registerObject(this, QuestGUI::_objectList);
56
57  this->toList(OM_GROUP_00);
58 
59  this->mainMenuBox = NULL;
60 
61  this->questBox = NULL;
62
63  this->currentlyOpened = NULL;
64 
65
66  if( root != NULL)
67    this->loadParams(root);
68
69}
70
71
72/**
73 * deconstructor
74 */
75QuestGUI::~QuestGUI () 
76{
77}
78
79
80
81
82/**
83 * loads the xml tags
84 * @param root: root xml tag for this element
85 */
86void QuestGUI::loadParams(const TiXmlElement* root)
87{
88   WorldEntity::loadParams(root);
89   
90   LoadParam(root, "quest-name", this, QuestGUI, setQuestName)
91       .describe("sets the name of a quest");
92   LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription)
93       .describe("sets the description of a quest");
94}
95
96
97/**
98 * initializes the gui
99 */
100void QuestGUI::guiInit()
101{ 
102  if (mainMenuBox == NULL)
103  {
104    this->mainMenuBox = new OrxGui::GLGuiBox();
105    {
106      OrxGui::GLGuiButton* startButton = new OrxGui::GLGuiPushButton("Quests");
107      startButton->released.connect(this, &QuestGUI::showQuest);
108      this->mainMenuBox->pack(startButton);
109      startButton->select();
110
111      OrxGui::GLGuiButton* networkButton = new OrxGui::GLGuiPushButton("Bla Bla");
112      //networkButton->released.connect(this, &QuestGUI::showMultiPlayer);
113      this->mainMenuBox->pack(networkButton);
114
115      OrxGui::GLGuiButton* optionsButton = new OrxGui::GLGuiPushButton("Blobb");
116      //optionsButton->released.connect(this, &QuestGUI::showOptionsMenu);
117      this->mainMenuBox->pack(optionsButton);
118
119
120      OrxGui::GLGuiButton* quitButton = new OrxGui::GLGuiPushButton("Quit Menu");
121      this->mainMenuBox->pack(quitButton);
122      quitButton->released.connect(this, &QuestGUI::quitMenu);
123    }
124 
125    this->mainMenuBox->showAll();
126
127    this->mainMenuBox->setRelCoor2D(200, 100); 
128 
129    OrxGui::GLGuiHandler::getInstance()->activate();
130    OrxGui::GLGuiHandler::getInstance()->activateCursor();
131  }
132  else
133  {
134    OrxGui::GLGuiHandler::getInstance()->deactivate();
135    OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
136    delete this->mainMenuBox;
137    this->mainMenuBox = NULL;
138  }
139 
140}
141
142void QuestGUI::showQuest()
143{
144  if (this->questBox== NULL)
145  {
146    this->questBox= new OrxGui::GLGuiBox(OrxGui::Horizontal);
147   
148    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox();
149   
150    OrxGui::GLGuiText* questTxt = new OrxGui::GLGuiText();
151    questTxt->setText(this->questDescription);
152    labelBox->pack(questTxt);
153
154    OrxGui::GLGuiImage* image = new OrxGui::GLGuiImage();
155    image->show();
156    image->setWidgetSize( 250, 200);
157    image->setAbsCoor2D(400, 150);
158    image->setForegroundColor(Color( 1,1,1,.6));
159   
160    this->questBox->pack(labelBox);
161    this->questBox->pack(image);
162  }
163 
164  this->showSecondLevelElement(this->questBox);
165
166}
167
168void QuestGUI::quitMenu()
169{
170  delete this->mainMenuBox;
171  this->mainMenuBox = NULL;
172}
173
174void QuestGUI::showSecondLevelElement(OrxGui::GLGuiBox* element)
175{
176  if (this->currentlyOpened != NULL && this->currentlyOpened != element)
177    this->currentlyOpened->hideAll();
178
179  element->showAll();
180  element->setRelCoor2D(200, 100);
181
182  this->currentlyOpened = element;
183
184  this->mainMenuBox->setRelCoorSoft2D(50, 100, 5);
185}
186
187
188
189
190
Note: See TracBrowser for help on using the repository browser.