Properly apply changes when backing out of chargen dialogs (Fixes #2627)

sceneinput
scrawl 10 years ago
parent 86f0e505e9
commit 0d8f07d563

@ -312,7 +312,7 @@ namespace MWGui
}; };
} }
void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) void CharacterCreation::selectPickedClass()
{ {
if (mPickClassDialog) if (mPickClassDialog)
{ {
@ -332,20 +332,18 @@ namespace MWGui
} }
updatePlayerHealth(); updatePlayerHealth();
}
void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
{
selectPickedClass();
handleDialogDone(CSE_ClassChosen, GM_Birth); handleDialogDone(CSE_ClassChosen, GM_Birth);
} }
void CharacterCreation::onPickClassDialogBack() void CharacterCreation::onPickClassDialogBack()
{ {
if (mPickClassDialog) selectPickedClass();
{
const std::string classId = mPickClassDialog->getClassId();
if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
MWBase::Environment::get().getWindowManager()->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
}
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
@ -390,7 +388,7 @@ namespace MWGui
handleDialogDone(CSE_NameChosen, GM_Race); handleDialogDone(CSE_NameChosen, GM_Race);
} }
void CharacterCreation::onRaceDialogBack() void CharacterCreation::selectRace()
{ {
if (mRaceDialog) if (mRaceDialog)
{ {
@ -404,40 +402,31 @@ namespace MWGui
data.mHair data.mHair
); );
} }
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog); MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
mRaceDialog = 0; mRaceDialog = 0;
} }
updatePlayerHealth();
}
void CharacterCreation::onRaceDialogBack()
{
selectRace();
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Name); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Name);
} }
void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
{ {
if (mRaceDialog) selectRace();
{
const ESM::NPC &data = mRaceDialog->getResult();
mPlayerRaceId = data.mRace;
if (!mPlayerRaceId.empty()) {
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(
data.mRace,
data.isMale(),
data.mHead,
data.mHair
);
}
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
mRaceDialog = 0;
}
updatePlayerHealth();
handleDialogDone(CSE_RaceChosen, GM_Class); handleDialogDone(CSE_RaceChosen, GM_Class);
} }
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow) void CharacterCreation::selectBirthSign()
{ {
if (mBirthSignDialog) if (mBirthSignDialog)
{ {
@ -449,24 +438,24 @@ namespace MWGui
} }
updatePlayerHealth(); updatePlayerHealth();
}
void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
{
selectBirthSign();
handleDialogDone(CSE_BirthSignChosen, GM_Review); handleDialogDone(CSE_BirthSignChosen, GM_Review);
} }
void CharacterCreation::onBirthSignDialogBack() void CharacterCreation::onBirthSignDialogBack()
{ {
if (mBirthSignDialog) selectBirthSign();
{
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
MWBase::Environment::get().getWindowManager()->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
}
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
} }
void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) void CharacterCreation::selectCreatedClass()
{ {
if (mCreateClassDialog) if (mCreateClassDialog)
{ {
@ -495,19 +484,23 @@ namespace MWGui
mPlayerClass = klass; mPlayerClass = klass;
MWBase::Environment::get().getWindowManager()->setPlayerClass(klass); MWBase::Environment::get().getWindowManager()->setPlayerClass(klass);
// Do not delete dialog, so that choices are rembered in case we want to go back and adjust them later // Do not delete dialog, so that choices are remembered in case we want to go back and adjust them later
mCreateClassDialog->setVisible(false); mCreateClassDialog->setVisible(false);
} }
updatePlayerHealth(); updatePlayerHealth();
}
void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
{
selectCreatedClass();
handleDialogDone(CSE_ClassChosen, GM_Birth); handleDialogDone(CSE_ClassChosen, GM_Birth);
} }
void CharacterCreation::onCreateClassDialogBack() void CharacterCreation::onCreateClassDialogBack()
{ {
// Do not delete dialog, so that choices are rembered in case we want to go back and adjust them later // not done in MW, but we do it for consistency with the other dialogs
mCreateClassDialog->setVisible(false); selectCreatedClass();
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class); MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
@ -631,18 +624,7 @@ namespace MWGui
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps(mGenerateClassStep).mSound); MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps(mGenerateClassStep).mSound);
} }
void CharacterCreation::onGenerateClassBack() void CharacterCreation::selectGeneratedClass()
{
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
}
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{ {
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog); MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0; mGenerateClassResultDialog = 0;
@ -656,6 +638,19 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setPlayerClass(mPlayerClass); MWBase::Environment::get().getWindowManager()->setPlayerClass(mPlayerClass);
updatePlayerHealth(); updatePlayerHealth();
}
void CharacterCreation::onGenerateClassBack()
{
selectGeneratedClass();
MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
}
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{
selectGeneratedClass();
handleDialogDone(CSE_ClassChosen, GM_Birth); handleDialogDone(CSE_ClassChosen, GM_Birth);
} }

@ -83,6 +83,7 @@ namespace MWGui
//Race dialog //Race dialog
void onRaceDialogDone(WindowBase* parWindow); void onRaceDialogDone(WindowBase* parWindow);
void onRaceDialogBack(); void onRaceDialogBack();
void selectRace();
//Class dialogs //Class dialogs
void onClassChoice(int _index); void onClassChoice(int _index);
@ -94,10 +95,14 @@ namespace MWGui
void onClassQuestionChosen(int _index); void onClassQuestionChosen(int _index);
void onGenerateClassBack(); void onGenerateClassBack();
void onGenerateClassDone(WindowBase* parWindow); void onGenerateClassDone(WindowBase* parWindow);
void selectGeneratedClass();
void selectCreatedClass();
void selectPickedClass();
//Birthsign dialog //Birthsign dialog
void onBirthSignDialogDone(WindowBase* parWindow); void onBirthSignDialogDone(WindowBase* parWindow);
void onBirthSignDialogBack(); void onBirthSignDialogBack();
void selectBirthSign();
//Review dialog //Review dialog
void onReviewDialogDone(WindowBase* parWindow); void onReviewDialogDone(WindowBase* parWindow);

Loading…
Cancel
Save