[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 | SHELL_COMMAND(gui, QuestGUI, guiInit); |
---|
[10225] | 57 | //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); |
---|
[10026] | 58 | |
---|
| 59 | |
---|
[10265] | 60 | #include "script_class.h" |
---|
| 61 | CREATE_SCRIPTABLE_CLASS(QuestGUI, |
---|
| 62 | addMethod("guiInit", Executor0<QuestGUI, lua_State*>(&QuestGUI::guiInit)) |
---|
| 63 | ); |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | |
---|
[10026] | 67 | QuestGUI::QuestGUI(const TiXmlElement* root) |
---|
| 68 | { |
---|
[10265] | 69 | if (root != NULL) |
---|
| 70 | { |
---|
[10026] | 71 | this->registerObject(this, QuestGUI::_objectList); |
---|
[10225] | 72 | |
---|
[10026] | 73 | this->toList(OM_GROUP_00); |
---|
[10225] | 74 | |
---|
| 75 | this->questBox = NULL; |
---|
| 76 | |
---|
[10129] | 77 | this->bKillGui = false; |
---|
[10026] | 78 | |
---|
[10265] | 79 | this->background = "maps/rand2.png"; |
---|
| 80 | |
---|
| 81 | this->backgroundBottom = "maps/rand-untent.png"; |
---|
[10225] | 82 | |
---|
[10129] | 83 | this->myQuest = new Quest(root); |
---|
| 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 | */ |
---|
| 113 | void QuestGUI::guiInit() |
---|
[10225] | 114 | { |
---|
[10066] | 115 | if (questBox == NULL) |
---|
[10026] | 116 | { |
---|
[10069] | 117 | this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10222] | 118 | questBox->setBorderTop(10); |
---|
| 119 | questBox->setBorderRight(10); |
---|
| 120 | questBox->setBorderLeft(10); |
---|
[10265] | 121 | questBox->setBorderBottom(10); |
---|
[10222] | 122 | this->questBox->setBackgroundTexture(background); |
---|
[10129] | 123 | this->bKillGui = false; |
---|
[10225] | 124 | |
---|
[10069] | 125 | OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 126 | { |
---|
[10265] | 127 | headerBox->setBackgroundTexture(backgroundBottom); |
---|
[10069] | 128 | OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage(); |
---|
[10213] | 129 | questImage->setWidgetSize(100, 100); |
---|
[10129] | 130 | questImage->loadImageFromFile(this->myQuest->getQuestPicture()); |
---|
[10069] | 131 | questImage->show(); |
---|
| 132 | headerBox->pack(questImage); |
---|
[10225] | 133 | |
---|
[10069] | 134 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[10265] | 135 | { |
---|
[10222] | 136 | OrxGui::GLGuiMultiLineText* questDetails = new OrxGui::GLGuiMultiLineText(); |
---|
| 137 | questDetails->setText(this->myQuest->getQuestDifficulty()); |
---|
| 138 | questDetails->append(this->myQuest->getQuestPersons()); |
---|
| 139 | outlineBox->setBorderTop(0); |
---|
| 140 | outlineBox->setBorderRight(0); |
---|
| 141 | outlineBox->setBorderLeft(0); |
---|
[10265] | 142 | outlineBox->setBorderBottom(10); |
---|
[10222] | 143 | outlineBox->pack(questDetails); |
---|
[10069] | 144 | } |
---|
[10222] | 145 | headerBox->setBorderTop(0); |
---|
| 146 | headerBox->setBorderRight(0); |
---|
| 147 | headerBox->setBorderLeft(0); |
---|
[10265] | 148 | headerBox->setBorderBottom(10); |
---|
[10069] | 149 | headerBox->pack(outlineBox); |
---|
| 150 | } |
---|
[10225] | 151 | |
---|
[10265] | 152 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
[10225] | 153 | { |
---|
[10265] | 154 | labelBox->setWidgetSize(500,500); |
---|
| 155 | labelBox->setBackgroundTexture(backgroundBottom); |
---|
[10164] | 156 | OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10213] | 157 | questTxt->setText(this->myQuest->getQuestDescription()); |
---|
[10265] | 158 | //questTxt->setLineWidth( 400); |
---|
| 159 | labelBox->pack(questTxt); |
---|
[10222] | 160 | labelBox->setBorderTop(0); |
---|
| 161 | labelBox->setBorderRight(0); |
---|
[10265] | 162 | labelBox->setBorderLeft(40); |
---|
| 163 | labelBox->setBorderBottom(10); |
---|
[10069] | 164 | } |
---|
[10225] | 165 | |
---|
| 166 | |
---|
[10265] | 167 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
[10069] | 168 | { |
---|
| 169 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
[10265] | 170 | rewardImage->setWidgetSize(100, 100); |
---|
[10129] | 171 | rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); |
---|
[10069] | 172 | rewardImage->show(); |
---|
| 173 | rewardBox->pack(rewardImage); |
---|
[10225] | 174 | |
---|
[10164] | 175 | OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); |
---|
[10129] | 176 | rewardTxt->setText(this->myQuest->getRewardDescription()); |
---|
[10222] | 177 | rewardBox->setBorderTop(0); |
---|
| 178 | rewardBox->setBorderRight(0); |
---|
| 179 | rewardBox->setBorderLeft(0); |
---|
[10265] | 180 | rewardBox->setBorderBottom(10); |
---|
[10069] | 181 | rewardBox->pack(rewardTxt); |
---|
| 182 | } |
---|
[10225] | 183 | |
---|
[10069] | 184 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 185 | { |
---|
[10167] | 186 | OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 187 | { |
---|
| 188 | OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept"); |
---|
| 189 | acceptButton->released.connect(this, &QuestGUI::accept); |
---|
[10265] | 190 | acceptBox->setBorderLeft(50); |
---|
| 191 | acceptBox->setBorderRight(150); |
---|
[10167] | 192 | acceptBox->pack(acceptButton); |
---|
| 193 | } |
---|
[10225] | 194 | |
---|
[10167] | 195 | OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 196 | { |
---|
| 197 | OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse"); |
---|
| 198 | refuseButton->released.connect(this, &QuestGUI::refuse); |
---|
| 199 | refuseBox->setBorderLeft(0); |
---|
| 200 | refuseBox->pack(refuseButton); |
---|
| 201 | } |
---|
[10265] | 202 | answerBox->setBorderTop(0); |
---|
| 203 | answerBox->setBorderRight(0); |
---|
| 204 | answerBox->setBorderLeft(0); |
---|
| 205 | answerBox->setBorderBottom(0); |
---|
[10167] | 206 | answerBox->pack(acceptBox); |
---|
| 207 | answerBox->pack(refuseBox); |
---|
[10069] | 208 | } |
---|
| 209 | this->questBox->pack(headerBox); |
---|
[10026] | 210 | this->questBox->pack(labelBox); |
---|
[10069] | 211 | this->questBox->pack(rewardBox); |
---|
| 212 | this->questBox->pack(answerBox); |
---|
[10066] | 213 | this->questBox->showAll(); |
---|
[10225] | 214 | |
---|
[10222] | 215 | this->questBox->setAbsCoor2D(300, 100); |
---|
[10066] | 216 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
| 217 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
[10026] | 218 | } |
---|
[10066] | 219 | else |
---|
| 220 | { |
---|
[10129] | 221 | this->bKillGui = true; |
---|
[10066] | 222 | } |
---|
[10225] | 223 | |
---|
[10026] | 224 | } |
---|
| 225 | |
---|
[10225] | 226 | |
---|
[10129] | 227 | void QuestGUI::tick(float dt) |
---|
| 228 | { |
---|
| 229 | if( this->bKillGui) |
---|
| 230 | this->killgui(); |
---|
| 231 | } |
---|
[10031] | 232 | |
---|
[10225] | 233 | |
---|
[10129] | 234 | void QuestGUI::accept() |
---|
| 235 | { |
---|
[10167] | 236 | this->myQuest->setQuestActive(); |
---|
[10129] | 237 | this->bKillGui = true; |
---|
| 238 | } |
---|
[10026] | 239 | |
---|
[10129] | 240 | void QuestGUI::refuse() |
---|
| 241 | { |
---|
| 242 | this->bKillGui = true; |
---|
| 243 | } |
---|
[10026] | 244 | |
---|
[10129] | 245 | void QuestGUI::killgui() |
---|
| 246 | { |
---|
| 247 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
| 248 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
| 249 | delete this->questBox; |
---|
| 250 | this->questBox = NULL; |
---|
| 251 | } |
---|