xoreos  0.0.5
chargen.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 
26 
27 #include "src/engines/nwn/module.h"
29 
39 
41 
42 namespace Engines {
43 
44 namespace NWN {
45 
47  CharGenBase(console), _module(&module) {
48 
49  load("cg_main");
50 
51  getWidget("PlayButton" , true)->setDisabled(true);
52 
53  init();
54 }
55 
57  delete _choices;
58 }
59 
61  _choices->reset();
62 
63  for (Common::PtrVector<CharGenBase>::iterator g = _chargenGuis.begin(); g != _chargenGuis.end(); ++g)
64  (*g)->reset();
65 
66  for (std::vector<WidgetButton *>::iterator b = ++_charButtons.begin(); b != _charButtons.end(); ++b)
67  (*b)->setDisabled(true);
68 }
69 
71  for (size_t it = 0; it < _chargenGuis.size(); ++it) {
72  if (widget.getTag() == _charButtons[it]->getTag()) {
73  if (sub(*_chargenGuis[it]) == 2) {
74  // Unblocked/blocked PlayButton.
75  if (it == _chargenGuis.size() - 1) {
76  getButton("PlayButton")->setDisabled(false);
77  return;
78  } else {
79  getButton("PlayButton")->setDisabled(true);
80  }
81 
82  _charButtons[it + 1]->setDisabled(false);
83  _chargenGuis[it + 1]->reset();
84  for (size_t next = it + 2; next < _charButtons.size(); ++next) {
85  _charButtons[next]->setDisabled(true);
86  _chargenGuis[next]->reset();
87  }
88  return;
89  }
90  }
91  }
92 
93  if (widget.getTag() == "CancelButton") {
94  _returnCode = 1;
95  return;
96  }
97 
98  if (widget.getTag() == "ResetButton") {
99  reset();
100  return;
101  }
102 
103  if (widget.getTag() == "PlayButton") {
106  _returnCode = 2;
107  return;
108  }
109 }
110 
112  delete _choices;
113  _choices = new CharGenChoices();
114 
115  _charButtons.push_back(getButton("GenderButton", true));
116  _charButtons.push_back(getButton("RaceButton", true));
117  _charButtons.push_back(getButton("PortraitButton", true));
118  _charButtons.push_back(getButton("ClassButton", true));
119  _charButtons.push_back(getButton("AlignButton", true));
120  _charButtons.push_back(getButton("AbilitiesButton", true));
121  _charButtons.push_back(getButton("PackagesButton", true));
122  _charButtons.push_back(getButton("CustomizeButton", true));
123 
124  for (std::vector<WidgetButton *>::iterator b = ++_charButtons.begin(); b != _charButtons.end(); ++b)
125  (*b)->setDisabled(true);
126 
127 
128  _chargenGuis.push_back(new CharSex(*_choices, _console));
129  _chargenGuis.push_back(new CharRace(*_choices, _console));
130  _chargenGuis.push_back(new CharPortrait(*_choices, _console));
131  _chargenGuis.push_back(new CharClass(*_choices, _console));
132  _chargenGuis.push_back(new CharAlignment(*_choices, _console));
133  _chargenGuis.push_back(new CharAttributes(*_choices, _console));
134  _chargenGuis.push_back(new CharPackage(*_choices, _console));
135  _chargenGuis.push_back(new CharAppearance(*_choices, _console));
136 }
137 
138 } // End of namespace NWN
139 
140 } // End of namespace Engines
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
The class chooser in CharGen.
A NWN button widget.
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: chargen.cpp:70
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: button.cpp:107
Console * _console
Definition: gui.h:70
The gender chooser in CharGen.
The alignment chooser in CharGen.
The race chooser in NWN CharGen.
A vector of pointer to objects, with automatic deletion.
Definition: ptrvector.h:44
The context needed to run a Neverwinter Nights module.
WidgetButton * getButton(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:306
std::vector< WidgetButton * > _charButtons
Definition: chargen.h:55
Common::PtrVector< CharGenBase > _chargenGuis
Definition: chargen.h:57
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
CharGenChoices * _choices
Definition: chargenbase.h:45
uint32 sub(GUI &gui, uint32 startCode=kStartCodeNone, bool showSelf=true, bool hideSelf=true)
Open up a sub GUI.
Definition: gui.cpp:349
void load(const Common::UString &resref)
Definition: gui.cpp:77
void useCharacter(Module *module)
A widget in a GUI.
CharGenMenu(Module &module, ::Engines::Console *console=0)
Definition: chargen.cpp:46
A widget in a GUI.
Definition: widget.h:40
The attributes chooser in CharGen.
The character appearance GUI in CharGen.
The package selection GUI.
The portrait chooser in CharGen.
The NWN character generator.
The character choices in the character generator.