[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 | |
---|
| 53 | ObjectListDefinition(QuestGUI); |
---|
| 54 | |
---|
| 55 | CREATE_FACTORY(QuestGUI); |
---|
| 56 | |
---|
| 57 | |
---|
[10493] | 58 | |
---|
[10265] | 59 | #include "script_class.h" |
---|
| 60 | CREATE_SCRIPTABLE_CLASS(QuestGUI, |
---|
[10492] | 61 | addMethod("startGUI", Executor0<QuestGUI, lua_State*>(&QuestGUI::startGUI)) |
---|
| 62 | ->addMethod("stopGUI", Executor0<QuestGUI, lua_State*>(&QuestGUI::stopGUI)) |
---|
| 63 | ->addMethod("isActive", Executor0ret<QuestGUI, lua_State*,bool>(&QuestGUI::isActive)) |
---|
[10265] | 64 | ); |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | |
---|
[10026] | 68 | QuestGUI::QuestGUI(const TiXmlElement* root) |
---|
| 69 | { |
---|
[10265] | 70 | if (root != NULL) |
---|
| 71 | { |
---|
[10026] | 72 | this->registerObject(this, QuestGUI::_objectList); |
---|
[10225] | 73 | |
---|
[10026] | 74 | this->toList(OM_GROUP_00); |
---|
[10225] | 75 | |
---|
| 76 | this->questBox = NULL; |
---|
| 77 | |
---|
[10129] | 78 | this->bKillGui = false; |
---|
[10489] | 79 | |
---|
[10277] | 80 | this->bActive = false; |
---|
[10026] | 81 | |
---|
[10129] | 82 | this->myQuest = new Quest(root); |
---|
[10492] | 83 | |
---|
[10129] | 84 | if(root) |
---|
| 85 | this->loadParams( root); |
---|
[10265] | 86 | } |
---|
[10026] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * deconstructor |
---|
| 92 | */ |
---|
[10225] | 93 | QuestGUI::~QuestGUI () |
---|
[10026] | 94 | { |
---|
[10129] | 95 | if( this->myQuest) |
---|
| 96 | delete this->myQuest; |
---|
[10026] | 97 | } |
---|
| 98 | |
---|
| 99 | /** |
---|
[10066] | 100 | * loads the xml tagsthis->questDescription |
---|
[10026] | 101 | * @param root: root xml tag for this element |
---|
| 102 | */ |
---|
| 103 | void QuestGUI::loadParams(const TiXmlElement* root) |
---|
| 104 | { |
---|
[10129] | 105 | WorldEntity::loadParams(root); |
---|
[10026] | 106 | } |
---|
| 107 | |
---|
| 108 | |
---|
[10129] | 109 | |
---|
[10026] | 110 | /** |
---|
| 111 | * initializes the gui |
---|
| 112 | */ |
---|
[10492] | 113 | void QuestGUI::startGUI() |
---|
[10225] | 114 | { |
---|
[10492] | 115 | this->bKillGui = false; |
---|
| 116 | |
---|
| 117 | |
---|
[10066] | 118 | if (questBox == NULL) |
---|
[10026] | 119 | { |
---|
[10069] | 120 | this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10222] | 121 | questBox->setBorderTop(10); |
---|
| 122 | questBox->setBorderRight(10); |
---|
| 123 | questBox->setBorderLeft(10); |
---|
[10265] | 124 | questBox->setBorderBottom(10); |
---|
[10489] | 125 | this->questBox->setBackgroundTexture("textures/gui/gui_quest_border.png"); |
---|
[10225] | 126 | |
---|
[10069] | 127 | OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 128 | { |
---|
[10489] | 129 | headerBox->setBackgroundTexture("textures/gui/gui_quest_border_low.png"); |
---|
[10069] | 130 | OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage(); |
---|
[10213] | 131 | questImage->setWidgetSize(100, 100); |
---|
[10129] | 132 | questImage->loadImageFromFile(this->myQuest->getQuestPicture()); |
---|
[10069] | 133 | questImage->show(); |
---|
| 134 | headerBox->pack(questImage); |
---|
[10225] | 135 | |
---|
[10069] | 136 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10489] | 137 | { |
---|
[10222] | 138 | OrxGui::GLGuiMultiLineText* questDetails = new OrxGui::GLGuiMultiLineText(); |
---|
| 139 | questDetails->setText(this->myQuest->getQuestDifficulty()); |
---|
| 140 | questDetails->append(this->myQuest->getQuestPersons()); |
---|
| 141 | outlineBox->setBorderTop(0); |
---|
| 142 | outlineBox->setBorderRight(0); |
---|
| 143 | outlineBox->setBorderLeft(0); |
---|
[10265] | 144 | outlineBox->setBorderBottom(10); |
---|
[10222] | 145 | outlineBox->pack(questDetails); |
---|
[10069] | 146 | } |
---|
[10222] | 147 | headerBox->setBorderTop(0); |
---|
| 148 | headerBox->setBorderRight(0); |
---|
| 149 | headerBox->setBorderLeft(0); |
---|
[10265] | 150 | headerBox->setBorderBottom(10); |
---|
[10069] | 151 | headerBox->pack(outlineBox); |
---|
| 152 | } |
---|
[10225] | 153 | |
---|
[10265] | 154 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
[10225] | 155 | { |
---|
[10489] | 156 | labelBox->setBackgroundTexture("textures/gui/gui_quest_border_low.png"); |
---|
[10164] | 157 | OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10213] | 158 | questTxt->setText(this->myQuest->getQuestDescription()); |
---|
[10265] | 159 | labelBox->pack(questTxt); |
---|
[10489] | 160 | |
---|
[10273] | 161 | OrxGui::GLGuiImage* placeImage = new OrxGui::GLGuiImage(); |
---|
| 162 | placeImage->setWidgetSize(85, 10); |
---|
[10491] | 163 | placeImage->loadImageFromFile("textures/gui/gui_quest_black.png"); |
---|
[10273] | 164 | placeImage->show(); |
---|
| 165 | labelBox->pack(placeImage); |
---|
[10489] | 166 | |
---|
| 167 | |
---|
[10222] | 168 | labelBox->setBorderTop(0); |
---|
| 169 | labelBox->setBorderRight(0); |
---|
[10273] | 170 | labelBox->setBorderLeft(55); |
---|
[10265] | 171 | labelBox->setBorderBottom(10); |
---|
[10069] | 172 | } |
---|
[10225] | 173 | |
---|
| 174 | |
---|
[10265] | 175 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
[10069] | 176 | { |
---|
[10489] | 177 | rewardBox->setBackgroundTexture("textures/gui/gui_quest_border_low.png"); |
---|
[10069] | 178 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
[10265] | 179 | rewardImage->setWidgetSize(100, 100); |
---|
[10129] | 180 | rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); |
---|
[10069] | 181 | rewardImage->show(); |
---|
| 182 | rewardBox->pack(rewardImage); |
---|
[10225] | 183 | |
---|
[10164] | 184 | OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10129] | 185 | rewardTxt->setText(this->myQuest->getRewardDescription()); |
---|
[10222] | 186 | rewardBox->setBorderTop(0); |
---|
| 187 | rewardBox->setBorderRight(0); |
---|
| 188 | rewardBox->setBorderLeft(0); |
---|
[10265] | 189 | rewardBox->setBorderBottom(10); |
---|
[10069] | 190 | rewardBox->pack(rewardTxt); |
---|
| 191 | } |
---|
[10225] | 192 | |
---|
[10069] | 193 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 194 | { |
---|
[10334] | 195 | OrxGui::GLGuiImage* placeImage = new OrxGui::GLGuiImage(); |
---|
| 196 | placeImage->setWidgetSize(20, 10); |
---|
[10491] | 197 | placeImage->loadImageFromFile("textures/gui/gui_quest_black.png"); |
---|
[10334] | 198 | placeImage->show(); |
---|
| 199 | answerBox->pack(placeImage); |
---|
[10489] | 200 | |
---|
[10167] | 201 | OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 202 | { |
---|
[10336] | 203 | //acceptBox->setBackgroundTexture("maps/accept.png"); |
---|
[10489] | 204 | acceptBox->setBackgroundTexture("textures/gui/gui_quest_accept.jpg", OrxGui::Normal); |
---|
| 205 | //acceptBox->setBackgroundTexture("maps/gui_quest_acceptrout.png", OrxGui::Selected); |
---|
[10334] | 206 | OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton(" "); |
---|
[10167] | 207 | acceptButton->released.connect(this, &QuestGUI::accept); |
---|
[10336] | 208 | acceptBox->setBorderTop(7); |
---|
| 209 | acceptBox->setBorderRight(7); |
---|
| 210 | acceptBox->setBorderLeft(7); |
---|
| 211 | acceptBox->setBorderBottom(7); |
---|
[10167] | 212 | acceptBox->pack(acceptButton); |
---|
| 213 | } |
---|
[10273] | 214 | answerBox->pack(acceptBox); |
---|
[10489] | 215 | |
---|
[10334] | 216 | OrxGui::GLGuiImage* placeImage2 = new OrxGui::GLGuiImage(); |
---|
| 217 | placeImage2->setWidgetSize(300, 10); |
---|
[10489] | 218 | placeImage2->loadImageFromFile("textures/gui/gui_quest_black.png"); |
---|
[10334] | 219 | placeImage2->show(); |
---|
| 220 | answerBox->pack(placeImage2); |
---|
[10489] | 221 | |
---|
[10167] | 222 | OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 223 | { |
---|
[10489] | 224 | refuseBox->setBackgroundTexture("textures/gui/gui_quest_refuserout.gif"); |
---|
[10334] | 225 | OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton(" "); |
---|
[10167] | 226 | refuseButton->released.connect(this, &QuestGUI::refuse); |
---|
[10336] | 227 | refuseBox->setBorderTop(7); |
---|
| 228 | refuseBox->setBorderRight(7); |
---|
| 229 | refuseBox->setBorderLeft(7); |
---|
| 230 | refuseBox->setBorderBottom(7); |
---|
[10167] | 231 | refuseBox->pack(refuseButton); |
---|
| 232 | } |
---|
[10334] | 233 | answerBox->setBorderTop(15); |
---|
[10265] | 234 | answerBox->setBorderRight(0); |
---|
| 235 | answerBox->setBorderLeft(0); |
---|
[10273] | 236 | answerBox->setBorderBottom(20); |
---|
[10167] | 237 | answerBox->pack(refuseBox); |
---|
[10069] | 238 | } |
---|
| 239 | this->questBox->pack(headerBox); |
---|
[10026] | 240 | this->questBox->pack(labelBox); |
---|
[10069] | 241 | this->questBox->pack(rewardBox); |
---|
| 242 | this->questBox->pack(answerBox); |
---|
[10066] | 243 | this->questBox->showAll(); |
---|
[10225] | 244 | |
---|
[10222] | 245 | this->questBox->setAbsCoor2D(300, 100); |
---|
[10066] | 246 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
| 247 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
[10026] | 248 | } |
---|
[10492] | 249 | } |
---|
| 250 | |
---|
| 251 | void QuestGUI::stopGUI() |
---|
| 252 | { |
---|
[10129] | 253 | this->bKillGui = true; |
---|
[10026] | 254 | } |
---|
| 255 | |
---|
[10225] | 256 | |
---|
[10129] | 257 | void QuestGUI::tick(float dt) |
---|
| 258 | { |
---|
| 259 | if( this->bKillGui) |
---|
| 260 | this->killgui(); |
---|
| 261 | } |
---|
[10031] | 262 | |
---|
[10225] | 263 | |
---|
[10129] | 264 | void QuestGUI::accept() |
---|
| 265 | { |
---|
[10167] | 266 | this->myQuest->setQuestActive(); |
---|
[10129] | 267 | this->bKillGui = true; |
---|
[10277] | 268 | bActive=true; |
---|
[10129] | 269 | } |
---|
[10026] | 270 | |
---|
[10129] | 271 | void QuestGUI::refuse() |
---|
| 272 | { |
---|
| 273 | this->bKillGui = true; |
---|
[10277] | 274 | bActive=false; |
---|
[10129] | 275 | } |
---|
[10026] | 276 | |
---|
[10129] | 277 | void QuestGUI::killgui() |
---|
| 278 | { |
---|
| 279 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
| 280 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
| 281 | delete this->questBox; |
---|
| 282 | this->questBox = NULL; |
---|
[10334] | 283 | this->bKillGui = false; |
---|
[10492] | 284 | this->bActive = false; |
---|
[10129] | 285 | } |
---|