Skip to content

Commit

Permalink
KOTOR: Enable creation of random names in chargen
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Jul 16, 2018
1 parent a2b78df commit 4ba84e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/engines/kotor/gui/chargen/chargenname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ namespace Engines {
namespace KotOR {

CharacterGenerationNameMenu::CharacterGenerationNameMenu(CharacterGenerationInfo &info, Console *console) :
CharacterGenerationBaseMenu(info, console) {
CharacterGenerationBaseMenu(info, console),
_humanFirst(info.getGender() == kGenderMale ? "humanm" : "humanf"), _humanLast("humanl"),
_name(_info.getName()) {

load("name");

addBackground(kBackgroundTypeMenu);

_nameLabel = getLabel("NAME_BOX_EDIT");
_nameLabel->setText("_");
_nameLabel->setText(_info.getName() + "_");

EventMan.enableTextInput(true);
EventMan.enableKeyRepeat(true);
}

void CharacterGenerationNameMenu::callbackActive(Widget &widget) {
if (widget.getTag() == "BTN_RANDOM") {
_name = _humanFirst.generateRandomName(8) + " " + _humanLast.generateRandomName(8);
_nameLabel->setText(_name + "_");
_info.setName(_name);
return;
}

if (widget.getTag() == "BTN_BACK") {
_returnCode = 1;
EventMan.enableTextInput(false);
Expand All @@ -69,6 +78,7 @@ void CharacterGenerationNameMenu::callbackKeyInput(const Events::Key &key, const
if (!_name.empty()) {
_name.erase(--_name.end());
_nameLabel->setText(_name + "_");
_info.setName(_name);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/engines/kotor/gui/chargen/chargenname.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef ENGINES_KOTOR_GUI_CHARGEN_CHARGENNAME_H
#define ENGINES_KOTOR_GUI_CHARGEN_CHARGENNAME_H

#include "src/aurora/ltrfile.h"

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

#include "src/engines/kotor/gui/chargen/chargenbase.h"
Expand All @@ -42,6 +44,9 @@ class CharacterGenerationNameMenu : public CharacterGenerationBaseMenu {
void callbackTextInput(const Common::UString &text);
void callbackKeyInput(const Events::Key &key, const Events::EventType &type);

Aurora::LTRFile _humanFirst;
Aurora::LTRFile _humanLast;

WidgetLabel *_nameLabel;
Common::UString _name;
};
Expand Down

0 comments on commit 4ba84e6

Please sign in to comment.