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 <boost/bind.hpp>
26 
27 #include "glm/gtc/matrix_transform.hpp"
28 
29 #include "src/common/util.h"
30 
31 #include "src/sound/sound.h"
32 
33 #include "src/events/events.h"
34 
37 
40 
43 
45 
49 
53 
55 
56 namespace Engines {
57 
58 namespace KotOR {
59 
60 MainMenu::MainMenu(const Version &gameVersion, Module &module, ::Engines::Console *console) : GUI(console),
61  _module(&module), _gameVersion(&gameVersion) {
62 
64 
65  load((_gameVersion->getPlatform() == Aurora::kPlatformXbox) ? "mainmenu" : "mainmenu16x12");
66 
67  getListBox("LB_MODULES")->setInvisible(true);
68 
70 
72 
74 
75  _malakModel.reset(loadModelObject("mainmenu"));
76 
77  if (_malakModel) {
78  _malakModel->playAnimation("default", true, -1);
79  _malakModel->setOrientation(1.0f, 0.0f, 0.0f, -90.0f);
80 
81  _malakScene->add(_malakModel.get());
82 
83  getLabel("LBL_3DVIEW")->setSubScene(_malakScene.get());
84  // TODO: Possibly change this to perspective projection.
85  glm::mat4 projection = glm::ortho(-2.0f, 2.0f, -0.2f, 2.6f, -3.0f, 3.0f);
86  _malakScene->setProjectionMatrix(projection);
87 
88  _malakScene->setClearEnabled(false);
89  }
90 }
91 
93 }
94 
96  hide();
97  LoadScreen loadScreen("chargen", _console);
98  loadScreen.show();
99 
100  // Load the texture pack, needed for the character generator
102 
103  // Create the class selection menu
105 
106  loadScreen.hide();
107  show();
108 }
109 
111  if (_movies)
112  return;
113 
114  // Create the movies menu
115  _movies.reset(new MoviesMenu(_console));
116 }
117 
119  if (_options)
120  return;
121 
122  // Create the options menu
124 
125 }
126 
128  if (_loadGame)
129  return;
130 
131  // Create the load game menu
132  _loadGame.reset(new SaveLoadMenu(*_module, _console));
133 }
134 
136  _menuMusic = playSound("mus_theme_cult", Sound::kSoundTypeMusic, true);
137 }
138 
140  _menuMusic = playSound("mus_theme_rep", Sound::kSoundTypeMusic, true);
141 }
142 
144  SoundMan.stopChannel(_menuMusic);
145 }
146 
148  // BioWare logo, the original game doesn't display it.
149  if (widget.getTag() == "LBL_BW") {
150  widget.setInvisible(true);
151  return;
152  }
153 
154  // LucasArts logo, the original game doesn't display it.
155  if (widget.getTag() == "LBL_LUCAS") {
156  widget.setInvisible(true);
157  return;
158  }
159 
160  // Warp button? O_o
161  if ((widget.getTag() == "BTN_WARP") || (widget.getTag() == "LBL_WARP")) {
162  widget.setInvisible(true);
163  return;
164  }
165 
166  // "Y" label
167  if (widget.getTag() == "LBL_Y") {
168  widget.setInvisible(true);
169  return;
170  }
171 
172  // New downloadable content is available, bluhbluh.
173  if (widget.getTag() == "LBL_NEWCONTENT") {
174  widget.setInvisible(true);
175  return;
176  }
177 
178  // New game button. Forcibly move it to the front, for the Xbox version
179  if (widget.getTag() == "BTN_NEWGAME") {
180  float x, y, z;
181  widget.getPosition(x, y, z);
182 
183  widget.setPosition(x, y, z - 10.0f);
184  }
185 }
186 
188 
189  if (widget.getTag() == "BTN_NEWGAME") {
191 
192  // Stop the currently running main music
193  stopMenuMusic();
194 
195  // Start the charGen music
197  if (sub(*_classSelection) == 2) {
198  _returnCode = 2;
199  stopMenuMusic();
200  return;
201  }
202 
203  // If we return from the chargen we stop the music and play the main music
204  stopMenuMusic();
205  startMainMusic();
206 
207  return;
208  }
209 
210  if (widget.getTag() == "BTN_LOADGAME") {
211  createLoadGame();
212 
213  if (sub(*_loadGame) == 2) {
214  _returnCode = 2;
215  stopMenuMusic();
216  }
217 
218  return;
219  }
220 
221  if (widget.getTag() == "BTN_MOVIES") {
222  createMovies();
223 
224  sub(*_movies);
225  return;
226  }
227 
228  if (widget.getTag() == "BTN_OPTIONS") {
229  createOptions();
230 
231  sub(*_options);
232  return;
233  }
234 
235  if (widget.getTag() == "BTN_EXIT") {
236  EventMan.requestQuit();
237 
238  _returnCode = 1;
239  return;
240  }
241 }
242 
243 } // End of namespace KotOR
244 
245 } // End of namespace Engines
void load(const Common::UString &resref)
Definition: gui.cpp:103
The options menu.
static const Common::UString & kBackgroundTypeMenu
Definition: guibackground.h:42
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
The loading screen gui.
Common::ScopedPtr< GUI > _loadGame
Definition: main.h:61
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
Common::ScopedPtr< GUI > _options
Definition: main.h:60
void initWidget(Widget &widget)
Definition: main.cpp:147
const Version * _gameVersion
Definition: main.h:53
A button widget for Star Wars: Knights of the Old Republic and Jade Empire.
virtual void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: widget.cpp:119
Common::ScopedPtr< Graphics::Aurora::Model > _malakModel
Definition: main.h:56
The class selection menu.
void setSubScene(Graphics::Aurora::SubSceneQuad *subscene)
Console * _console
Definition: gui.h:70
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
The KotOR movies menu.
Definition: movies.h:35
Common::ScopedPtr< GUI > _movies
Definition: main.h:59
The KotOR main menu.
virtual void hide()
Hide the GUI.
Definition: gui.cpp:75
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: main.cpp:187
Load/save game menu.
Aurora::Platform getPlatform() const
Definition: version.cpp:59
Common::ScopedPtr< GUI > _classSelection
Definition: main.h:58
Common::ScopedPtr< Graphics::Aurora::SubSceneQuad > _malakScene
Definition: main.h:55
Utility templates and functions.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
A list box widget for Star Wars: Knights of the Old Republic and Jade Empire.
Module * _module
Definition: main.h:52
Microsoft Xbox.
Definition: types.h:433
void createClassSelection()
Definition: main.cpp:95
The global events manager.
uint32 sub(GUI &gui, uint32 startCode=kStartCodeNone, bool showSelf=true, bool hideSelf=true)
Open up a sub GUI.
Definition: gui.cpp:349
Star Wars: Knights of the Old Republic installation version detection.
The global sound manager, handling all sound output.
#define SoundMan
Shortcut for accessing the sound manager.
Definition: sound.h:293
The movies menu.
void addBackground(const Common::UString &background, bool front=false)
Definition: gui.cpp:300
virtual void show()
Show the GUI.
Definition: gui.cpp:69
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
A widget in a GUI.
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:204
PointerType get() const
Returns the plain pointer value.
Definition: scopedptr.h:96
void loadTexturePack()
Load texture pack used by the module.
Definition: module.cpp:260
A widget in a GUI.
Definition: widget.h:40
virtual void setInvisible(bool invisible)
Make the widget invisible.
MainMenu(const Version &gameVersion, Module &module, ::Engines::Console *console=0)
Definition: main.cpp:60
WidgetListBox * getListBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:288
Generic Aurora engines utility functions.
The context needed to run a Star Wars: Knights of the Old Republic module.
A KotOR GUI.
Definition: gui.h:57
Sound::ChannelHandle _menuMusic
Definition: main.h:63
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
Definition: model.cpp:47
The menu background.
Generic Aurora engines model functions.