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 | |
---|
56 | ObjectListDefinition(QuestGUI); |
---|
57 | |
---|
58 | CREATE_FACTORY(QuestGUI); |
---|
59 | SHELL_COMMAND(gui, QuestGUI, guiInit); |
---|
60 | //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); |
---|
61 | |
---|
62 | |
---|
63 | QuestGUI::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 = "/pictures/map.jpg"; |
---|
74 | |
---|
75 | this->myQuest = new Quest(root); |
---|
76 | if(root) |
---|
77 | this->loadParams( root); |
---|
78 | |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | /** |
---|
83 | * deconstructor |
---|
84 | */ |
---|
85 | QuestGUI::~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 | */ |
---|
95 | void QuestGUI::loadParams(const TiXmlElement* root) |
---|
96 | { |
---|
97 | WorldEntity::loadParams(root); |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | |
---|
102 | /** |
---|
103 | * initializes the gui |
---|
104 | */ |
---|
105 | void QuestGUI::guiInit() |
---|
106 | { |
---|
107 | if (questBox == NULL) |
---|
108 | { |
---|
109 | this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
110 | this->bKillGui = false; |
---|
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(this->myQuest->getQuestPicture()); |
---|
117 | questImage->show(); |
---|
118 | headerBox->pack(questImage); |
---|
119 | |
---|
120 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
121 | { |
---|
122 | OrxGui::GLGuiMultiLineText* questDifficulty = new OrxGui::GLGuiMultiLineText(); |
---|
123 | questDifficulty->setText(this->myQuest->getQuestDifficulty()); |
---|
124 | outlineBox->pack(questDifficulty); |
---|
125 | } |
---|
126 | headerBox->setBorderBottom(40); |
---|
127 | headerBox->pack(outlineBox); |
---|
128 | } |
---|
129 | |
---|
130 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
131 | { |
---|
132 | OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); |
---|
133 | questTxt->setText(this->myQuest->getQuestDescription()); |
---|
134 | labelBox->pack(questTxt); |
---|
135 | labelBox->setBorderBottom(40); |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
140 | { |
---|
141 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
142 | rewardImage->setWidgetSize(50, 50); |
---|
143 | rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); |
---|
144 | rewardImage->show(); |
---|
145 | rewardBox->pack(rewardImage); |
---|
146 | |
---|
147 | OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); |
---|
148 | rewardTxt->setText(this->myQuest->getRewardDescription()); |
---|
149 | rewardBox->setBorderBottom(40); |
---|
150 | rewardBox->pack(rewardTxt); |
---|
151 | } |
---|
152 | |
---|
153 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
154 | { |
---|
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 | } |
---|
162 | |
---|
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); |
---|
172 | } |
---|
173 | this->questBox->pack(headerBox); |
---|
174 | this->questBox->pack(labelBox); |
---|
175 | this->questBox->pack(rewardBox); |
---|
176 | this->questBox->pack(answerBox); |
---|
177 | this->questBox->showAll(); |
---|
178 | |
---|
179 | this->questBox->setAbsCoor2D(300, 200); |
---|
180 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
181 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
182 | } |
---|
183 | else |
---|
184 | { |
---|
185 | this->bKillGui = true; |
---|
186 | } |
---|
187 | |
---|
188 | } |
---|
189 | |
---|
190 | |
---|
191 | void QuestGUI::tick(float dt) |
---|
192 | { |
---|
193 | if( this->bKillGui) |
---|
194 | this->killgui(); |
---|
195 | } |
---|
196 | |
---|
197 | |
---|
198 | void QuestGUI::accept() |
---|
199 | { |
---|
200 | this->myQuest->setQuestActive(); |
---|
201 | this->bKillGui = true; |
---|
202 | } |
---|
203 | |
---|
204 | void QuestGUI::refuse() |
---|
205 | { |
---|
206 | this->bKillGui = true; |
---|
207 | } |
---|
208 | |
---|
209 | void QuestGUI::killgui() |
---|
210 | { |
---|
211 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
212 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
213 | delete this->questBox; |
---|
214 | this->questBox = NULL; |
---|
215 | } |
---|