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/util.h"
26 
27 #include "src/sound/sound.h"
28 
29 #include "src/events/events.h"
30 
33 
35 
38 
39 namespace Engines {
40 
41 namespace KotOR2 {
42 
43 MainMenu::MainMenu(Module &module, ::Engines::Console *console) : GUI(console), _module(&module) {
44  load("mainmenu8x6_p");
45 
47 }
48 
50 }
51 
54 
55  // ...BioWare...
56  if (widget.getTag() == "LBL_GAMELOGO") {
57  dynamic_cast< KotORJadeWidget & >(widget).setFill("kotor2logo");
58  return;
59  }
60 
61  // Warp button? O_o
62  if (widget.getTag() == "BTN_WARP") {
63  widget.setInvisible(true);
64  return;
65  }
66 
67  // New downloadable content is available, bluhbluh.
68  if (widget.getTag() == "LBL_NEWCONTENT") {
69  widget.setInvisible(true);
70  return;
71  }
72 
73  // Whatever this module stuff is about
74  if (widget.getTag() == "LB_MODULES") {
75  widget.setInvisible(true);
76  return;
77  }
78 }
79 
81  if (!_classSelection)
83 }
84 
86  _menuMusic = playSound("mus_sion", Sound::kSoundTypeMusic, true);
87 }
88 
90  _menuMusic = playSound("mus_main", Sound::kSoundTypeMusic, true);
91 }
92 
94  SoundMan.stopChannel(_menuMusic);
95 }
96 
98  if (widget.getTag() == "BTN_EXIT") {
99  EventMan.requestQuit();
100 
101  _returnCode = 1;
102  return;
103  }
104 
105  if (widget.getTag() == "BTN_NEWGAME") {
107  stopMusic();
109  if (sub(*_classSelection) == 2) {
110  stopMusic();
111  _returnCode = 2;
112  return;
113  }
114  stopMusic();
115  startMainMusic();
116  return;
117  }
118 }
119 
120 } // End of namespace KotOR2
121 
122 } // End of namespace Engines
Sound::ChannelHandle _menuMusic
Definition: main.h:55
void load(const Common::UString &resref)
Definition: gui.cpp:103
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
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: main.cpp:97
void createClassSelection()
Definition: main.cpp:80
The KotOR 2 main menu.
Common::ScopedPtr< GUI > _classSelection
Definition: main.h:53
Utility templates and functions.
const Common::UString & getTag() const
Get the widget&#39;s tag.
Definition: widget.cpp:45
The global events manager.
The KotOR 2 class selection.
uint32 sub(GUI &gui, uint32 startCode=kStartCodeNone, bool showSelf=true, bool hideSelf=true)
Open up a sub GUI.
Definition: gui.cpp:349
The global sound manager, handling all sound output.
#define SoundMan
Shortcut for accessing the sound manager.
Definition: sound.h:293
The context needed to run a Star Wars: Knights of the Old Republic II - The Sith Lords module...
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
Common base for Star Wars: Knights of the Old Republic and Jade Empire widgets.
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
MainMenu(Module &module, ::Engines::Console *console=0)
Definition: main.cpp:43
A widget in a GUI.
Definition: widget.h:40
Generic Aurora engines utility functions.
virtual void initWidget(Widget &widget)
Definition: gui.cpp:37
void initWidget(Widget &widget)
Definition: main.cpp:52