Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

fast gutes design und skript geht

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