From 84acab03ecd7b94822a9cb60d8342e104df851ae Mon Sep 17 00:00:00 2001 From: Jan Borsodi Date: Wed, 15 Sep 2010 19:44:53 +0200 Subject: [PATCH] Avoid delegates being called repeatedly when pressing enter in name dialog. --- apps/openmw/mwgui/race.hpp | 3 +-- apps/openmw/mwgui/text_input.hpp | 3 +-- apps/openmw/mwgui/window_manager.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 98e1dd1fe..e0cbe08f0 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -21,8 +21,6 @@ namespace MWGui { using namespace MyGUI; - typedef delegates::CDelegate0 EventHandle_Void; - class RaceDialog : public OEngine::GUI::Layout { public: @@ -47,6 +45,7 @@ namespace MWGui void setNextButtonShow(bool shown); // Events + typedef delegates::CDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwgui/text_input.hpp b/apps/openmw/mwgui/text_input.hpp index 34312575b..eac6495ea 100644 --- a/apps/openmw/mwgui/text_input.hpp +++ b/apps/openmw/mwgui/text_input.hpp @@ -15,8 +15,6 @@ namespace MWGui { using namespace MyGUI; - typedef delegates::CDelegate0 EventHandle_Void; - class TextInputDialog : public OEngine::GUI::Layout { public: @@ -29,6 +27,7 @@ namespace MWGui void setTextLabel(const std::string &label); // Events + typedef delegates::CDelegate0 EventHandle_Void; /** Event : Dialog finished, OK button clicked.\n signature : void method()\n diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index fbd545bb3..044198152 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -115,7 +115,7 @@ void WindowManager::updateVisible() { if (!raceDialog) raceDialog = new RaceDialog(environment); - nameDialog->setNextButtonShow(raceChosen); + raceDialog->setNextButtonShow(raceChosen); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); raceDialog->setVisible(true); @@ -189,6 +189,8 @@ void WindowManager::updateCharacterGeneration() void WindowManager::onNameDialogDone() { + nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void(); + bool goNext = nameChosen; // Go to next dialog if name was previously chosen nameChosen = true; if (nameDialog) @@ -209,7 +211,9 @@ void WindowManager::onNameDialogDone() void WindowManager::onRaceDialogDone() { - bool goNext = nameChosen; // Go to next dialog if race was previously chosen + raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void(); + + bool goNext = raceChosen; // Go to next dialog if race was previously chosen raceChosen = true; if (raceDialog) {