聊天重做前缓存

This commit is contained in:
rucky
2026-04-09 09:46:47 +08:00
parent 6e18269bfd
commit e915bbd74a
39 changed files with 8501 additions and 2308 deletions

442
Mail.lua
View File

@@ -45,6 +45,7 @@ local S = {
inboxRows = {},
currentTab = 1,
inboxPage = 1,
bagPage = 1,
inboxChecked = {},
collectQueue = {},
collectTimer = nil,
@@ -53,11 +54,23 @@ local S = {
isSending = false,
collectElapsed = 0,
multiSend = nil, -- active multi-send state table
codMode = false, -- send panel: 付款取信 mode toggle
}
local L = {
W = 360, H = 480, HEADER = 34, PAD = 12, TAB_H = 28,
BOTTOM = 46, ROWS = 8, ROW_H = 38, ICON = 30, MAX_SEND = 12,
BAG_SLOT = 38, BAG_GAP = 3, BAG_PER_ROW = 8, BAG_ROWS = 8,
}
StaticPopupDialogs["NANAMI_MAIL_COD_CONFIRM"] = {
text = "确认支付 %s 取回此物品?",
button1 = "确认",
button2 = "取消",
OnAccept = function() end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
}
--------------------------------------------------------------------------------
@@ -476,18 +489,27 @@ local function UpdateInbox()
if money and money > 0 then
row.moneyFrame:SetMoney(money)
elseif CODAmount and CODAmount > 0 then
row.codFS:SetText("COD:"); row.codFS:Show()
row.codFS:SetText("付款:"); row.codFS:Show()
row.moneyFrame:SetMoney(CODAmount)
else
row.moneyFrame:SetMoney(0)
end
row.expiryFS:SetText(FormatExpiry(daysLeft))
local canTake = (hasItem or (money and money > 0)) and (not CODAmount or CODAmount == 0)
local canTake = hasItem or (money and money > 0)
row.takeBtn:SetDisabled(not canTake)
row.takeBtn:SetScript("OnClick", function()
if row.mailIndex then
if hasItem then
TakeInboxItem(row.mailIndex)
if CODAmount and CODAmount > 0 then
local codStr = FormatMoneyString(CODAmount)
local idx = row.mailIndex
StaticPopupDialogs["NANAMI_MAIL_COD_CONFIRM"].OnAccept = function()
TakeInboxItem(idx)
end
StaticPopup_Show("NANAMI_MAIL_COD_CONFIRM", codStr)
else
TakeInboxItem(row.mailIndex)
end
elseif money and money > 0 then
local idx = row.mailIndex
TakeInboxMoney(idx)
@@ -543,7 +565,7 @@ end
local function StopCollecting()
S.isCollecting = false; S.collectQueue = {}; S.collectPendingDelete = nil
if S.collectTimer then S.collectTimer:SetScript("OnUpdate", nil) end
UpdateInbox()
if S.currentTab == 3 then ML:UpdateMailBag() else UpdateInbox() end
end
local function ProcessCollectQueue()
@@ -683,6 +705,8 @@ end
local function ResetSendForm()
if not S.frame then return end
ClearSendItems()
S.codMode = false
if S.frame.UpdateMoneyToggle then S.frame.UpdateMoneyToggle() end
if S.frame.toEditBox then S.frame.toEditBox:SetText("") end
if S.frame.subjectEditBox then S.frame.subjectEditBox:SetText("") end
if S.frame.bodyEditBox then S.frame.bodyEditBox:SetText("") end
@@ -733,8 +757,15 @@ local function DoMultiSend(recipient, subject, body, money)
local items = {}
for i = 1, table.getn(S.sendQueue) do table.insert(items, S.sendQueue[i]) end
-- No attachments: plain text / money mail
-- No attachments: plain text / money mail (付款取信 requires attachments)
if table.getn(items) == 0 then
if S.codMode and money and money > 0 then
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF6666[Nanami-Mail]|r 付款取信模式需要添加附件物品")
if S.frame and S.frame.sendBtn then
S.frame.sendBtn.label:SetText("发送"); S.frame.sendBtn:SetDisabled(false)
end
return
end
if money and money > 0 then SetSendMailMoney(money) end
SendMail(recipient, subject, body or "")
return
@@ -746,6 +777,7 @@ local function DoMultiSend(recipient, subject, body, money)
subject = subject or "",
body = body or "",
money = money,
codMode = S.codMode,
total = table.getn(items),
sentCount = 0,
phase = "attach", -- "attach" → "wait_send" → "cooldown" → "attach" ...
@@ -803,9 +835,13 @@ local function DoMultiSend(recipient, subject, body, money)
return
end
-- Money only on first mail
if ms.sentCount == 1 and ms.money and ms.money > 0 then
SetSendMailMoney(ms.money)
-- Money or 付款取信
if ms.money and ms.money > 0 then
if ms.codMode then
SetSendMailCOD(ms.money)
elseif ms.sentCount == 1 then
SetSendMailMoney(ms.money)
end
end
-- Send this single-attachment mail
@@ -903,13 +939,18 @@ local function BuildMainFrame()
sep:SetPoint("TOPRIGHT", f, "TOPRIGHT", -6, -L.HEADER)
sep:SetVertexColor(T.divider[1], T.divider[2], T.divider[3], T.divider[4])
local tabInbox = CreateTabBtn(f, "收件箱", 70)
local tabInbox = CreateTabBtn(f, "收件箱", 62)
tabInbox:SetPoint("TOPLEFT", f, "TOPLEFT", L.PAD, -(L.HEADER + 6))
tabInbox:SetScript("OnClick", function() S.currentTab = 1; ML:ShowInboxPanel() end)
f.tabInbox = tabInbox
local tabSend = CreateTabBtn(f, "发送", 70)
tabSend:SetPoint("LEFT", tabInbox, "RIGHT", 4, 0)
local tabBag = CreateTabBtn(f, "邮包", 50)
tabBag:SetPoint("LEFT", tabInbox, "RIGHT", 4, 0)
tabBag:SetScript("OnClick", function() S.currentTab = 3; ML:ShowMailBagPanel() end)
f.tabBag = tabBag
local tabSend = CreateTabBtn(f, "发送", 62)
tabSend:SetPoint("LEFT", tabBag, "RIGHT", 4, 0)
tabSend:SetScript("OnClick", function() S.currentTab = 2; ML:ShowSendPanel() end)
f.tabSend = tabSend
@@ -1128,16 +1169,25 @@ function ML:ShowMailDetail(mailIndex)
dp.detailMoney:SetMoney(money); dp.detailMoney:Show()
end
if CODAmount and CODAmount > 0 then
dp.detailCodLabel:SetText("COD:"); dp.detailCodLabel:Show()
dp.detailCodLabel:SetText("付款取信:"); dp.detailCodLabel:Show()
dp.detailCod:SetMoney(CODAmount); dp.detailCod:Show()
end
-- Take items button
local canTakeItem = hasItem and (not CODAmount or CODAmount == 0)
local canTakeItem = hasItem
dp.takeItemBtn:SetDisabled(not canTakeItem)
dp.takeItemBtn:SetScript("OnClick", function()
if S.detailMailIndex then
TakeInboxItem(S.detailMailIndex)
if CODAmount and CODAmount > 0 then
local codStr = FormatMoneyString(CODAmount)
local idx = S.detailMailIndex
StaticPopupDialogs["NANAMI_MAIL_COD_CONFIRM"].OnAccept = function()
TakeInboxItem(idx)
end
StaticPopup_Show("NANAMI_MAIL_COD_CONFIRM", codStr)
else
TakeInboxItem(S.detailMailIndex)
end
end
end)
@@ -1205,6 +1255,294 @@ function ML:HideMailDetail()
UpdateInbox()
end
--------------------------------------------------------------------------------
-- BUILD: Mail Bag panel (grid view of all inbox items)
--------------------------------------------------------------------------------
local function BuildMailBagPanel()
local f = S.frame
local panelTop = L.HEADER + 6 + L.TAB_H + 4
local bp = CreateFrame("Frame", nil, f)
bp:SetPoint("TOPLEFT", f, "TOPLEFT", 0, -panelTop)
bp:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 0)
bp:Hide()
f.bagPanel = bp
local font = GetFont()
local slotsPerPage = L.BAG_PER_ROW * L.BAG_ROWS
local infoFS = bp:CreateFontString(nil, "OVERLAY")
infoFS:SetFont(font, 10, "OUTLINE")
infoFS:SetPoint("TOPLEFT", bp, "TOPLEFT", L.PAD, -2)
infoFS:SetTextColor(T.dimText[1], T.dimText[2], T.dimText[3])
f.bagInfoFS = infoFS
local codLegend = bp:CreateFontString(nil, "OVERLAY")
codLegend:SetFont(font, 9, "OUTLINE")
codLegend:SetPoint("TOPRIGHT", bp, "TOPRIGHT", -L.PAD, -2)
codLegend:SetText("|cFFFF5555■|r 付款取信")
codLegend:SetTextColor(T.dimText[1], T.dimText[2], T.dimText[3])
f.bagSlots = {}
local gridTop = 16
for i = 1, slotsPerPage do
local row = math.floor((i - 1) / L.BAG_PER_ROW)
local col = math.mod((i - 1), L.BAG_PER_ROW)
local sf = CreateFrame("Button", "SFramesMailBagSlot" .. i, bp)
sf:SetWidth(L.BAG_SLOT); sf:SetHeight(L.BAG_SLOT)
sf:SetPoint("TOPLEFT", bp, "TOPLEFT",
L.PAD + col * (L.BAG_SLOT + L.BAG_GAP),
-(gridTop + row * (L.BAG_SLOT + L.BAG_GAP)))
sf:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 12,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
sf:SetBackdropColor(T.slotBg[1], T.slotBg[2], T.slotBg[3], T.slotBg[4])
sf:SetBackdropBorderColor(T.slotBorder[1], T.slotBorder[2], T.slotBorder[3], T.slotBorder[4])
local ico = sf:CreateTexture(nil, "ARTWORK")
ico:SetTexCoord(0.08, 0.92, 0.08, 0.92)
ico:SetPoint("TOPLEFT", 3, -3); ico:SetPoint("BOTTOMRIGHT", -3, 3)
ico:Hide()
sf.icon = ico
local cnt = sf:CreateFontString(nil, "OVERLAY")
cnt:SetFont(font, 11, "OUTLINE")
cnt:SetPoint("BOTTOMRIGHT", sf, "BOTTOMRIGHT", -2, 2)
cnt:SetJustifyH("RIGHT")
sf.countFS = cnt
local moneyFS = sf:CreateFontString(nil, "OVERLAY")
moneyFS:SetFont(font, 8, "OUTLINE")
moneyFS:SetPoint("BOTTOM", sf, "BOTTOM", 0, 2)
moneyFS:SetWidth(L.BAG_SLOT)
moneyFS:SetJustifyH("CENTER")
moneyFS:Hide()
sf.moneyFS = moneyFS
local codFS = sf:CreateFontString(nil, "OVERLAY")
codFS:SetFont(font, 7, "OUTLINE")
codFS:SetPoint("TOP", sf, "TOP", 0, -1)
codFS:SetText("|cFFFF3333付款|r")
codFS:Hide()
sf.codFS = codFS
sf.mailData = nil
sf:RegisterForClicks("LeftButtonUp")
sf:SetScript("OnClick", function()
local data = this.mailData
if not data then return end
if data.codAmount and data.codAmount > 0 then
local codStr = FormatMoneyString(data.codAmount)
local idx = data.mailIndex
StaticPopupDialogs["NANAMI_MAIL_COD_CONFIRM"].OnAccept = function()
TakeInboxItem(idx)
end
StaticPopup_Show("NANAMI_MAIL_COD_CONFIRM", codStr)
elseif data.hasItem then
TakeInboxItem(data.mailIndex)
elseif data.money and data.money > 0 then
local idx = data.mailIndex
TakeInboxMoney(idx)
if not S.deleteTimer then S.deleteTimer = CreateFrame("Frame") end
S.deleteElapsed = 0
S.deleteTimer:SetScript("OnUpdate", function()
S.deleteElapsed = S.deleteElapsed + arg1
if S.deleteElapsed >= 0.5 then
this:SetScript("OnUpdate", nil)
if idx <= GetInboxNumItems() then DeleteInboxItem(idx) end
end
end)
end
end)
sf:SetScript("OnEnter", function()
this:SetBackdropBorderColor(T.slotHover[1], T.slotHover[2], T.slotHover[3], T.slotHover[4])
local data = this.mailData
if not data then return end
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
if data.hasItem then
pcall(GameTooltip.SetInboxItem, GameTooltip, data.mailIndex)
else
GameTooltip:AddLine("金币邮件", 1, 0.84, 0)
end
GameTooltip:AddLine(" ")
if data.sender then
GameTooltip:AddLine("发件人: " .. data.sender, 0.7, 0.7, 0.7)
end
if data.subject and data.subject ~= "" then
GameTooltip:AddLine(data.subject, 0.5, 0.5, 0.5)
end
if data.codAmount and data.codAmount > 0 then
GameTooltip:AddLine(" ")
GameTooltip:AddLine("付款取信: " .. FormatMoneyString(data.codAmount), 1, 0.3, 0.3)
GameTooltip:AddLine("|cFFFFCC00点击支付并取回|r")
elseif data.money and data.money > 0 and not data.hasItem then
GameTooltip:AddLine(" ")
GameTooltip:AddLine("金额: " .. FormatMoneyString(data.money), 1, 0.84, 0)
GameTooltip:AddLine("|cFFFFCC00点击收取金币|r")
elseif data.hasItem then
GameTooltip:AddLine(" ")
GameTooltip:AddLine("|cFFFFCC00点击收取物品|r")
end
GameTooltip:Show()
end)
sf:SetScript("OnLeave", function()
local data = this.mailData
if data and data.codAmount and data.codAmount > 0 then
this:SetBackdropBorderColor(1, 0.3, 0.3, 0.8)
else
this:SetBackdropBorderColor(T.slotBorder[1], T.slotBorder[2], T.slotBorder[3], T.slotBorder[4])
end
GameTooltip:Hide()
end)
f.bagSlots[i] = sf
end
local bsep = bp:CreateTexture(nil, "ARTWORK")
bsep:SetTexture("Interface\\Buttons\\WHITE8X8"); bsep:SetHeight(1)
bsep:SetPoint("BOTTOMLEFT", bp, "BOTTOMLEFT", 6, L.BOTTOM)
bsep:SetPoint("BOTTOMRIGHT", bp, "BOTTOMRIGHT", -6, L.BOTTOM)
bsep:SetVertexColor(T.divider[1], T.divider[2], T.divider[3], T.divider[4])
local prev = CreateActionBtn(bp, "<", 28)
prev:SetHeight(22); prev:SetPoint("BOTTOMLEFT", bp, "BOTTOMLEFT", L.PAD, 12)
prev:SetScript("OnClick", function() S.bagPage = S.bagPage - 1; ML:UpdateMailBag() end)
f.bagPrevBtn = prev
local nxt = CreateActionBtn(bp, ">", 28)
nxt:SetHeight(22); nxt:SetPoint("LEFT", prev, "RIGHT", 4, 0)
nxt:SetScript("OnClick", function() S.bagPage = S.bagPage + 1; ML:UpdateMailBag() end)
f.bagNextBtn = nxt
local pageFS = bp:CreateFontString(nil, "OVERLAY")
pageFS:SetFont(font, 10, "OUTLINE")
pageFS:SetPoint("LEFT", nxt, "RIGHT", 8, 0)
pageFS:SetTextColor(T.dimText[1], T.dimText[2], T.dimText[3])
f.bagPageFS = pageFS
local colAll = CreateActionBtn(bp, "全部收取", 80)
colAll:SetHeight(24); colAll:SetPoint("BOTTOMRIGHT", bp, "BOTTOMRIGHT", -L.PAD, 10)
colAll:SetScript("OnClick", function()
if S.isCollecting then StopCollecting() else CollectAll() end
end)
f.bagCollectAllBtn = colAll
end
--------------------------------------------------------------------------------
-- Mail Bag: Update
--------------------------------------------------------------------------------
function ML:UpdateMailBag()
if not S.frame or not S.frame:IsVisible() or S.currentTab ~= 3 then return end
local slotsPerPage = L.BAG_PER_ROW * L.BAG_ROWS
local numMails = GetInboxNumItems()
local entries = {}
for mi = 1, numMails do
local _, _, sender, subject, money, CODAmount, daysLeft, hasItem = GetInboxHeaderInfo(mi)
if hasItem or (money and money > 0) or (CODAmount and CODAmount > 0) then
local itemName, itemTex
if hasItem then itemName, itemTex = GetInboxItem(mi) end
table.insert(entries, {
mailIndex = mi,
hasItem = hasItem,
itemName = itemName,
itemTexture = itemTex,
money = money or 0,
codAmount = CODAmount or 0,
sender = sender or "未知",
subject = subject or "",
daysLeft = daysLeft,
})
end
end
local totalEntries = table.getn(entries)
local totalPages = math.max(1, math.ceil(totalEntries / slotsPerPage))
if S.bagPage > totalPages then S.bagPage = totalPages end
if S.bagPage < 1 then S.bagPage = 1 end
S.frame.bagInfoFS:SetText(string.format("共 %d 件可收取 (%d 封邮件)", totalEntries, numMails))
S.frame.bagPageFS:SetText(string.format("第 %d/%d 页", S.bagPage, totalPages))
S.frame.bagPrevBtn:SetDisabled(S.bagPage <= 1)
S.frame.bagNextBtn:SetDisabled(S.bagPage >= totalPages)
S.frame.bagCollectAllBtn:SetDisabled(numMails == 0 and not S.isCollecting)
if S.isCollecting then
S.frame.bagCollectAllBtn.label:SetText("收取中...")
else
S.frame.bagCollectAllBtn.label:SetText("全部收取")
end
for i = 1, slotsPerPage do
local slot = S.frame.bagSlots[i]
local ei = (S.bagPage - 1) * slotsPerPage + i
local entry = entries[ei]
if entry then
slot.mailData = entry
if entry.hasItem and entry.itemTexture then
slot.icon:SetTexture(entry.itemTexture)
elseif entry.money > 0 then
slot.icon:SetTexture("Interface\\Icons\\INV_Misc_Coin_01")
else
slot.icon:SetTexture("Interface\\Icons\\INV_Misc_Note_01")
end
slot.icon:Show()
slot.countFS:SetText("")
slot.moneyFS:Hide()
if entry.money > 0 and not entry.hasItem then
local g = math.floor(entry.money / 10000)
if g > 0 then
slot.moneyFS:SetText("|cFFFFD700" .. g .. "g|r")
else
local sv = math.floor(math.mod(entry.money, 10000) / 100)
if sv > 0 then
slot.moneyFS:SetText("|cFFC7C7CF" .. sv .. "s|r")
else
local cv = math.mod(entry.money, 100)
slot.moneyFS:SetText("|cFFB87333" .. cv .. "c|r")
end
end
slot.moneyFS:Show()
end
if entry.codAmount > 0 then
slot.codFS:Show()
slot:SetBackdropBorderColor(1, 0.3, 0.3, 0.8)
else
slot.codFS:Hide()
slot:SetBackdropBorderColor(T.slotBorder[1], T.slotBorder[2], T.slotBorder[3], T.slotBorder[4])
end
slot:Show()
else
slot.mailData = nil
slot.icon:Hide()
slot.countFS:SetText("")
slot.moneyFS:Hide()
slot.codFS:Hide()
slot:SetBackdropBorderColor(T.slotBorder[1], T.slotBorder[2], T.slotBorder[3], T.slotBorder[4])
slot:Show()
end
end
end
--------------------------------------------------------------------------------
-- Mail Bag: Panel Switching
--------------------------------------------------------------------------------
function ML:ShowMailBagPanel()
if not S.frame then return end
S.frame.tabInbox:SetActive(false)
S.frame.tabBag:SetActive(true)
S.frame.tabSend:SetActive(false)
if S.frame.detailPanel then S.frame.detailPanel:Hide() end
S.detailMailIndex = nil
S.frame.inboxPanel:Hide()
S.frame.sendPanel:Hide()
S.frame.bagPanel:Show()
ML:UpdateMailBag()
end
--------------------------------------------------------------------------------
-- BUILD: Send panel
--------------------------------------------------------------------------------
@@ -1555,29 +1893,56 @@ local function BuildSendPanel()
bsf:SetScrollChild(bodyEB)
f.bodyEditBox = bodyEB
-- Money row
local mLabel = sp:CreateFontString(nil, "OVERLAY")
mLabel:SetFont(font, 11, "OUTLINE"); mLabel:SetPoint("TOPLEFT", bsf, "BOTTOMLEFT", 0, -10)
mLabel:SetText("附加金币:"); mLabel:SetTextColor(T.labelText[1], T.labelText[2], T.labelText[3])
-- Money mode toggle (附加金币 / 付款取信)
local mToggle = CreateActionBtn(sp, "附加金币", 72)
mToggle:SetHeight(20); mToggle:SetPoint("TOPLEFT", bsf, "BOTTOMLEFT", 0, -10)
f.moneyToggle = mToggle
local function UpdateMoneyToggle()
if S.codMode then
mToggle.label:SetText("|cFFFF5555付款取信|r")
mToggle:SetBackdropBorderColor(1, 0.3, 0.3, 0.8)
else
mToggle.label:SetText("附加金币")
mToggle:SetBackdropBorderColor(T.btnBorder[1], T.btnBorder[2], T.btnBorder[3], T.btnBorder[4])
end
end
f.UpdateMoneyToggle = UpdateMoneyToggle
mToggle:SetScript("OnClick", function()
S.codMode = not S.codMode; UpdateMoneyToggle()
end)
mToggle:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT")
if S.codMode then
GameTooltip:AddLine("付款取信模式", 1, 0.5, 0.5)
GameTooltip:AddLine("收件人需支付指定金额才能取回附件", 0.8, 0.8, 0.8)
else
GameTooltip:AddLine("附加金币模式", 1, 0.84, 0)
GameTooltip:AddLine("随邮件附送金币给收件人", 0.8, 0.8, 0.8)
end
GameTooltip:AddLine("|cFFFFCC00点击切换模式|r")
GameTooltip:Show()
end)
mToggle:SetScript("OnLeave", function() GameTooltip:Hide() end)
UpdateMoneyToggle()
local gL = sp:CreateFontString(nil, "OVERLAY")
gL:SetFont(font, 10, "OUTLINE"); gL:SetPoint("LEFT", mLabel, "RIGHT", 6, 0)
gL:SetFont(font, 10, "OUTLINE"); gL:SetPoint("LEFT", mToggle, "RIGHT", 6, 0)
gL:SetText(""); gL:SetTextColor(T.moneyGold[1], T.moneyGold[2], T.moneyGold[3])
local gEB = CreateStyledEditBox(sp, 60, 20, true); gEB:SetPoint("LEFT", gL, "RIGHT", 4, 0); gEB:SetText("0"); f.goldEB = gEB
local gEB = CreateStyledEditBox(sp, 50, 20, true); gEB:SetPoint("LEFT", gL, "RIGHT", 4, 0); gEB:SetText("0"); f.goldEB = gEB
local sL = sp:CreateFontString(nil, "OVERLAY")
sL:SetFont(font, 10, "OUTLINE"); sL:SetPoint("LEFT", gEB, "RIGHT", 6, 0)
sL:SetText(""); sL:SetTextColor(T.moneySilver[1], T.moneySilver[2], T.moneySilver[3])
local sEB = CreateStyledEditBox(sp, 40, 20, true); sEB:SetPoint("LEFT", sL, "RIGHT", 4, 0); sEB:SetText("0"); f.silverEB = sEB
local sEB = CreateStyledEditBox(sp, 36, 20, true); sEB:SetPoint("LEFT", sL, "RIGHT", 4, 0); sEB:SetText("0"); f.silverEB = sEB
local cL = sp:CreateFontString(nil, "OVERLAY")
cL:SetFont(font, 10, "OUTLINE"); cL:SetPoint("LEFT", sEB, "RIGHT", 6, 0)
cL:SetText(""); cL:SetTextColor(T.moneyCopper[1], T.moneyCopper[2], T.moneyCopper[3])
local cEB = CreateStyledEditBox(sp, 40, 20, true); cEB:SetPoint("LEFT", cL, "RIGHT", 4, 0); cEB:SetText("0"); f.copperEB = cEB
local cEB = CreateStyledEditBox(sp, 36, 20, true); cEB:SetPoint("LEFT", cL, "RIGHT", 4, 0); cEB:SetText("0"); f.copperEB = cEB
-- Attachments
local aLabel = sp:CreateFontString(nil, "OVERLAY")
aLabel:SetFont(font, 11, "OUTLINE"); aLabel:SetPoint("TOPLEFT", mLabel, "TOPLEFT", 0, -28)
aLabel:SetFont(font, 11, "OUTLINE"); aLabel:SetPoint("TOPLEFT", mToggle, "TOPLEFT", 0, -28)
aLabel:SetText("附件 (右击/拖放背包物品添加):"); aLabel:SetTextColor(T.labelText[1], T.labelText[2], T.labelText[3])
local clrBtn = CreateActionBtn(sp, "清空", 50)
@@ -1679,7 +2044,7 @@ local function SetupEvents()
f:SetScript("OnEvent", function()
if event == "MAIL_SHOW" then
if SFramesDB and SFramesDB.enableMail == false then return end
S.currentTab = 1; S.inboxPage = 1; S.inboxChecked = {}
S.currentTab = 1; S.inboxPage = 1; S.bagPage = 1; S.inboxChecked = {}
CheckInbox(); f:Show(); ML:ShowInboxPanel()
elseif event == "MAIL_INBOX_UPDATE" then
if f:IsVisible() then
@@ -1689,10 +2054,28 @@ local function SetupEvents()
else
ML:HideMailDetail()
end
elseif S.currentTab == 3 then
ML:UpdateMailBag()
else
UpdateInbox()
end
end
-- 收件箱清空后同步小地图信件图标状态
if MiniMapMailFrame then
if HasNewMail and HasNewMail() then
MiniMapMailFrame:Show()
elseif GetInboxNumItems() == 0 then
MiniMapMailFrame:Hide()
end
end
elseif event == "UPDATE_PENDING_MAIL" then
if MiniMapMailFrame then
if HasNewMail and HasNewMail() then
MiniMapMailFrame:Show()
else
MiniMapMailFrame:Hide()
end
end
elseif event == "MAIL_CLOSED" then
if S.multiSend then AbortMultiSend("邮箱已关闭") end
f:Hide()
@@ -1721,6 +2104,7 @@ local function SetupEvents()
f:RegisterEvent("MAIL_SHOW"); f:RegisterEvent("MAIL_INBOX_UPDATE")
f:RegisterEvent("MAIL_CLOSED"); f:RegisterEvent("MAIL_SEND_SUCCESS")
f:RegisterEvent("MAIL_SEND_INFO_UPDATE"); f:RegisterEvent("MAIL_FAILED")
f:RegisterEvent("UPDATE_PENDING_MAIL")
if MailFrame then
local origMailOnShow = MailFrame:GetScript("OnShow")
@@ -1728,6 +2112,7 @@ local function SetupEvents()
if origMailOnShow then origMailOnShow() end
this:ClearAllPoints()
this:SetPoint("TOPLEFT", UIParent, "TOPLEFT", -10000, 10000)
this:SetAlpha(0)
this:EnableMouse(false)
end)
for i = table.getn(UISpecialFrames), 1, -1 do
@@ -1772,6 +2157,7 @@ function ML:Initialize()
BuildMainFrame()
BuildInboxPanel()
BuildDetailPanel()
BuildMailBagPanel()
BuildSendPanel()
SetupEvents()
end
@@ -1781,19 +2167,19 @@ end
--------------------------------------------------------------------------------
function ML:ShowInboxPanel()
if not S.frame then return end
S.frame.tabInbox:SetActive(true); S.frame.tabSend:SetActive(false)
S.frame.tabInbox:SetActive(true); S.frame.tabBag:SetActive(false); S.frame.tabSend:SetActive(false)
if S.frame.detailPanel then S.frame.detailPanel:Hide() end
S.frame.inboxPanel:Show(); S.frame.sendPanel:Hide()
S.frame.inboxPanel:Show(); S.frame.sendPanel:Hide(); S.frame.bagPanel:Hide()
S.detailMailIndex = nil
UpdateInbox()
end
function ML:ShowSendPanel()
if not S.frame then return end
S.frame.tabInbox:SetActive(false); S.frame.tabSend:SetActive(true)
S.frame.tabInbox:SetActive(false); S.frame.tabBag:SetActive(false); S.frame.tabSend:SetActive(true)
if S.frame.detailPanel then S.frame.detailPanel:Hide() end
S.detailMailIndex = nil
S.frame.inboxPanel:Hide(); S.frame.sendPanel:Show()
S.frame.inboxPanel:Hide(); S.frame.sendPanel:Show(); S.frame.bagPanel:Hide()
if S.frame.sendStatus then S.frame.sendStatus:SetText("") end
if S.statusFadeTimer then S.statusFadeTimer:SetScript("OnUpdate", nil) end
ML:UpdateSendPanel()