1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Updated WindowManager to use the new removeDialog function.

This commit is contained in:
Jan Borsodi 2010-10-22 23:34:41 +02:00
parent f756e171cc
commit 06f226f2d8
2 changed files with 25 additions and 92 deletions

View File

@ -168,10 +168,7 @@ void WindowManager::updateVisible()
if (mode == GM_Name) if (mode == GM_Name)
{ {
if (nameDialog) if (nameDialog)
{ removeDialog(nameDialog);
nameDialog->setVisible(false);
garbageDialogs.push_back(nameDialog);
}
nameDialog = new TextInputDialog(environment, gui->getViewSize()); nameDialog = new TextInputDialog(environment, gui->getViewSize());
std::string sName = getGameSettingString("sName", "Name"); std::string sName = getGameSettingString("sName", "Name");
nameDialog->setTextLabel(sName); nameDialog->setTextLabel(sName);
@ -184,10 +181,7 @@ void WindowManager::updateVisible()
if (mode == GM_Race) if (mode == GM_Race)
{ {
if (raceDialog) if (raceDialog)
{ removeDialog(raceDialog);
raceDialog->setVisible(false);
garbageDialogs.push_back(raceDialog);
}
raceDialog = new RaceDialog(environment, gui->getViewSize()); raceDialog = new RaceDialog(environment, gui->getViewSize());
raceDialog->setNextButtonShow(raceChosen); raceDialog->setNextButtonShow(raceChosen);
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
@ -199,10 +193,7 @@ void WindowManager::updateVisible()
if (mode == GM_Class) if (mode == GM_Class)
{ {
if (classChoiceDialog) if (classChoiceDialog)
{ removeDialog(classChoiceDialog);
classChoiceDialog->setVisible(false);
garbageDialogs.push_back(classChoiceDialog);
}
classChoiceDialog = new ClassChoiceDialog(environment); classChoiceDialog = new ClassChoiceDialog(environment);
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice); classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice);
return; return;
@ -218,10 +209,7 @@ void WindowManager::updateVisible()
if (mode == GM_ClassPick) if (mode == GM_ClassPick)
{ {
if (pickClassDialog) if (pickClassDialog)
{ removeDialog(pickClassDialog);
pickClassDialog->setVisible(false);
garbageDialogs.push_back(pickClassDialog);
}
pickClassDialog = new PickClassDialog(environment, gui->getViewSize()); pickClassDialog = new PickClassDialog(environment, gui->getViewSize());
pickClassDialog->setNextButtonShow(classChosen); pickClassDialog->setNextButtonShow(classChosen);
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone); pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
@ -233,10 +221,7 @@ void WindowManager::updateVisible()
if (mode == GM_ClassCreate) if (mode == GM_ClassCreate)
{ {
if (createClassDialog) if (createClassDialog)
{ removeDialog(createClassDialog);
createClassDialog->setVisible(false);
garbageDialogs.push_back(createClassDialog);
}
createClassDialog = new CreateClassDialog(environment, gui->getViewSize()); createClassDialog = new CreateClassDialog(environment, gui->getViewSize());
createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone); createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone);
createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack); createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack);
@ -247,10 +232,7 @@ void WindowManager::updateVisible()
if (mode == GM_Birth) if (mode == GM_Birth)
{ {
if (birthSignDialog) if (birthSignDialog)
{ removeDialog(birthSignDialog);
birthSignDialog->setVisible(false);
garbageDialogs.push_back(birthSignDialog);
}
birthSignDialog = new BirthDialog(environment, gui->getViewSize()); birthSignDialog = new BirthDialog(environment, gui->getViewSize());
birthSignDialog->setNextButtonShow(birthSignChosen); birthSignDialog->setNextButtonShow(birthSignChosen);
birthSignDialog->setBirthId(playerBirthSignId); birthSignDialog->setBirthId(playerBirthSignId);
@ -264,10 +246,7 @@ void WindowManager::updateVisible()
{ {
reviewNext = false; reviewNext = false;
if (reviewDialog) if (reviewDialog)
{ removeDialog(reviewDialog);
reviewDialog->setVisible(false);
garbageDialogs.push_back(reviewDialog);
}
reviewDialog = new ReviewDialog(environment, gui->getViewSize()); reviewDialog = new ReviewDialog(environment, gui->getViewSize());
reviewDialog->setPlayerName(playerName); reviewDialog->setPlayerName(playerName);
reviewDialog->setRace(playerRaceId); reviewDialog->setRace(playerRaceId);
@ -511,9 +490,7 @@ void WindowManager::onNameDialogDone()
{ {
environment.mMechanicsManager->setPlayerName(nameDialog->getTextInput()); environment.mMechanicsManager->setPlayerName(nameDialog->getTextInput());
nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void(); nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void();
nameDialog->setVisible(false); removeDialog(nameDialog);
garbageDialogs.push_back(nameDialog);
nameDialog = nullptr;
} }
bool goNext = nameChosen; // Go to next dialog if name was previously chosen bool goNext = nameChosen; // Go to next dialog if name was previously chosen
@ -537,9 +514,7 @@ void WindowManager::onRaceDialogDone()
if (!raceId.empty()) if (!raceId.empty())
environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male); environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male);
raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void(); raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void();
raceDialog->setVisible(false); removeDialog(raceDialog);
garbageDialogs.push_back(raceDialog);
raceDialog = nullptr;
} }
bool goNext = raceChosen; // Go to next dialog if race was previously chosen bool goNext = raceChosen; // Go to next dialog if race was previously chosen
@ -562,9 +537,7 @@ void WindowManager::onRaceDialogBack()
const std::string &raceId = raceDialog->getRaceId(); const std::string &raceId = raceDialog->getRaceId();
if (!raceId.empty()) if (!raceId.empty())
environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male); environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male);
raceDialog->setVisible(false); removeDialog(raceDialog);
garbageDialogs.push_back(raceDialog);
raceDialog = nullptr;
} }
updateCharacterGeneration(); updateCharacterGeneration();
@ -576,9 +549,7 @@ void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index)
{ {
if (classChoiceDialog) if (classChoiceDialog)
{ {
classChoiceDialog->setVisible(false); removeDialog(classChoiceDialog);
garbageDialogs.push_back(classChoiceDialog);
classChoiceDialog = nullptr;
} }
if (_index == ClassChoiceDialog::Class_Generate) if (_index == ClassChoiceDialog::Class_Generate)
@ -625,10 +596,7 @@ void WindowManager::showClassQuestionDialog()
generateClass = "acrobat"; generateClass = "acrobat";
if (generateClassResultDialog) if (generateClassResultDialog)
{ removeDialog(generateClassResultDialog);
generateClassResultDialog->setVisible(false);
garbageDialogs.push_back(generateClassResultDialog);
}
generateClassResultDialog = new GenerateClassResultDialog(environment); generateClassResultDialog = new GenerateClassResultDialog(environment);
generateClassResultDialog->setClassId(generateClass); generateClassResultDialog->setClassId(generateClass);
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack); generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack);
@ -644,10 +612,7 @@ void WindowManager::showClassQuestionDialog()
} }
if (generateClassQuestionDialog) if (generateClassQuestionDialog)
{ removeDialog(generateClassQuestionDialog);
generateClassQuestionDialog->setVisible(false);
garbageDialogs.push_back(generateClassQuestionDialog);
}
generateClassQuestionDialog = new InfoBoxDialog(environment); generateClassQuestionDialog = new InfoBoxDialog(environment);
InfoBoxDialog::ButtonList buttons; InfoBoxDialog::ButtonList buttons;
@ -664,11 +629,7 @@ void WindowManager::showClassQuestionDialog()
void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index) void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
{ {
if (generateClassQuestionDialog) if (generateClassQuestionDialog)
{ removeDialog(generateClassQuestionDialog);
generateClassQuestionDialog->setVisible(false);
garbageDialogs.push_back(generateClassQuestionDialog);
generateClassQuestionDialog = nullptr;
}
if (_index < 0 || _index >= 3) if (_index < 0 || _index >= 3)
{ {
setGuiMode(GM_Class); setGuiMode(GM_Class);
@ -685,11 +646,7 @@ void WindowManager::onGenerateClassBack()
classChosen = true; classChosen = true;
if (generateClassResultDialog) if (generateClassResultDialog)
{ removeDialog(generateClassResultDialog);
generateClassResultDialog->setVisible(false);
garbageDialogs.push_back(generateClassResultDialog);
generateClassResultDialog = nullptr;
}
environment.mMechanicsManager->setPlayerClass(generateClass); environment.mMechanicsManager->setPlayerClass(generateClass);
updateCharacterGeneration(); updateCharacterGeneration();
@ -703,11 +660,7 @@ void WindowManager::onGenerateClassDone()
classChosen = true; classChosen = true;
if (generateClassResultDialog) if (generateClassResultDialog)
{ removeDialog(generateClassResultDialog);
generateClassResultDialog->setVisible(false);
garbageDialogs.push_back(generateClassResultDialog);
generateClassResultDialog = nullptr;
}
environment.mMechanicsManager->setPlayerClass(generateClass); environment.mMechanicsManager->setPlayerClass(generateClass);
updateCharacterGeneration(); updateCharacterGeneration();
@ -729,9 +682,7 @@ void WindowManager::onPickClassDialogDone()
if (!classId.empty()) if (!classId.empty())
environment.mMechanicsManager->setPlayerClass(classId); environment.mMechanicsManager->setPlayerClass(classId);
pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void(); pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void();
pickClassDialog->setVisible(false); removeDialog(pickClassDialog);
garbageDialogs.push_back(pickClassDialog);
pickClassDialog = nullptr;
} }
bool goNext = classChosen; // Go to next dialog if class was previously chosen bool goNext = classChosen; // Go to next dialog if class was previously chosen
@ -754,9 +705,7 @@ void WindowManager::onPickClassDialogBack()
const std::string classId = pickClassDialog->getClassId(); const std::string classId = pickClassDialog->getClassId();
if (!classId.empty()) if (!classId.empty())
environment.mMechanicsManager->setPlayerClass(classId); environment.mMechanicsManager->setPlayerClass(classId);
pickClassDialog->setVisible(false); removeDialog(pickClassDialog);
garbageDialogs.push_back(pickClassDialog);
pickClassDialog = nullptr;
} }
updateCharacterGeneration(); updateCharacterGeneration();
@ -792,9 +741,7 @@ void WindowManager::onCreateClassDialogDone()
environment.mMechanicsManager->setPlayerClass(klass); environment.mMechanicsManager->setPlayerClass(klass);
createClassDialog->eventDone = MWGui::CreateClassDialog::EventHandle_Void(); createClassDialog->eventDone = MWGui::CreateClassDialog::EventHandle_Void();
createClassDialog->setVisible(false); removeDialog(createClassDialog);
garbageDialogs.push_back(createClassDialog);
createClassDialog = nullptr;
} }
bool goNext = classChosen; // Go to next dialog if class was previously chosen bool goNext = classChosen; // Go to next dialog if class was previously chosen
@ -813,11 +760,7 @@ void WindowManager::onCreateClassDialogDone()
void WindowManager::onCreateClassDialogBack() void WindowManager::onCreateClassDialogBack()
{ {
if (createClassDialog) if (createClassDialog)
{ removeDialog(createClassDialog);
createClassDialog->setVisible(false);
garbageDialogs.push_back(createClassDialog);
createClassDialog = nullptr;
}
updateCharacterGeneration(); updateCharacterGeneration();
@ -830,9 +773,7 @@ void WindowManager::onBirthSignDialogDone()
{ {
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId()); environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
birthSignDialog->eventDone = MWGui::BirthDialog::EventHandle_Void(); birthSignDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
birthSignDialog->setVisible(false); removeDialog(birthSignDialog);
garbageDialogs.push_back(birthSignDialog);
birthSignDialog = nullptr;
} }
bool goNext = birthSignChosen; // Go to next dialog if birth sign was previously chosen bool goNext = birthSignChosen; // Go to next dialog if birth sign was previously chosen
@ -851,9 +792,7 @@ void WindowManager::onBirthSignDialogBack()
if (birthSignDialog) if (birthSignDialog)
{ {
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId()); environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
birthSignDialog->setVisible(false); removeDialog(birthSignDialog);
garbageDialogs.push_back(birthSignDialog);
birthSignDialog = nullptr;
} }
updateCharacterGeneration(); updateCharacterGeneration();
@ -866,9 +805,7 @@ void WindowManager::onReviewDialogDone()
if (reviewDialog) if (reviewDialog)
{ {
reviewDialog->eventDone = MWGui::BirthDialog::EventHandle_Void(); reviewDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
reviewDialog->setVisible(false); removeDialog(reviewDialog);
garbageDialogs.push_back(reviewDialog);
reviewDialog = nullptr;
} }
updateCharacterGeneration(); updateCharacterGeneration();
@ -879,11 +816,7 @@ void WindowManager::onReviewDialogDone()
void WindowManager::onReviewDialogBack() void WindowManager::onReviewDialogBack()
{ {
if (reviewDialog) if (reviewDialog)
{ removeDialog(reviewDialog);
reviewDialog->setVisible(false);
garbageDialogs.push_back(reviewDialog);
reviewDialog = nullptr;
}
updateCharacterGeneration(); updateCharacterGeneration();

View File

@ -289,7 +289,7 @@ namespace MWGui
{ {
OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog); OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog);
removeDialog(d); removeDialog(d);
dialog = nullptr; dialog = 0;
} }
} }