diff options
-rw-r--r-- | src/client.cpp | 5 | ||||
-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 | ||||
-rw-r--r-- | src/net/ea/tradehandler.cpp | 1 |
9 files changed, 25 insertions, 8 deletions
diff --git a/src/client.cpp b/src/client.cpp index 824d07e5a..f53873c6a 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2892,10 +2892,13 @@ Window *Client::openErrorDialog(const std::string &header, } else { - return new ConfirmDialog(header, strprintf("%s %s", message.c_str(), + ConfirmDialog *const dialog = new ConfirmDialog( + header, strprintf("%s %s", message.c_str(), // TRANSLATORS: error message question _("Do you want to open support page?")), SOUND_ERROR, false, modal); + dialog->postInit(); + return dialog; } } 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; } diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index eb0441a19..85c33076a 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -107,6 +107,7 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) const strprintf(_("%s wants to trade with you, do" " you accept?"), tradePartnerName.c_str()), SOUND_REQUEST, true); + confirmDlg->postInit(); confirmDlg->addActionListener(&listener); } else |