diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 36 | ||||
-rw-r--r-- | src/gui/windows/mailwindow.h | 3 | ||||
-rw-r--r-- | src/net/eathena/mail2recv.cpp | 4 |
3 files changed, 35 insertions, 8 deletions
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index f41017543..18371b7ad 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -72,11 +72,14 @@ MailWindow::MailWindow() : // TRANSLATORS: mail window button mDeleteButton(new Button(this, _("Delete"), "delete", this)), // TRANSLATORS: mail window button - mReturnButton(new Button(this, _("Return"), "return", this)), + mReturnButton(new Button(this, + settings.enableNewMailSystem ? _("Get old") : _("Return"), + "return", this)), // TRANSLATORS: mail window button mOpenButton(new Button(this, _("Open"), "open", this)), mOpenType(MailOpenType::Mail), - mUseMail2(settings.enableNewMailSystem) + mUseMail2(settings.enableNewMailSystem), + mLastPage(false) { setWindowName("Mail"); setCloseButton(true); @@ -158,11 +161,22 @@ void MailWindow::action(const ActionEvent &event) } else if (eventId == "return") { - const int sel = mListBox->getSelected(); - if (sel < 0) - return; - const MailMessage *const mail = mMessages[sel]; - mailHandler->returnMessage(mail->id); + if (mUseMail2) + { + const size_t idx = mMessages.size(); + if (idx == 0) + mail2Handler->refreshMailList(MailOpenType::Mail, 0); + else + mail2Handler->nextPage(mOpenType, mMessages[idx - 1]->id); + } + else + { + const int sel = mListBox->getSelected(); + if (sel < 0) + return; + const MailMessage *const mail = mMessages[sel]; + mailHandler->returnMessage(mail->id); + } } } @@ -330,6 +344,8 @@ void MailWindow::refreshMails() { clear(); mail2Handler->refreshMailList(MailOpenType::Mail, 0); + mLastPage = false; + mReturnButton->setEnabled(true); } else { @@ -353,3 +369,9 @@ MailMessage *MailWindow::findMail(const int64_t id) return (*it).second; return nullptr; } + +void MailWindow::setLastPage() +{ + mLastPage = true; + mReturnButton->setEnabled(false); +} diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h index 3c38e0329..1639dfed0 100644 --- a/src/gui/windows/mailwindow.h +++ b/src/gui/windows/mailwindow.h @@ -78,6 +78,8 @@ class MailWindow final : public Window, MailOpenTypeT getOpenType() const A_WARN_UNUSED { return mOpenType; } + void setLastPage(); + private: void refreshMails(); @@ -96,6 +98,7 @@ class MailWindow final : public Window, Button *mOpenButton; MailOpenTypeT mOpenType; bool mUseMail2; + bool mLastPage; }; extern MailWindow *mailWindow; diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp index 32d4f76c6..14ae54383 100644 --- a/src/net/eathena/mail2recv.cpp +++ b/src/net/eathena/mail2recv.cpp @@ -332,7 +332,7 @@ void Mail2Recv::processMailListPage(Net::MessageIn &msg) mailWindow->setOpenType(fromInt(msg.readUInt8("open type"), MailOpenTypeT)); const int cnt = msg.readUInt8("cnt"); - msg.readUInt8("isEnd"); + const bool isEnd = msg.readUInt8("isEnd") != 0; for (int f = 0; f < cnt; f ++) { MailMessage *const mail = new MailMessage; @@ -347,6 +347,8 @@ void Mail2Recv::processMailListPage(Net::MessageIn &msg) mail->title = msg.readString(-1, "title"); mailWindow->addMail(mail); } + if (isEnd) + mailWindow->setLastPage(); } void Mail2Recv::processReadMail(Net::MessageIn &msg) |