xoreos  0.0.5
charschool.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 
30 
32 
33 namespace Engines {
34 
35 namespace NWN {
36 
37 CharSchool::CharSchool(CharGenChoices &choices, Console *console) : CharGenBase(console) {
38  _choices = &choices;
39  load("cg_school");
40 
41  // Init buttons and helpbox.
42  _buttons.reset(new ButtonsGroup(getEditBox("HelpBox", true)));
43 
44  uint32 textID = 10320;
45  uint32 titleID = 373;
46  _buttons->addButton(getButton("General", true), TalkMan.getString(5633), TalkMan.getString(5634));
47  _buttons->addButton(getButton("Abjuration", true), TalkMan.getString(titleID), TalkMan.getString(textID));
48  _buttons->addButton(getButton("Conjuration", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
49  _buttons->addButton(getButton("Divination", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
50  _buttons->addButton(getButton("Enchantment", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
51  _buttons->addButton(getButton("Evocation", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
52  _buttons->addButton(getButton("Illusion", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
53  _buttons->addButton(getButton("Necromancy", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
54  _buttons->addButton(getButton("Transmutation", true), TalkMan.getString(++titleID), TalkMan.getString(++textID));
55 
56  reset();
57 }
58 
60 }
61 
63  _buttons->setActive(getButton("General", true));
64 
65  getEditBox("HelpBox", true)->setTitle("fnt_galahad14", TalkMan.getString(381));
66  getEditBox("HelpBox", true)->setText("fnt_galahad14", TalkMan.getString(381), 1.0f);
67 
69 }
70 
73 
74  if (_returnCode == 1) {
75  // Set previous choice if any.
77  _buttons->setActive((size_t) _choices->getSpellSchool());
78  }
79 }
80 
82  if (widget.getTag() == "OkButton") {
83  _choices->setSpellSchool((uint8) _buttons->getChoice());
84  _returnCode = 2;
85  return;
86  }
87 
88  if (widget.getTag() == "CancelButton") {
89  _returnCode = 1;
90  return;
91  }
92 
93  if (widget.getTag() == "RecommendButton") {
94  _buttons->setActive(size_t(0));
95  return;
96  }
97 
98  _buttons->setActive(dynamic_cast<WidgetButton *>(&widget));
99 }
100 
101 } // End of namespace NWN
102 
103 } // End of namespace Engines
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
uint8_t uint8
Definition: types.h:200
Utility class that handles group of WidgetButton where only one button can be toggled.
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
void hide()
Hide the GUI.
Definition: charschool.cpp:71
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
CharGenChoices * _choices
Definition: chargenbase.h:45
#define UINT8_MAX
Definition: types.h:225
void load(const Common::UString &resref)
Definition: gui.cpp:77
WidgetEditBox * getEditBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:294
A widget in a GUI.
Definition: widget.h:40
The spell school chooser in CharGen.
void setTitle(const Common::UString &font, const Common::UString &title)
Set title text if available.
Definition: editbox.cpp:59
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: charschool.cpp:81
Common::ScopedPtr< ButtonsGroup > _buttons
Definition: charschool.h:49
CharSchool(CharGenChoices &choices, ::Engines::Console *console=0)
Definition: charschool.cpp:37
void setSpellSchool(uint8 spellSchool)
virtual void hide()
Hide the GUI.
Definition: gui.cpp:80