xoreos  0.0.5
newcamp.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/game.h"
28 
35 
36 namespace Engines {
37 
38 namespace NWN {
39 
40 NewCampMenu::NewCampMenu(Module &module, GUI &charType, ::Engines::Console *console) : GUI(console),
41  _module(&module), _charType(&charType) {
42 
43  load("pre_campaign");
44 
45  Widget *button = 0;
46 
47  button = getWidget("NWNXP1Button");
48  if (button)
49  button->setDisabled(!ConfigMan.getBool("NWN_hasXP1"));
50  button = getWidget("NWNXP2Button");
51  if (button)
52  button->setDisabled(!ConfigMan.getBool("NWN_hasXP2"));
53  button = getWidget("NWNXP3Button");
54  if (button)
56 
57  _base.reset (new NewMenu (*_module, *_charType, _console));
58  _xp1.reset (new NewXP1Menu (*_module, *_charType, _console));
59  _xp2.reset (new NewXP2Menu (*_module, *_charType, _console));
62 }
63 
65 }
66 
68  if (widget.getTag() == "CancelButton") {
69  _returnCode = 1;
70  return;
71  }
72 
73  if (widget.getTag() == "NWNButton") {
74  if (sub(*_base, 0, false) == 2) {
75  _returnCode = 2;
76  return;
77  }
78 
79  show();
80  return;
81  }
82 
83  if (widget.getTag() == "NWNXP1Button") {
84  if (sub(*_xp1, 0, false) == 2) {
85  _returnCode = 2;
86  return;
87  }
88 
89  show();
90  return;
91  }
92 
93  if (widget.getTag() == "NWNXP2Button") {
94  if (sub(*_xp2, 0, false) == 2) {
95  _returnCode = 2;
96  return;
97  }
98 
99  show();
100  return;
101  }
102 
103  if (widget.getTag() == "NWNXP3Button") {
104  if (sub(*_premium, 0, false) == 2) {
105  _returnCode = 2;
106  return;
107  }
108 
109  show();
110  return;
111  }
112 
113  if (widget.getTag() == "OtherButton") {
114  if (sub(*_modules, 0, false) == 2) {
115  _returnCode = 2;
116  return;
117  }
118 
119  show();
120  return;
121  }
122 
123 }
124 
125 } // End of namespace NWN
126 
127 } // End of namespace Engines
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
The global config manager.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: newcamp.cpp:67
Common::ScopedPtr< GUI > _xp1
Definition: newcamp.h:53
The NWN new game menu, expansion 2.
Definition: newxp2.h:37
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
Console * _console
Definition: gui.h:70
NewCampMenu(Module &module, GUI &charType, ::Engines::Console *console=0)
Definition: newcamp.cpp:40
The new game menu.
The new premium module menu.
Common::ScopedPtr< GUI > _base
Definition: newcamp.h:52
The new module menu.
The NWN new game menu.
Definition: new.h:39
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
Common::ScopedPtr< GUI > _modules
Definition: newcamp.h:55
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
static bool hasPremiumModules()
Do we actually have any premium modules installed at all?
Definition: game.cpp:242
The NWN new module menu.
Definition: newmodule.h:73
A widget in a GUI.
Definition: widget.h:40
The context handling the gameplay in Neverwinter Nights.
The new campaign menu.
The new game menu, expansion 1.
The NWN new premium module menu.
Definition: newpremium.h:73
Common::ScopedPtr< GUI > _premium
Definition: newcamp.h:56
The NWN new game menu, expansion 1.
Definition: newxp1.h:37
The new game menu, expansion 2.
Common::ScopedPtr< GUI > _xp2
Definition: newcamp.h:54