Finished handling of Create Class dialog, now a new class is created and set in the mechanics manager.

actorid
Jan Borsodi 14 years ago
parent 232164bfb0
commit 0cc8f84393

@ -525,6 +525,51 @@ CreateClassDialog::~CreateClassDialog()
delete descDialog;
}
std::string CreateClassDialog::getName() const
{
return editName->getOnlyText();
}
std::string CreateClassDialog::getDescription() const
{
return description;
}
ESM::Class::Specialization CreateClassDialog::getSpecializationId() const
{
return specializationId;
}
std::vector<int> CreateClassDialog::getFavoriteAttributes() const
{
std::vector<int> v;
v.push_back(favoriteAttribute0->getAttributeId());
v.push_back(favoriteAttribute1->getAttributeId());
return v;
}
std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMajorSkills() const
{
std::vector<ESM::Skill::SkillEnum> v;
v.push_back(majorSkill0->getSkillId());
v.push_back(majorSkill1->getSkillId());
v.push_back(majorSkill2->getSkillId());
v.push_back(majorSkill3->getSkillId());
v.push_back(majorSkill4->getSkillId());
return v;
}
std::vector<ESM::Skill::SkillEnum> CreateClassDialog::getMinorSkills() const
{
std::vector<ESM::Skill::SkillEnum> v;
v.push_back(majorSkill0->getSkillId());
v.push_back(majorSkill1->getSkillId());
v.push_back(majorSkill2->getSkillId());
v.push_back(majorSkill3->getSkillId());
v.push_back(majorSkill4->getSkillId());
return v;
}
void CreateClassDialog::setNextButtonShow(bool shown)
{
MyGUI::ButtonPtr descriptionButton;

@ -288,8 +288,12 @@ namespace MWGui
CreateClassDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize);
virtual ~CreateClassDialog();
// const std::string &getClassId() const { return currentClassId; }
// void setClassId(const std::string &classId);
std::string getName() const;
std::string getDescription() const;
ESM::Class::Specialization getSpecializationId() const;
std::vector<int> getFavoriteAttributes() const;
std::vector<ESM::Skill::SkillEnum> getMajorSkills() const;
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
void setNextButtonShow(bool shown);
void open();

@ -25,6 +25,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
, generateClassQuestionDialog(nullptr)
, generateClassResultDialog(nullptr)
, pickClassDialog(nullptr)
, createClassDialog(nullptr)
, birthSignDialog(nullptr)
, nameChosen(false)
, raceChosen(false)
@ -74,6 +75,7 @@ WindowManager::~WindowManager()
delete generateClassQuestionDialog;
delete generateClassResultDialog;
delete pickClassDialog;
delete createClassDialog;
delete birthSignDialog;
}
@ -163,8 +165,12 @@ void WindowManager::updateVisible()
if (mode == GM_ClassCreate)
{
CreateClassDialog *ccd = new CreateClassDialog(environment, gui->getViewSize());
ccd->open();
if (createClassDialog)
delete createClassDialog;
createClassDialog = new CreateClassDialog(environment, gui->getViewSize());
createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone);
createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack);
createClassDialog->open();
return;
}
@ -439,6 +445,9 @@ void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
void WindowManager::onGenerateClassBack()
{
bool goNext = classChosen; // Go to next dialog if class was previously chosen
classChosen = true;
if (generateClassResultDialog)
{
generateClassResultDialog->setVisible(false);
@ -452,6 +461,9 @@ void WindowManager::onGenerateClassBack()
void WindowManager::onGenerateClassDone()
{
bool goNext = classChosen; // Go to next dialog if class was previously chosen
classChosen = true;
if (generateClassResultDialog)
{
generateClassResultDialog->setVisible(false);
@ -460,7 +472,12 @@ void WindowManager::onGenerateClassDone()
updateCharacterGeneration();
environment.mInputManager->setGuiMode(GM_Review);
if (reviewNext)
environment.mInputManager->setGuiMode(GM_Review);
else if (goNext)
environment.mInputManager->setGuiMode(GM_Birth);
else
environment.mInputManager->setGuiMode(GM_Game);
}
@ -499,6 +516,63 @@ void WindowManager::onPickClassDialogBack()
environment.mInputManager->setGuiMode(GM_Class);
}
void WindowManager::onCreateClassDialogDone()
{
createClassDialog->eventDone = MWGui::CreateClassDialog::EventHandle_Void();
bool goNext = classChosen; // Go to next dialog if class was previously chosen
classChosen = true;
if (createClassDialog)
{
createClassDialog->setVisible(false);
// TODO: The ESM::Class should have methods to set these values to ensure correct data is assigned
ESM::Class klass;
klass.name = createClassDialog->getName();
klass.description = createClassDialog->getDescription();
klass.data.specialization = createClassDialog->getSpecializationId();
klass.data.isPlayable = 0x1;
std::vector<int> attributes = createClassDialog->getFavoriteAttributes();
assert(attributes.size() == 2);
klass.data.attribute[0] = attributes[0];
klass.data.attribute[1] = attributes[1];
std::vector<ESM::Skill::SkillEnum> majorSkills = createClassDialog->getMajorSkills();
std::vector<ESM::Skill::SkillEnum> minorSkills = createClassDialog->getMinorSkills();
assert(majorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0]));
assert(minorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0]));
for (size_t i = 0; i < sizeof(klass.data.skills)/sizeof(klass.data.skills[0]); ++i)
{
klass.data.skills[i][1] = majorSkills[i];
klass.data.skills[i][0] = minorSkills[i];
}
environment.mMechanicsManager->setPlayerClass(klass);
}
updateCharacterGeneration();
if (reviewNext)
environment.mInputManager->setGuiMode(GM_Review);
else if (goNext)
environment.mInputManager->setGuiMode(GM_Birth);
else
environment.mInputManager->setGuiMode(GM_Game);
}
void WindowManager::onCreateClassDialogBack()
{
if (pickClassDialog)
{
pickClassDialog->setVisible(false);
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
}
updateCharacterGeneration();
environment.mInputManager->setGuiMode(GM_Class);
}
void WindowManager::onBirthSignDialogDone()
{
birthSignDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();

@ -48,6 +48,7 @@ namespace MWGui
class ClassChoiceDialog;
class GenerateClassResultDialog;
class PickClassDialog;
class CreateClassDialog;
class BirthDialog;
class WindowManager
@ -69,6 +70,7 @@ namespace MWGui
InfoBoxDialog *generateClassQuestionDialog;
GenerateClassResultDialog *generateClassResultDialog;
PickClassDialog *pickClassDialog;
CreateClassDialog *createClassDialog;
BirthDialog *birthSignDialog;
// Which dialogs have been shown, controls back/next/ok buttons
@ -213,6 +215,10 @@ namespace MWGui
void onPickClassDialogDone();
void onPickClassDialogBack();
// Character generation: Create Class dialog
void onCreateClassDialogDone();
void onCreateClassDialogBack();
// Character generation: Birth sign dialog
void onBirthSignDialogDone();
void onBirthSignDialogBack();

Loading…
Cancel
Save