diff --git a/src/states_screens/dialogs/message_dialog.cpp b/src/states_screens/dialogs/message_dialog.cpp index 075774013..15feb9d50 100644 --- a/src/states_screens/dialogs/message_dialog.cpp +++ b/src/states_screens/dialogs/message_dialog.cpp @@ -68,25 +68,28 @@ MessageDialog::~MessageDialog() // ------------------------------------------------------------------------------------------------------ void MessageDialog::doInit(MessageDialogType type, - IConfirmDialogListener* listener, bool own_listener) + IConfirmDialogListener* listener, bool own_listener) { if (StateManager::get()->getGameState() == GUIEngine::GAME) { World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE); } - - loadFromFile("confirm_dialog.stkgui"); - + m_type = type; m_listener = listener; m_own_listener = own_listener; + loadFromFile("confirm_dialog.stkgui"); +} + +void MessageDialog::loadedFromFile() +{ LabelWidget* message = getWidget("title"); message->setText( m_msg.c_str(), false ); // If the dialog is a simple 'OK' dialog, then hide the "Yes" button and // change "Cancel" to "OK" - if (type == MessageDialog::MESSAGE_DIALOG_OK) + if (m_type == MessageDialog::MESSAGE_DIALOG_OK) { ButtonWidget* yesbtn = getWidget("confirm"); yesbtn->setVisible(false); @@ -95,13 +98,13 @@ void MessageDialog::doInit(MessageDialogType type, cancelbtn->setText(_("OK")); cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER); } - else if (type == MessageDialog::MESSAGE_DIALOG_YESNO) + else if (m_type == MessageDialog::MESSAGE_DIALOG_YESNO) { ButtonWidget* cancelbtn = getWidget("cancel"); cancelbtn->setText(_("No")); } - else if (type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL) + else if (m_type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL) { // In case of a OK_CANCEL dialog, change the text from 'Yes' to 'Ok' ButtonWidget* yesbtn = getWidget("confirm"); @@ -109,7 +112,6 @@ void MessageDialog::doInit(MessageDialogType type, } } - // ------------------------------------------------------------------------------------------------------ void MessageDialog::onEnterPressedInternal() diff --git a/src/states_screens/dialogs/message_dialog.hpp b/src/states_screens/dialogs/message_dialog.hpp index 05dfda475..fb39b6d8e 100644 --- a/src/states_screens/dialogs/message_dialog.hpp +++ b/src/states_screens/dialogs/message_dialog.hpp @@ -64,6 +64,8 @@ public: enum MessageDialogType { MESSAGE_DIALOG_OK, MESSAGE_DIALOG_CONFIRM, MESSAGE_DIALOG_OK_CANCEL, MESSAGE_DIALOG_YESNO }; + MessageDialogType m_type; + private: IConfirmDialogListener* m_listener; @@ -96,6 +98,8 @@ public: virtual void load(); GUIEngine::EventPropagation processEvent(const std::string& eventSource); + + virtual void loadedFromFile(); };