Skip to content

Commit

Permalink
JADE: Add main options menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Jan 20, 2018
1 parent 7352492 commit cc7188e
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 0 deletions.
182 changes: 182 additions & 0 deletions src/engines/jade/gui/main/options.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* The Jade Empire main options menu.
*/

#include "src/aurora/talkman.h"

#include "src/engines/jade/gui/main/options.h"

#include "src/engines/jade/gui/options/audio.h"
#include "src/engines/jade/gui/options/video.h"
#include "src/engines/jade/gui/options/diff.h"
#include "src/engines/jade/gui/options/feed.h"
#include "src/engines/jade/gui/options/control.h"

#include "src/engines/kotor/gui/widgets/listbox.h"
#include "src/engines/kotor/gui/widgets/label.h"

namespace Engines {

namespace Jade {

OptionsMenu::OptionsMenu(Console *console) : GUI(console) {
load("options");

// Move this label behind the buttons.
float x, y, z;
getWidget("Lopt")->getPosition(x, y, z);
getWidget("Lopt")->setPosition(x, y, z + 10);

Engines::KotOR::WidgetListBox *optionsListBox = getListBox("OptionsListBox");

addWidget(optionsListBox->createItem("AUDIO_SETTINGS"));
addWidget(optionsListBox->createItem("GRAPHIC_SETTINGS"));
addWidget(optionsListBox->createItem("DIFFICULTY"));
addWidget(optionsListBox->createItem("GAME_INFO"));
addWidget(optionsListBox->createItem("CONTROLS"));
addWidget(optionsListBox->createItem("CREDITS"));

_audioOptionsButton = getButton("AUDIO_SETTINGS");
_videoOptionsButton = getButton("GRAPHIC_SETTINGS");
_difficultyOptionsButton = getButton("DIFFICULTY");
_gameInfoOptionsButton = getButton("GAME_INFO");
_controlOptionsButton = getButton("CONTROLS");
_creditsButton = getButton("CREDITS");

_backButton = getButton("ButtonBack");
_currentButton = 0;

_optionsDescription = getLabel("OptionsDescLabel");

_audioOptionsDescription = TalkMan.getString(129);
_videoOptionsDescription = TalkMan.getString(130);
_difficultyOptionsDescription = TalkMan.getString(152);
_gameInfoOptionsDescription = TalkMan.getString(153);
_controlOptionsDescription = TalkMan.getString(154);
_creditsDescription = TalkMan.getString(33212);
_backButtonDescription = TalkMan.getString(130088);

_audioOptionsButton->setText(TalkMan.getString(132));
_videoOptionsButton->setText(TalkMan.getString(133));
_difficultyOptionsButton->setText(TalkMan.getString(149));
_gameInfoOptionsButton->setText(TalkMan.getString(150));
_controlOptionsButton->setText(TalkMan.getString(151));
_creditsButton->setText(TalkMan.getString(15709));

_optionsDescription->setText("");
}

void OptionsMenu::createAudioOptions() {
_audioOptions.reset(new AudioOptionsMenu(_console));
}

void OptionsMenu::createVideoOptions() {
_videoOptions.reset(new VideoOptionsMenu(_console));
}

void OptionsMenu::createDifficultyOptions() {
_difficultyOptions.reset(new DifficultyOptionsMenu(_console));
}

void OptionsMenu::createGameInfoOptions() {
_gameInfoOptions.reset(new GameInfoOptionsMenu(_console));
}

void OptionsMenu::createControlOptions() {
_controlOptions.reset(new ControlOptionsMenu(_console));
}

void OptionsMenu::callbackRun() {
// Set description text for specific options.
if (_audioOptionsButton->isHovered() && _currentButton != _audioOptionsButton) {
_optionsDescription->setText(_audioOptionsDescription);
_currentButton = _audioOptionsButton;
} else if (_videoOptionsButton->isHovered() && _currentButton != _videoOptionsButton) {
_optionsDescription->setText(_videoOptionsDescription);
_currentButton = _videoOptionsButton;
} else if (_difficultyOptionsButton->isHovered() && _currentButton != _difficultyOptionsButton) {
_optionsDescription->setText(_difficultyOptionsDescription);
_currentButton = _difficultyOptionsButton;
} else if (_gameInfoOptionsButton->isHovered() && _currentButton != _gameInfoOptionsButton) {
_optionsDescription->setText(_gameInfoOptionsDescription);
_currentButton = _gameInfoOptionsButton;
} else if (_controlOptionsButton->isHovered() && _currentButton != _controlOptionsButton) {
_optionsDescription->setText(_controlOptionsDescription);
_currentButton = _controlOptionsButton;
} else if (_creditsButton->isHovered() && _currentButton != _creditsButton) {
_optionsDescription->setText(_creditsDescription);
_currentButton = _creditsButton;
} else if (_backButton->isHovered() && _currentButton != _backButton) {
_optionsDescription->setText(_backButtonDescription);
_currentButton = _backButton;
}
}

void OptionsMenu::callbackActive(Widget &widget) {
if (widget.getTag() == "AUDIO_SETTINGS") {
if (!_audioOptions)
createAudioOptions();

sub(*_audioOptions);
return;
}

if (widget.getTag() == "GRAPHIC_SETTINGS") {
if (!_videoOptions)
createVideoOptions();

sub(*_videoOptions);
return;
}

if (widget.getTag() == "DIFFICULTY") {
if (!_difficultyOptions)
createDifficultyOptions();

sub(*_difficultyOptions);
return;
}

if (widget.getTag() == "GAME_INFO") {
if (!_gameInfoOptions)
createGameInfoOptions();

sub(*_gameInfoOptions);
return;
}

if (widget.getTag() == "CONTROLS") {
if (!_controlOptions)
createControlOptions();

sub(*_controlOptions);
return;
}

if (widget.getTag() == "ButtonBack")
_returnCode = kReturnCodeAbort;
}

} // End of namespace Jade

} // End of namespace Engines
86 changes: 86 additions & 0 deletions src/engines/jade/gui/main/options.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* The Jade Empire main options menu.
*/

#ifndef ENGINES_JADE_GUI_MAIN_OPTIONS_H
#define ENGINES_JADE_GUI_MAIN_OPTIONS_H

#include "src/common/ustring.h"

#include "src/engines/kotor/gui/gui.h"

#include "src/engines/kotor/gui/widgets/button.h"

namespace Engines {

namespace Jade {

class Module;

class OptionsMenu : public Engines::KotOR::GUI {
public:
OptionsMenu(::Engines::Console *console = 0);

private:
void createAudioOptions();
void createVideoOptions();
void createDifficultyOptions();
void createGameInfoOptions();
void createControlOptions();

Common::ScopedPtr<GUI> _audioOptions;
Common::ScopedPtr<GUI> _videoOptions;
Common::ScopedPtr<GUI> _difficultyOptions;
Common::ScopedPtr<GUI> _gameInfoOptions;
Common::ScopedPtr<GUI> _controlOptions;

Engines::KotOR::WidgetButton *_audioOptionsButton;
Engines::KotOR::WidgetButton *_videoOptionsButton;
Engines::KotOR::WidgetButton *_difficultyOptionsButton;
Engines::KotOR::WidgetButton *_gameInfoOptionsButton;
Engines::KotOR::WidgetButton *_controlOptionsButton;
Engines::KotOR::WidgetButton *_creditsButton;

Engines::KotOR::WidgetButton *_backButton;
Engines::KotOR::WidgetButton *_currentButton;

Engines::KotOR::WidgetLabel *_optionsDescription;

Common::UString _audioOptionsDescription;
Common::UString _videoOptionsDescription;
Common::UString _difficultyOptionsDescription;
Common::UString _gameInfoOptionsDescription;
Common::UString _controlOptionsDescription;
Common::UString _creditsDescription;
Common::UString _backButtonDescription;

protected:
void callbackActive(Widget &widget);
void callbackRun();
};

} // End of namespace Jade

} // End of namespace Engines

#endif // ENGINES_JADE_GUI_MAIN_OPTIONS_H
2 changes: 2 additions & 0 deletions src/engines/jade/gui/main/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

src_engines_jade_libjade_la_SOURCES += \
src/engines/jade/gui/main/main.h \
src/engines/jade/gui/main/options.h \
$(EMPTY)

src_engines_jade_libjade_la_SOURCES += \
src/engines/jade/gui/main/main.cpp \
src/engines/jade/gui/main/options.cpp \
$(EMPTY)

0 comments on commit cc7188e

Please sign in to comment.