[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: |
---|
| 14 | main-programmer: Andreas Hejj |
---|
| 15 | |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 20 | |
---|
[10031] | 21 | #include "debug.h" |
---|
[10027] | 22 | #include "quest_gui.h" |
---|
[10026] | 23 | |
---|
| 24 | #include "event_handler.h" |
---|
| 25 | |
---|
| 26 | #include "state.h" |
---|
| 27 | |
---|
| 28 | #include "util/loading/load_param.h" |
---|
| 29 | #include "util/loading/factory.h" |
---|
| 30 | |
---|
| 31 | #include "graphics_engine.h" |
---|
| 32 | #include "camera.h" |
---|
| 33 | #include "sound_engine.h" |
---|
| 34 | |
---|
| 35 | #include "sound_source.h" |
---|
| 36 | |
---|
| 37 | #include "glgui.h" |
---|
| 38 | #include "menu/glgui_imagebutton.h" |
---|
| 39 | #include "glgui_text.h" |
---|
[10066] | 40 | #include <glgui_image.h> |
---|
[10026] | 41 | |
---|
| 42 | |
---|
| 43 | #include "shell_command.h" |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | ObjectListDefinition(QuestGUI); |
---|
| 49 | |
---|
| 50 | CREATE_FACTORY(QuestGUI); |
---|
| 51 | SHELL_COMMAND(gui, QuestGUI, guiInit); |
---|
[10066] | 52 | //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); |
---|
[10026] | 53 | |
---|
| 54 | |
---|
| 55 | QuestGUI::QuestGUI(const TiXmlElement* root) |
---|
| 56 | { |
---|
| 57 | this->registerObject(this, QuestGUI::_objectList); |
---|
| 58 | |
---|
| 59 | this->toList(OM_GROUP_00); |
---|
| 60 | |
---|
[10069] | 61 | this->questBox = NULL; |
---|
[10026] | 62 | |
---|
| 63 | if( root != NULL) |
---|
| 64 | this->loadParams(root); |
---|
| 65 | |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * deconstructor |
---|
| 71 | */ |
---|
| 72 | QuestGUI::~QuestGUI () |
---|
| 73 | { |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /** |
---|
[10066] | 80 | * loads the xml tagsthis->questDescription |
---|
[10026] | 81 | * @param root: root xml tag for this element |
---|
| 82 | */ |
---|
| 83 | void QuestGUI::loadParams(const TiXmlElement* root) |
---|
| 84 | { |
---|
| 85 | WorldEntity::loadParams(root); |
---|
| 86 | |
---|
| 87 | LoadParam(root, "quest-name", this, QuestGUI, setQuestName) |
---|
| 88 | .describe("sets the name of a quest"); |
---|
| 89 | LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription) |
---|
| 90 | .describe("sets the description of a quest"); |
---|
[10066] | 91 | LoadParam(root, "quest-picture", this, QuestGUI, setQuestPicture) |
---|
| 92 | .describe("sets the picture of a quest"); |
---|
[10069] | 93 | LoadParam(root, "quest-difficulty", this, QuestGUI, setQuestDifficulty) |
---|
| 94 | .describe("sets the difficulty of a quest"); |
---|
| 95 | LoadParam(root, "reward-description", this, QuestGUI, setRewardDescription) |
---|
| 96 | .describe("sets the description of a reward"); |
---|
| 97 | LoadParam(root, "reward-picture", this, QuestGUI, setRewardPicture) |
---|
| 98 | .describe("sets the Picture of a reward"); |
---|
[10066] | 99 | |
---|
[10026] | 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | /** |
---|
| 104 | * initializes the gui |
---|
| 105 | */ |
---|
| 106 | void QuestGUI::guiInit() |
---|
[10031] | 107 | { |
---|
[10066] | 108 | if (questBox == NULL) |
---|
[10026] | 109 | { |
---|
[10069] | 110 | this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
[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); |
---|
| 116 | questImage->loadImageFromFile(questPicture); |
---|
| 117 | questImage->show(); |
---|
| 118 | headerBox->pack(questImage); |
---|
| 119 | |
---|
| 120 | OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 121 | { |
---|
| 122 | OrxGui::GLGuiText* questDifficulty = new OrxGui::GLGuiText(); |
---|
| 123 | questDifficulty->setText(this->questDifficulty); |
---|
| 124 | outlineBox->pack(questDifficulty); |
---|
| 125 | } |
---|
| 126 | headerBox->pack(outlineBox); |
---|
| 127 | |
---|
| 128 | } |
---|
[10031] | 129 | |
---|
[10069] | 130 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 131 | { |
---|
| 132 | OrxGui::GLGuiText* questTxt = new OrxGui::GLGuiText(); |
---|
| 133 | questTxt->setText(this->questDescription); |
---|
| 134 | labelBox->pack(questTxt); |
---|
| 135 | } |
---|
[10066] | 136 | |
---|
[10026] | 137 | |
---|
[10069] | 138 | OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical); |
---|
| 139 | { |
---|
| 140 | OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); |
---|
| 141 | rewardImage->setWidgetSize(50, 50); |
---|
| 142 | rewardImage->loadImageFromFile(rewardPicture); |
---|
| 143 | rewardImage->show(); |
---|
| 144 | rewardBox->pack(rewardImage); |
---|
[10066] | 145 | |
---|
[10069] | 146 | OrxGui::GLGuiText* rewardTxt = new OrxGui::GLGuiText(); |
---|
| 147 | rewardTxt->setText(this->rewardDescription); |
---|
| 148 | rewardBox->pack(rewardTxt); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
| 152 | { |
---|
| 153 | OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept"); |
---|
| 154 | answerBox->pack(acceptButton); |
---|
| 155 | |
---|
| 156 | OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse"); |
---|
| 157 | answerBox->pack(refuseButton); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | this->questBox->pack(headerBox); |
---|
[10026] | 161 | this->questBox->pack(labelBox); |
---|
[10069] | 162 | this->questBox->pack(rewardBox); |
---|
| 163 | this->questBox->pack(answerBox); |
---|
[10066] | 164 | this->questBox->showAll(); |
---|
| 165 | |
---|
[10069] | 166 | this->questBox->setAbsCoor2D(300, 40); |
---|
[10066] | 167 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
| 168 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
[10026] | 169 | } |
---|
[10066] | 170 | else |
---|
| 171 | { |
---|
| 172 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
| 173 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
| 174 | delete this->questBox; |
---|
| 175 | this->questBox = NULL; |
---|
| 176 | } |
---|
[10026] | 177 | |
---|
| 178 | } |
---|
| 179 | |
---|
[10031] | 180 | |
---|
[10026] | 181 | |
---|
| 182 | |
---|