Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/world_entities/questGUI/questGUI.cc @ 10026

Last change on this file since 10026 was 10026, checked in by hejja, 17 years ago

added new quest gui

File size: 3.9 KB
Line 
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
21
22#include "questGUI.h"
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"
40
41
42#include "shell_command.h"
43
44
45
46
47ObjectListDefinition(QuestGUI);
48
49CREATE_FACTORY(QuestGUI);
50SHELL_COMMAND(gui, QuestGUI, guiInit);
51
52
53QuestGUI::QuestGUI(const TiXmlElement* root)
54{
55  this->registerObject(this, QuestGUI::_objectList);
56
57  this->toList(OM_GROUP_00);
58 
59
60  if( root != NULL)
61    this->loadParams(root);
62
63}
64
65
66/**
67 * deconstructor
68 */
69QuestGUI::~QuestGUI () 
70{
71}
72
73
74
75
76/**
77 * loads the xml tags
78 * @param root: root xml tag for this element
79 */
80void QuestGUI::loadParams(const TiXmlElement* root)
81{
82   WorldEntity::loadParams(root);
83   
84   LoadParam(root, "quest-name", this, QuestGUI, setQuestName)
85       .describe("sets the name of a quest");
86   LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription)
87       .describe("sets the description of a quest");
88
89   this->mainMenuBox = NULL;
90
91   this->levelsBox = NULL;
92   
93   this->levelsBox = NULL;
94
95   this->currentlyOpened = NULL;
96}
97
98
99/**
100 * initializes the gui
101 */
102void QuestGUI::guiInit()
103{
104
105  if (mainMenuBox == NULL)
106  {
107    this->mainMenuBox = new OrxGui::GLGuiBox();
108    {
109      OrxGui::GLGuiButton* startButton = new OrxGui::GLGuiPushButton("Quests");
110      startButton->released.connect(this, &QuestGUI::showQuest);
111      this->mainMenuBox->pack(startButton);
112      startButton->select();
113
114      OrxGui::GLGuiButton* networkButton = new OrxGui::GLGuiPushButton("MultiPlayer");
115      //networkButton->released.connect(this, &QuestGUI::showMultiPlayer);
116      this->mainMenuBox->pack(networkButton);
117
118      OrxGui::GLGuiButton* optionsButton = new OrxGui::GLGuiPushButton("Options");
119      //optionsButton->released.connect(this, &QuestGUI::showOptionsMenu);
120      this->mainMenuBox->pack(optionsButton);
121
122
123      OrxGui::GLGuiButton* quitButton = new OrxGui::GLGuiPushButton("Quit");
124      this->mainMenuBox->pack(quitButton);
125      quitButton->released.connect(this, &QuestGUI::quitMenu);
126    }
127 
128    this->mainMenuBox->showAll();
129
130    this->mainMenuBox->setRelCoor2D(200, 100); 
131 
132    OrxGui::GLGuiHandler::getInstance()->activate();
133    OrxGui::GLGuiHandler::getInstance()->activateCursor();
134  }
135  else
136  {
137    OrxGui::GLGuiHandler::getInstance()->deactivate();
138    OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
139    delete this->mainMenuBox;
140    this->mainMenuBox = NULL;
141  }
142 
143}
144
145void QuestGUI::showQuest()
146{
147  if (this->questBox== NULL)
148  {
149    this->questBox= new OrxGui::GLGuiBox(OrxGui::Horizontal);
150   
151    OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox();
152
153    OrxGui::GLGuiImage* image = new OrxGui::GLGuiImage();
154    image->show();
155    image->setWidgetSize( 250, 200);
156    image->setAbsCoor2D(400, 150);
157    image->setForegroundColor(Color( 1,1,1,.6));
158   
159    this->questBox->pack(labelBox);
160    this->questBox->pack(image);
161  }
162 
163  this->showSecondLevelElement(this->questBox);
164
165}
166
167void QuestGUI::showSecondLevelElement(OrxGui::GLGuiBox* element)
168{
169  if (this->currentlyOpened != NULL && this->currentlyOpened != element)
170    this->currentlyOpened->hideAll();
171
172  element->showAll();
173  element->setRelCoor2D(200, 100);
174
175  this->currentlyOpened = element;
176
177  this->mainMenuBox->setRelCoorSoft2D(50, 100, 5);
178}
179
180void QuestGUI::quitMenu()
181{
182  delete this->mainMenuBox;
183  this->mainMenuBox = NULL;
184}
185
186
187
188
Note: See TracBrowser for help on using the repository browser.