xoreos  0.0.5
charfeatspopup.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/aurora/talkman.h"
26 #include "src/aurora/2dareg.h"
27 #include "src/aurora/2dafile.h"
28 
32 
33 namespace Engines {
34 
35 namespace NWN {
36 
38  load("cg_feats_popup");
39 
40  setPosition(0, 0, -220);
41 
42  _chosenFeat.featId = 0xFFFFFFFF;
43 
44  getButton("OkButton", true)->setDisabled(true);
45 }
46 
48 }
49 
50 void CharFeatsPopup::setFeats(std::vector<FeatItem> feats) {
51  _feats = feats;
52 
53  Engines::NWN::WidgetListBox *featBox = getListBox("FeatsList", true);
54  featBox->lock();
55  featBox->clear();
57  for (std::vector<FeatItem>::iterator f = feats.begin(); f != feats.end(); ++f) {
58  WidgetListItemTextLine *item = new WidgetListItemTextLine(*this, "fnt_galahad14", (*f).name);
59  featBox->add(item);
60  }
61  featBox->unlock();
62 }
63 
65  return _chosenFeat;
66 }
67 
69  if (widget.getTag() == "OkButton") {
70  _chosenFeat = _feats[getListBox("FeatsList", true)->getSelected()];
71 
72  _returnCode = 2;
73  return;
74  }
75 
76  if (widget.getTag() == "CancelButton") {
77  _chosenFeat.featId = 0xFFFFFFFF;
78  getListBox("FeatsList", true)->deselect();
79  getButton("OkButton", true)->setDisabled(true);
80 
81  _returnCode = 1;
82  return;
83  }
84 
85  if (widget.getTag() == "FeatsList" && getListBox("FeatsList", true)->getSelected() != 0xFFFFFFFF) {
86  getButton("OkButton", true)->setDisabled(false);
87  }
88 }
89 
90 } // End of namespace NWN
91 
92 } // End of namespace Engines
A NWN button widget.
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
void setPosition(float x, float y, float z)
Set the GUI&#39;s position.
Definition: gui.cpp:394
WidgetListBox * getListBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:318
void add(WidgetListItem *item, bool noTag=false)
Definition: listbox.cpp:411
void setFeats(std::vector< FeatItem > feats)
void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: button.cpp:107
Feat popup GUI.
A NWN listbox widget.
WidgetButton * getButton(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:306
size_t getSelected() const
Definition: listbox.cpp:626
A NWN GUI.
Definition: gui.h:54
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
void setMode(Mode mode)
Definition: listbox.cpp:313
Handling BioWare&#39;s 2DAs (two-dimensional array).
void load(const Common::UString &resref)
Definition: gui.cpp:77
CharFeatsPopup(::Engines::Console *console=0)
A NWN listbox widget.
Definition: listbox.h:116
The global 2DA registry.
std::vector< FeatItem > _feats
A widget in a GUI.
Definition: widget.h:40
The global talk manager for Aurora strings.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
A text line widget within a NWN listbox widget.
Definition: listbox.h:82