/* 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: Andreas Hejj */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #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.h" #include "menu/glgui_imagebutton.h" #include "glgui_text.h" #include "shell_command.h" ObjectListDefinition(QuestGUI); CREATE_FACTORY(QuestGUI); SHELL_COMMAND(gui, QuestGUI, guiInit); QuestGUI::QuestGUI(const TiXmlElement* root) { this->registerObject(this, QuestGUI::_objectList); this->toList(OM_GROUP_00); if( root != NULL) this->loadParams(root); } /** * deconstructor */ QuestGUI::~QuestGUI () { } /** * loads the xml tags * @param root: root xml tag for this element */ void QuestGUI::loadParams(const TiXmlElement* root) { WorldEntity::loadParams(root); LoadParam(root, "quest-name", this, QuestGUI, setQuestName) .describe("sets the name of a quest"); LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription) .describe("sets the description of a quest"); this->mainMenuBox = NULL; this->levelsBox = NULL; this->levelsBox = NULL; this->currentlyOpened = NULL; } /** * initializes the gui */ void QuestGUI::guiInit() { if (mainMenuBox == NULL) { this->mainMenuBox = new OrxGui::GLGuiBox(); { OrxGui::GLGuiButton* startButton = new OrxGui::GLGuiPushButton("Quests"); startButton->released.connect(this, &QuestGUI::showQuest); this->mainMenuBox->pack(startButton); startButton->select(); OrxGui::GLGuiButton* networkButton = new OrxGui::GLGuiPushButton("MultiPlayer"); //networkButton->released.connect(this, &QuestGUI::showMultiPlayer); this->mainMenuBox->pack(networkButton); OrxGui::GLGuiButton* optionsButton = new OrxGui::GLGuiPushButton("Options"); //optionsButton->released.connect(this, &QuestGUI::showOptionsMenu); this->mainMenuBox->pack(optionsButton); OrxGui::GLGuiButton* quitButton = new OrxGui::GLGuiPushButton("Quit"); this->mainMenuBox->pack(quitButton); quitButton->released.connect(this, &QuestGUI::quitMenu); } this->mainMenuBox->showAll(); this->mainMenuBox->setRelCoor2D(200, 100); OrxGui::GLGuiHandler::getInstance()->activate(); OrxGui::GLGuiHandler::getInstance()->activateCursor(); } else { OrxGui::GLGuiHandler::getInstance()->deactivate(); OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); delete this->mainMenuBox; this->mainMenuBox = NULL; } } void QuestGUI::showQuest() { if (this->questBox== NULL) { this->questBox= new OrxGui::GLGuiBox(OrxGui::Horizontal); OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(); OrxGui::GLGuiImage* image = new OrxGui::GLGuiImage(); image->show(); image->setWidgetSize( 250, 200); image->setAbsCoor2D(400, 150); image->setForegroundColor(Color( 1,1,1,.6)); this->questBox->pack(labelBox); this->questBox->pack(image); } this->showSecondLevelElement(this->questBox); } void QuestGUI::showSecondLevelElement(OrxGui::GLGuiBox* element) { if (this->currentlyOpened != NULL && this->currentlyOpened != element) this->currentlyOpened->hideAll(); element->showAll(); element->setRelCoor2D(200, 100); this->currentlyOpened = element; this->mainMenuBox->setRelCoorSoft2D(50, 100, 5); } void QuestGUI::quitMenu() { delete this->mainMenuBox; this->mainMenuBox = NULL; }