xoreos  0.0.5
charsex.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 
28 
32 
34 
35 namespace Engines {
36 
37 namespace NWN {
38 
39 CharSex::CharSex(CharGenChoices &choices, ::Engines::Console *console) : CharGenBase(console) {
40  _choices = &choices;
41  load("cg_sex");
42 
43  getEditBox("HelpBox", true)->setTitle("fnt_galahad14", TalkMan.getString(203));
44  getEditBox("HelpBox", true)->setText("fnt_galahad14", TalkMan.getString(447), 1.0f);
45 
46  _buttons.reset(new ButtonsGroup(getEditBox("HelpBox", true)));
47  _buttons->addButton(getButton("MaleButton", true), TalkMan.getString(203), TalkMan.getString(199));
48  _buttons->addButton(getButton("FemaleButton", true), TalkMan.getString(203), TalkMan.getString(200));
49 
50  getButton("MaleButton", true)->setPressed(true);
51 }
52 
54 }
55 
57  _buttons->setActive(getButton("MaleButton", true));
58 
59  getEditBox("HelpBox", true)->setTitle("fnt_galahad14", TalkMan.getString(203));
60  getEditBox("HelpBox", true)->setText("fnt_galahad14", TalkMan.getString(447), 1.0f);
61 }
62 
63 void CharSex::hide() {
65 
66  if (_returnCode == 1) {
67  // Set previous choice if any.
68  Gender previousGender = _choices->getCharacter().getGender();
69 
70  if (previousGender != kGenderNone)
71  _buttons->setActive((size_t) previousGender);
72  else
73  reset();
74  }
75 }
76 
78  if (widget.getTag() == "OkButton") {
79  _choices->setGender((Gender) _buttons->getChoice());
80  _returnCode = 2;
81  return;
82  }
83 
84  if (widget.getTag() == "CancelButton") {
85  _returnCode = 1;
86  return;
87  }
88 
89  _buttons->setActive(dynamic_cast<WidgetButton *>(&widget));
90 }
91 
92 } // End of namespace NWN
93 
94 } // End of namespace Engines
Common::ScopedPtr< ButtonsGroup > _buttons
Definition: charsex.h:50
CharSex(CharGenChoices &choices, ::Engines::Console *console=0)
Definition: charsex.cpp:39
A NWN editbox widget.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
A NWN button widget.
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
const Creature & getCharacter()
Utility class that handles group of WidgetButton where only one button can be toggled.
The gender chooser in CharGen.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: charsex.cpp:77
WidgetButton * getButton(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:306
void setText(const Common::UString &font, const Common::UString &text, float spacing=0.0f)
Definition: listbox.cpp:523
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
CharGenChoices * _choices
Definition: chargenbase.h:45
void load(const Common::UString &resref)
Definition: gui.cpp:77
WidgetEditBox * getEditBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:294
void setGender(Gender gender)
A widget in a GUI.
Definition: widget.h:40
void setTitle(const Common::UString &font, const Common::UString &title)
Set title text if available.
Definition: editbox.cpp:59
Gender getGender() const
Get the creature&#39;s gender.
Definition: creature.cpp:190
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
void setPressed(bool pushed)
Definition: button.cpp:93
virtual void hide()
Hide the GUI.
Definition: gui.cpp:80
void hide()
Hide the GUI.
Definition: charsex.cpp:63