xoreos  0.0.5
main.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/events/events.h"
28 
29 #include "src/engines/nwn/module.h"
30 
32 
41 
42 namespace Engines {
43 
44 namespace NWN {
45 
46 MainMenu::MainMenu(Module &module, ::Engines::Console *console) : GUI(console),
47  _module(&module) {
48 
49  load("pre_main");
50 
51  bool hasXP1 = ConfigMan.getBool("NWN_hasXP1");
52  bool hasXP2 = ConfigMan.getBool("NWN_hasXP2");
53 
54  _hasXP = hasXP1 || hasXP2;
55 
56  if (hasXP1) {
57  WidgetPanel *xp1 = new WidgetPanel(*this, "TextXP1", "ctl_xp1_text");
58  xp1->setPosition(124.0f, 0.00f, -50.0f);
59  addWidget(xp1);
60  }
61 
62  if (hasXP2) {
63  WidgetPanel *xp2 = new WidgetPanel(*this, "TextXP2", "ctl_xp2_text");
64  xp2->setPosition(124.0f, -147.0f, -50.0f);
65  addWidget(xp2);
66  }
67 
68  getWidget("LoadButton" , true)->setDisabled(true);
69  getWidget("MultiButton", true)->setDisabled(true);
70 
71  _charType.reset(new CharTypeMenu(*_module, _console));
72 }
73 
75 }
76 
78  if (_new)
79  return;
80 
81  if (_hasXP)
82  // If we have at least an expansion, create the campaign selection game menu
83  _new.reset(new NewCampMenu(*_module, *_charType, _console));
84  else
85  // If not, create the base game menu
86  _new.reset(new NewMenu(*_module, *_charType, _console));
87 }
88 
90  if (_movies)
91  return;
92 
93  if (_hasXP)
94  // If we have at least an expansion, create the campaign selection movies menu
95  _movies.reset(new MoviesCampMenu(_console));
96  else
97  // If not, create the base game movies menu
98  _movies.reset(new MoviesBaseMenu(_console));
99 }
100 
102  if (_options)
103  return;
104 
106 }
107 
109  GUI::show();
110 
111  getWidget("NewButton", true)->show();
112 }
113 
115  // If we're aborting the main menu, quit everything
116  EventMan.requestQuit();
117 
118  GUI::abort();
119 }
120 
122  if (widget.getTag() == "ExitButton") {
123  EventMan.requestQuit();
124  return;
125  }
126 
127  if (widget.getTag() == "NewButton") {
128  createNew();
129 
130  NewGameFogs fogs(ConfigMan.getInt("menufogcount", 4));
131  fogs.show();
132 
133  if (sub(*_new, 0, false) == 2) {
134  _returnCode = 2;
135  return;
136  }
137 
138  show();
139  return;
140  }
141 
142  if (widget.getTag() == "MoviesButton") {
143  createMovies();
144 
145  sub(*_movies);
146  return;
147  }
148 
149  if (widget.getTag() == "OptionsButton") {
150  createOptions();
151 
152  sub(*_options);
153  return;
154  }
155 
156 }
157 
158 } // End of namespace NWN
159 
160 } // End of namespace Engines
A NWN panel widget.
Definition: panel.h:41
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
The base game movies menu.
void show()
Show the GUI.
Definition: main.cpp:108
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
The global config manager.
The fog behind the new game dialogs.
virtual void setDisabled(bool disabled)
Disable/Enable the widget.
Definition: widget.cpp:154
Console * _console
Definition: gui.h:70
MainMenu(Module &module, ::Engines::Console *console=0)
Definition: main.cpp:46
The NWN new/premade character selection menu.
Definition: chartype.h:39
const Version & getGameVersion() const
Definition: module.cpp:119
The NWN options menu.
Definition: options.h:39
The new game menu.
The context needed to run a Neverwinter Nights module.
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
The new/premade character selection menu.
The global events manager.
The NWN campaign movies menu.
Definition: moviescamp.h:37
The NWN base game movies menu.
Definition: moviesbase.h:35
The main menu.
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
The campaign movies menu.
virtual void abort()
Abort the currently running GUI.
Definition: gui.cpp:156
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
A widget in a GUI.
Definition: widget.h:40
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: modelwidget.cpp:71
Common::ScopedPtr< GUI > _new
Definition: main.h:58
virtual void show()
Show the widget.
Definition: widget.cpp:71
Module * _module
Definition: main.h:52
The NWN new campaign menu.
Definition: newcamp.h:39
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: main.cpp:121
void addWidget(Widget *widget)
Add a widget.
Definition: gui.cpp:250
The new campaign menu.
Common::ScopedPtr< GUI > _options
Definition: main.h:60
A NWN panel widget.
Common::ScopedPtr< GUI > _charType
Definition: main.h:56
void abort()
Abort the currently running GUI.
Definition: main.cpp:114
Common::ScopedPtr< GUI > _movies
Definition: main.h:59
The options menu.