From 765687ed547ecde984d6c2ced65a8d7f15657164 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 22:48:17 +0100 Subject: [PATCH] 0.1.156: Brief an Absender zurueck; Codex-Datenbank ohne langes Einfrieren (Item-Werte in Zeitscheiben) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9 --- Freewood-OctoWoW-Mail.toc | 2 +- Locales.lua | 8 +++++++ Mail.lua | 21 ++++++++++++++++- MailUI.lua | 48 ++++++++++++++++++++++++++++++++++----- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/Freewood-OctoWoW-Mail.toc b/Freewood-OctoWoW-Mail.toc index 4580e50..dd301a1 100644 --- a/Freewood-OctoWoW-Mail.toc +++ b/Freewood-OctoWoW-Mail.toc @@ -3,7 +3,7 @@ ## Notes: Own mailbox window: open all or selected mails safely, recent recipients, mailing lists with automatic sending, multi-item mails, gold surplus and cash on delivery. ## Notes-deDE: Eigenes Briefkasten-Fenster: alles oder Ausgewähltes sicher öffnen, letzte Empfänger, Mailinglisten mit Automatik, mehrere Items, Gold-Überschuss und Nachnahme. ## Author: Lacustat -## Version: 0.1.155 +## Version: 0.1.156 ## Dependencies: Freewood-OctoWoW-Core ## OptionalDeps: Freewood-OctoWoW-Creator, Freewood-OctoWoW-Brett diff --git a/Locales.lua b/Locales.lua index 5c57f40..42d3af0 100644 --- a/Locales.lua +++ b/Locales.lua @@ -117,6 +117,10 @@ FW:AddLocale("enUS", { MAIL_TAKE_COD_CONFIRM = "Really pay %s? Click again", MAIL_REPLY = "Reply", MAIL_DELETE = "Delete", + MAIL_RETURN = "Return to sender", + MAIL_RETURN_CONFIRM = "Really return?", + MAIL_RETURN_TIP = "Sends the whole mail (with attached items and gold) back to the sender. Click twice to confirm. Not possible for system or auction mails.", + MAIL_ERR_noreturn = "This mail cannot be returned.", MAIL_DELETE_TIP = "Moves the mail to the archive and deletes it from the mailbox. Only possible when nothing is attached (take items and gold first).", MAIL_ERR_codbad = "Blocked: the cash on delivery is higher than agreed (board check).", MAIL_ERR_codmoney = "Not enough gold for the cash on delivery.", @@ -253,6 +257,10 @@ FW:AddLocale("deDE", { MAIL_TAKE_COD_CONFIRM = "%s wirklich zahlen? Nochmal klicken", MAIL_REPLY = "Antworten", MAIL_DELETE = "Löschen", + MAIL_RETURN = "An Absender zurück", + MAIL_RETURN_CONFIRM = "Wirklich zurück?", + MAIL_RETURN_TIP = "Schickt den ganzen Brief (mit Items und Gold) an den Absender zurück. Zur Bestätigung zweimal klicken. Bei System- oder Auktionsbriefen nicht möglich.", + MAIL_ERR_noreturn = "Dieser Brief kann nicht zurückgeschickt werden.", MAIL_DELETE_TIP = "Legt den Brief ins Archiv und löscht ihn aus dem Briefkasten. Nur möglich, wenn nichts mehr angehängt ist (erst Items und Gold nehmen).", MAIL_ERR_codbad = "Gesperrt: Die Nachnahme ist höher als vereinbart (Brett-Prüfung).", MAIL_ERR_codmoney = "Nicht genug Gold für die Nachnahme.", diff --git a/Mail.lua b/Mail.lua index f368e31..b6e8b6b 100644 --- a/Mail.lua +++ b/Mail.lua @@ -233,12 +233,13 @@ function Mail.ReadInbox() n = (ok and tonumber(n)) or 0 local seen = {} for i = 1, n do - local ok1, _, _, sender, subject, money, cod, days, hasItem, wasRead = pcall(GetInboxHeaderInfo, i) + local ok1, _, _, sender, subject, money, cod, days, hasItem, wasRead, wasReturned, _, canReply = pcall(GetInboxHeaderInfo, i) if ok1 then local m = { i = i, sender = sender or "?", subject = subject or "", money = tonumber(money) or 0, cod = tonumber(cod) or 0, days = tonumber(days), hasItem = (hasItem and hasItem ~= 0) and true or false, read = wasRead and true or false, + returned = wasReturned and true or false, canReply = not (canReply == false or canReply == 0), } if m.hasItem and GetInboxItem then local ok2, name, tex, count = pcall(GetInboxItem, i) @@ -359,6 +360,24 @@ function Mail:RemoveMail(m) return true, own and "own" or "archived" end +-- Brief an den Absender zurueckschicken (Anhang und Gold gehen mit zurueck). Nicht moeglich bei System-/Auktionsbriefen. +function Mail.Returnable(m) + if not m or not m.canReply or m.returned then return false end + local s = tostring(m.sender or "") + if s == "" or s == "?" or Mail.IsSelf(s) then return false end + return true +end + +function Mail:ReturnMail(m) + if self.busy then return false, "busy" end + if not Mail.Returnable(m) then return false, "noreturn" end + if not ReturnInboxItem then return false, "noreturn" end + local ok = pcall(ReturnInboxItem, m.i) + if not ok then return false, "noreturn" end + Mail.taken[Pair(m)] = nil + return true +end + function Mail:FindMail(key, pair) local list = Mail.ReadInbox() for _, m in ipairs(list) do diff --git a/MailUI.lua b/MailUI.lua index be5effb..f6ebe67 100644 --- a/MailUI.lua +++ b/MailUI.lua @@ -340,17 +340,20 @@ local function BuildInbox(parent) d.attach:SetWordWrap(false) d.bodyScroll = UI.CreateScrollFrame(d) d.bodyScroll:SetPoint("TOPLEFT", d, "TOPLEFT", 12, -76) - d.bodyScroll:SetPoint("BOTTOMRIGHT", d, "BOTTOMRIGHT", -12, 68) + d.bodyScroll:SetPoint("BOTTOMRIGHT", d, "BOTTOMRIGHT", -12, 100) d.body = UI.CreateLabel(d.bodyScroll.child, "", { size = 12, justifyV = "TOP" }) d.body:SetPoint("TOPLEFT", d.bodyScroll.child, "TOPLEFT", 2, -2) d.msg = UI.CreateLabel(d, "", { size = 11, color = "danger" }) - d.msg:SetPoint("BOTTOMLEFT", d, "BOTTOMLEFT", 12, 44) + d.msg:SetPoint("BOTTOMLEFT", d, "BOTTOMLEFT", 12, 76) d.msg:SetPoint("RIGHT", d, "RIGHT", -12, 0) d.msg:SetWordWrap(false) d.take = UI.CreateButton(d, T("MAIL_TAKE_ITEM"), 120, 26, nil, "primary") d.take:SetPoint("BOTTOMLEFT", d, "BOTTOMLEFT", 12, 12) d.reply = UI.CreateButton(d, T("MAIL_REPLY"), 80, 26, nil, "default") d.reply:SetPoint("LEFT", d.take, "RIGHT", 6, 0) + d.ret = UI.CreateButton(d, T("MAIL_RETURN"), 170, 26, nil, "default") + d.ret:SetPoint("BOTTOMLEFT", d, "BOTTOMLEFT", 12, 44) + UI.AttachTooltip(d.ret, function() return T("MAIL_RETURN") end, function() return T("MAIL_RETURN_TIP") end) d.delete = UI.CreateButton(d, T("MAIL_DELETE"), 80, 26, nil, "danger") d.delete:SetPoint("BOTTOMRIGHT", d, "BOTTOMRIGHT", -12, 12) UI.AttachTooltip(d.delete, function() return T("MAIL_DELETE") end, function() return T("MAIL_DELETE_TIP") end) @@ -385,6 +388,25 @@ local function BuildInbox(parent) end f.Refresh() end) + local function DoReturn(m) + if not m then return end + if f.retConfirm ~= m.key then + f.retConfirm = m.key + f.Refresh() + return + end + f.retConfirm = nil + local ok, why = Mail:ReturnMail(m) + if ok then + Mail.view, f.current, f.shownKey = nil, nil, nil + ShowError(nil) + else + ShowError(why) + end + f.Refresh() + end + f.DoReturn = DoReturn + d.ret:SetScript("OnClick", function() DoReturn(f.current) end) d.reply:SetScript("OnClick", function() local m = f.current if m and panes.send and panes.send.Prefill then @@ -411,19 +433,29 @@ local function BuildInbox(parent) row.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) row.l1 = UI.CreateLabel(row, "", { size = 12 }) row.l1:SetPoint("TOPLEFT", row, "TOPLEFT", 66, -6) - row.l1:SetPoint("RIGHT", row, "RIGHT", -40, 0) + row.l1:SetPoint("RIGHT", row, "RIGHT", -70, 0) row.l1:SetWordWrap(false) row.l2 = UI.CreateLabel(row, "", { size = 11, color = "textDim" }) row.l2:SetPoint("TOPLEFT", row, "TOPLEFT", 66, -22) - row.l2:SetPoint("RIGHT", row, "RIGHT", -40, 0) + row.l2:SetPoint("RIGHT", row, "RIGHT", -70, 0) row.l2:SetWordWrap(false) + row.ret = UI.CreateButton(row, "<", 24, 22, nil, "default") + row.ret:SetPoint("RIGHT", row, "RIGHT", -6, 0) + UI.AttachTooltip(row.ret, function() return T("MAIL_RETURN") end, function() return T("MAIL_RETURN_TIP") end) + row.ret:SetScript("OnClick", function() + if row.mail then + Mail.view = { key = row.mail.key, pair = Mail.Pair(row.mail) } + f.DoReturn(row.mail) + end + end) row.days = UI.CreateLabel(row, "", { size = 11, color = "textDim", justify = "RIGHT" }) - row.days:SetPoint("RIGHT", row, "RIGHT", -8, 0) + row.days:SetPoint("RIGHT", row.ret, "LEFT", -4, 0) Tooltip(row) row:SetScript("OnMouseUp", function() if row.mail then Mail.view = { key = row.mail.key, pair = Mail.Pair(row.mail) } f.codConfirm = nil + f.retConfirm = nil ShowError(nil) f.Refresh() end @@ -447,7 +479,7 @@ local function BuildInbox(parent) end f.current = cur d.empty:SetShown(cur == nil) - for _, w in ipairs({ d.subj, d.meta, d.attach, d.bodyScroll, d.msg, d.take, d.reply, d.delete }) do + for _, w in ipairs({ d.subj, d.meta, d.attach, d.bodyScroll, d.msg, d.take, d.reply, d.ret, d.delete }) do w:SetShown(cur ~= nil) end if not cur then f.shownKey = nil return end @@ -483,6 +515,8 @@ local function BuildInbox(parent) d.take:SetButtonEnabled(canTake and not busy and Mail.open) d.delete:SetButtonEnabled(Mail.Deletable(cur) and not busy and Mail.open) d.reply:SetButtonEnabled(true) + d.ret:SetLabel(f.retConfirm == cur.key and T("MAIL_RETURN_CONFIRM") or T("MAIL_RETURN")) + d.ret:SetButtonEnabled(Mail.Returnable(cur) and not busy and Mail.open) end function f.Refresh() @@ -518,6 +552,8 @@ local function BuildInbox(parent) end row.l2:SetText(text) row.days:SetText(m.days and string.format(T("MAIL_ROW_DAYS"), math.floor(m.days)) or "") + row.ret:SetLabel(f.retConfirm == m.key and "?" or "<") + row.ret:SetButtonEnabled(Mail.Returnable(m) and not busy and Mail.open) row.cb:SetShown(m.take) row:SetAlpha(m.take and 1 or 0.75) row.cb:Refresh()