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