Mercurial > wow > mailopener
comparison Core.lua @ 115:97205db58bad
Disabling Mail Opener will now also stop the overriding of the CheckInbox function.
| author | Zerotorescue |
|---|---|
| date | Thu, 07 Oct 2010 23:34:34 +0200 |
| parents | 91fe61693247 |
| children | cff956d6e9d0 |
comparison
equal
deleted
inserted
replaced
| 114:05084fdb7e3d | 115:97205db58bad |
|---|---|
| 4 | 4 |
| 5 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end) | 5 -- You can check if MailOpener is busy with the global MailAddonBusy (if not MailAddonBusy then ...do something... end) |
| 6 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working | 6 -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working |
| 7 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish | 7 -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish |
| 8 | 8 |
| 9 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit, hasOpenedMailAlready; | 9 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit, hasOpenedMailAlready, originalCheckInbox; |
| 10 | 10 |
| 11 function MailOpener:OnInitialize() | 11 function MailOpener:OnInitialize() |
| 12 self:Debug("OnInitialize"); | 12 self:Debug("OnInitialize"); |
| 13 | 13 |
| 14 | 14 |
| 319 self:RegisterEvent("MAIL_SHOW"); | 319 self:RegisterEvent("MAIL_SHOW"); |
| 320 self:RegisterEvent("PLAYER_ENTERING_WORLD"); | 320 self:RegisterEvent("PLAYER_ENTERING_WORLD"); |
| 321 | 321 |
| 322 self.btnConfig:Show(); | 322 self.btnConfig:Show(); |
| 323 | 323 |
| 324 if not originalCheckInbox then | |
| 325 -- Override the CheckInbox function | |
| 326 -- Remember the original | |
| 327 originalCheckInbox = CheckInbox; | |
| 328 -- Then override that | |
| 329 CheckInbox = NewCheckInbox; | |
| 330 end | |
| 331 | |
| 324 -- Reset variables | 332 -- Reset variables |
| 325 lastAmount = 0; | 333 lastAmount = 0; |
| 326 self.debugChannel = nil; | 334 self.debugChannel = nil; |
| 327 | 335 |
| 328 --BETA:if (self.db.profile.uses % 15) == 0 then | |
| 329 --BETA: -- Automatically show once every 15 uses | |
| 330 --BETA: self:ShowBetaPopup(); | |
| 331 --BETA:end | |
| 332 | |
| 333 -- If we were toggling this addon on while the mailbox is opened we must register all events again | 336 -- If we were toggling this addon on while the mailbox is opened we must register all events again |
| 334 if MailFrame:IsVisible() then | 337 if MailFrame:IsVisible() then |
| 335 self:MAIL_SHOW(); | 338 self:MAIL_SHOW(); |
| 336 end | 339 end |
| 337 end | 340 end |
| 338 | 341 |
| 339 function MailOpener:OnDisable() | 342 function MailOpener:OnDisable() |
| 340 self:UnregisterEvent("MAIL_SHOW"); | 343 self:UnregisterEvent("MAIL_SHOW"); |
| 341 | 344 |
| 342 self.btnConfig:Hide(); | 345 self.btnConfig:Hide(); |
| 346 | |
| 347 if originalCheckInbox then | |
| 348 -- Change checkinbox back to the original value | |
| 349 CheckInbox = originalCheckInbox; | |
| 350 -- Forget the other reference | |
| 351 originalCheckInbox = nil; | |
| 352 end | |
| 343 | 353 |
| 344 MailOpener:Stop(); | 354 MailOpener:Stop(); |
| 345 end | 355 end |
| 346 | 356 |
| 347 -- We must disable Quick Auction's auto mail (if set up that way in the settings) before opening the mailbox or it will instantly start sending stuff | 357 -- We must disable Quick Auction's auto mail (if set up that way in the settings) before opening the mailbox or it will instantly start sending stuff |
| 788 }; | 798 }; |
| 789 | 799 |
| 790 | 800 |
| 791 -- The idea for this is to wait with refresing while there is still mail remaining which can be opened | 801 -- The idea for this is to wait with refresing while there is still mail remaining which can be opened |
| 792 -- This should speed things up a tiny bit, but might become buggy if coded wrong | 802 -- This should speed things up a tiny bit, but might become buggy if coded wrong |
| 793 local originalCheckInbox = CheckInbox; | 803 -- We actually override the function in the onenable |
| 794 function CheckInbox(...) | 804 function NewCheckInbox(...) |
| 795 if not MailOpener.db.profile.general.overrideCheckInbox or not MailOpener.db.profile.general.continueOpening or lastAmount == 0 then | 805 if not MailOpener.db.profile.general.overrideCheckInbox or not MailOpener.db.profile.general.continueOpening or lastAmount == 0 then |
| 796 -- If the override Check Inbox option is off | 806 -- If the override Check Inbox option is off |
| 797 -- or continuous opening is off | 807 -- or continuous opening is off |
| 798 -- or there's currently no mail visible | 808 -- or there's currently no mail visible |
| 799 | 809 |
| 800 MailOpener:Debug("CheckInbox:" .. tostring(MailOpener.db.profile.general.overrideCheckInbox) .. "/" .. tostring(MailOpener.db.profile.general.continueOpening) .. "/" .. tostring(lastAmount == 0)); | 810 MailOpener:Debug("CheckInbox:" .. tostring((not MailOpener.db.profile.general.overrideCheckInbox)) .. "/" .. tostring((not MailOpener.db.profile.general.continueOpening)) .. "/" .. tostring(lastAmount == 0)); |
| 801 | 811 |
| 802 -- Just call the original function | 812 -- Just call the original function |
| 803 return originalCheckInbox(...); | 813 return originalCheckInbox(...); |
| 804 end | 814 end |
| 805 | 815 |
