Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10129 was 10129, checked in by hejja, 14 years ago

Quest-Klasse implementiert

File size: 4.8 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    std::string             questName;
15    std::string             questDescription;
16    std::string             questPicture;
17    std::string             questDifficulty;
18    std::string             rewardDescription;
19    std::string             rewardPicture;: Andreas Hejj
20
21*/
22
23
24#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
25
26#include "debug.h"
27#include "quest_gui.h"
28
29#include "event_handler.h"
30
31#include "state.h"
32
33#include "util/loading/load_param.h"
34#include "util/loading/factory.h"
35
36#include "graphics_engine.h"
37#include "camera.h"
38#include "sound_engine.h"
39
40#include "sound_source.h"
41
42#include "glgui_widget.h"
43#include "glgui.h"
44#include "menu/glgui_imagebutton.h"
45#include "glgui_text.h"
46#include <glgui_image.h>
47
48
49#include "quest.h"
50
51#include "shell_command.h"
52
53
54
55
56ObjectListDefinition(QuestGUI);
57
58CREATE_FACTORY(QuestGUI);
59SHELL_COMMAND(gui, QuestGUI, guiInit);
60//SHELL_COMMAND(cancel, QuestGUI, guiDestruct);
61
62
63QuestGUI::QuestGUI(const TiXmlElement* root)
64{
65  this->registerObject(this, QuestGUI::_objectList);
66
67  this->toList(OM_GROUP_00);
68 
69  this->questBox = NULL; 
70 
71  this->bKillGui = false;
72
73  this->myQuest = new Quest(root);
74  if(root)
75    this->loadParams( root);
76
77}
78
79
80/**
81 * deconstructor
82 */
83QuestGUI::~QuestGUI () 
84{
85  if( this->myQuest)
86    delete this->myQuest;
87}
88
89/**
90 * loads the xml tagsthis->questDescription
91 * @param root: root xml tag for this element
92 */
93void QuestGUI::loadParams(const TiXmlElement* root)
94{
95  WorldEntity::loadParams(root);
96}
97
98
99
100/**
101 * initializes the gui
102 */
103void QuestGUI::guiInit()
104{ 
105  if (questBox == NULL)
106  {
107    this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical);
108    this->bKillGui = false;
109   
110    OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
111    {
112      OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage();
113      questImage->setWidgetSize(100, 100);
114      questImage->loadImageFromFile(this->myQuest->getQuestPicture());
115      questImage->show();
116      questImage->setBorderBottom(20);
117      headerBox->pack(questImage);
118      headerBox->setBorderBottom(20);
119     
120      OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
121      {
122        OrxGui::GLGuiText* questDifficulty = new OrxGui::GLGuiText();
123        questDifficulty->setText(this->myQuest->getQuestDifficulty());
124        outlineBox->pack(questDifficulty);
125      }
126      headerBox->pack(outlineBox);
127      headerBox->setBorderBottom(75);
128     
129    }
130   
131    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
132    { 
133      OrxGui::GLGuiText* questTxt = new OrxGui::GLGuiText();
134      questTxt->setText(this->myQuest->getQuestDescription());
135      labelBox->pack(questTxt);
136      labelBox->setBorderBottom(75);
137    }
138   
139   
140    OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
141    {
142      OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage();
143      rewardImage->setWidgetSize(50, 50);
144      rewardImage->loadImageFromFile(this->myQuest->getRewardPicture());
145      rewardImage->show();
146      rewardBox->pack(rewardImage);
147      rewardImage->setBorderBottom(50);
148   
149      OrxGui::GLGuiText* rewardTxt = new OrxGui::GLGuiText();
150      rewardTxt->setText(this->myQuest->getRewardDescription());
151      rewardBox->pack(rewardTxt);
152      rewardBox->setBorderBottom(75);
153     
154    }
155   
156    OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
157    {
158      OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept");
159      acceptButton->released.connect(this, &QuestGUI::accept);
160      answerBox->pack(acceptButton);
161      acceptButton->select();
162     
163      OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse");
164      refuseButton->released.connect(this, &QuestGUI::refuse);
165      answerBox->pack(refuseButton);
166    }
167   
168    this->questBox->pack(headerBox);
169    this->questBox->pack(labelBox);
170    this->questBox->pack(rewardBox);
171    this->questBox->pack(answerBox);
172    this->questBox->showAll();
173   
174    this->questBox->setAbsCoor2D(300, 40);
175    OrxGui::GLGuiHandler::getInstance()->activate();
176    OrxGui::GLGuiHandler::getInstance()->activateCursor();
177  }
178  else
179  {
180    this->bKillGui = true;
181  }
182 
183}
184
185   
186void QuestGUI::tick(float dt)
187{
188  if( this->bKillGui)
189    this->killgui();
190}
191   
192
193void QuestGUI::accept()
194{
195  this->bKillGui = true;
196 
197}
198
199void QuestGUI::refuse()
200{
201  this->bKillGui = true;
202}
203
204void QuestGUI::killgui()
205{
206  OrxGui::GLGuiHandler::getInstance()->deactivate();
207  OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
208  delete this->questBox;
209  this->questBox = NULL;
210}
Note: See TracBrowser for help on using the repository browser.