summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/confirmdialog.cpp14
-rw-r--r--src/gui/windows/confirmdialog.h3
-rw-r--r--src/gui/windows/logindialog.cpp1
-rw-r--r--src/gui/windows/selldialog.cpp1
-rw-r--r--src/gui/windows/shopwindow.cpp1
-rw-r--r--src/gui/windows/socialwindow.cpp6
6 files changed, 19 insertions, 7 deletions
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;
}