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 | #include "debug.h" |
---|
22 | #include "quest_gui.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 | #include <glgui_image.h> |
---|
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); |
---|
52 | //SHELL_COMMAND(cancel, QuestGUI, guiDestruct); |
---|
53 | |
---|
54 | |
---|
55 | QuestGUI::QuestGUI(const TiXmlElement* root) |
---|
56 | { |
---|
57 | this->registerObject(this, QuestGUI::_objectList); |
---|
58 | |
---|
59 | this->toList(OM_GROUP_00); |
---|
60 | |
---|
61 | this->questBox = NULL; |
---|
62 | |
---|
63 | this->currentlyOpened = NULL; |
---|
64 | |
---|
65 | |
---|
66 | if( root != NULL) |
---|
67 | this->loadParams(root); |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | /** |
---|
73 | * deconstructor |
---|
74 | */ |
---|
75 | QuestGUI::~QuestGUI () |
---|
76 | { |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | /** |
---|
83 | * loads the xml tagsthis->questDescription |
---|
84 | * @param root: root xml tag for this element |
---|
85 | */ |
---|
86 | void QuestGUI::loadParams(const TiXmlElement* root) |
---|
87 | { |
---|
88 | WorldEntity::loadParams(root); |
---|
89 | |
---|
90 | LoadParam(root, "quest-name", this, QuestGUI, setQuestName) |
---|
91 | .describe("sets the name of a quest"); |
---|
92 | LoadParam(root, "quest-description", this, QuestGUI, setQuestDescription) |
---|
93 | .describe("sets the description of a quest"); |
---|
94 | LoadParam(root, "quest-picture", this, QuestGUI, setQuestPicture) |
---|
95 | .describe("sets the picture of a quest"); |
---|
96 | LoadParam(root, "quest-outline", this, QuestGUI, setQuestOutline) |
---|
97 | .describe("sets the outline of a quiest"); |
---|
98 | |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | /** |
---|
103 | * initializes the gui |
---|
104 | */ |
---|
105 | void QuestGUI::guiInit() |
---|
106 | { |
---|
107 | if (questBox == NULL) |
---|
108 | { |
---|
109 | this->questBox= new OrxGui::GLGuiBox(); |
---|
110 | |
---|
111 | OrxGui::GLGuiBox* labelBox = new OrxGui::GLGuiBox(OrxGui::Horizontal); |
---|
112 | //labelBox->setWidgetSize(100, 200); |
---|
113 | |
---|
114 | OrxGui::GLGuiText* questTxt = new OrxGui::GLGuiText(); |
---|
115 | questTxt->setText(this->questDescription); |
---|
116 | labelBox->pack(questTxt); |
---|
117 | |
---|
118 | OrxGui::GLGuiImage* image = new OrxGui::GLGuiImage(); |
---|
119 | image->setWidgetSize(100, 100); |
---|
120 | image->loadImageFromFile(questPicture); |
---|
121 | image->show(); |
---|
122 | |
---|
123 | this->questBox->setAbsCoor2D(300, 40); |
---|
124 | labelBox->setRelCoor2D(300, 300); |
---|
125 | image->setRelCoor2D(0, 0); |
---|
126 | |
---|
127 | this->questBox->pack(image); |
---|
128 | this->questBox->pack(labelBox); |
---|
129 | this->questBox->showAll(); |
---|
130 | |
---|
131 | OrxGui::GLGuiHandler::getInstance()->activate(); |
---|
132 | OrxGui::GLGuiHandler::getInstance()->activateCursor(); |
---|
133 | } |
---|
134 | else |
---|
135 | { |
---|
136 | OrxGui::GLGuiHandler::getInstance()->deactivate(); |
---|
137 | OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); |
---|
138 | delete this->questBox; |
---|
139 | this->questBox = NULL; |
---|
140 | } |
---|
141 | |
---|
142 | } |
---|
143 | |
---|
144 | |
---|
145 | |
---|
146 | |
---|