diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-26 20:06:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-26 20:06:09 +0300 |
commit | 7a94bb34d78f88c93e280da04dd8542b26686ed1 (patch) | |
tree | 5b149edf9799e8a482a4bdc26bc0f83a8df7ca7a | |
parent | 86735e142e86391e46b0eafbcb7ef01e25fc969a (diff) | |
download | plus-7a94bb34d78f88c93e280da04dd8542b26686ed1.tar.gz plus-7a94bb34d78f88c93e280da04dd8542b26686ed1.tar.bz2 plus-7a94bb34d78f88c93e280da04dd8542b26686ed1.tar.xz plus-7a94bb34d78f88c93e280da04dd8542b26686ed1.zip |
Add support for getting attached money from mail message.
-rw-r--r-- | src/enums/resources/notifytypes.h | 3 | ||||
-rw-r--r-- | src/gui/windows/mailviewwindow.cpp | 25 | ||||
-rw-r--r-- | src/gui/windows/mailviewwindow.h | 2 | ||||
-rw-r--r-- | src/net/eathena/mail2recv.cpp | 27 | ||||
-rw-r--r-- | src/resources/notifications.h | 12 |
5 files changed, 66 insertions, 3 deletions
diff --git a/src/enums/resources/notifytypes.h b/src/enums/resources/notifytypes.h index 6513c4f4f..1c2dee843 100644 --- a/src/enums/resources/notifytypes.h +++ b/src/enums/resources/notifytypes.h @@ -245,6 +245,9 @@ namespace NotifyTypes MAIL_SEND_ITEM_ERROR, MAIL_SEND_RECEIVER_ERROR, MAIL_GET_ATTACH_FULL_ERROR, + MAIL_GET_MONEY_OK, + MAIL_GET_MONEY_ERROR, + MAIL_GET_MONEY_LIMIT_ERROR, TYPE_END }; diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp index b250fad43..15c28480c 100644 --- a/src/gui/windows/mailviewwindow.cpp +++ b/src/gui/windows/mailviewwindow.cpp @@ -251,3 +251,28 @@ void MailViewWindow::removeItems(const int64_t mailId) if (mailWindow) mailWindow->refreshMailNames(); } + +void MailViewWindow::removeMoney(const int64_t mailId) +{ + if (mailId != mMessage->id) + return; + mMessage->type = static_cast<MailMessageType::Type>( + CAST_S32(mMessage->type) | CAST_S32(MailMessageType::Money)); + mMessage->type = static_cast<MailMessageType::Type>( + CAST_S32(mMessage->type) ^ CAST_S32(MailMessageType::Money)); + + mMessage->money = 0; + + if (mMoneyLabel == nullptr) + return; + + if (mGetMoneyButton) + mGetMoneyButton->setVisible(Visible_false); + + mMoneyLabel->setCaption(strprintf("%s %d", + // TRANSLATORS: mail view window label + _("Money:"), + 0)); + if (mailWindow) + mailWindow->refreshMailNames(); +} diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h index 13ad25676..c3f691629 100644 --- a/src/gui/windows/mailviewwindow.h +++ b/src/gui/windows/mailviewwindow.h @@ -53,6 +53,8 @@ class MailViewWindow final : public Window, void removeItems(const int64_t mailId); + void removeMoney(const int64_t mailId); + private: void updateAttachButton(); diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp index 392e679d6..0ed6f44f0 100644 --- a/src/net/eathena/mail2recv.cpp +++ b/src/net/eathena/mail2recv.cpp @@ -459,10 +459,31 @@ void Mail2Recv::processMailDelete(Net::MessageIn &msg) void Mail2Recv::processRequestMoney(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readInt64("mail id"); + const int64_t mailId = msg.readInt64("mail id"); msg.readUInt8("open type"); - msg.readUInt8("result"); + const int res = msg.readUInt8("result"); + switch (res) + { + case 0: + NotifyManager::notify( + NotifyTypes::MAIL_GET_MONEY_OK); + if (mailViewWindow) + mailViewWindow->removeMoney(mailId); + break; + case 1: + NotifyManager::notify( + NotifyTypes::MAIL_GET_MONEY_ERROR); + break; + case 2: + NotifyManager::notify( + NotifyTypes::MAIL_GET_MONEY_LIMIT_ERROR); + break; + default: + UNIMPLEMENTEDPACKETFIELD(res); + NotifyManager::notify( + NotifyTypes::MAIL_GET_MONEY_ERROR); + break; + } } void Mail2Recv::processRequestItems(Net::MessageIn &msg) diff --git a/src/resources/notifications.h b/src/resources/notifications.h index 08526bb81..84a738c79 100644 --- a/src/resources/notifications.h +++ b/src/resources/notifications.h @@ -897,6 +897,18 @@ namespace NotifyManager // TRANSLATORS: notification message N_("Error on getting attach. No space or weight too high."), NotifyFlags::EMPTY}, + {"mail get money ok", + // TRANSLATORS: notification message + N_("You got money from mail."), + NotifyFlags::EMPTY}, + {"mail get money error", + // TRANSLATORS: notification message + N_("Error on getting money attach."), + NotifyFlags::EMPTY}, + {"mail get money limit error", + // TRANSLATORS: notification message + N_("Error on getting money attach. Too many money."), + NotifyFlags::EMPTY}, }; } // namespace NotifyManager #endif // RESOURCES_NOTIFICATIONS_H |