mirror of
https://github.com/Lacustat/Freewood-OctoWoW-Mail.git
synced 2026-11-01 05:37:06 +00:00
0.1.156: Brief an Absender zurueck; Codex-Datenbank ohne langes Einfrieren (Item-Werte in Zeitscheiben)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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
|
||||
|
||||
+42
-6
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user