Issue #107: removed a template from the window manager

actorid
Marc Zinnschlag 13 years ago
parent 484cce12a8
commit 35a64edf2a

@ -187,8 +187,8 @@ void CharacterCreation::spawnDialog(const char id)
switch (id)
{
case GM_Name:
if(mNameDialog)
mWM->removeDialog(mNameDialog);
mWM->removeDialog(mNameDialog);
mNameDialog = 0;
mNameDialog = new TextInputDialog(*mWM);
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
mNameDialog->setTextInput(mPlayerName);
@ -198,8 +198,8 @@ void CharacterCreation::spawnDialog(const char id)
break;
case GM_Race:
if (mRaceDialog)
mWM->removeDialog(mRaceDialog);
mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
mRaceDialog = new RaceDialog(*mWM);
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
mRaceDialog->setRaceId(mPlayerRaceId);
@ -209,16 +209,16 @@ void CharacterCreation::spawnDialog(const char id)
break;
case GM_Class:
if (mClassChoiceDialog)
mWM->removeDialog(mClassChoiceDialog);
mWM->removeDialog(mClassChoiceDialog);
mClassChoiceDialog = 0;
mClassChoiceDialog = new ClassChoiceDialog(*mWM);
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
mClassChoiceDialog->open();
break;
case GM_ClassPick:
if (mPickClassDialog)
mWM->removeDialog(mPickClassDialog);
mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
mPickClassDialog = new PickClassDialog(*mWM);
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mPickClassDialog->setClassId(mPlayerClass.name);
@ -228,8 +228,8 @@ void CharacterCreation::spawnDialog(const char id)
break;
case GM_Birth:
if (mBirthSignDialog)
mWM->removeDialog(mBirthSignDialog);
mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
mBirthSignDialog = new BirthDialog(*mWM);
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
@ -238,8 +238,8 @@ void CharacterCreation::spawnDialog(const char id)
break;
case GM_ClassCreate:
if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog);
mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
mCreateClassDialog = new CreateClassDialog(*mWM);
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
@ -255,8 +255,8 @@ void CharacterCreation::spawnDialog(const char id)
showClassQuestionDialog();
break;
case GM_Review:
if (mReviewDialog)
mWM->removeDialog(mReviewDialog);
mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mReviewDialog = new ReviewDialog(*mWM);
mReviewDialog->setPlayerName(mPlayerName);
mReviewDialog->setRace(mPlayerRaceId);
@ -311,24 +311,24 @@ void CharacterCreation::setPlayerFatigue (const MWMechanics::DynamicStat<int>& v
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
{
if (mReviewDialog)
mWM->removeDialog(mReviewDialog);
mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mWM->popGuiMode();
}
void CharacterCreation::onReviewDialogBack()
{
if (mReviewDialog)
mWM->removeDialog(mReviewDialog);
mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mWM->pushGuiMode(GM_Birth);
}
void CharacterCreation::onReviewActivateDialog(int parDialog)
{
if (mReviewDialog)
mWM->removeDialog(mReviewDialog);
mWM->removeDialog(mReviewDialog);
mReviewDialog = 0;
mCreationStage = CSE_ReviewNext;
mWM->popGuiMode();
@ -363,6 +363,7 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
mWM->setPlayerClass(mPlayerClass);
}
mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
}
//TODO This bit gets repeated a few times; wrap it in a function
@ -391,6 +392,7 @@ void CharacterCreation::onPickClassDialogBack()
if (!classId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
mWM->removeDialog(mPickClassDialog);
mPickClassDialog = 0;
}
mWM->popGuiMode();
@ -399,10 +401,8 @@ void CharacterCreation::onPickClassDialogBack()
void CharacterCreation::onClassChoice(int _index)
{
if (mClassChoiceDialog)
{
mWM->removeDialog(mClassChoiceDialog);
}
mWM->removeDialog(mClassChoiceDialog);
mClassChoiceDialog = 0;
mWM->popGuiMode();
@ -432,6 +432,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
mWM->setValue("name", mPlayerName);
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
mWM->removeDialog(mNameDialog);
mNameDialog = 0;
}
if (mCreationStage == CSE_ReviewNext)
@ -459,6 +460,7 @@ void CharacterCreation::onRaceDialogBack()
if (!mPlayerRaceId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
}
mWM->popGuiMode();
@ -474,6 +476,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
if (!mPlayerRaceId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
mWM->removeDialog(mRaceDialog);
mRaceDialog = 0;
}
if (mCreationStage == CSE_ReviewNext)
@ -501,6 +504,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
if (!mPlayerBirthSignId.empty())
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
}
if (mCreationStage >= CSE_BirthSignChosen)
@ -521,6 +525,7 @@ void CharacterCreation::onBirthSignDialogBack()
{
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
mWM->removeDialog(mBirthSignDialog);
mBirthSignDialog = 0;
}
mWM->popGuiMode();
@ -556,6 +561,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
mWM->setPlayerClass(klass);
mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
}
if (mCreationStage == CSE_ReviewNext)
@ -577,8 +583,8 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
void CharacterCreation::onCreateClassDialogBack()
{
if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog);
mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
@ -588,8 +594,9 @@ void CharacterCreation::onClassQuestionChosen(int _index)
{
MWBase::Environment::get().getSoundManager()->stopSay();
if (mGenerateClassQuestionDialog)
mWM->removeDialog(mGenerateClassQuestionDialog);
mWM->removeDialog(mGenerateClassQuestionDialog);
mGenerateClassQuestionDialog = 0;
if (_index < 0 || _index >= 3)
{
mWM->popGuiMode();
@ -666,8 +673,9 @@ void CharacterCreation::showClassQuestionDialog()
}
}
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog);
mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
mGenerateClassResultDialog->setClassId(mGenerateClass);
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
@ -683,8 +691,9 @@ void CharacterCreation::showClassQuestionDialog()
return;
}
if (mGenerateClassQuestionDialog)
mWM->removeDialog(mGenerateClassQuestionDialog);
mWM->removeDialog(mGenerateClassQuestionDialog);
mGenerateClassQuestionDialog = 0;
mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM);
InfoBoxDialog::ButtonList buttons;
@ -704,8 +713,9 @@ void CharacterCreation::onGenerateClassBack()
if(mCreationStage < CSE_ClassChosen)
mCreationStage = CSE_ClassChosen;
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog);
mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
mWM->popGuiMode();
@ -714,8 +724,9 @@ void CharacterCreation::onGenerateClassBack()
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
{
if (mGenerateClassResultDialog)
mWM->removeDialog(mGenerateClassResultDialog);
mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = 0;
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass);
mPlayerClass = *klass;

@ -558,26 +558,17 @@ void CreateClassDialog::open()
void CreateClassDialog::onDialogCancel()
{
if (mSpecDialog)
{
mWindowManager.removeDialog(mSpecDialog);
mSpecDialog = 0;
}
if (mAttribDialog)
{
mWindowManager.removeDialog(mAttribDialog);
mAttribDialog = 0;
}
if (mSkillDialog)
{
mWindowManager.removeDialog(mSkillDialog);
mSkillDialog = 0;
}
if (mDescDialog)
{
mWindowManager.removeDialog(mDescDialog);
mDescDialog = 0;
}
mWindowManager.removeDialog(mSpecDialog);
mSpecDialog = 0;
mWindowManager.removeDialog(mAttribDialog);
mAttribDialog = 0;
mWindowManager.removeDialog(mSkillDialog);
mSkillDialog = 0;
mWindowManager.removeDialog(mDescDialog);
mDescDialog = 0;
}
void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)

@ -177,8 +177,6 @@ namespace MWGui
void unsetSelectedSpell();
void unsetSelectedWeapon();
template<typename T>
void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr.
void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
@ -271,14 +269,6 @@ namespace MWGui
*/
void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
};
template<typename T>
void WindowManager::removeDialog(T*& dialog)
{
OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog);
removeDialog(d);
dialog = 0;
}
}
#endif

Loading…
Cancel
Save