Skip to content

Commit

Permalink
KOTOR2: Add the class selection menu to kotor2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius committed May 9, 2018
1 parent 47e68a8 commit a35c943
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 8 deletions.
127 changes: 127 additions & 0 deletions src/engines/kotor2/gui/chargen/classselection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/* 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 KotOR 2 class selection.
*/

#include "src/aurora/talkman.h"

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

namespace Engines {

namespace KotOR2 {

ClassSelection::ClassSelection(Module *module, Console *console) : GUI(console) {
load("classsel_p");

_module = module;

Common::UString malePrefix, femalePrefix;
malePrefix = TalkMan.getString(646);
femalePrefix = TalkMan.getString(647);

_guardianMaleTitle = malePrefix + " " + TalkMan.getString(355);
_guardianFemaleTitle = femalePrefix + " " + TalkMan.getString(355);
_consularMaleTitle = malePrefix + " " + TalkMan.getString(354);
_consularFemaleTitle = femalePrefix + " " + TalkMan.getString(354);
_sentinelMaleTitle = malePrefix + " " + TalkMan.getString(353);
_sentinelFemaleTitle = femalePrefix + " " + TalkMan.getString(353);

_guardianDescription = TalkMan.getString(48032);
_sentinelDescription = TalkMan.getString(48033);
_consularDescription = TalkMan.getString(48031);

_labelDesc = getLabel("LBL_DESC");
_labelDesc->setWrapped(true);

_labelTitle = getLabel("LBL_CLASS");

_consularMaleButton = getButton("BTN_SEL1");
_guardianMaleButton = getButton("BTN_SEL2");
_sentinelMaleButton = getButton("BTN_SEL3");
_sentinelFemaleButton = getButton("BTN_SEL4");
_guardianFemaleButton = getButton("BTN_SEL5");
_consularFemaleButton = getButton("BTN_SEL6");

_labelDesc->setText(_consularDescription);
_labelTitle->setText(_consularMaleTitle);
_hoveredButton = _consularMaleButton;
}

void ClassSelection::callbackRun() {
if (_consularMaleButton->isHovered() && _hoveredButton != _consularMaleButton) {
_labelDesc->setText(_consularDescription);
_labelTitle->setText(_consularMaleTitle);
_hoveredButton = _consularMaleButton;
} else if (_consularFemaleButton->isHovered() && _hoveredButton != _consularFemaleButton) {
_labelDesc->setText(_consularDescription);
_labelTitle->setText(_consularFemaleTitle);
_hoveredButton = _consularFemaleButton;
} else if (_sentinelMaleButton->isHovered() && _hoveredButton != _sentinelMaleButton) {
_labelDesc->setText(_sentinelDescription);
_labelTitle->setText(_sentinelMaleTitle);
_hoveredButton = _sentinelMaleButton;
} else if (_sentinelFemaleButton->isHovered() && _hoveredButton != _sentinelFemaleButton) {
_labelDesc->setText(_sentinelDescription);
_labelTitle->setText(_sentinelFemaleTitle);
_hoveredButton = _sentinelFemaleButton;
} else if (_guardianMaleButton->isHovered() && _hoveredButton != _guardianMaleButton) {
_labelDesc->setText(_guardianDescription);
_labelTitle->setText(_guardianMaleTitle);
_hoveredButton = _guardianMaleButton;
} else if (_guardianFemaleButton->isHovered() && _hoveredButton != _guardianFemaleButton) {
_labelDesc->setText(_guardianDescription);
_labelTitle->setText(_guardianFemaleTitle);
_hoveredButton = _guardianFemaleButton;
}
}

void ClassSelection::callbackActive(Widget &widget) {
//TODO Add different character generations
if (widget.getTag() == "BTN_SEL1") {
return;
}
if (widget.getTag() == "BTN_SEL2") {
return;
}
if (widget.getTag() == "BTN_SEL3") {
return;
}
if (widget.getTag() == "BTN_SEL4") {
return;
}
if (widget.getTag() == "BTN_SEL5") {
return;
}
if (widget.getTag() == "BTN_SEL6") {
return;
}

if (widget.getTag() == "BTN_BACK") {
_returnCode = 1;
return;
}
}

} // End of namespace KotOR2

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

#ifndef ENGINES_KOTOR2_GUI_CHARGEN_CLASSSELECTION_H
#define ENGINES_KOTOR2_GUI_CHARGEN_CLASSSELECTION_H

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

namespace Engines {

namespace KotOR2 {

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

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

private:
Module *_module;

WidgetButton *_consularMaleButton;
WidgetButton *_sentinelMaleButton;
WidgetButton *_guardianMaleButton;
WidgetButton *_guardianFemaleButton;
WidgetButton *_sentinelFemaleButton;
WidgetButton *_consularFemaleButton;
WidgetButton *_hoveredButton;

WidgetLabel *_labelDesc;
WidgetLabel *_labelTitle;

Common::UString _guardianMaleTitle;
Common::UString _guardianFemaleTitle;
Common::UString _consularMaleTitle;
Common::UString _consularFemaleTitle;
Common::UString _sentinelMaleTitle;
Common::UString _sentinelFemaleTitle;

Common::UString _guardianDescription;
Common::UString _consularDescription;
Common::UString _sentinelDescription;
};

} // End of namespace KotOR2

} // End of namespace Engines

#endif // ENGINES_KOTOR2_GUI_CHARGEN_CLASSSELECTION_H
2 changes: 2 additions & 0 deletions src/engines/kotor2/gui/chargen/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
# Character Generation system in Star Wars: Knights of the Old Republic II - The Sith Lords.

src_engines_kotor2_libkotor2_la_SOURCES += \
src/engines/kotor2/gui/chargen/classselection.h \
$(EMPTY)

src_engines_kotor2_libkotor2_la_SOURCES += \
src/engines/kotor2/gui/chargen/classselection.cpp \
$(EMPTY)
16 changes: 8 additions & 8 deletions src/engines/kotor2/gui/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "src/engines/kotor2/gui/widgets/kotorwidget.h"

#include "src/engines/kotor2/gui/main/main.h"
#include "src/engines/kotor2/gui/chargen/classselection.h"

namespace Engines {

Expand Down Expand Up @@ -69,6 +70,11 @@ void MainMenu::initWidget(Widget &widget) {
}
}

void MainMenu::createClassSelection() {
if (!_classSelection)
_classSelection.reset(new ClassSelection(_module));
}

void MainMenu::callbackActive(Widget &widget) {
if (widget.getTag() == "BTN_EXIT") {
EventMan.requestQuit();
Expand All @@ -78,14 +84,8 @@ void MainMenu::callbackActive(Widget &widget) {
}

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

_returnCode = 2;
createClassSelection();
sub(*_classSelection);
return;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/engines/kotor2/gui/main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class MainMenu : public GUI {
void callbackActive(Widget &widget);

private:
void createClassSelection();

Common::ScopedPtr<GUI> _classSelection;

Module *_module;
};

Expand Down

0 comments on commit a35c943

Please sign in to comment.