Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

grobe version nr1

File size: 4.4 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: Andreas Hejj
15
16*/
17
18
19#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
20
21#include "debug.h"
22#include "quest_gui.h"
23
24#include "event_handler.h"
25
26#include "state.h"
27
28#include "util/loading/load_param.h"
29#include "util/loading/factory.h"
30
31#include "graphics_engine.h"
32#include "camera.h"
33#include "sound_engine.h"
34
35#include "sound_source.h"
36
37#include "glgui.h"
38#include "menu/glgui_imagebutton.h"
39#include "glgui_text.h"
40#include <glgui_image.h>
41
42
43#include "shell_command.h"
44
45
46
47
48ObjectListDefinition(QuestGUI);
49
50CREATE_FACTORY(QuestGUI);
51SHELL_COMMAND(gui, QuestGUI, guiInit);
52//SHELL_COMMAND(cancel, QuestGUI, guiDestruct);
53
54
55QuestGUI::QuestGUI(const TiXmlElement* root)
56{
57  this->registerObject(this, QuestGUI::_objectList);
58
59  this->toList(OM_GROUP_00);
60 
61  this->questBox = NULL; 
62
63  if( root != NULL)
64    this->loadParams(root);
65
66}
67
68
69/**
70 * deconstructor
71 */
72QuestGUI::~QuestGUI () 
73{
74}
75
76
77
78
79/**
80 * loads the xml tagsthis->questDescription
81 * @param root: root xml tag for this element
82 */
83void QuestGUI::loadParams(const TiXmlElement* root)
84{
85   WorldEntity::loadParams(root);
86   
87   LoadParam(root, "quest-name", this, QuestGUI, setQuestName)
88       .describe("sets the name of a quest");
89   LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription)
90       .describe("sets the description of a quest");
91   LoadParam(root, "quest-picture", this, QuestGUI, setQuestPicture)
92       .describe("sets the picture of a quest");
93   LoadParam(root, "quest-difficulty", this, QuestGUI, setQuestDifficulty)
94       .describe("sets the difficulty of a quest");
95   LoadParam(root, "reward-description", this, QuestGUI, setRewardDescription)
96       .describe("sets the description of a reward");
97   LoadParam(root, "reward-picture", this, QuestGUI, setRewardPicture)
98       .describe("sets the Picture of a reward");
99   
100}
101
102
103/**
104 * initializes the gui
105 */
106void QuestGUI::guiInit()
107{ 
108  if (questBox == NULL)
109  {
110    this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical);
111   
112    OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
113    {
114      OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage();
115      questImage->setWidgetSize(100, 100);
116      questImage->loadImageFromFile(questPicture);
117      questImage->show();
118      headerBox->pack(questImage);
119     
120      OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
121      {
122        OrxGui::GLGuiText* questDifficulty = new OrxGui::GLGuiText();
123        questDifficulty->setText(this->questDifficulty);
124        outlineBox->pack(questDifficulty);
125      }
126      headerBox->pack(outlineBox);
127     
128    }
129   
130    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
131    { 
132      OrxGui::GLGuiText* questTxt = new OrxGui::GLGuiText();
133      questTxt->setText(this->questDescription);
134      labelBox->pack(questTxt);
135    }
136   
137   
138    OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical);
139    {
140      OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage();
141      rewardImage->setWidgetSize(50, 50);
142      rewardImage->loadImageFromFile(rewardPicture);
143      rewardImage->show();
144      rewardBox->pack(rewardImage);
145   
146      OrxGui::GLGuiText* rewardTxt = new OrxGui::GLGuiText();
147      rewardTxt->setText(this->rewardDescription);
148      rewardBox->pack(rewardTxt);
149    }
150   
151    OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
152    {
153      OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept");
154      answerBox->pack(acceptButton);
155     
156      OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse");
157      answerBox->pack(refuseButton);
158    }
159   
160    this->questBox->pack(headerBox);
161    this->questBox->pack(labelBox);
162    this->questBox->pack(rewardBox);
163    this->questBox->pack(answerBox);
164    this->questBox->showAll();
165   
166    this->questBox->setAbsCoor2D(300, 40);
167    OrxGui::GLGuiHandler::getInstance()->activate();
168    OrxGui::GLGuiHandler::getInstance()->activateCursor();
169  }
170  else
171  {
172    OrxGui::GLGuiHandler::getInstance()->deactivate();
173    OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
174    delete this->questBox;
175    this->questBox = NULL;
176  }
177 
178}
179
180
181
182
Note: See TracBrowser for help on using the repository browser.