xoreos  0.0.5
options.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/aurora/talkman.h"
26 
28 
33 
35 
41 
42 namespace Engines {
43 
44 namespace Jade {
45 
46 OptionsMenu::OptionsMenu(Console *console) : GUI(console) {
47  load("options");
48 
49  // Move this label behind the buttons.
50  float x, y, z;
51  getWidget("Lopt")->getPosition(x, y, z);
52  getWidget("Lopt")->setPosition(x, y, z + 10);
53 
54  Engines::WidgetListBox *optionsListBox = getListBox("OptionsListBox");
55  optionsListBox->createItemWidgets(6);
56 
57  optionsListBox->addItem(TalkMan.getString(132)); // Audio Settings
58  optionsListBox->addItem(TalkMan.getString(133)); // Graphic Settings
59  optionsListBox->addItem(TalkMan.getString(149)); // Difficulty
60  optionsListBox->addItem(TalkMan.getString(150)); // Game Info
61  optionsListBox->addItem(TalkMan.getString(151)); // Controls
62  optionsListBox->addItem(TalkMan.getString(15709)); // Credits
63 
64  optionsListBox->refreshItemWidgets();
65 
66  _audioOptionsButton = getProtoItem("OptionsListBox_ITEM_0");
67  _videoOptionsButton = getProtoItem("OptionsListBox_ITEM_1");
68  _difficultyOptionsButton = getProtoItem("OptionsListBox_ITEM_2");
69  _gameInfoOptionsButton = getProtoItem("OptionsListBox_ITEM_3");
70  _controlOptionsButton = getProtoItem("OptionsListBox_ITEM_4");
71  _creditsButton = getProtoItem("OptionsListBox_ITEM_5");
72 
73  _backButton = getButton("ButtonBack");
74  _currentButton = 0;
75 
76  _optionsDescription = getLabel("OptionsDescLabel");
77 
78  _audioOptionsDescription = TalkMan.getString(129);
79  _videoOptionsDescription = TalkMan.getString(130);
80  _difficultyOptionsDescription = TalkMan.getString(152);
81  _gameInfoOptionsDescription = TalkMan.getString(153);
82  _controlOptionsDescription = TalkMan.getString(154);
83  _creditsDescription = TalkMan.getString(33212);
84  _backButtonDescription = TalkMan.getString(130088);
85 
86  _optionsDescription->setText("");
87 }
88 
89 void OptionsMenu::createAudioOptions() {
90  _audioOptions.reset(new AudioOptionsMenu(_console));
91 }
92 
93 void OptionsMenu::createVideoOptions() {
94  _videoOptions.reset(new VideoOptionsMenu(_console));
95 }
96 
97 void OptionsMenu::createDifficultyOptions() {
98  _difficultyOptions.reset(new DifficultyOptionsMenu(_console));
99 }
100 
101 void OptionsMenu::createGameInfoOptions() {
102  _gameInfoOptions.reset(new GameInfoOptionsMenu(_console));
103 }
104 
105 void OptionsMenu::createControlOptions() {
106  _controlOptions.reset(new ControlOptionsMenu(_console));
107 }
108 
110  // Set description text for specific options.
111  if (_audioOptionsButton->isHovered() && _currentButton != _audioOptionsButton) {
112  _optionsDescription->setText(_audioOptionsDescription);
113  _currentButton = _audioOptionsButton;
114  } else if (_videoOptionsButton->isHovered() && _currentButton != _videoOptionsButton) {
115  _optionsDescription->setText(_videoOptionsDescription);
116  _currentButton = _videoOptionsButton;
117  } else if (_difficultyOptionsButton->isHovered() && _currentButton != _difficultyOptionsButton) {
118  _optionsDescription->setText(_difficultyOptionsDescription);
119  _currentButton = _difficultyOptionsButton;
120  } else if (_gameInfoOptionsButton->isHovered() && _currentButton != _gameInfoOptionsButton) {
121  _optionsDescription->setText(_gameInfoOptionsDescription);
122  _currentButton = _gameInfoOptionsButton;
123  } else if (_controlOptionsButton->isHovered() && _currentButton != _controlOptionsButton) {
124  _optionsDescription->setText(_controlOptionsDescription);
125  _currentButton = _controlOptionsButton;
126  } else if (_creditsButton->isHovered() && _currentButton != _creditsButton) {
127  _optionsDescription->setText(_creditsDescription);
128  _currentButton = _creditsButton;
129  } else if (_backButton->isHovered() && _currentButton != _backButton) {
130  _optionsDescription->setText(_backButtonDescription);
131  _currentButton = _backButton;
132  }
133 }
134 
136  if (widget.getTag() == _audioOptionsButton->getTag()) {
137  if (!_audioOptions)
138  createAudioOptions();
139 
140  sub(*_audioOptions);
141  return;
142  }
143 
144  if (widget.getTag() == _videoOptionsButton->getTag()) {
145  if (!_videoOptions)
146  createVideoOptions();
147 
148  sub(*_videoOptions);
149  return;
150  }
151 
152  if (widget.getTag() == _difficultyOptionsButton->getTag()) {
153  if (!_difficultyOptions)
154  createDifficultyOptions();
155 
156  sub(*_difficultyOptions);
157  return;
158  }
159 
160  if (widget.getTag() == _gameInfoOptionsButton->getTag()) {
161  if (!_gameInfoOptions)
162  createGameInfoOptions();
163 
164  sub(*_gameInfoOptions);
165  return;
166  }
167 
168  if (widget.getTag() == _controlOptionsButton->getTag()) {
169  if (!_controlOptions)
170  createControlOptions();
171 
172  sub(*_controlOptions);
173  return;
174  }
175 
176  if (widget.getTag() == _creditsButton->getTag()) {
177  playVideo("creditmovie");
178  return;
179  }
180 
181  if (widget.getTag() == "ButtonBack")
183 }
184 
185 } // End of namespace Jade
186 
187 } // End of namespace Engines
The Jade Empire audio options menu.
Widget * getWidget(const Common::UString &tag, bool vital=false)
Return a widget in the GUI.
Definition: gui.cpp:314
void playVideo(const Common::UString &video)
Play this video resource.
Definition: util.cpp:54
static const uint32 kReturnCodeAbort
Definition: gui.h:47
A label widget for Star Wars: Knights of the Old Republic and Jade Empire.
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
OptionsMenu(::Engines::Console *console=0)
uint32 _returnCode
The GUI&#39;s return code.
Definition: gui.h:75
WidgetListBox * getListBox(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:318
void createItemWidgets(uint32 count)
Definition: listbox.cpp:131
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
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 Jade Empire game info options menu.
WidgetButton * getButton(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:306
WidgetLabel * getLabel(const Common::UString &tag, bool vital=false)
Definition: gui.cpp:270
The Jade Empire main options menu.
virtual void callbackRun()
Callback that&#39;s triggered periodically in the run() method.
Definition: gui.cpp:227
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.
void addItem(const Common::UString &contents)
Definition: listbox.cpp:122
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 Jade Empire difficulty options menu.
A widget in a GUI.
Definition: widget.h:40
The global talk manager for Aurora strings.
A protoitem widget for Star Wars: Knights of the Old Republic and Jade Empire.
The Jade Empire control options menu.
Generic Aurora engines utility functions.
void callbackActive(Widget &widget)
Callback that&#39;s triggered when a widget was activated.
Definition: options.cpp:74
The Jade Empire video options menu.