forked from mirror/openmw-tes3mp
Updated all dialogs to use a garbage list for postponed cleanup, this list is cleared in update() which is called for each frame.
Fixed incorrect code in onCreateClassDialogBack, should use set class from pickClassDialog. Add private method setGuiMode() which calls the input manager, updated all gui-mode changes in WindowManager to use that.
This commit is contained in:
parent
3e5f278882
commit
16aa13721a
3 changed files with 225 additions and 91 deletions
|
@ -36,6 +36,8 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, reviewNext(false)
|
, reviewNext(false)
|
||||||
, gui(_gui)
|
, gui(_gui)
|
||||||
, mode(GM_Game)
|
, mode(GM_Game)
|
||||||
|
, nextMode(GM_Game)
|
||||||
|
, needModeChange(false)
|
||||||
, shown(GW_ALL)
|
, shown(GW_ALL)
|
||||||
, allowed(newGame ? GW_None : GW_ALL)
|
, allowed(newGame ? GW_None : GW_ALL)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +95,37 @@ WindowManager::~WindowManager()
|
||||||
delete reviewDialog;
|
delete reviewDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::update()
|
||||||
|
{
|
||||||
|
// Delete any dialogs which no longer in use
|
||||||
|
if (!garbageDialogs.empty())
|
||||||
|
{
|
||||||
|
for (std::vector<OEngine::GUI::Layout*>::iterator it = garbageDialogs.begin(); it != garbageDialogs.end(); ++it)
|
||||||
|
{
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
garbageDialogs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needModeChange)
|
||||||
|
{
|
||||||
|
needModeChange = false;
|
||||||
|
environment.mInputManager->setGuiMode(nextMode);
|
||||||
|
nextMode = GM_Game;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowManager::setNextMode(GuiMode newMode)
|
||||||
|
{
|
||||||
|
nextMode = newMode;
|
||||||
|
needModeChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowManager::setGuiMode(GuiMode newMode)
|
||||||
|
{
|
||||||
|
environment.mInputManager->setGuiMode(newMode);
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::updateVisible()
|
void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
// Start out by hiding everything except the HUD
|
// Start out by hiding everything except the HUD
|
||||||
|
@ -128,9 +161,12 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Name)
|
if (mode == GM_Name)
|
||||||
{
|
{
|
||||||
if (!nameDialog)
|
if (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);
|
||||||
nameDialog->setNextButtonShow(nameChosen);
|
nameDialog->setNextButtonShow(nameChosen);
|
||||||
|
@ -141,7 +177,11 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Race)
|
if (mode == GM_Race)
|
||||||
{
|
{
|
||||||
if (!raceDialog)
|
if (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);
|
||||||
|
@ -153,7 +193,10 @@ void WindowManager::updateVisible()
|
||||||
if (mode == GM_Class)
|
if (mode == GM_Class)
|
||||||
{
|
{
|
||||||
if (classChoiceDialog)
|
if (classChoiceDialog)
|
||||||
delete 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;
|
||||||
|
@ -168,7 +211,11 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_ClassPick)
|
if (mode == GM_ClassPick)
|
||||||
{
|
{
|
||||||
if (!pickClassDialog)
|
if (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);
|
||||||
|
@ -180,7 +227,10 @@ void WindowManager::updateVisible()
|
||||||
if (mode == GM_ClassCreate)
|
if (mode == GM_ClassCreate)
|
||||||
{
|
{
|
||||||
if (createClassDialog)
|
if (createClassDialog)
|
||||||
delete 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);
|
||||||
|
@ -190,9 +240,14 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Birth)
|
if (mode == GM_Birth)
|
||||||
{
|
{
|
||||||
if (!birthSignDialog)
|
if (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->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
||||||
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
||||||
birthSignDialog->open();
|
birthSignDialog->open();
|
||||||
|
@ -202,9 +257,12 @@ void WindowManager::updateVisible()
|
||||||
if (mode == GM_Review)
|
if (mode == GM_Review)
|
||||||
{
|
{
|
||||||
reviewNext = false;
|
reviewNext = false;
|
||||||
if (!reviewDialog)
|
if (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);
|
||||||
reviewDialog->setClass(playerClass);
|
reviewDialog->setClass(playerClass);
|
||||||
|
@ -259,7 +317,7 @@ void WindowManager::updateVisible()
|
||||||
// Unsupported mode, switch back to game
|
// Unsupported mode, switch back to game
|
||||||
// Note: The call will eventually end up this method again but
|
// Note: The call will eventually end up this method again but
|
||||||
// will stop at the check if(mode == GM_Game) above.
|
// will stop at the check if(mode == GM_Game) above.
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
||||||
|
@ -434,81 +492,91 @@ void WindowManager::updateCharacterGeneration()
|
||||||
|
|
||||||
void WindowManager::onNameDialogDone()
|
void WindowManager::onNameDialogDone()
|
||||||
{
|
{
|
||||||
|
if (nameDialog)
|
||||||
|
{
|
||||||
|
environment.mMechanicsManager->setPlayerName(nameDialog->getTextInput());
|
||||||
nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void();
|
nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void();
|
||||||
|
nameDialog->setVisible(false);
|
||||||
|
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
|
||||||
nameChosen = true;
|
nameChosen = true;
|
||||||
if (nameDialog)
|
|
||||||
{
|
|
||||||
nameDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerName(nameDialog->getTextInput());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext)
|
if (reviewNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onRaceDialogDone()
|
void WindowManager::onRaceDialogDone()
|
||||||
{
|
{
|
||||||
|
if (raceDialog)
|
||||||
|
{
|
||||||
|
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male);
|
||||||
raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void();
|
raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void();
|
||||||
|
raceDialog->setVisible(false);
|
||||||
|
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
|
||||||
raceChosen = true;
|
raceChosen = true;
|
||||||
if (raceDialog)
|
|
||||||
{
|
|
||||||
raceDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext)
|
if (reviewNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onRaceDialogBack()
|
void WindowManager::onRaceDialogBack()
|
||||||
{
|
{
|
||||||
if (raceDialog)
|
if (raceDialog)
|
||||||
{
|
{
|
||||||
raceDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male);
|
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male);
|
||||||
|
raceDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(raceDialog);
|
||||||
|
raceDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Name);
|
setGuiMode(GM_Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index)
|
void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index)
|
||||||
|
{
|
||||||
|
if (classChoiceDialog)
|
||||||
{
|
{
|
||||||
classChoiceDialog->setVisible(false);
|
classChoiceDialog->setVisible(false);
|
||||||
// classChoiceDialog = nullptr;
|
garbageDialogs.push_back(classChoiceDialog);
|
||||||
|
classChoiceDialog = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (_index == ClassChoiceDialog::Class_Generate)
|
if (_index == ClassChoiceDialog::Class_Generate)
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_ClassGenerate);
|
setGuiMode(GM_ClassGenerate);
|
||||||
}
|
}
|
||||||
else if (_index == ClassChoiceDialog::Class_Pick)
|
else if (_index == ClassChoiceDialog::Class_Pick)
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_ClassPick);
|
setGuiMode(GM_ClassPick);
|
||||||
}
|
}
|
||||||
else if (_index == ClassChoiceDialog::Class_Create)
|
else if (_index == ClassChoiceDialog::Class_Create)
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_ClassCreate);
|
setGuiMode(GM_ClassCreate);
|
||||||
}
|
}
|
||||||
else if (_index == ClassChoiceDialog::Class_Back)
|
else if (_index == ClassChoiceDialog::Class_Back)
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +606,10 @@ void WindowManager::showClassQuestionDialog()
|
||||||
generateClass = "acrobat";
|
generateClass = "acrobat";
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
delete 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);
|
||||||
|
@ -549,11 +620,15 @@ void WindowManager::showClassQuestionDialog()
|
||||||
|
|
||||||
if (generateClassStep > steps.size())
|
if (generateClassStep > steps.size())
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!generateClassQuestionDialog)
|
if (generateClassQuestionDialog)
|
||||||
|
{
|
||||||
|
generateClassQuestionDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(generateClassQuestionDialog);
|
||||||
|
}
|
||||||
generateClassQuestionDialog = new InfoBoxDialog(environment);
|
generateClassQuestionDialog = new InfoBoxDialog(environment);
|
||||||
|
|
||||||
InfoBoxDialog::ButtonList buttons;
|
InfoBoxDialog::ButtonList buttons;
|
||||||
|
@ -568,11 +643,16 @@ void WindowManager::showClassQuestionDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
|
void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
|
||||||
|
{
|
||||||
|
if (generateClassQuestionDialog)
|
||||||
{
|
{
|
||||||
generateClassQuestionDialog->setVisible(false);
|
generateClassQuestionDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(generateClassQuestionDialog);
|
||||||
|
generateClassQuestionDialog = nullptr;
|
||||||
|
}
|
||||||
if (_index < 0 || _index >= 3)
|
if (_index < 0 || _index >= 3)
|
||||||
{
|
{
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,12 +668,14 @@ void WindowManager::onGenerateClassBack()
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
{
|
{
|
||||||
generateClassResultDialog->setVisible(false);
|
generateClassResultDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(generateClassResultDialog);
|
||||||
|
generateClassResultDialog = nullptr;
|
||||||
}
|
}
|
||||||
environment.mMechanicsManager->setPlayerClass(generateClass);
|
environment.mMechanicsManager->setPlayerClass(generateClass);
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onGenerateClassDone()
|
void WindowManager::onGenerateClassDone()
|
||||||
|
@ -604,65 +686,65 @@ void WindowManager::onGenerateClassDone()
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
{
|
{
|
||||||
generateClassResultDialog->setVisible(false);
|
generateClassResultDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(generateClassResultDialog);
|
||||||
|
generateClassResultDialog = nullptr;
|
||||||
}
|
}
|
||||||
environment.mMechanicsManager->setPlayerClass(generateClass);
|
environment.mMechanicsManager->setPlayerClass(generateClass);
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext)
|
if (reviewNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WindowManager::onPickClassDialogDone()
|
void WindowManager::onPickClassDialogDone()
|
||||||
{
|
{
|
||||||
|
if (pickClassDialog)
|
||||||
|
{
|
||||||
|
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
|
||||||
pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void();
|
pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void();
|
||||||
|
pickClassDialog->setVisible(false);
|
||||||
|
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
|
||||||
classChosen = true;
|
classChosen = true;
|
||||||
if (pickClassDialog)
|
|
||||||
{
|
|
||||||
pickClassDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext)
|
if (reviewNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onPickClassDialogBack()
|
void WindowManager::onPickClassDialogBack()
|
||||||
{
|
{
|
||||||
if (pickClassDialog)
|
if (pickClassDialog)
|
||||||
{
|
{
|
||||||
pickClassDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
|
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
|
||||||
|
pickClassDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(pickClassDialog);
|
||||||
|
pickClassDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onCreateClassDialogDone()
|
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)
|
if (createClassDialog)
|
||||||
{
|
{
|
||||||
createClassDialog->setVisible(false);
|
|
||||||
|
|
||||||
// TODO: The ESM::Class should have methods to set these values to ensure correct data is assigned
|
// TODO: The ESM::Class should have methods to set these values to ensure correct data is assigned
|
||||||
ESM::Class klass;
|
ESM::Class klass;
|
||||||
klass.name = createClassDialog->getName();
|
klass.name = createClassDialog->getName();
|
||||||
|
@ -685,77 +767,90 @@ void WindowManager::onCreateClassDialogDone()
|
||||||
klass.data.skills[i][0] = minorSkills[i];
|
klass.data.skills[i][0] = minorSkills[i];
|
||||||
}
|
}
|
||||||
environment.mMechanicsManager->setPlayerClass(klass);
|
environment.mMechanicsManager->setPlayerClass(klass);
|
||||||
|
|
||||||
|
createClassDialog->eventDone = MWGui::CreateClassDialog::EventHandle_Void();
|
||||||
|
createClassDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(createClassDialog);
|
||||||
|
createClassDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
||||||
|
classChosen = true;
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext)
|
if (reviewNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onCreateClassDialogBack()
|
void WindowManager::onCreateClassDialogBack()
|
||||||
{
|
{
|
||||||
if (pickClassDialog)
|
if (createClassDialog)
|
||||||
{
|
{
|
||||||
pickClassDialog->setVisible(false);
|
createClassDialog->setVisible(false);
|
||||||
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId());
|
garbageDialogs.push_back(createClassDialog);
|
||||||
|
createClassDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onBirthSignDialogDone()
|
void WindowManager::onBirthSignDialogDone()
|
||||||
{
|
{
|
||||||
|
if (birthSignDialog)
|
||||||
|
{
|
||||||
|
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
|
||||||
birthSignDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
|
birthSignDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
|
||||||
|
birthSignDialog->setVisible(false);
|
||||||
|
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
|
||||||
birthSignChosen = true;
|
birthSignChosen = true;
|
||||||
if (birthSignDialog)
|
|
||||||
{
|
|
||||||
birthSignDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
if (reviewNext || goNext)
|
if (reviewNext || goNext)
|
||||||
environment.mInputManager->setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else
|
else
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onBirthSignDialogBack()
|
void WindowManager::onBirthSignDialogBack()
|
||||||
{
|
{
|
||||||
if (birthSignDialog)
|
if (birthSignDialog)
|
||||||
{
|
{
|
||||||
birthSignDialog->setVisible(false);
|
|
||||||
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
|
environment.mMechanicsManager->setPlayerBirthsign(birthSignDialog->getBirthId());
|
||||||
|
birthSignDialog->setVisible(false);
|
||||||
|
garbageDialogs.push_back(birthSignDialog);
|
||||||
|
birthSignDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onReviewDialogDone()
|
void WindowManager::onReviewDialogDone()
|
||||||
{
|
{
|
||||||
reviewDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
|
|
||||||
|
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
{
|
{
|
||||||
|
reviewDialog->eventDone = MWGui::BirthDialog::EventHandle_Void();
|
||||||
reviewDialog->setVisible(false);
|
reviewDialog->setVisible(false);
|
||||||
//environment.mMechanicsManager->setPlayerBirthsign(reviewDialog->getBirthId());
|
garbageDialogs.push_back(reviewDialog);
|
||||||
|
reviewDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onReviewDialogBack()
|
void WindowManager::onReviewDialogBack()
|
||||||
|
@ -763,10 +858,11 @@ void WindowManager::onReviewDialogBack()
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
{
|
{
|
||||||
reviewDialog->setVisible(false);
|
reviewDialog->setVisible(false);
|
||||||
//environment.mMechanicsManager->setPlayerBirthsign(reviewDialog->getBirthId());
|
garbageDialogs.push_back(reviewDialog);
|
||||||
|
reviewDialog = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCharacterGeneration();
|
updateCharacterGeneration();
|
||||||
|
|
||||||
environment.mInputManager->setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,14 @@ namespace MWWorld
|
||||||
class Environment;
|
class Environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace OEngine
|
||||||
|
{
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
class Layout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class HUD;
|
class HUD;
|
||||||
|
@ -109,6 +117,18 @@ namespace MWGui
|
||||||
// Current gui mode
|
// Current gui mode
|
||||||
GuiMode mode;
|
GuiMode mode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Next mode to activate in update().
|
||||||
|
*/
|
||||||
|
GuiMode nextMode;
|
||||||
|
/**
|
||||||
|
* Whether a mode change is needed in update().
|
||||||
|
* Will use @a nextMode as the new mode.
|
||||||
|
*/
|
||||||
|
bool needModeChange;
|
||||||
|
|
||||||
|
std::vector<OEngine::GUI::Layout*> garbageDialogs;
|
||||||
|
|
||||||
// Currently shown windows in inventory mode
|
// Currently shown windows in inventory mode
|
||||||
GuiWindow shown;
|
GuiWindow shown;
|
||||||
|
|
||||||
|
@ -126,12 +146,21 @@ namespace MWGui
|
||||||
// allowed settings.
|
// allowed settings.
|
||||||
void updateVisible();
|
void updateVisible();
|
||||||
|
|
||||||
|
void setGuiMode(GuiMode newMode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The constructor needs the main Gui object
|
/// The constructor needs the main Gui object
|
||||||
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame);
|
const Compiler::Extensions& extensions, bool newGame);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be called each frame to update windows/gui elements.
|
||||||
|
* This could mean updating sizes of gui elements or opening
|
||||||
|
* new dialogs.
|
||||||
|
*/
|
||||||
|
void update();
|
||||||
|
|
||||||
void setMode(GuiMode newMode)
|
void setMode(GuiMode newMode)
|
||||||
{
|
{
|
||||||
if (newMode==GM_Inventory && allowed==GW_None)
|
if (newMode==GM_Inventory && allowed==GW_None)
|
||||||
|
@ -140,6 +169,7 @@ namespace MWGui
|
||||||
mode = newMode;
|
mode = newMode;
|
||||||
updateVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
|
void setNextMode(GuiMode newMode);
|
||||||
|
|
||||||
GuiMode getMode() const { return mode; }
|
GuiMode getMode() const { return mode; }
|
||||||
|
|
||||||
|
|
|
@ -225,6 +225,14 @@ namespace MWInput
|
||||||
// Tell OIS to handle all input events
|
// Tell OIS to handle all input events
|
||||||
input.capture();
|
input.capture();
|
||||||
|
|
||||||
|
// Update windows/gui as a result of input events
|
||||||
|
// For instance this could mean opening a new window/dialog,
|
||||||
|
// by doing this after the input events are handled we
|
||||||
|
// ensure that window/gui changes appear quickly while
|
||||||
|
// avoiding that window/gui changes does not happen in
|
||||||
|
// event callbacks (which may crash)
|
||||||
|
windows.update();
|
||||||
|
|
||||||
// Disable movement in Gui mode
|
// Disable movement in Gui mode
|
||||||
if(windows.isGuiMode()) return true;
|
if(windows.isGuiMode()) return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue