Mercurial > wow > mailopener
changeset 2:57ba1593ac42
Reducing amount of calculations regarding mail updates, all mail changes are now addon-wide broadcasted messages. Main reason for this is to allow for another plugin.
| author | Zerotorescue |
|---|---|
| date | Sun, 05 Sep 2010 17:26:35 +0200 |
| parents | 6f17035de058 |
| children | c6f0976069c7 |
| files | Core.lua Modules/OpenAll.lua |
| diffstat | 2 files changed, 38 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Sun Sep 05 17:02:19 2010 +0200 +++ b/Core.lua Sun Sep 05 17:26:35 2010 +0200 @@ -338,6 +338,11 @@ -- Open the current mail self:ScheduleOpen(false); end + elseif current < tempLastAmount then + -- We lost a mail + + -- Yell that we successfully opened/removed a mail + self:SendMessage("MO_MAIL_DELETED"); elseif (current == 50 and tempLastAmount == 50) then if not IsShiftKeyDown() then -- Allow overriding of mailopening with the shift key
--- a/Modules/OpenAll.lua Sun Sep 05 17:02:19 2010 +0200 +++ b/Modules/OpenAll.lua Sun Sep 05 17:26:35 2010 +0200 @@ -144,11 +144,11 @@ self:RegisterEvent("UI_ERROR_MESSAGE"); -- Only look again after bags updated self:RegisterEvent("BAG_UPDATE"); - self:RegisterEvent("MAIL_INBOX_UPDATE"); -- We need to know when to start opening self:RegisterMessage("MO_OPEN_MAIL", "Open"); self:RegisterMessage("MO_SERVER_SYNCED"); + self:RegisterMessage("MO_MAIL_DELETED"); self:CancelTimer(self.tmrTimeRemaining, true); self.tmrTimeRemaining = self:ScheduleRepeatingTimer("UpdateTimer", 1); @@ -165,11 +165,11 @@ -- We care about a full inventory just a little self:UnregisterEvent("UI_ERROR_MESSAGE"); self:UnregisterEvent("BAG_UPDATE"); - self:UnregisterEvent("MAIL_INBOX_UPDATE"); -- We no longer care self:UnregisterMessage("MO_OPEN_MAIL"); self:UnregisterMessage("MO_SERVER_SYNCED"); + self:UnregisterMessage("MO_MAIL_DELETED"); self:CancelTimer(self.tmrMailOpener, true); self:CancelTimer(self.tmrTimeRemaining, true); @@ -180,12 +180,30 @@ function OpenAll:MO_SERVER_SYNCED() self:Debug("MO_SERVER_SYNCED"); + -- Stop opening now to prevent the opener from continue while Beancounter is counting + self:StopOpening(false); + lastSync = GetTime(); + self:UpdateMailCount(); +end + +function OpenAll:MO_MAIL_DELETED() + self:Debug("MO_MAIL_DELETED"); + + -- A mail has been deleted so we can process the next + continue = true; + + self:UpdateMailCount(); +end + +function OpenAll:UpdateMailCount() local numItems, totalItems = GetInboxNumItems(); numCurrentMail = numItems; numHiddenMail = ( totalItems - numItems ); + + self:UpdateTimer(); end function OpenAll:BAG_UPDATE() @@ -195,25 +213,6 @@ inventoryFullSoundPlayed = nil; end -function OpenAll:MAIL_INBOX_UPDATE() - local numItems, totalItems = GetInboxNumItems(); - - if numItems ~= numCurrentMail then - continue = true; - - if numCurrentMail ~= nil and numItems > numCurrentMail then - -- This is a server sync - - self:StopOpening(false); - end - end - - numCurrentMail = numItems; - numHiddenMail = ( totalItems - numItems ); - - self:UpdateTimer(); -end - -- We registered this event to look for the inventory full error message because this is faster than counting the amount of items in the inventory all the time function OpenAll:UI_ERROR_MESSAGE(e, errorMessage) if errorMessage == ERR_INV_FULL then @@ -434,6 +433,9 @@ else continue = false; + -- Notifiy other modules of opening + self:SendMessage("MO_OPENING_MAIL"); + -- Open current mail AutoLootMailItem(index); @@ -492,6 +494,11 @@ end end +function OpenAll:Continue() + continue = true; + self:OpenNext(); +end + local mailRemainingPatterns = { minutesSeconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes and |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)"; minutes = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r minutes (next refresh in |cffffffff%d|r seconds)"; @@ -565,16 +572,18 @@ end function OpenAll:StopOpening(simple) + -- Stop opener timer + self:CancelTimer(self.tmrMailOpener, true); + if not simple then + -- A simple stop is an automated stop, an advance stop is one manually or after a sever sync + -- Recheck inventory full inventoryFull = false; -- Replay sound inventoryFullSoundPlayed = nil; end - -- Stop opener timer - self:CancelTimer(self.tmrMailOpener, true); - -- Reset opener position MAIL_ITEM_INDEX = 0; -- Stopped opening, so allow to continue
