Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

texturfehler

File size: 5.3 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_multiline_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->background = "maps/pogo_bunny.png";
74
75  this->myQuest = new Quest(root);
76  if(root)
77    this->loadParams( root);
78
79}
80
81
82/**
83 * deconstructor
84 */
85QuestGUI::~QuestGUI () 
86{
87  if( this->myQuest)
88    delete this->myQuest;
89}
90
91/**
92 * loads the xml tagsthis->questDescription
93 * @param root: root xml tag for this element
94 */
95void QuestGUI::loadParams(const TiXmlElement* root)
96{
97  WorldEntity::loadParams(root);
98}
99
100
101
102/**
103 * initializes the gui
104 */
105void QuestGUI::guiInit()
106{ 
107  if (questBox == NULL)
108  {
109    this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical);
110    this->bKillGui = false;
111    this->questBox->setBackgroundTexture(background);
112   
113    OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
114    {
115      OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage();
116      questImage->setWidgetSize(100, 100);
117
118      questImage->loadImageFromFile(this->myQuest->getQuestPicture());
119      questImage->show();
120      headerBox->setBackgroundTexture("maps/pogo_bunny.png");
121      headerBox->pack(questImage);
122     
123      OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
124      {
125        OrxGui::GLGuiMultiLineText* questDifficulty = new OrxGui::GLGuiMultiLineText();
126        questDifficulty->setText(this->myQuest->getQuestDifficulty());
127        outlineBox->setBackgroundTexture("pogo_bunny.png");
128        outlineBox->pack(questDifficulty);
129      }
130      headerBox->setBorderBottom(40);
131      headerBox->pack(outlineBox);
132    }
133   
134    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
135    { 
136      OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText();
137      questTxt->setText(this->myQuest->getQuestDescription());
138      labelBox->pack(questTxt);
139      labelBox->setBorderBottom(40);
140    }
141   
142   
143    OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
144    {
145      OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage();
146      rewardImage->setWidgetSize(50, 50);
147      rewardImage->loadImageFromFile(this->myQuest->getRewardPicture());
148      rewardImage->show();
149      rewardBox->pack(rewardImage);
150   
151      OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText();
152      rewardTxt->setText(this->myQuest->getRewardDescription());
153      rewardBox->setBorderBottom(40);
154      rewardBox->pack(rewardTxt);
155    }
156   
157    OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
158    {
159      OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
160      {
161        OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept");
162        acceptButton->released.connect(this, &QuestGUI::accept);
163        acceptBox->setBorderRight(70);
164        acceptBox->pack(acceptButton);
165      }
166     
167      OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
168      {
169        OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse");
170        refuseButton->released.connect(this, &QuestGUI::refuse);
171        refuseBox->setBorderLeft(0);
172        refuseBox->pack(refuseButton);
173      }
174      answerBox->pack(acceptBox);
175      answerBox->pack(refuseBox);
176    }
177    this->questBox->pack(headerBox);
178    this->questBox->pack(labelBox);
179    this->questBox->pack(rewardBox);
180    this->questBox->pack(answerBox);
181    this->questBox->showAll();
182   
183    this->questBox->setAbsCoor2D(300, 200);
184    OrxGui::GLGuiHandler::getInstance()->activate();
185    OrxGui::GLGuiHandler::getInstance()->activateCursor();
186  }
187  else
188  {
189    this->bKillGui = true;
190  }
191 
192}
193
194   
195void QuestGUI::tick(float dt)
196{
197  if( this->bKillGui)
198    this->killgui();
199}
200   
201
202void QuestGUI::accept()
203{
204  this->myQuest->setQuestActive();
205  this->bKillGui = true;
206}
207
208void QuestGUI::refuse()
209{
210  this->bKillGui = true;
211}
212
213void QuestGUI::killgui()
214{
215  OrxGui::GLGuiHandler::getInstance()->deactivate();
216  OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
217  delete this->questBox;
218  this->questBox = NULL;
219}
Note: See TracBrowser for help on using the repository browser.