xoreos  0.0.5
new.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/common/configman.h"
26 
27 #include "src/engines/nwn/module.h"
28 
31 
32 namespace Engines {
33 
34 namespace NWN {
35 
36 NewMenu::NewMenu(Module &module, GUI &charType, ::Engines::Console *console) : GUI(console),
37  _module(&module), _charType(&charType) {
38 
39  load("pre_newgame");
40 
41  _hasXP = ConfigMan.getBool("NWN_hasXP1") || ConfigMan.getBool("NWN_hasXP2");
42 
43  if (_hasXP)
44  // If we have an expansion, hide the "Other modules" button, it's
45  // already in the campaign menu
46  getWidget("OtherButton", true)->setInvisible(true);
47 
48  if (!_hasXP)
50 }
51 
53 }
54 
56  if (widget.getTag() == "CancelButton") {
57  _returnCode = 1;
58  return;
59  }
60 
61  if (widget.getTag() == "OtherButton") {
62  if (sub(*_modules, 0, false) == 2) {
63  _returnCode = 2;
64  return;
65  }
66 
67  show();
68  return;
69  }
70 
71  if (widget.getTag() == "PreludeButton") {
72  loadModule("prelude.nwm");
73  return;
74  }
75 
76  if (widget.getTag() == "Chapter1Button") {
77  loadModule("chapter1.nwm");
78  return;
79  }
80 
81  if (widget.getTag() == "Chapter2Button") {
82  loadModule("chapter2.nwm");
83  return;
84  }
85 
86  if (widget.getTag() == "Chapter3Button") {
87  loadModule("chapter3.nwm");
88  return;
89  }
90 
91  if (widget.getTag() == "Chapter4Button") {
92  loadModule("chapter4.nwm");
93  return;
94  }
95 }
96 
97 void NewMenu::loadModule(const Common::UString &module) {
98  try {
99  _module->load(module);
100  } catch (...) {
102  return;
103  }
104 
105  if (sub(*_charType, 0, false) == 2) {
106  _returnCode = 2;
107  return;
108  }
109 
110  show();
111 }
112 
113 } // End of namespace NWN
114 
115 } // End of namespace Engines
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: new.cpp:55
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
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
A class holding an UTF-8 string.
Definition: ustring.h:48
The global config manager.
Console * _console
Definition: gui.h:70
void loadModule(const Common::UString &module)
Definition: new.cpp:97
The new game menu.
NewMenu(Module &module, GUI &charType, ::Engines::Console *console=0)
Definition: new.cpp:36
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
Definition: error.cpp:158
The context needed to run a Neverwinter Nights module.
void load(const Common::UString &module)
Load a module.
Definition: module.cpp:127
The new module menu.
virtual void show()
Show the GUI.
Definition: gui.cpp:62
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
A NWN GUI.
Definition: gui.h:54
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
GUI * _charType
Definition: new.h:52
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
Module * _module
Definition: new.h:48
The NWN new module menu.
Definition: newmodule.h:73
A widget in a GUI.
Definition: widget.h:40
Common::ScopedPtr< GUI > _modules
Definition: new.h:54