WoWInterface SVN OpenAll

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/OpenAll.lua New file
0,0 → 1,85
local deletedelay, t = 0.5, 0
local takingOnlyCash = false
local button, button2, waitForMail, doNothing, openAll, openAllCash, openMail, lastopened, stopOpening, onEvent, needsToWait
local _G = _G
local baseInboxFrame_OnClick
function doNothing() end
 
function openAll()
if GetInboxNumItems() == 0 then return end
button:SetScript("OnClick", nil)
button2:SetScript("OnClick", nil)
baseInboxFrame_OnClick = InboxFrame_OnClick
InboxFrame_OnClick = doNothing
button:RegisterEvent("UI_ERROR_MESSAGE")
openMail(GetInboxNumItems())
end
function openAllCash()
takingOnlyCash = true
openAll()
end
function openMail(index)
if not InboxFrame:IsVisible() then return stopOpening("Need a mailbox.") end
if index == 0 then return stopOpening("Reached the end.") end
local _, _, _, _, money, COD, _, numItems = GetInboxHeaderInfo(index)
if money > 0 then
TakeInboxMoney(index)
needsToWait = true
elseif (not takingOnlyCash) and numItems and (numItems > 0) and COD <= 0 then
TakeInboxItem(index)
needsToWait = true
end
local items = GetInboxNumItems()
if (numItems and numItems > 1) or (items > 1 and index <= items) then
lastopened = index
t = 0
button:SetScript("OnUpdate", waitForMail)
else
stopOpening("All done.")
end
end
function waitForMail()
t = t + arg1
if (not needsToWait) or (t > deletedelay) then
needsToWait = false
button:SetScript("OnUpdate", nil)
local _, _, _, _, money, COD, _, numItems = GetInboxHeaderInfo(lastopened)
if money > 0 or ((not takingOnlyCash) and COD <= 0 and numItems and (numItems > 0)) then
--The lastopened index inbox item still contains stuff we want
openMail(lastopened)
else
openMail(lastopened - 1)
end
end
end
function stopOpening(msg)
button:SetScript("OnUpdate", nil)
button:SetScript("OnClick", openAll)
button2:SetScript("OnClick", openAllCash)
if baseInboxFrame_OnClick then
InboxFrame_OnClick = baseInboxFrame_OnClick
end
button:UnregisterEvent("UI_ERROR_MESSAGE")
takingOnlyCash = false
if msg then DEFAULT_CHAT_FRAME:AddMessage("OpenAll: "..msg) end
end
function onEvent(frame, event, arg1, arg2, arg3, arg4)
if event == "UI_ERROR_MESSAGE" then
if arg1 == ERR_INV_FULL then
stopOpening("Stopped, inventory is full.")
end
end
end
local function makeButton(id, text, w, h, x, y)
local button = CreateFrame("Button", id, InboxFrame, "UIPanelButtonTemplate")
button:SetWidth(w)
button:SetHeight(h)
button:SetPoint("CENTER", InboxFrame, "TOP", x, y)
button:SetText(text)
return button
end
button = makeButton("OpenAllButton", "Take All", 60, 25, -50, -410)
button:SetScript("OnClick", openAll)
button:SetScript("OnEvent", onEvent)
button2 = makeButton("OpenAllButton2", "Take Cash", 60, 25, 20, -410)
button2:SetScript("OnClick", openAllCash)
Property changes : Added: svn:eol-style + native Added: svn:executable + *
trunk/OpenAll.toc New file
0,0 → 1,12
## Interface: 20400
 
## Title: OpenAll
## Notes: Open all your mail
## Author: Kemayo
## Version: 1
## X-Category: Mail
## LoadManagers: SupplyAndDemand, AddonLoader
## X-S&D-AtMail: true
## X-LoadOn-Mailbox: true
 
OpenAll.lua