xoreos  0.0.5
newxp2.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 
27 #include "src/engines/nwn/module.h"
28 
30 
32 
33 namespace Engines {
34 
35 namespace NWN {
36 
37 NewXP2Menu::NewXP2Menu(Module &module, GUI &charType, ::Engines::Console *console) : GUI(console),
38  _module(&module), _charType(&charType) {
39 
40  load("pre_newgame");
41 
42  getWidget("OtherButton" , true)->setInvisible(true);
43  getWidget("PreludeButton" , true)->setInvisible(true);
44  getWidget("Chapter4Button", true)->setInvisible(true);
45 }
46 
48 }
49 
51  if (widget.getTag() == "Chapter1Button") {
52  dynamic_cast<WidgetButton &>(widget).setText(TalkMan.getString(100777));
53  return;
54  }
55 
56  if (widget.getTag() == "Chapter2Button") {
57  dynamic_cast<WidgetButton &>(widget).setText(TalkMan.getString(100778));
58  return;
59  }
60 
61  if (widget.getTag() == "Chapter3Button") {
62  dynamic_cast<WidgetButton &>(widget).setText(TalkMan.getString(100779));
63  return;
64  }
65 }
66 
68  if (widget.getTag() == "CancelButton") {
69  _returnCode = 1;
70  return;
71  }
72 
73  if (widget.getTag() == "Chapter1Button") {
74  loadModule("xp2_chapter1.nwm");
75  return;
76  }
77 
78  if (widget.getTag() == "Chapter2Button") {
79  loadModule("xp2_chapter2.nwm");
80  return;
81  }
82 
83  if (widget.getTag() == "Chapter3Button") {
84  loadModule("xp2_chapter3.nwm");
85  return;
86  }
87 
88 }
89 
91  try {
92  _module->load(module);
93  } catch (...) {
95  return;
96  }
97 
98  if (sub(*_charType, 0, false) == 2) {
99  _returnCode = 2;
100  return;
101  }
102 
103  show();
104 }
105 
106 } // End of namespace NWN
107 
108 } // End of namespace Engines
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
virtual void setInvisible(bool invisible)
Make the widget invisible.
Definition: widget.cpp:168
#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
A class holding an UTF-8 string.
Definition: ustring.h:48
NewXP2Menu(Module &module, GUI &charType, ::Engines::Console *console=0)
Definition: newxp2.cpp:37
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: newxp2.cpp:67
void loadModule(const Common::UString &module)
Definition: newxp2.cpp:90
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
Definition: error.cpp:158
A NWN button widget.
Definition: button.h:39
The context needed to run a Neverwinter Nights module.
void load(const Common::UString &module)
Load a module.
Definition: module.cpp:127
virtual void show()
Show the GUI.
Definition: gui.cpp:62
A NWN GUI.
Definition: gui.h:54
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp: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
A widget in a GUI.
Definition: widget.h:40
The global talk manager for Aurora strings.
void initWidget(Widget &widget)
Definition: newxp2.cpp:50
The new game menu, expansion 2.