summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/windows/mailviewwindow.cpp34
-rw-r--r--src/gui/windows/mailviewwindow.h2
-rw-r--r--src/net/eathena/mail2recv.cpp1
-rw-r--r--src/net/eathena/mailrecv.cpp4
4 files changed, 26 insertions, 15 deletions
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index 6a55f6a2e..2f6c1c28b 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -60,8 +60,8 @@ MailViewWindow::MailViewWindow(const MailMessage *const message,
Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
ActionListener(),
mMessage(message),
- // TRANSLATORS: mail view window button
- mGetAttachButton(nullptr),
+ // TRANSLATORS: mail view attach button
+ mGetAttachButton(new Button(this, _("Get attach"), "attach", this)),
// TRANSLATORS: mail view window button
mCloseButton(new Button(this, _("Close"), "close", this)),
mPrevButton(new Button(this, "<", "prev", this)),
@@ -121,20 +121,9 @@ MailViewWindow::MailViewWindow(const MailMessage *const message,
placer(0, n++, mMessageLabel);
placer(0, n++, mItemScrollArea);
- logger->log("sizes: %d, %d",
- mItemContainer->getWidth(),
- mItemContainer->getHeight());
+ placer(0, n++, mGetAttachButton);
+ updateAttachButton();
- if (message->money != 0 ||
- message->itemId != 0)
- {
- mGetAttachButton = new Button(this,
- // TRANSLATORS: mail view attach button
- _("Get attach"),
- "attach",
- this);
- placer(0, n++, mGetAttachButton);
- }
ContainerPlacer placer2;
placer2 = getPlacer(0, n);
@@ -198,7 +187,22 @@ Inventory *MailViewWindow::getInventory() const
return mInventory;
}
+void MailViewWindow::updateAttachButton()
+{
+ if (mMessage->money != 0 ||
+ mMessage->itemId != 0 ||
+ mInventory->getLastUsedSlot() != -1)
+ {
+ mGetAttachButton->setVisible(Visible_true);
+ }
+ else
+ {
+ mGetAttachButton->setVisible(Visible_false);
+ }
+}
+
void MailViewWindow::updateItems()
{
mItemContainer->updateMatrix();
+ updateAttachButton();
}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
index a9d19e57e..9f09bb9a7 100644
--- a/src/gui/windows/mailviewwindow.h
+++ b/src/gui/windows/mailviewwindow.h
@@ -52,6 +52,8 @@ class MailViewWindow final : public Window,
void updateItems();
private:
+ void updateAttachButton();
+
const MailMessage *mMessage;
Button *mGetAttachButton;
Button *mCloseButton;
diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp
index 14ae54383..1cb2a7f58 100644
--- a/src/net/eathena/mail2recv.cpp
+++ b/src/net/eathena/mail2recv.cpp
@@ -442,6 +442,7 @@ void Mail2Recv::processReadMail(Net::MessageIn &msg)
inventory->setOptions(slot, options);
delete options;
}
+ mailViewWindow->updateItems();
}
void Mail2Recv::processMailDelete(Net::MessageIn &msg)
diff --git a/src/net/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp
index ac638b300..d8897f38c 100644
--- a/src/net/eathena/mailrecv.cpp
+++ b/src/net/eathena/mailrecv.cpp
@@ -26,6 +26,7 @@
#include "gui/mailmessage.h"
+#include "gui/windows/mailviewwindow.h"
#include "gui/windows/mailwindow.h"
#include "net/mailhandler.h"
@@ -111,6 +112,9 @@ void MailRecv::processReadMail(Net::MessageIn &msg)
msg.readUInt8("zero");
mail->strTime = timeToStr(mail->time);
mailWindow->showMessage(mail, mail->itemId != 0 ? 1 : 0);
+ // +++ here need add item into item container
+ if (mailViewWindow)
+ mailViewWindow->updateItems();
}
void MailRecv::processGetAttachment(Net::MessageIn &msg)