xoreos  0.0.5
charrace.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 
24 #include "src/aurora/talkman.h"
25 
26 #include "src/engines/nwn/types.h"
28 
32 
35 
36 namespace Engines {
37 
38 namespace NWN {
39 
41  _choices = &choices;
42  load("cg_race");
43 
44  // TODO Implement subrace.
45  getWidget("SubRaceButton", true)->setDisabled(true);
46 
47  // Init buttons and helpbox.
48  _buttons.reset(new ButtonsGroup(getEditBox("HelpBox", true)));
49 
50  uint textID = 251;
51  uint titleID = 1985;
52 
53  _buttons->addButton(getButton("DwarfButton", true),
54  TalkMan.getString(titleID), TalkMan.getString(textID));
55  _buttons->addButton(getButton("ElfButton", true),
56  TalkMan.getString(++titleID), TalkMan.getString(++textID));
57  _buttons->addButton(getButton("GnomeButton", true),
58  TalkMan.getString(++titleID), TalkMan.getString(++textID));
59  _buttons->addButton(getButton("HalflingButton", true),
60  TalkMan.getString(++titleID), TalkMan.getString(++textID));
61  _buttons->addButton(getButton("HalfElfButton", true),
62  TalkMan.getString(++titleID), TalkMan.getString(++textID));
63  _buttons->addButton(getButton("HalfOrcButton", true),
64  TalkMan.getString(++titleID), TalkMan.getString(++textID));
65  _buttons->addButton(getButton("HumanButton", true),
66  TalkMan.getString(++titleID), TalkMan.getString(++textID));
67 
68  reset();
69 }
70 
72 }
73 
75  _buttons->setActive(getButton("HumanButton", true));
76 
77  getEditBox("HelpBox", true)->setTitle("fnt_galahad14", TalkMan.getString(481));
78  getEditBox("HelpBox", true)->setText("fnt_galahad14", TalkMan.getString(485), 1.0f);
79 
80  // Set human as default race.
81  _choices->setRace(6);
82 }
83 
86 
87  if (_returnCode == 1) {
88  // Set previous choice if any.
90  _buttons->setActive(_choices->getCharacter().getRace());
91  }
92 }
93 
95  if (widget.getTag() == "OkButton") {
96  _choices->setRace(_buttons->getChoice());
97  _returnCode = 2;
98  return;
99  }
100 
101  if (widget.getTag() == "CancelButton") {
102  _returnCode = 1;
103  return;
104  }
105 
106  if (widget.getTag() == "RecommendButton") {
107  _buttons->setActive(6);
108  }
109 
110  _buttons->setActive(dynamic_cast<WidgetButton *>(&widget));
111 }
112 
113 } // End of namespace NWN
114 
115 } // End of namespace Engines
Common::ScopedPtr< ButtonsGroup > _buttons
Definition: charrace.h:49
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
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()
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
Utility class that handles group of WidgetButton where only one button can be toggled.
Basic Neverwinter Nights type definitions.
The race chooser in NWN CharGen.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: charrace.cpp:94
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
static const uint32 kRaceInvalid
Definition: types.h:278
WidgetEditBox * getEditBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:294
CharRace(CharGenChoices &choices, ::Engines::Console *console=0)
Definition: charrace.cpp:40
uint32 getRace() const
Return the creature&#39;s race value.
Definition: creature.cpp:205
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
void hide()
Hide the GUI.
Definition: charrace.cpp:84
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
The character choices in the character generator.
virtual void hide()
Hide the GUI.
Definition: gui.cpp:80
unsigned int uint
Definition: types.h:211