Avoid delegates being called repeatedly when pressing enter in name dialog.

This commit is contained in:
Jan Borsodi 2010-09-15 19:44:53 +02:00
parent 07dd5e5631
commit 84acab03ec
3 changed files with 8 additions and 6 deletions

View file

@ -21,8 +21,6 @@ namespace MWGui
{ {
using namespace MyGUI; using namespace MyGUI;
typedef delegates::CDelegate0 EventHandle_Void;
class RaceDialog : public OEngine::GUI::Layout class RaceDialog : public OEngine::GUI::Layout
{ {
public: public:
@ -47,6 +45,7 @@ namespace MWGui
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n

View file

@ -15,8 +15,6 @@ namespace MWGui
{ {
using namespace MyGUI; using namespace MyGUI;
typedef delegates::CDelegate0 EventHandle_Void;
class TextInputDialog : public OEngine::GUI::Layout class TextInputDialog : public OEngine::GUI::Layout
{ {
public: public:
@ -29,6 +27,7 @@ namespace MWGui
void setTextLabel(const std::string &label); void setTextLabel(const std::string &label);
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void;
/** Event : Dialog finished, OK button clicked.\n /** Event : Dialog finished, OK button clicked.\n
signature : void method()\n signature : void method()\n

View file

@ -115,7 +115,7 @@ void WindowManager::updateVisible()
{ {
if (!raceDialog) if (!raceDialog)
raceDialog = new RaceDialog(environment); raceDialog = new RaceDialog(environment);
nameDialog->setNextButtonShow(raceChosen); raceDialog->setNextButtonShow(raceChosen);
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack); raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
raceDialog->setVisible(true); raceDialog->setVisible(true);
@ -189,6 +189,8 @@ void WindowManager::updateCharacterGeneration()
void WindowManager::onNameDialogDone() void WindowManager::onNameDialogDone()
{ {
nameDialog->eventDone = MWGui::TextInputDialog::EventHandle_Void();
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) if (nameDialog)
@ -209,7 +211,9 @@ void WindowManager::onNameDialogDone()
void WindowManager::onRaceDialogDone() 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; raceChosen = true;
if (raceDialog) if (raceDialog)
{ {