diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-17 23:53:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-19 15:12:18 +0300 |
commit | 649348f19cdb3d65f825a2a3270b185fc9d83c75 (patch) | |
tree | 3a31f64178d266383899c67782843736578e580e /src/gui | |
parent | 0c6d457fe227ba9fd0a7c4c51cc2eb5995ca2c19 (diff) | |
download | manaverse-649348f19cdb3d65f825a2a3270b185fc9d83c75.tar.gz manaverse-649348f19cdb3d65f825a2a3270b185fc9d83c75.tar.bz2 manaverse-649348f19cdb3d65f825a2a3270b185fc9d83c75.tar.xz manaverse-649348f19cdb3d65f825a2a3270b185fc9d83c75.zip |
move virtual member calls from confirmdialog constuctor into postInit.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 1 | ||||
-rw-r--r-- | src/gui/windows/confirmdialog.cpp | 14 | ||||
-rw-r--r-- | src/gui/windows/confirmdialog.h | 3 | ||||
-rw-r--r-- | src/gui/windows/logindialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/windows/selldialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/windows/shopwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/windows/socialwindow.cpp | 6 |
7 files changed, 20 insertions, 7 deletions
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 85aa4e090..18eccecb1 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -90,6 +90,7 @@ void ItemLinkHandler::handleLink(const std::string &link, ConfirmDialog *const confirmDlg = new ConfirmDialog( // TRANSLATORS: dialog message _("Open url"), url, SOUND_REQUEST, false, true); + confirmDlg->postInit(); confirmDlg->addActionListener(&listener); } else if (button == gcn::MouseInput::RIGHT) diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 34c54582c..863cb1cf3 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -38,17 +38,22 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, const bool modal, Window *const parent): Window(title, modal, parent, "confirm.xml"), gcn::ActionListener(), - mTextBox(new TextBox(this)) + mTextBox(new TextBox(this)), + mIgnore(ignore) { mTextBox->setEditable(false); mTextBox->setOpaque(false); mTextBox->setTextWrapped(msg, 260); + soundManager.playGuiSound(soundEvent); +} +void ConfirmDialog::postInit() +{ // TRANSLATORS: confirm dialog button Button *const yesButton = new Button(this, _("Yes"), "yes", this); // TRANSLATORS: confirm dialog button Button *const noButton = new Button(this, _("No"), "no", this); - Button *const ignoreButton = ignore ? new Button( + Button *const ignoreButton = mIgnore ? new Button( // TRANSLATORS: confirm dialog button this, _("Ignore"), "ignore", this) : nullptr; @@ -61,7 +66,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, const int fontHeight = getFont()->getHeight(); const int height = numRows * fontHeight; - int width = getFont()->getWidth(title); + int width = getFont()->getWidth(getCaption()); if (width < mTextBox->getMinWidth()) width = mTextBox->getMinWidth(); @@ -88,7 +93,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, add(yesButton); add(noButton); - if (ignore && ignoreButton) + if (mIgnore && ignoreButton) add(ignoreButton); if (getParent()) @@ -98,7 +103,6 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, } setVisible(true); yesButton->requestFocus(); - soundManager.playGuiSound(soundEvent); } void ConfirmDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h index 015117fac..85d719e85 100644 --- a/src/gui/windows/confirmdialog.h +++ b/src/gui/windows/confirmdialog.h @@ -58,8 +58,11 @@ class ConfirmDialog : public Window, public gcn::ActionListener */ void action(const gcn::ActionEvent &event) override; + void postInit(); + private: TextBox *mTextBox; + bool mIgnore; }; #endif // GUI_WINDOWS_CONFIRMDIALOG_H diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index ab80e2db1..c320e0e10 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -299,6 +299,7 @@ void LoginDialog::action(const gcn::ActionEvent &event) // TRANSLATORS: question dialog ConfirmDialog *const confirmDlg = new ConfirmDialog( _("Open register url"), url, SOUND_REQUEST, false, true); + confirmDlg->postInit(); confirmDlg->addActionListener(&urlListener); } } diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 6c0edbe74..a188861f0 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -245,6 +245,7 @@ void SellDialog::action(const gcn::ActionEvent &event) // TRANSLATORS: sell confirmation message strprintf(_("Do you really want to sell %s?"), info.getName().c_str()), SOUND_REQUEST, false, true); + dialog->postInit(); dialog->addActionListener(this); return; } diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 1c854c9fd..18ad32470 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -777,6 +777,7 @@ void ShopWindow::processRequest(const std::string &nick, std::string data, (_("Request for Trade"), strprintf(_("%s wants to %s %s do you " "accept?"), nick.c_str(), msg.c_str(), mTradeItem->getInfo().getName().c_str()), SOUND_REQUEST, true); + confirmDlg->postInit(); confirmDlg->addActionListener(this); } } diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 4adcc5051..e54d0bf55 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -262,7 +262,7 @@ public: // TRANSLATORS: guild leave message strprintf(_("Are you sure you want to leave guild %s?"), mGuild->getName().c_str()), SOUND_REQUEST, socialWindow); - + mConfirmDialog->postInit(); mConfirmDialog->addActionListener(this); } @@ -461,7 +461,7 @@ public: // TRANSLATORS: party leave message strprintf(_("Are you sure you want to leave party %s?"), mParty->getName().c_str()), SOUND_REQUEST, socialWindow); - + mConfirmDialog->postInit(); mConfirmDialog->addActionListener(this); } @@ -1624,6 +1624,7 @@ void SocialWindow::showGuildInvite(const std::string &guildName, // TRANSLATORS: guild invite message mGuildAcceptDialog = new ConfirmDialog(_("Accept Guild Invite"), msg, SOUND_REQUEST, false, false, this); + mGuildAcceptDialog->postInit(); mGuildAcceptDialog->addActionListener(this); mGuildInvited = guildId; } @@ -1681,6 +1682,7 @@ void SocialWindow::showPartyInvite(const std::string &partyName, // TRANSLATORS: party invite message mPartyAcceptDialog = new ConfirmDialog(_("Accept Party Invite"), msg, SOUND_REQUEST, false, false, this); + mPartyAcceptDialog->postInit(); mPartyAcceptDialog->addActionListener(this); mPartyInviter = inviter; } |