Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Borders done

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