/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer std::string questName; std::string questDescription; std::string questPicture; std::string questDifficulty; std::string rewardDescription; std::string rewardPicture;: Andreas Hejj */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "debug.h" #include "quest_gui.h" #include "event_handler.h" #include "state.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "graphics_engine.h" #include "camera.h" #include "sound_engine.h" #include "sound_source.h" #include "glgui_widget.h" #include "glgui.h" #include "menu/glgui_imagebutton.h" #include "glgui_multiline_text.h" #include #include "quest.h" #include "shell_command.h" ObjectListDefinition(QuestGUI); CREATE_FACTORY(QuestGUI); SHELL_COMMAND(gui, QuestGUI, guiInit); //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); QuestGUI::QuestGUI(const TiXmlElement* root) { this->registerObject(this, QuestGUI::_objectList); this->toList(OM_GROUP_00); this->questBox = NULL; this->bKillGui = false; this->background = "/pictures/map.jpg"; this->myQuest = new Quest(root); if(root) this->loadParams( root); } /** * deconstructor */ QuestGUI::~QuestGUI () { if( this->myQuest) delete this->myQuest; } /** * loads the xml tagsthis->questDescription * @param root: root xml tag for this element */ void QuestGUI::loadParams(const TiXmlElement* root) { WorldEntity::loadParams(root); } /** * initializes the gui */ void QuestGUI::guiInit() { if (questBox == NULL) { this->questBox= new OrxGui::GLGuiBox(OrxGui::Vertical); this->bKillGui = false; OrxGui::GLGuiBox* headerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); { OrxGui::GLGuiImage* questImage = new OrxGui::GLGuiImage(); questImage->setWidgetSize(100, 100); questImage->loadImageFromFile(this->myQuest->getQuestPicture()); questImage->show(); headerBox->pack(questImage); OrxGui::GLGuiBox* outlineBox = new OrxGui::GLGuiBox(OrxGui::Vertical); { OrxGui::GLGuiMultiLineText* questDifficulty = new OrxGui::GLGuiMultiLineText(); questDifficulty->setText(this->myQuest->getQuestDifficulty()); outlineBox->pack(questDifficulty); } headerBox->setBorderBottom(40); headerBox->pack(outlineBox); } OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Vertical); { OrxGui::GLGuiMultiLineText* questTxt = new OrxGui::GLGuiMultiLineText(); questTxt->setText(this->myQuest->getQuestDescription()); labelBox->pack(questTxt); labelBox->setBorderBottom(40); } OrxGui::GLGuiBox* rewardBox = new OrxGui::GLGuiBox(OrxGui::Vertical); { OrxGui::GLGuiImage* rewardImage = new OrxGui::GLGuiImage(); rewardImage->setWidgetSize(50, 50); rewardImage->loadImageFromFile(this->myQuest->getRewardPicture()); rewardImage->show(); rewardBox->pack(rewardImage); OrxGui::GLGuiMultiLineText* rewardTxt = new OrxGui::GLGuiMultiLineText(); rewardTxt->setText(this->myQuest->getRewardDescription()); rewardBox->setBorderBottom(40); rewardBox->pack(rewardTxt); } OrxGui::GLGuiBox* answerBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); { OrxGui::GLGuiBox* acceptBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); { OrxGui::GLGuiButton* acceptButton = new OrxGui::GLGuiPushButton("Accept"); acceptButton->released.connect(this, &QuestGUI::accept); acceptBox->setBorderRight(70); acceptBox->pack(acceptButton); } OrxGui::GLGuiBox* refuseBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); { OrxGui::GLGuiButton* refuseButton = new OrxGui::GLGuiPushButton("Refuse"); refuseButton->released.connect(this, &QuestGUI::refuse); refuseBox->setBorderLeft(0); refuseBox->pack(refuseButton); } answerBox->pack(acceptBox); answerBox->pack(refuseBox); } this->questBox->pack(headerBox); this->questBox->pack(labelBox); this->questBox->pack(rewardBox); this->questBox->pack(answerBox); this->questBox->showAll(); this->questBox->setAbsCoor2D(300, 200); OrxGui::GLGuiHandler::getInstance()->activate(); OrxGui::GLGuiHandler::getInstance()->activateCursor(); } else { this->bKillGui = true; } } void QuestGUI::tick(float dt) { if( this->bKillGui) this->killgui(); } void QuestGUI::accept() { this->myQuest->setQuestActive(); this->bKillGui = true; } void QuestGUI::refuse() { this->bKillGui = true; } void QuestGUI::killgui() { OrxGui::GLGuiHandler::getInstance()->deactivate(); OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); delete this->questBox; this->questBox = NULL; }