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
RevLine 
[10026]1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
[10222]6   Copyright (C) 1004 orx
[10026]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:
[10129]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
[10026]20
21*/
22
23
24#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
25
[10031]26#include "debug.h"
[10027]27#include "quest_gui.h"
[10026]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
[10129]42#include "glgui_widget.h"
[10026]43#include "glgui.h"
44#include "menu/glgui_imagebutton.h"
[10213]45#include "glgui_multiline_text.h"
[10066]46#include <glgui_image.h>
[10026]47
48
[10129]49#include "quest.h"
50
[10026]51#include "shell_command.h"
52
53ObjectListDefinition(QuestGUI);
54
55CREATE_FACTORY(QuestGUI);
56SHELL_COMMAND(gui, QuestGUI, guiInit);
57
58
[10265]59#include "script_class.h"
60CREATE_SCRIPTABLE_CLASS(QuestGUI,
61                        addMethod("guiInit", Executor0<QuestGUI, lua_State*>(&QuestGUI::guiInit))
62                       );
63
64
65
[10026]66QuestGUI::QuestGUI(const TiXmlElement* root)
67{
[10265]68  if (root != NULL)
69  {
[10026]70  this->registerObject(this, QuestGUI::_objectList);
[10225]71
[10026]72  this->toList(OM_GROUP_00);
[10225]73
74  this->questBox = NULL;
75
[10129]76  this->bKillGui = false;
[10026]77
[10129]78  this->myQuest = new Quest(root);
79  if(root)
80    this->loadParams( root);
[10265]81  }
[10026]82}
83
84
85/**
86 * deconstructor
87 */
[10225]88QuestGUI::~QuestGUI ()
[10026]89{
[10129]90  if( this->myQuest)
91    delete this->myQuest;
[10026]92}
93
94/**
[10066]95 * loads the xml tagsthis->questDescription
[10026]96 * @param root: root xml tag for this element
97 */
98void QuestGUI::loadParams(const TiXmlElement* root)
99{
[10129]100  WorldEntity::loadParams(root);
[10026]101}
102
103
[10129]104
[10026]105/**
106 * initializes the gui
107 */
108void QuestGUI::guiInit()
[10225]109{
[10066]110  if (questBox == NULL)
[10026]111  {
[10069]112    this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical);
[10222]113    questBox->setBorderTop(10);
114    questBox->setBorderRight(10);
115    questBox->setBorderLeft(10);
[10265]116    questBox->setBorderBottom(10);
[10273]117    this->questBox->setBackgroundTexture("maps/rand.png");
[10129]118    this->bKillGui = false;
[10225]119
[10069]120    OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
121    {
[10273]122      headerBox->setBackgroundTexture("maps/rand-unten.png");
[10069]123      OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage();
[10213]124      questImage->setWidgetSize(100, 100);
[10129]125      questImage->loadImageFromFile(this->myQuest->getQuestPicture());
[10069]126      questImage->show();
127      headerBox->pack(questImage);
[10225]128
[10069]129      OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
[10265]130      {     
[10222]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);
[10265]137        outlineBox->setBorderBottom(10);
[10222]138        outlineBox->pack(questDetails);
[10069]139      }
[10222]140      headerBox->setBorderTop(0);
141      headerBox->setBorderRight(0);
142      headerBox->setBorderLeft(0);
[10265]143      headerBox->setBorderBottom(10);
[10069]144      headerBox->pack(outlineBox);
145    }
[10225]146
[10265]147    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
[10225]148    {
[10273]149      labelBox->setBackgroundTexture("maps/rand-unten.png");
[10164]150      OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText();
[10213]151      questTxt->setText(this->myQuest->getQuestDescription());
[10265]152      labelBox->pack(questTxt);
[10273]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     
[10222]161      labelBox->setBorderTop(0);
162      labelBox->setBorderRight(0);
[10273]163      labelBox->setBorderLeft(55);
[10265]164      labelBox->setBorderBottom(10);
[10069]165    }
[10225]166
167
[10265]168    OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
[10069]169    {
170      OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage();
[10265]171      rewardImage->setWidgetSize(100, 100);
[10129]172      rewardImage->loadImageFromFile(this->myQuest->getRewardPicture());
[10069]173      rewardImage->show();
174      rewardBox->pack(rewardImage);
[10225]175
[10164]176      OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText();
[10129]177      rewardTxt->setText(this->myQuest->getRewardDescription());
[10222]178      rewardBox->setBorderTop(0);
179      rewardBox->setBorderRight(0);
180      rewardBox->setBorderLeft(0);
[10265]181      rewardBox->setBorderBottom(10);
[10069]182      rewardBox->pack(rewardTxt);
183    }
[10225]184
[10069]185    OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
186    {
[10167]187      OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
188      {
[10273]189        //acceptBox->setBackgroundTexture("maps/rand-oben.png");
[10167]190        OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept");
191        acceptButton->released.connect(this, &QuestGUI::accept);
[10273]192        acceptBox->setBorderTop(10);
193        acceptBox->setBorderRight(10);
194        acceptBox->setBorderLeft(10);
195        acceptBox->setBorderBottom(0);
[10167]196        acceptBox->pack(acceptButton);
197      }
[10273]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     
[10167]206      OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
207      {
[10273]208        //refuseBox->setBackgroundTexture("maps/rand-oben.png");
[10167]209        OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse");
210        refuseButton->released.connect(this, &QuestGUI::refuse);
[10273]211        refuseBox->setBorderTop(10);
212        refuseBox->setBorderRight(10);
213        refuseBox->setBorderLeft(10);
214        refuseBox->setBorderBottom(0);
[10167]215        refuseBox->pack(refuseButton);
216      }
[10265]217      answerBox->setBorderTop(0);
218      answerBox->setBorderRight(0);
219      answerBox->setBorderLeft(0);
[10273]220      answerBox->setBorderBottom(20);
[10167]221      answerBox->pack(refuseBox);
[10069]222    }
223    this->questBox->pack(headerBox);
[10026]224    this->questBox->pack(labelBox);
[10069]225    this->questBox->pack(rewardBox);
226    this->questBox->pack(answerBox);
[10066]227    this->questBox->showAll();
[10225]228
[10222]229    this->questBox->setAbsCoor2D(300, 100);
[10066]230    OrxGui::GLGuiHandler::getInstance()->activate();
231    OrxGui::GLGuiHandler::getInstance()->activateCursor();
[10026]232  }
[10066]233  else
234  {
[10129]235    this->bKillGui = true;
[10066]236  }
[10225]237
[10026]238}
239
[10225]240
[10129]241void QuestGUI::tick(float dt)
242{
243  if( this->bKillGui)
244    this->killgui();
245}
[10031]246
[10225]247
[10129]248void QuestGUI::accept()
249{
[10167]250  this->myQuest->setQuestActive();
[10129]251  this->bKillGui = true;
252}
[10026]253
[10129]254void QuestGUI::refuse()
255{
256  this->bKillGui = true;
257}
[10026]258
[10129]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.