Skip to content

Commit

Permalink
KOTOR: Add the class selection menu including the change of the music
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Jun 26, 2017
1 parent 6bd2a44 commit e573ec3
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/engines/kotor/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ void Game::stopMusic() {
}

void Game::mainMenu() {
playMenuMusic();

EventMan.flushEvents();

MainMenu menu(*_module, _platform == Aurora::kPlatformXbox, _console);
Expand All @@ -157,8 +155,6 @@ void Game::mainMenu() {

_console->enableCommand("loadmodule");
_console->enableCommand("exitmodule");

stopMenuMusic();
}

void Game::getModules(std::vector<Common::UString> &modules) {
Expand Down
141 changes: 141 additions & 0 deletions src/engines/kotor/gui/chargen/classselection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/* 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 class selection menu.
*/

#include "src/aurora/talkman.h"

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

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

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

namespace Engines {

namespace KotOR {

ClassSelectionMenu::ClassSelectionMenu(Module *module, ::Engines::Console *console) : GUI(console),
_module(module) {

load("classsel");

addBackground(kBackgroundTypeMenu);

// Get the six class buttons
_maleScoundrelButton = getButton("BTN_SEL1");
_maleScoutButton = getButton("BTN_SEL2");
_maleSoldierButton = getButton("BTN_SEL3");
_femaleSoldierButton = getButton("BTN_SEL4");
_femaleScoutButton = getButton("BTN_SEL5");
_femaleScoundrelButton = getButton("BTN_SEL6");

// Get the description label
_labelDesc = getLabel("LBL_DESC");
_labelDesc->setWrapped(true);
_labelDesc->setText(TalkMan.getString(32111));

// Get the title label
_labelTitle = getLabel("LBL_CLASS");
_labelTitle->setText("");

// Get the class descriptions
_soldierDesc = TalkMan.getString(32111);
_scoutDesc = TalkMan.getString(32110);
_scoundrelDesc = TalkMan.getString(32109);

// Combine the titles with gender prefix and class name
Common::UString malePrefix = TalkMan.getString(358);
Common::UString femalePrefix = TalkMan.getString(359);
_soldierMaleTitle = malePrefix + " " + TalkMan.getString(134);
_soldierFemaleTitle = femalePrefix + " " + TalkMan.getString(134);
_scoutMaleTitle = malePrefix + " " + TalkMan.getString(133);
_scoutFemaleTitle = femalePrefix + " " + TalkMan.getString(133);
_scoundrelMaleTitle = malePrefix + " " + TalkMan.getString(135);
_scoundrelFemaleTitle = femalePrefix + " " + TalkMan.getString(135);
}

void ClassSelectionMenu::callbackRun() {
// Check if a specific button is hovered and set title and description
if (_maleSoldierButton->isHovered() && _hoveredButton != _maleSoldierButton) {
_labelDesc->setText(_soldierDesc);
_labelTitle->setText(_soldierMaleTitle);
_hoveredButton = _maleSoldierButton;
return;
}
if (_femaleSoldierButton->isHovered() && _hoveredButton != _femaleSoldierButton) {
_labelDesc->setText(_soldierDesc);
_labelTitle->setText(_soldierFemaleTitle);
_hoveredButton = _femaleSoldierButton;
return;
}
if (_maleScoutButton->isHovered() && _hoveredButton != _maleScoutButton) {
_labelDesc->setText(_scoutDesc);
_labelTitle->setText(_scoutMaleTitle);
_hoveredButton = _maleScoutButton;
return;
}
if (_femaleScoutButton->isHovered() && _hoveredButton != _femaleScoutButton) {
_labelDesc->setText(_scoutDesc);
_labelTitle->setText(_scoutFemaleTitle);
_hoveredButton = _femaleScoutButton;
return;
}
if (_maleScoundrelButton->isHovered() && _hoveredButton != _maleScoundrelButton) {
_labelDesc->setText(_scoundrelDesc);
_labelTitle->setText(_scoundrelMaleTitle);
_hoveredButton = _maleScoundrelButton;
return;
}
if (_femaleScoundrelButton->isHovered() && _hoveredButton != _femaleScoundrelButton) {
_labelDesc->setText(_scoundrelDesc);
_labelTitle->setText(_scoundrelFemaleTitle);
_hoveredButton = _femaleScoundrelButton;
return;
}
}

void ClassSelectionMenu::callbackActive(Widget &widget) {
// Return to the main menu
if (widget.getTag() == "BTN_BACK") {
_returnCode = 1;
return;
}

// TODO: add class specific character generation code
if (widget.getTag() == "BTN_SEL1") {
}
if (widget.getTag() == "BTN_SEL2") {
}
if (widget.getTag() == "BTN_SEL3") {
}
if (widget.getTag() == "BTN_SEL4") {
}
if (widget.getTag() == "BTN_SEL5") {
}
if (widget.getTag() == "BTN_SEL6") {
}
}

} // End of namespace KotOR

} // End of namespace Engines
80 changes: 80 additions & 0 deletions src/engines/kotor/gui/chargen/classselection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* 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 class selection menu.
*/

#ifndef ENGINES_KOTOR_GUI_CHARGEN_CLASSSELECTION_H
#define ENGINES_KOTOR_GUI_CHARGEN_CLASSSELECTION_H

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

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

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

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

namespace Engines {

namespace KotOR {

class ClassSelectionMenu : public GUI {
public:
ClassSelectionMenu(Module *module, ::Engines::Console *console = 0);

private:
void callbackRun();
void callbackActive(Widget &widget);

WidgetLabel *_labelDesc;
WidgetLabel *_labelTitle;

WidgetButton *_maleSoldierButton;
WidgetButton *_maleScoutButton;
WidgetButton *_maleScoundrelButton;
WidgetButton *_femaleSoldierButton;
WidgetButton *_femaleScoutButton;
WidgetButton *_femaleScoundrelButton;

WidgetButton *_hoveredButton;

Module *_module;

Common::UString _soldierDesc;
Common::UString _scoundrelDesc;
Common::UString _scoutDesc;

Common::UString _soldierMaleTitle;
Common::UString _soldierFemaleTitle;
Common::UString _scoundrelMaleTitle;
Common::UString _scoundrelFemaleTitle;
Common::UString _scoutMaleTitle;
Common::UString _scoutFemaleTitle;
};

} // End of namespace KotOR

} // End of namespace Engines


#endif // ENGINES_KOTOR_GUI_CHARGEN_CLASSSELECTION_H
2 changes: 2 additions & 0 deletions src/engines/kotor/gui/chargen/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
# Character generation menu in Star Wars: Knights of the Old Republic.

src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/classselection.h \
$(EMPTY)

src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/classselection.cpp \
$(EMPTY)
50 changes: 41 additions & 9 deletions src/engines/kotor/gui/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@

#include "src/common/util.h"

#include "src/sound/sound.h"

#include "src/events/events.h"

#include "src/engines/aurora/util.h"
#include "src/engines/aurora/widget.h"

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

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

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

#include "src/engines/kotor/gui/main/main.h"
#include "src/engines/kotor/gui/main/movies.h"
#include "src/engines/kotor/gui/main/options.h"

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

namespace Engines {

Expand All @@ -47,11 +53,20 @@ MainMenu::MainMenu(Module &module, bool isXbox, ::Engines::Console *console) : G
load(isXbox ? "mainmenu" : "mainmenu16x12");

addBackground(kBackgroundTypeMenu);

startMainMusic();
}

MainMenu::~MainMenu() {
}

void MainMenu::createClassSelection() {
if (_classSelection)
return;

// Create the class selection menu
_classSelection.reset(new ClassSelectionMenu(_module, _console));
}

void MainMenu::createMovies() {
if (_movies)
Expand All @@ -70,6 +85,18 @@ void MainMenu::createOptions() {

}

void MainMenu::startMainMusic() {
_menuMusic = playSound("mus_theme_cult", Sound::kSoundTypeMusic, true);
}

void MainMenu::startCharGenMusic() {
_menuMusic = playSound("mus_theme_rep", Sound::kSoundTypeMusic, true);
}

void MainMenu::stopMenuMusic() {
SoundMan.stopChannel(_menuMusic);
}

void MainMenu::initWidget(Widget &widget) {
// BioWare logo, the original game doesn't display it.
if (widget.getTag() == "LBL_BW") {
Expand Down Expand Up @@ -113,14 +140,19 @@ void MainMenu::initWidget(Widget &widget) {
void MainMenu::callbackActive(Widget &widget) {

if (widget.getTag() == "BTN_NEWGAME") {
try {
_module->load("end_m01aa");
} catch (...) {
Common::exceptionDispatcherWarning();
return;
}

_returnCode = 2;
// Stop the currently running main music
stopMenuMusic();

createClassSelection();

// Start the charGen music
startCharGenMusic();
sub(*_classSelection);

// If we return from the chargen we stop the music and play the main music
stopMenuMusic();
startMainMusic();

return;
}

Expand Down
8 changes: 8 additions & 0 deletions src/engines/kotor/gui/main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,17 @@ class MainMenu : public GUI {
Module *_module;
bool _isXbox;

Common::ScopedPtr<GUI> _classSelection;
Common::ScopedPtr<GUI> _movies;
Common::ScopedPtr<GUI> _options;

Sound::ChannelHandle _menuMusic;

void startMainMusic();
void startCharGenMusic();
void stopMenuMusic();

void createClassSelection();
void createMovies();
void createOptions();
};
Expand Down

0 comments on commit e573ec3

Please sign in to comment.