[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 | |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | ObjectListDefinition(QuestGUI); |
---|
| 57 | |
---|
| 58 | CREATE_FACTORY(QuestGUI); |
---|
| 59 | SHELL_COMMAND(gui, QuestGUI, guiInit); |
---|
[10066] | 60 | //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); |
---|
[10026] | 61 | |
---|
| 62 | |
---|
| 63 | QuestGUI::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 | |
---|
[10222] | 73 | this->background = "maps/rand2.png"; |
---|
[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 | */ |
---|
| 85 | QuestGUI::~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 | */ |
---|
| 95 | void QuestGUI::loadParams(const TiXmlElement* root) |
---|
| 96 | { |
---|
[10129] | 97 | WorldEntity::loadParams(root); |
---|
[10026] | 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
[10129] | 101 | |
---|
[10026] | 102 | /** |
---|
| 103 | * initializes the gui |
---|
| 104 | */ |
---|
| 105 | void QuestGUI::guiInit() |
---|
[10031] | 106 | { |
---|
[10066] | 107 | if (questBox == NULL) |
---|
[10026] | 108 | { |
---|
[10069] | 109 | this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10222] | 110 | questBox->setBorderTop(10); |
---|
| 111 | questBox->setBorderRight(10); |
---|
| 112 | questBox->setBorderBottom(20); |
---|
| 113 | questBox->setBorderLeft(10); |
---|
| 114 | this->questBox->setBackgroundTexture(background); |
---|
[10129] | 115 | this->bKillGui = false; |
---|
[10026] | 116 | |
---|
[10069] | 117 | OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 118 | { |
---|
| 119 | OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage(); |
---|
[10213] | 120 | questImage->setWidgetSize(100, 100); |
---|
[10129] | 121 | questImage->loadImageFromFile(this->myQuest->getQuestPicture()); |
---|
[10069] | 122 | questImage->show(); |
---|
| 123 | headerBox->pack(questImage); |
---|
| 124 | |
---|
| 125 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 126 | { |
---|
[10222] | 127 | OrxGui::GLGuiMultiLineText* questDetails = new OrxGui::GLGuiMultiLineText(); |
---|
| 128 | questDetails->setText(this->myQuest->getQuestDifficulty()); |
---|
| 129 | questDetails->append(this->myQuest->getQuestPersons()); |
---|
| 130 | outlineBox->setBorderTop(0); |
---|
| 131 | outlineBox->setBorderRight(0); |
---|
| 132 | outlineBox->setBorderBottom(20); |
---|
| 133 | outlineBox->setBorderLeft(0); |
---|
| 134 | outlineBox->pack(questDetails); |
---|
[10069] | 135 | } |
---|
[10222] | 136 | headerBox->setBorderTop(0); |
---|
| 137 | headerBox->setBorderRight(0); |
---|
| 138 | headerBox->setBorderBottom(20); |
---|
| 139 | headerBox->setBorderLeft(0); |
---|
[10069] | 140 | headerBox->pack(outlineBox); |
---|
| 141 | } |
---|
[10031] | 142 | |
---|
[10069] | 143 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 144 | { |
---|
[10164] | 145 | OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10213] | 146 | questTxt->setText(this->myQuest->getQuestDescription()); |
---|
[10222] | 147 | labelBox->setBorderTop(0); |
---|
| 148 | labelBox->setBorderRight(0); |
---|
| 149 | labelBox->setBorderBottom(20); |
---|
| 150 | labelBox->setBorderLeft(0); |
---|
[10069] | 151 | labelBox->pack(questTxt); |
---|
| 152 | } |
---|
[10066] | 153 | |
---|
[10026] | 154 | |
---|
[10069] | 155 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 156 | { |
---|
| 157 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
| 158 | rewardImage->setWidgetSize(50, 50); |
---|
[10129] | 159 | rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); |
---|
[10069] | 160 | rewardImage->show(); |
---|
| 161 | rewardBox->pack(rewardImage); |
---|
[10066] | 162 | |
---|
[10164] | 163 | OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10129] | 164 | rewardTxt->setText(this->myQuest->getRewardDescription()); |
---|
[10222] | 165 | rewardBox->setBorderTop(0); |
---|
| 166 | rewardBox->setBorderRight(0); |
---|
| 167 | rewardBox->setBorderBottom(20); |
---|
| 168 | rewardBox->setBorderLeft(0); |
---|
[10069] | 169 | rewardBox->pack(rewardTxt); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 173 | { |
---|
[10167] | 174 | OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 175 | { |
---|
| 176 | OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept"); |
---|
| 177 | acceptButton->released.connect(this, &QuestGUI::accept); |
---|
| 178 | acceptBox->setBorderRight(70); |
---|
| 179 | acceptBox->pack(acceptButton); |
---|
| 180 | } |
---|
[10069] | 181 | |
---|
[10167] | 182 | OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 183 | { |
---|
| 184 | OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse"); |
---|
| 185 | refuseButton->released.connect(this, &QuestGUI::refuse); |
---|
| 186 | refuseBox->setBorderLeft(0); |
---|
| 187 | refuseBox->pack(refuseButton); |
---|
| 188 | } |
---|
| 189 | answerBox->pack(acceptBox); |
---|
| 190 | answerBox->pack(refuseBox); |
---|
[10069] | 191 | } |
---|
| 192 | this->questBox->pack(headerBox); |
---|
[10026] | 193 | this->questBox->pack(labelBox); |
---|
[10069] | 194 | this->questBox->pack(rewardBox); |
---|
| 195 | this->questBox->pack(answerBox); |
---|
[10066] | 196 | this->questBox->showAll(); |
---|
| 197 | |
---|
[10222] | 198 | this->questBox->setAbsCoor2D(300, 100); |
---|
[10066] | 199 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
| 200 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
[10026] | 201 | } |
---|
[10066] | 202 | else |
---|
| 203 | { |
---|
[10129] | 204 | this->bKillGui = true; |
---|
[10066] | 205 | } |
---|
[10026] | 206 | |
---|
| 207 | } |
---|
| 208 | |
---|
[10129] | 209 | |
---|
| 210 | void QuestGUI::tick(float dt) |
---|
| 211 | { |
---|
| 212 | if( this->bKillGui) |
---|
| 213 | this->killgui(); |
---|
| 214 | } |
---|
| 215 | |
---|
[10031] | 216 | |
---|
[10129] | 217 | void QuestGUI::accept() |
---|
| 218 | { |
---|
[10167] | 219 | this->myQuest->setQuestActive(); |
---|
[10129] | 220 | this->bKillGui = true; |
---|
| 221 | } |
---|
[10026] | 222 | |
---|
[10129] | 223 | void QuestGUI::refuse() |
---|
| 224 | { |
---|
| 225 | this->bKillGui = true; |
---|
| 226 | } |
---|
[10026] | 227 | |
---|
[10129] | 228 | void QuestGUI::killgui() |
---|
| 229 | { |
---|
| 230 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
| 231 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
| 232 | delete this->questBox; |
---|
| 233 | this->questBox = NULL; |
---|
| 234 | } |
---|