Finished refactoring, brought CharacterCreation up to standards

actorid
Cris Mihalache 13 years ago
parent ed5892eb5c
commit 4bc7051741

@ -6,26 +6,25 @@
#include "birth.hpp" #include "birth.hpp"
#include "review.hpp" #include "review.hpp"
#include "dialogue.hpp" #include "dialogue.hpp"
#include "mode.hpp" #include "mode.hpp"
using namespace MWGui; using namespace MWGui;
CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment) CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment)
: nameDialog(0) : mNameDialog(0)
, raceDialog(0) , mRaceDialog(0)
, dialogueWindow(0) , mDialogueWindow(0)
, classChoiceDialog(0) , mClassChoiceDialog(0)
, generateClassQuestionDialog(0) , mGenerateClassQuestionDialog(0)
, generateClassResultDialog(0) , mGenerateClassResultDialog(0)
, pickClassDialog(0) , mPickClassDialog(0)
, createClassDialog(0) , mCreateClassDialog(0)
, birthSignDialog(0) , mBirthSignDialog(0)
, reviewDialog(0) , mReviewDialog(0)
, wm(_wm) , mWM(_wm)
, environment(_environment) , mEnvironment(_environment)
{ {
creationStage = NotStarted; mCreationStage = CSE_NotStarted;
} }
void CharacterCreation::spawnDialog(const char id) void CharacterCreation::spawnDialog(const char id)
@ -33,210 +32,210 @@ void CharacterCreation::spawnDialog(const char id)
switch (id) switch (id)
{ {
case GM_Name: case GM_Name:
if(nameDialog) if(mNameDialog)
wm->removeDialog(nameDialog); mWM->removeDialog(mNameDialog);
nameDialog = new TextInputDialog(*wm); mNameDialog = new TextInputDialog(*mWM);
nameDialog->setTextLabel(wm->getGameSettingString("sName", "Name")); mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
nameDialog->setTextInput(playerName); mNameDialog->setTextInput(mPlayerName);
nameDialog->setNextButtonShow(creationStage >= NameChosen); mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
nameDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone); mNameDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
nameDialog->open(); mNameDialog->open();
break; break;
case GM_Race: case GM_Race:
if (raceDialog) if (mRaceDialog)
wm->removeDialog(raceDialog); mWM->removeDialog(mRaceDialog);
raceDialog = new RaceDialog(*wm); mRaceDialog = new RaceDialog(*mWM);
raceDialog->setNextButtonShow(creationStage >= RaceChosen); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
raceDialog->setRaceId(playerRaceId); mRaceDialog->setRaceId(mPlayerRaceId);
raceDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); mRaceDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
raceDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack); mRaceDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
raceDialog->open(); mRaceDialog->open();
break; break;
case GM_Class: case GM_Class:
if (classChoiceDialog) if (mClassChoiceDialog)
wm->removeDialog(classChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
classChoiceDialog = new ClassChoiceDialog(*wm); mClassChoiceDialog = new ClassChoiceDialog(*mWM);
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); mClassChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
classChoiceDialog->open(); mClassChoiceDialog->open();
break; break;
case GM_ClassPick: case GM_ClassPick:
if (pickClassDialog) if (mPickClassDialog)
wm->removeDialog(pickClassDialog); mWM->removeDialog(mPickClassDialog);
pickClassDialog = new PickClassDialog(*wm); mPickClassDialog = new PickClassDialog(*mWM);
pickClassDialog->setNextButtonShow(creationStage >= ClassChosen); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
pickClassDialog->setClassId(playerClass.name); mPickClassDialog->setClassId(mPlayerClass.name);
pickClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); mPickClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
pickClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); mPickClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
pickClassDialog->open(); mPickClassDialog->open();
break; break;
case GM_Birth: case GM_Birth:
if (birthSignDialog) if (mBirthSignDialog)
wm->removeDialog(birthSignDialog); mWM->removeDialog(mBirthSignDialog);
birthSignDialog = new BirthDialog(*wm); mBirthSignDialog = new BirthDialog(*mWM);
birthSignDialog->setNextButtonShow(creationStage >= BirthSignChosen); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
birthSignDialog->setBirthId(playerBirthSignId); mBirthSignDialog->setBirthId(mPlayerBirthSignId);
birthSignDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
birthSignDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
birthSignDialog->open(); mBirthSignDialog->open();
break; break;
case GM_ClassCreate: case GM_ClassCreate:
if (createClassDialog) if (mCreateClassDialog)
wm->removeDialog(createClassDialog); mWM->removeDialog(mCreateClassDialog);
createClassDialog = new CreateClassDialog(*wm); mCreateClassDialog = new CreateClassDialog(*mWM);
createClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone); mCreateClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
createClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack); mCreateClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
createClassDialog->open(); mCreateClassDialog->open();
break; break;
case GM_ClassGenerate: case GM_ClassGenerate:
generateClassStep = 0; mGenerateClassStep = 0;
generateClass = ""; mGenerateClass = "";
generateClassSpecializations[0] = 0; mGenerateClassSpecializations[0] = 0;
generateClassSpecializations[1] = 0; mGenerateClassSpecializations[1] = 0;
generateClassSpecializations[2] = 0; mGenerateClassSpecializations[2] = 0;
showClassQuestionDialog(); showClassQuestionDialog();
break; break;
case GM_Review: case GM_Review:
if (reviewDialog) if (mReviewDialog)
wm->removeDialog(reviewDialog); mWM->removeDialog(mReviewDialog);
reviewDialog = new ReviewDialog(*wm); mReviewDialog = new ReviewDialog(*mWM);
reviewDialog->setPlayerName(playerName); mReviewDialog->setPlayerName(mPlayerName);
reviewDialog->setRace(playerRaceId); mReviewDialog->setRace(mPlayerRaceId);
reviewDialog->setClass(playerClass); mReviewDialog->setClass(mPlayerClass);
reviewDialog->setBirthSign(playerBirthSignId); mReviewDialog->setBirthSign(mPlayerBirthSignId);
reviewDialog->setHealth(wm->getValue("HBar")); mReviewDialog->setHealth(mWM->getValue("HBar"));
reviewDialog->setMagicka(wm->getValue("MBar")); mReviewDialog->setMagicka(mWM->getValue("MBar"));
reviewDialog->setFatigue(wm->getValue("FBar")); mReviewDialog->setFatigue(mWM->getValue("FBar"));
{ {
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator end = playerAttributes.end(); std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator end = mPlayerAttributes.end();
for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = playerAttributes.begin(); it != end; ++it) for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = mPlayerAttributes.begin(); it != end; ++it)
{ {
reviewDialog->setAttribute(it->first, it->second); mReviewDialog->setAttribute(it->first, it->second);
} }
} }
{ {
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator end = playerSkillValues.end(); std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator end = mPlayerSkillValues.end();
for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = playerSkillValues.begin(); it != end; ++it) for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = mPlayerSkillValues.begin(); it != end; ++it)
{ {
reviewDialog->setSkillValue(it->first, it->second); mReviewDialog->setSkillValue(it->first, it->second);
} }
reviewDialog->configureSkills(playerMajorSkills, playerMinorSkills); mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills);
} }
reviewDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); mReviewDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
reviewDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack); mReviewDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
reviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog); mReviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
reviewDialog->open(); mReviewDialog->open();
break; break;
} }
} }
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow) void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
{ {
if (reviewDialog) if (mReviewDialog)
wm->removeDialog(reviewDialog); mWM->removeDialog(mReviewDialog);
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
void CharacterCreation::onReviewDialogBack() void CharacterCreation::onReviewDialogBack()
{ {
if (reviewDialog) if (mReviewDialog)
wm->removeDialog(reviewDialog); mWM->removeDialog(mReviewDialog);
wm->setGuiMode(GM_Birth); mWM->setGuiMode(GM_Birth);
} }
void CharacterCreation::onReviewActivateDialog(int parDialog) void CharacterCreation::onReviewActivateDialog(int parDialog)
{ {
if (reviewDialog) if (mReviewDialog)
wm->removeDialog(reviewDialog); mWM->removeDialog(mReviewDialog);
creationStage = ReviewNext; mCreationStage = CSE_ReviewNext;
switch(parDialog) switch(parDialog)
{ {
case ReviewDialog::NAME_DIALOG: case ReviewDialog::NAME_DIALOG:
wm->setGuiMode(GM_Name); mWM->setGuiMode(GM_Name);
break; break;
case ReviewDialog::RACE_DIALOG: case ReviewDialog::RACE_DIALOG:
wm->setGuiMode(GM_Race); mWM->setGuiMode(GM_Race);
break; break;
case ReviewDialog::CLASS_DIALOG: case ReviewDialog::CLASS_DIALOG:
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
break; break;
case ReviewDialog::BIRTHSIGN_DIALOG: case ReviewDialog::BIRTHSIGN_DIALOG:
wm->setGuiMode(GM_Birth); mWM->setGuiMode(GM_Birth);
}; };
} }
void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
{ {
if (pickClassDialog) if (mPickClassDialog)
{ {
const std::string &classId = pickClassDialog->getClassId(); const std::string &classId = mPickClassDialog->getClassId();
if (!classId.empty()) if (!classId.empty())
environment->mMechanicsManager->setPlayerClass(classId); mEnvironment->mMechanicsManager->setPlayerClass(classId);
const ESM::Class *klass = environment->mWorld->getStore().classes.find(classId); const ESM::Class *klass = mEnvironment->mWorld->getStore().classes.find(classId);
if (klass) if (klass)
{ {
playerClass = *klass; mPlayerClass = *klass;
wm->setPlayerClass(playerClass); mWM->setPlayerClass(mPlayerClass);
} }
wm->removeDialog(pickClassDialog); mWM->removeDialog(mPickClassDialog);
} }
//TODO This bit gets repeated a few times; wrap it in a function //TODO This bit gets repeated a few times; wrap it in a function
if (creationStage == ReviewNext) if (mCreationStage == CSE_ReviewNext)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else if (creationStage >= ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
wm->setGuiMode(GM_Birth); mWM->setGuiMode(GM_Birth);
else else
{ {
creationStage = ClassChosen; mCreationStage = CSE_ClassChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
void CharacterCreation::onPickClassDialogBack() void CharacterCreation::onPickClassDialogBack()
{ {
if (pickClassDialog) if (mPickClassDialog)
{ {
const std::string classId = pickClassDialog->getClassId(); const std::string classId = mPickClassDialog->getClassId();
if (!classId.empty()) if (!classId.empty())
environment->mMechanicsManager->setPlayerClass(classId); mEnvironment->mMechanicsManager->setPlayerClass(classId);
wm->removeDialog(pickClassDialog); mWM->removeDialog(mPickClassDialog);
} }
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
} }
void CharacterCreation::onClassChoice(int _index) void CharacterCreation::onClassChoice(int _index)
{ {
if (classChoiceDialog) if (mClassChoiceDialog)
{ {
wm->removeDialog(classChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
} }
switch(_index) switch(_index)
{ {
case ClassChoiceDialog::Class_Generate: case ClassChoiceDialog::Class_Generate:
wm->setGuiMode(GM_ClassGenerate); mWM->setGuiMode(GM_ClassGenerate);
break; break;
case ClassChoiceDialog::Class_Pick: case ClassChoiceDialog::Class_Pick:
wm->setGuiMode(GM_ClassPick); mWM->setGuiMode(GM_ClassPick);
break; break;
case ClassChoiceDialog::Class_Create: case ClassChoiceDialog::Class_Create:
wm->setGuiMode(GM_ClassCreate); mWM->setGuiMode(GM_ClassCreate);
break; break;
case ClassChoiceDialog::Class_Back: case ClassChoiceDialog::Class_Back:
wm->setGuiMode(GM_Race); mWM->setGuiMode(GM_Race);
break; break;
}; };
@ -244,108 +243,108 @@ void CharacterCreation::onClassChoice(int _index)
void CharacterCreation::onNameDialogDone(WindowBase* parWindow) void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
{ {
if (nameDialog) if (mNameDialog)
{ {
playerName = nameDialog->getTextInput(); mPlayerName = mNameDialog->getTextInput();
wm->setValue("name", playerName); mWM->setValue("name", mPlayerName);
environment->mMechanicsManager->setPlayerName(playerName); mEnvironment->mMechanicsManager->setPlayerName(mPlayerName);
wm->removeDialog(nameDialog); mWM->removeDialog(mNameDialog);
} }
if (creationStage == ReviewNext) if (mCreationStage == CSE_ReviewNext)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else if (creationStage >= NameChosen) else if (mCreationStage >= CSE_NameChosen)
wm->setGuiMode(GM_Race); mWM->setGuiMode(GM_Race);
else else
{ {
creationStage = NameChosen; mCreationStage = CSE_NameChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
void CharacterCreation::onRaceDialogBack() void CharacterCreation::onRaceDialogBack()
{ {
if (raceDialog) if (mRaceDialog)
{ {
playerRaceId = raceDialog->getRaceId(); mPlayerRaceId = mRaceDialog->getRaceId();
if (!playerRaceId.empty()) if (!mPlayerRaceId.empty())
environment->mMechanicsManager->setPlayerRace(playerRaceId, raceDialog->getGender() == RaceDialog::GM_Male); mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
wm->removeDialog(raceDialog); mWM->removeDialog(mRaceDialog);
} }
wm->setGuiMode(GM_Name); mWM->setGuiMode(GM_Name);
} }
void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
{ {
if (raceDialog) if (mRaceDialog)
{ {
playerRaceId = raceDialog->getRaceId(); mPlayerRaceId = mRaceDialog->getRaceId();
wm->setValue("race", playerRaceId); mWM->setValue("race", mPlayerRaceId);
if (!playerRaceId.empty()) if (!mPlayerRaceId.empty())
environment->mMechanicsManager->setPlayerRace(playerRaceId, raceDialog->getGender() == RaceDialog::GM_Male); mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
wm->removeDialog(raceDialog); mWM->removeDialog(mRaceDialog);
} }
if (creationStage == ReviewNext) if (mCreationStage == CSE_ReviewNext)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else if(creationStage >= RaceChosen) else if(mCreationStage >= CSE_RaceChosen)
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
else else
{ {
creationStage = RaceChosen; mCreationStage = CSE_RaceChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow) void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
{ {
if (birthSignDialog) if (mBirthSignDialog)
{ {
playerBirthSignId = birthSignDialog->getBirthId(); mPlayerBirthSignId = mBirthSignDialog->getBirthId();
wm->setBirthSign(playerBirthSignId); mWM->setBirthSign(mPlayerBirthSignId);
if (!playerBirthSignId.empty()) if (!mPlayerBirthSignId.empty())
environment->mMechanicsManager->setPlayerBirthsign(playerBirthSignId); mEnvironment->mMechanicsManager->setPlayerBirthsign(mPlayerBirthSignId);
wm->removeDialog(birthSignDialog); mWM->removeDialog(mBirthSignDialog);
} }
if (creationStage >= BirthSignChosen) if (mCreationStage >= CSE_BirthSignChosen)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else else
{ {
creationStage = BirthSignChosen; mCreationStage = CSE_BirthSignChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
void CharacterCreation::onBirthSignDialogBack() void CharacterCreation::onBirthSignDialogBack()
{ {
if (birthSignDialog) if (mBirthSignDialog)
{ {
environment->mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId()); mEnvironment->mMechanicsManager->setPlayerBirthsign(mBirthSignDialog->getBirthId());
wm->removeDialog(birthSignDialog); mWM->removeDialog(mBirthSignDialog);
} }
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
} }
void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
{ {
if (createClassDialog) if (mCreateClassDialog)
{ {
ESM::Class klass; ESM::Class klass;
klass.name = createClassDialog->getName(); klass.name = mCreateClassDialog->getName();
klass.description = createClassDialog->getDescription(); klass.description = mCreateClassDialog->getDescription();
klass.data.specialization = createClassDialog->getSpecializationId(); klass.data.specialization = mCreateClassDialog->getSpecializationId();
klass.data.isPlayable = 0x1; klass.data.isPlayable = 0x1;
std::vector<int> attributes = createClassDialog->getFavoriteAttributes(); std::vector<int> attributes = mCreateClassDialog->getFavoriteAttributes();
assert(attributes.size() == 2); assert(attributes.size() == 2);
klass.data.attribute[0] = attributes[0]; klass.data.attribute[0] = attributes[0];
klass.data.attribute[1] = attributes[1]; klass.data.attribute[1] = attributes[1];
std::vector<ESM::Skill::SkillEnum> majorSkills = createClassDialog->getMajorSkills(); std::vector<ESM::Skill::SkillEnum> majorSkills = mCreateClassDialog->getMajorSkills();
std::vector<ESM::Skill::SkillEnum> minorSkills = createClassDialog->getMinorSkills(); std::vector<ESM::Skill::SkillEnum> minorSkills = mCreateClassDialog->getMinorSkills();
assert(majorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0])); assert(majorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0]));
assert(minorSkills.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) for (size_t i = 0; i < sizeof(klass.data.skills)/sizeof(klass.data.skills[0]); ++i)
@ -353,56 +352,56 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
klass.data.skills[i][1] = majorSkills[i]; klass.data.skills[i][1] = majorSkills[i];
klass.data.skills[i][0] = minorSkills[i]; klass.data.skills[i][0] = minorSkills[i];
} }
environment->mMechanicsManager->setPlayerClass(klass); mEnvironment->mMechanicsManager->setPlayerClass(klass);
playerClass = klass; mPlayerClass = klass;
wm->setPlayerClass(klass); mWM->setPlayerClass(klass);
wm->removeDialog(createClassDialog); mWM->removeDialog(mCreateClassDialog);
} }
if (creationStage == ReviewNext) if (mCreationStage == CSE_ReviewNext)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else if (creationStage >= ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
wm->setGuiMode(GM_Birth); mWM->setGuiMode(GM_Birth);
else else
{ {
creationStage = ClassChosen; mCreationStage = CSE_ClassChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
void CharacterCreation::onCreateClassDialogBack() void CharacterCreation::onCreateClassDialogBack()
{ {
if (createClassDialog) if (mCreateClassDialog)
wm->removeDialog(createClassDialog); mWM->removeDialog(mCreateClassDialog);
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
} }
void CharacterCreation::onClassQuestionChosen(int _index) void CharacterCreation::onClassQuestionChosen(int _index)
{ {
if (generateClassQuestionDialog) if (mGenerateClassQuestionDialog)
wm->removeDialog(generateClassQuestionDialog); mWM->removeDialog(mGenerateClassQuestionDialog);
if (_index < 0 || _index >= 3) if (_index < 0 || _index >= 3)
{ {
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
return; return;
} }
ESM::Class::Specialization specialization = generateClassSteps[generateClassStep].specializations[_index]; ESM::Class::Specialization specialization = sGenerateClassSteps[mGenerateClassStep].mSpecializations[_index];
if (specialization == ESM::Class::Stealth) if (specialization == ESM::Class::Stealth)
++generateClassSpecializations[0]; ++mGenerateClassSpecializations[0];
else if (specialization == ESM::Class::Combat) else if (specialization == ESM::Class::Combat)
++generateClassSpecializations[1]; ++mGenerateClassSpecializations[1];
else if (specialization == ESM::Class::Magic) else if (specialization == ESM::Class::Magic)
++generateClassSpecializations[2]; ++mGenerateClassSpecializations[2];
++generateClassStep; ++mGenerateClassStep;
showClassQuestionDialog(); showClassQuestionDialog();
} }
void CharacterCreation::showClassQuestionDialog() void CharacterCreation::showClassQuestionDialog()
{ {
if (generateClassStep == generateClassSteps.size()) if (mGenerateClassStep == sGenerateClassSteps.size())
{ {
static boost::array<ClassPoint, 23> classes = { { static boost::array<ClassPoint, 23> classes = { {
{"Acrobat", {6, 2, 2}}, {"Acrobat", {6, 2, 2}},
@ -433,100 +432,100 @@ void CharacterCreation::showClassQuestionDialog()
int match = -1; int match = -1;
for (unsigned i = 0; i < classes.size(); ++i) for (unsigned i = 0; i < classes.size(); ++i)
{ {
if (generateClassSpecializations[0] == classes[i].points[0] && if (mGenerateClassSpecializations[0] == classes[i].points[0] &&
generateClassSpecializations[1] == classes[i].points[1] && mGenerateClassSpecializations[1] == classes[i].points[1] &&
generateClassSpecializations[2] == classes[i].points[2]) mGenerateClassSpecializations[2] == classes[i].points[2])
{ {
match = i; match = i;
generateClass = classes[i].id; mGenerateClass = classes[i].id;
break; break;
} }
} }
if (match == -1) if (match == -1)
{ {
if (generateClassSpecializations[0] >= 7) if (mGenerateClassSpecializations[0] >= 7)
generateClass = "Thief"; mGenerateClass = "Thief";
else if (generateClassSpecializations[1] >= 7) else if (mGenerateClassSpecializations[1] >= 7)
generateClass = "Warrior"; mGenerateClass = "Warrior";
else if (generateClassSpecializations[2] >= 7) else if (mGenerateClassSpecializations[2] >= 7)
generateClass = "Mage"; mGenerateClass = "Mage";
else else
{ {
std::cerr << "Failed to deduce class from chosen answers in generate class dialog" << std::endl; std::cerr << "Failed to deduce class from chosen answers in generate class dialog" << std::endl;
generateClass = "Thief"; mGenerateClass = "Thief";
} }
} }
if (generateClassResultDialog) if (mGenerateClassResultDialog)
wm->removeDialog(generateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
generateClassResultDialog = new GenerateClassResultDialog(*wm); mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
generateClassResultDialog->setClassId(generateClass); mGenerateClassResultDialog->setClassId(mGenerateClass);
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack); mGenerateClassResultDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone); mGenerateClassResultDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
generateClassResultDialog->open(); mGenerateClassResultDialog->open();
return; return;
} }
if (generateClassStep > generateClassSteps.size()) if (mGenerateClassStep > sGenerateClassSteps.size())
{ {
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
return; return;
} }
if (generateClassQuestionDialog) if (mGenerateClassQuestionDialog)
wm->removeDialog(generateClassQuestionDialog); mWM->removeDialog(mGenerateClassQuestionDialog);
generateClassQuestionDialog = new InfoBoxDialog(*wm); mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM);
InfoBoxDialog::ButtonList buttons; InfoBoxDialog::ButtonList buttons;
generateClassQuestionDialog->setText(generateClassSteps[generateClassStep].text); mGenerateClassQuestionDialog->setText(sGenerateClassSteps[mGenerateClassStep].mText);
buttons.push_back(generateClassSteps[generateClassStep].buttons[0]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[0]);
buttons.push_back(generateClassSteps[generateClassStep].buttons[1]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[1]);
buttons.push_back(generateClassSteps[generateClassStep].buttons[2]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
generateClassQuestionDialog->setButtons(buttons); mGenerateClassQuestionDialog->setButtons(buttons);
generateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); mGenerateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
generateClassQuestionDialog->open(); mGenerateClassQuestionDialog->open();
} }
void CharacterCreation::onGenerateClassBack() void CharacterCreation::onGenerateClassBack()
{ {
if(creationStage < ClassChosen) if(mCreationStage < CSE_ClassChosen)
creationStage = ClassChosen; mCreationStage = CSE_ClassChosen;
if (generateClassResultDialog) if (mGenerateClassResultDialog)
wm->removeDialog(generateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
environment->mMechanicsManager->setPlayerClass(generateClass); mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass);
wm->setGuiMode(GM_Class); mWM->setGuiMode(GM_Class);
} }
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{ {
if (generateClassResultDialog) if (mGenerateClassResultDialog)
wm->removeDialog(generateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
environment->mMechanicsManager->setPlayerClass(generateClass); mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass);
if (creationStage == ReviewNext) if (mCreationStage == CSE_ReviewNext)
wm->setGuiMode(GM_Review); mWM->setGuiMode(GM_Review);
else if (creationStage >= ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
wm->setGuiMode(GM_Birth); mWM->setGuiMode(GM_Birth);
else else
{ {
creationStage = ClassChosen; mCreationStage = CSE_ClassChosen;
wm->setGuiMode(GM_Game); mWM->setGuiMode(GM_Game);
} }
} }
CharacterCreation::~CharacterCreation() CharacterCreation::~CharacterCreation()
{ {
delete nameDialog; delete mNameDialog;
delete raceDialog; delete mRaceDialog;
delete dialogueWindow; delete mDialogueWindow;
delete classChoiceDialog; delete mClassChoiceDialog;
delete generateClassQuestionDialog; delete mGenerateClassQuestionDialog;
delete generateClassResultDialog; delete mGenerateClassResultDialog;
delete pickClassDialog; delete mPickClassDialog;
delete createClassDialog; delete mCreateClassDialog;
delete birthSignDialog; delete mBirthSignDialog;
delete reviewDialog; delete mReviewDialog;
} }

@ -37,34 +37,34 @@ namespace MWGui
void spawnDialog(const char id); void spawnDialog(const char id);
private: private:
WindowManager* wm;
MWWorld::Environment* environment;
//Dialogs //Dialogs
TextInputDialog *nameDialog; TextInputDialog* mNameDialog;
RaceDialog *raceDialog; RaceDialog* mRaceDialog;
DialogueWindow *dialogueWindow; DialogueWindow* mDialogueWindow;
ClassChoiceDialog *classChoiceDialog; ClassChoiceDialog* mClassChoiceDialog;
InfoBoxDialog *generateClassQuestionDialog; InfoBoxDialog* mGenerateClassQuestionDialog;
GenerateClassResultDialog *generateClassResultDialog; GenerateClassResultDialog* mGenerateClassResultDialog;
PickClassDialog *pickClassDialog; PickClassDialog* mPickClassDialog;
CreateClassDialog *createClassDialog; CreateClassDialog* mCreateClassDialog;
BirthDialog *birthSignDialog; BirthDialog* mBirthSignDialog;
ReviewDialog *reviewDialog; ReviewDialog* mReviewDialog;
WindowManager* mWM;
MWWorld::Environment* mEnvironment;
//Player data //Player data
std::string playerName; std::string mPlayerName;
std::string playerRaceId; std::string mPlayerRaceId;
std::string playerBirthSignId; std::string mPlayerBirthSignId;
ESM::Class playerClass; ESM::Class mPlayerClass;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes; std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > mPlayerAttributes;
SkillList playerMajorSkills, playerMinorSkills; SkillList mPlayerMajorSkills, mPlayerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues; std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > mPlayerSkillValues;
//Class generation vars //Class generation vars
unsigned generateClassStep; // Keeps track of current step in Generate Class dialog unsigned mGenerateClassStep; // Keeps track of current step in Generate Class dialog
unsigned generateClassSpecializations[3]; // A counter for each specialization which is increased when an answer is chosen unsigned mGenerateClassSpecializations[3]; // A counter for each specialization which is increased when an answer is chosen
std::string generateClass; // In order: Stealth, Combat, Magic std::string mGenerateClass; // In order: Stealth, Combat, Magic
////Dialog events ////Dialog events
//Name dialog //Name dialog
@ -94,27 +94,27 @@ namespace MWGui
void onReviewDialogBack(); void onReviewDialogBack();
void onReviewActivateDialog(int parDialog); void onReviewActivateDialog(int parDialog);
enum CreationStageEnum enum CSE //Creation Stage Enum
{ {
NotStarted, CSE_NotStarted,
NameChosen, CSE_NameChosen,
RaceChosen, CSE_RaceChosen,
ClassChosen, CSE_ClassChosen,
BirthSignChosen, CSE_BirthSignChosen,
ReviewNext CSE_ReviewNext
}; };
CreationStageEnum creationStage; // Which state the character creating is in, controls back/next/ok buttons CSE mCreationStage; // Which state the character creating is in, controls back/next/ok buttons
}; };
struct Step struct Step
{ {
const char* text; const char* mText;
const char* buttons[3]; const char* mButtons[3];
ESM::Class::Specialization specializations[3]; // The specialization for each answer ESM::Class::Specialization mSpecializations[3]; // The specialization for each answer
}; };
static boost::array<Step, 10> generateClassSteps = { { static boost::array<Step, 10> sGenerateClassSteps = { {
// Question 1 // Question 1
{"On a clear day you chance upon a strange animal, its legs trapped in a hunter's clawsnare. Judging from the bleeding, it will not survive long.", {"On a clear day you chance upon a strange animal, its legs trapped in a hunter's clawsnare. Judging from the bleeding, it will not survive long.",
{"Draw your dagger, mercifully endings its life with a single thrust.", {"Draw your dagger, mercifully endings its life with a single thrust.",

@ -80,58 +80,6 @@ namespace MWGui
typedef std::vector<Faction> FactionList; typedef std::vector<Faction> FactionList;
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
private:
MWWorld::Environment& environment;
HUD *hud;
MapWindow *map;
MainMenu *menu;
StatsWindow *stats;
MessageBoxManager *mMessageBoxManager;
Console *console;
JournalWindow* mJournal;
DialogueWindow *dialogueWindow;
CharacterCreation* mCharGen;
// Various stats about player as needed by window manager
ESM::Class playerClass;
std::string playerName;
std::string playerRaceId;
std::string playerBirthSignId;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes;
SkillList playerMajorSkills, playerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues;
MWMechanics::DynamicStat<int> playerHealth, playerMagicka, playerFatigue;
MyGUI::Gui *gui; // Gui
GuiMode mode; // Current gui mode
GuiMode nextMode; // Next mode to activate in update()
bool needModeChange; //Whether a mode change is needed in update() [will use nextMode]
std::vector<OEngine::GUI::Layout*> garbageDialogs;
void cleanupGarbage();
GuiWindow shown; // Currently shown windows in inventory mode
/* Currently ALLOWED windows in inventory mode. This is used at
the start of the game, when windows are enabled one by one
through script commands. You can manipulate this through using
allow() and disableAll().
The setting should also affect visibility of certain HUD
elements, but this is not done yet.
*/
GuiWindow allowed;
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
int showFPSLevel;
float mFPS;
size_t mTriangleCount;
size_t mBatchCount;
public:
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment, const Compiler::Extensions& extensions, int fpsLevel, bool newGame); WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment, const Compiler::Extensions& extensions, int fpsLevel, bool newGame);
virtual ~WindowManager(); virtual ~WindowManager();
@ -222,6 +170,55 @@ namespace MWGui
const ESMS::ESMStore& getStore() const; const ESMS::ESMStore& getStore() const;
private: private:
MWWorld::Environment& environment;
HUD *hud;
MapWindow *map;
MainMenu *menu;
StatsWindow *stats;
MessageBoxManager *mMessageBoxManager;
Console *console;
JournalWindow* mJournal;
DialogueWindow *dialogueWindow;
CharacterCreation* mCharGen;
// Various stats about player as needed by window manager
ESM::Class playerClass;
std::string playerName;
std::string playerRaceId;
std::string playerBirthSignId;
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > playerAttributes;
SkillList playerMajorSkills, playerMinorSkills;
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > playerSkillValues;
MWMechanics::DynamicStat<int> playerHealth, playerMagicka, playerFatigue;
MyGUI::Gui *gui; // Gui
GuiMode mode; // Current gui mode
GuiMode nextMode; // Next mode to activate in update()
bool needModeChange; //Whether a mode change is needed in update() [will use nextMode]
std::vector<OEngine::GUI::Layout*> garbageDialogs;
void cleanupGarbage();
GuiWindow shown; // Currently shown windows in inventory mode
/* Currently ALLOWED windows in inventory mode. This is used at
the start of the game, when windows are enabled one by one
through script commands. You can manipulate this through using
allow() and disableAll().
The setting should also affect visibility of certain HUD
elements, but this is not done yet.
*/
GuiWindow allowed;
void updateVisible(); // Update visibility of all windows based on mode, shown and allowed settings
int showFPSLevel;
float mFPS;
size_t mTriangleCount;
size_t mBatchCount;
void onDialogueWindowBye(); void onDialogueWindowBye();
}; };

Loading…
Cancel
Save