Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

2 Folgequestscd ..

File size: 7.2 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 1004 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_multiline_text.h"
46#include <glgui_image.h>
47
48
49#include "quest.h"
50
51#include "shell_command.h"
52
53ObjectListDefinition(QuestGUI);
54
55CREATE_FACTORY(QuestGUI);
56SHELL_COMMAND(gui, QuestGUI, guiInit);
57
58
59#include "script_class.h"
60CREATE_SCRIPTABLE_CLASS(QuestGUI,
61                        addMethod("guiInit", Executor0<QuestGUI, lua_State*>(&QuestGUI::guiInit))
62                        ->addMethod("isActive", Executor0ret<QuestGUI, lua_State*,bool>(&QuestGUI::isActive))
63                       );
64
65
66
67QuestGUI::QuestGUI(const TiXmlElement* root)
68{
69  if (root != NULL)
70  {
71  this->registerObject(this, QuestGUI::_objectList);
72
73  this->toList(OM_GROUP_00);
74
75  this->questBox = NULL;
76
77  this->bKillGui = false;
78 
79  this->bActive = false;
80
81  this->myQuest = new Quest(root);
82  if(root)
83    this->loadParams( root);
84  }
85}
86
87
88/**
89 * deconstructor
90 */
91QuestGUI::~QuestGUI ()
92{
93  if( this->myQuest)
94    delete this->myQuest;
95}
96
97/**
98 * loads the xml tagsthis->questDescription
99 * @param root: root xml tag for this element
100 */
101void QuestGUI::loadParams(const TiXmlElement* root)
102{
103  WorldEntity::loadParams(root);
104}
105
106
107
108/**
109 * initializes the gui
110 */
111void QuestGUI::guiInit()
112{
113  if (questBox == NULL)
114  {
115    this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical);
116    questBox->setBorderTop(10);
117    questBox->setBorderRight(10);
118    questBox->setBorderLeft(10);
119    questBox->setBorderBottom(10);
120    this->questBox->setBackgroundTexture("maps/rand.png");
121    this->bKillGui = false;
122
123    OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
124    {
125      headerBox->setBackgroundTexture("maps/rand-unten.png");
126      OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage();
127      questImage->setWidgetSize(100, 100);
128      questImage->loadImageFromFile(this->myQuest->getQuestPicture());
129      questImage->show();
130      headerBox->pack(questImage);
131
132      OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
133      {     
134        OrxGui::GLGuiMultiLineText* questDetails = new OrxGui::GLGuiMultiLineText();
135        questDetails->setText(this->myQuest->getQuestDifficulty());
136        questDetails->append(this->myQuest->getQuestPersons());
137        outlineBox->setBorderTop(0);
138        outlineBox->setBorderRight(0);
139        outlineBox->setBorderLeft(0);
140        outlineBox->setBorderBottom(10);
141        outlineBox->pack(questDetails);
142      }
143      headerBox->setBorderTop(0);
144      headerBox->setBorderRight(0);
145      headerBox->setBorderLeft(0);
146      headerBox->setBorderBottom(10);
147      headerBox->pack(outlineBox);
148    }
149
150    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
151    {
152      labelBox->setBackgroundTexture("maps/rand-unten.png");
153      OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText();
154      questTxt->setText(this->myQuest->getQuestDescription());
155      labelBox->pack(questTxt);
156     
157      OrxGui::GLGuiImage* placeImage = new OrxGui::GLGuiImage();
158      placeImage->setWidgetSize(85, 10);
159      placeImage->loadImageFromFile("maps/schwarz.png");
160      placeImage->show();
161      labelBox->pack(placeImage);
162     
163     
164      labelBox->setBorderTop(0);
165      labelBox->setBorderRight(0);
166      labelBox->setBorderLeft(55);
167      labelBox->setBorderBottom(10);
168    }
169
170
171    OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
172    {
173      OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage();
174      rewardImage->setWidgetSize(100, 100);
175      rewardImage->loadImageFromFile(this->myQuest->getRewardPicture());
176      rewardImage->show();
177      rewardBox->pack(rewardImage);
178
179      OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText();
180      rewardTxt->setText(this->myQuest->getRewardDescription());
181      rewardBox->setBorderTop(0);
182      rewardBox->setBorderRight(0);
183      rewardBox->setBorderLeft(0);
184      rewardBox->setBorderBottom(10);
185      rewardBox->pack(rewardTxt);
186    }
187
188    OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
189    {
190      OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
191      {
192        //acceptBox->setBackgroundTexture("maps/rand-oben.png");
193        OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept");
194        acceptButton->released.connect(this, &QuestGUI::accept);
195        acceptBox->setBorderTop(10);
196        acceptBox->setBorderRight(10);
197        acceptBox->setBorderLeft(10);
198        acceptBox->setBorderBottom(0);
199        acceptBox->pack(acceptButton);
200      }
201      answerBox->pack(acceptBox);
202     
203      OrxGui::GLGuiImage* placeImage = new OrxGui::GLGuiImage();
204      placeImage->setWidgetSize(300, 10);
205      placeImage->loadImageFromFile("maps/schwarz.png");
206      placeImage->show();
207      answerBox->pack(placeImage);
208     
209      OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
210      {
211        //refuseBox->setBackgroundTexture("maps/rand-oben.png");
212        OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse");
213        refuseButton->released.connect(this, &QuestGUI::refuse);
214        refuseBox->setBorderTop(10);
215        refuseBox->setBorderRight(10);
216        refuseBox->setBorderLeft(10);
217        refuseBox->setBorderBottom(0);
218        refuseBox->pack(refuseButton);
219      }
220      answerBox->setBorderTop(0);
221      answerBox->setBorderRight(0);
222      answerBox->setBorderLeft(0);
223      answerBox->setBorderBottom(20);
224      answerBox->pack(refuseBox);
225    }
226    this->questBox->pack(headerBox);
227    this->questBox->pack(labelBox);
228    this->questBox->pack(rewardBox);
229    this->questBox->pack(answerBox);
230    this->questBox->showAll();
231
232    this->questBox->setAbsCoor2D(300, 100);
233    OrxGui::GLGuiHandler::getInstance()->activate();
234    OrxGui::GLGuiHandler::getInstance()->activateCursor();
235  }
236  else
237  {
238    this->bKillGui = true;
239  }
240
241}
242
243
244void QuestGUI::tick(float dt)
245{
246  if( this->bKillGui)
247    this->killgui();
248}
249
250
251void QuestGUI::accept()
252{
253  this->myQuest->setQuestActive();
254  this->bKillGui = true;
255  bActive=true;
256}
257
258void QuestGUI::refuse()
259{
260  this->bKillGui = true;
261  bActive=false;
262}
263
264void QuestGUI::killgui()
265{
266  OrxGui::GLGuiHandler::getInstance()->deactivate();
267  OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
268  delete this->questBox;
269  this->questBox = NULL;
270}
Note: See TracBrowser for help on using the repository browser.