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