[10026] | 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: |
---|
[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 | |
---|
[10213] | 73 | this->background = "maps/pogo_bunny.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); |
---|
[10129] | 110 | this->bKillGui = false; |
---|
[10213] | 111 | this->questBox->setBackgroundTexture(background); |
---|
[10026] | 112 | |
---|
[10069] | 113 | OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 114 | { |
---|
| 115 | OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage(); |
---|
[10213] | 116 | questImage->setWidgetSize(100, 100); |
---|
[10211] | 117 | |
---|
[10129] | 118 | questImage->loadImageFromFile(this->myQuest->getQuestPicture()); |
---|
[10069] | 119 | questImage->show(); |
---|
[10213] | 120 | headerBox->setBackgroundTexture("maps/pogo_bunny.png"); |
---|
[10069] | 121 | headerBox->pack(questImage); |
---|
| 122 | |
---|
| 123 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 124 | { |
---|
[10164] | 125 | OrxGui::GLGuiMultiLineText* questDifficulty = new OrxGui::GLGuiMultiLineText(); |
---|
[10129] | 126 | questDifficulty->setText(this->myQuest->getQuestDifficulty()); |
---|
[10213] | 127 | outlineBox->setBackgroundTexture("pogo_bunny.png"); |
---|
[10069] | 128 | outlineBox->pack(questDifficulty); |
---|
| 129 | } |
---|
[10167] | 130 | headerBox->setBorderBottom(40); |
---|
[10069] | 131 | headerBox->pack(outlineBox); |
---|
| 132 | } |
---|
[10031] | 133 | |
---|
[10069] | 134 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 135 | { |
---|
[10164] | 136 | OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10213] | 137 | questTxt->setText(this->myQuest->getQuestDescription()); |
---|
[10069] | 138 | labelBox->pack(questTxt); |
---|
[10167] | 139 | labelBox->setBorderBottom(40); |
---|
[10069] | 140 | } |
---|
[10066] | 141 | |
---|
[10026] | 142 | |
---|
[10069] | 143 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 144 | { |
---|
| 145 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
| 146 | rewardImage->setWidgetSize(50, 50); |
---|
[10129] | 147 | rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); |
---|
[10069] | 148 | rewardImage->show(); |
---|
| 149 | rewardBox->pack(rewardImage); |
---|
[10066] | 150 | |
---|
[10164] | 151 | OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10129] | 152 | rewardTxt->setText(this->myQuest->getRewardDescription()); |
---|
[10167] | 153 | rewardBox->setBorderBottom(40); |
---|
[10069] | 154 | rewardBox->pack(rewardTxt); |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 158 | { |
---|
[10167] | 159 | OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 160 | { |
---|
| 161 | OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept"); |
---|
| 162 | acceptButton->released.connect(this, &QuestGUI::accept); |
---|
| 163 | acceptBox->setBorderRight(70); |
---|
| 164 | acceptBox->pack(acceptButton); |
---|
| 165 | } |
---|
[10069] | 166 | |
---|
[10167] | 167 | OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 168 | { |
---|
| 169 | OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse"); |
---|
| 170 | refuseButton->released.connect(this, &QuestGUI::refuse); |
---|
| 171 | refuseBox->setBorderLeft(0); |
---|
| 172 | refuseBox->pack(refuseButton); |
---|
| 173 | } |
---|
| 174 | answerBox->pack(acceptBox); |
---|
| 175 | answerBox->pack(refuseBox); |
---|
[10069] | 176 | } |
---|
| 177 | this->questBox->pack(headerBox); |
---|
[10026] | 178 | this->questBox->pack(labelBox); |
---|
[10069] | 179 | this->questBox->pack(rewardBox); |
---|
| 180 | this->questBox->pack(answerBox); |
---|
[10066] | 181 | this->questBox->showAll(); |
---|
| 182 | |
---|
[10164] | 183 | this->questBox->setAbsCoor2D(300, 200); |
---|
[10066] | 184 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
| 185 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
[10026] | 186 | } |
---|
[10066] | 187 | else |
---|
| 188 | { |
---|
[10129] | 189 | this->bKillGui = true; |
---|
[10066] | 190 | } |
---|
[10026] | 191 | |
---|
| 192 | } |
---|
| 193 | |
---|
[10129] | 194 | |
---|
| 195 | void QuestGUI::tick(float dt) |
---|
| 196 | { |
---|
| 197 | if( this->bKillGui) |
---|
| 198 | this->killgui(); |
---|
| 199 | } |
---|
| 200 | |
---|
[10031] | 201 | |
---|
[10129] | 202 | void QuestGUI::accept() |
---|
| 203 | { |
---|
[10167] | 204 | this->myQuest->setQuestActive(); |
---|
[10129] | 205 | this->bKillGui = true; |
---|
| 206 | } |
---|
[10026] | 207 | |
---|
[10129] | 208 | void QuestGUI::refuse() |
---|
| 209 | { |
---|
| 210 | this->bKillGui = true; |
---|
| 211 | } |
---|
[10026] | 212 | |
---|
[10129] | 213 | void QuestGUI::killgui() |
---|
| 214 | { |
---|
| 215 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
| 216 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
| 217 | delete this->questBox; |
---|
| 218 | this->questBox = NULL; |
---|
| 219 | } |
---|