Mercurial > wow > mailopener
comparison Core.lua @ 108:f5558317ced3
Added an experimental option to override the CheckInbox function to delay mailbox refresh while there is still mail remaining.
| author | Zerotorescue |
|---|---|
| date | Thu, 30 Sep 2010 15:21:38 +0200 |
| parents | d62eaa354443 |
| children | 91fe61693247 |
comparison
equal
deleted
inserted
replaced
| 107:5fe1f61452a1 | 108:f5558317ced3 |
|---|---|
| 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; | 9 local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit, hasOpenedMailAlready; |
| 10 | 10 |
| 11 function MailOpener:OnInitialize() | 11 function MailOpener:OnInitialize() |
| 12 self:Debug("OnInitialize"); | 12 self:Debug("OnInitialize"); |
| 13 | 13 |
| 14 | 14 |
| 31 autoReenableQAAutoMail = false, | 31 autoReenableQAAutoMail = false, |
| 32 autoSetBackQAAutoMail = true, | 32 autoSetBackQAAutoMail = true, |
| 33 continueOpening = false, | 33 continueOpening = false, |
| 34 waitTime = 5, | 34 waitTime = 5, |
| 35 initialDelay = 0.5, | 35 initialDelay = 0.5, |
| 36 overrideCheckInbox = false, | |
| 36 }, | 37 }, |
| 37 modules = { | 38 modules = { |
| 38 BeanCounterSupport = true, | 39 BeanCounterSupport = true, |
| 39 Config = false, | 40 Config = false, |
| 40 Collected = true, | 41 Collected = true, |
| 428 -- Hide the x mail remaining text | 429 -- Hide the x mail remaining text |
| 429 QAMail.totalMail:Hide(); | 430 QAMail.totalMail:Hide(); |
| 430 end | 431 end |
| 431 end | 432 end |
| 432 | 433 |
| 434 hasOpenedMailAlready = nil; | |
| 433 mailboxEmptySoundPlayed = nil; | 435 mailboxEmptySoundPlayed = nil; |
| 434 mailboxEmptySoundPlayedThisVisit = nil; | 436 mailboxEmptySoundPlayedThisVisit = nil; |
| 435 | 437 |
| 436 self:Recheck(); | 438 self:Recheck(); |
| 437 | 439 |
| 575 function MailOpener:MO_OPEN_COMPLETE() | 577 function MailOpener:MO_OPEN_COMPLETE() |
| 576 if MailAddonBusy == self:GetName() then | 578 if MailAddonBusy == self:GetName() then |
| 577 MailAddonBusy = nil; | 579 MailAddonBusy = nil; |
| 578 end | 580 end |
| 579 | 581 |
| 582 hasOpenedMailAlready = true; | |
| 583 | |
| 580 -- Try a recheck | 584 -- Try a recheck |
| 581 self:Recheck(); | 585 self:Recheck(); |
| 582 | 586 |
| 583 local current, total = GetInboxNumItems(); | 587 local current, total = GetInboxNumItems(); |
| 584 | 588 |
| 657 -- Stop checking for new mail and unregister the events we needed | 661 -- Stop checking for new mail and unregister the events we needed |
| 658 function MailOpener:Stop() | 662 function MailOpener:Stop() |
| 659 if MailAddonBusy == self:GetName() then | 663 if MailAddonBusy == self:GetName() then |
| 660 MailAddonBusy = nil; | 664 MailAddonBusy = nil; |
| 661 end | 665 end |
| 666 | |
| 667 hasOpenedMailAlready = nil; | |
| 662 | 668 |
| 663 -- We won't need this anymore | 669 -- We won't need this anymore |
| 664 self:UnregisterEvent("MAIL_CLOSED"); | 670 self:UnregisterEvent("MAIL_CLOSED"); |
| 665 self:UnregisterEvent("PLAYER_LEAVING_WORLD"); | 671 self:UnregisterEvent("PLAYER_LEAVING_WORLD"); |
| 666 self:UnregisterEvent("MAIL_INBOX_UPDATE"); | 672 self:UnregisterEvent("MAIL_INBOX_UPDATE"); |
| 779 whileDead = 1, | 785 whileDead = 1, |
| 780 hideOnEscape = 1, | 786 hideOnEscape = 1, |
| 781 maxLetters = 1024, | 787 maxLetters = 1024, |
| 782 }; | 788 }; |
| 783 | 789 |
| 784 --BETA: The below either has to be removed or changed when releasing | 790 |
| 785 | 791 -- The idea for this is to wait with refresing while there is still mail remaining which can be opened |
| 786 --[[ | 792 -- This should speed things up a tiny bit, but might become buggy if coded wrong |
| 787 BETA/ALPHA request box | 793 local originalCheckInbox = CheckInbox; |
| 788 function MailOpener:ShowBetaPopup() | 794 function CheckInbox(...) |
| 789 function TableDump(key, val, jumps) | 795 if not MailOpener.db.profile.general.overrideCheckInbox or not MailOpener.db.profile.general.continueOpening or lastAmount == 0 then |
| 790 local cache = ""; | 796 -- If the override Check Inbox option is off |
| 791 | 797 -- or continuous opening is off |
| 792 if not jumps then | 798 -- or there's currently no mail visible |
| 793 jumps = 0; | 799 |
| 794 end | 800 MailOpener:Debug("CheckInbox:" .. tostring(MailOpener.db.profile.general.overrideCheckInbox) .. "/" .. tostring(MailOpener.db.profile.general.continueOpening) .. "/" .. tostring(lastAmount == 0)); |
| 795 | 801 |
| 796 local spacer = ""; | 802 -- Just call the original function |
| 797 if jumps > 0 then | 803 return originalCheckInbox(...); |
| 798 for i = 1, jumps do | 804 end |
| 799 spacer = spacer .. " "; | 805 |
| 800 end | 806 if not hasOpenedMailAlready then |
| 801 end | 807 -- If MO hasn't opened mail yet, we wait. |
| 802 | 808 -- MO will call this function when mail opening is done |
| 803 if type(val) == "table" then | 809 |
| 804 cache = cache .. spacer .. key .. " = {\n"; | 810 MailOpener:Debug("CheckInbox:Waiting..."); |
| 805 foreach(val, function(k, v) | 811 |
| 806 cache = cache .. TableDump(k, v, (jumps + 1)); | 812 return false; |
| 807 end); | 813 else |
| 808 cache = cache .. spacer .. "},\n"; | 814 MailOpener:Debug("CheckInbox:Refresh!"); |
| 809 else | 815 |
| 810 cache = cache .. spacer .. key .. " = " .. tostring(val) .. ",\n"; | 816 return originalCheckInbox(...); |
| 811 end | 817 end |
| 812 | 818 end |
| 813 return cache; | |
| 814 end | |
| 815 | |
| 816 local cache = ""; | |
| 817 foreach(MailOpener.db.profile, function(k, v) | |
| 818 cache = cache .. TableDump(k, v, 0); | |
| 819 end); | |
| 820 | |
| 821 local AceGUI = LibStub("AceGUI-3.0"); | |
| 822 local frame = AceGUI:Create("Frame"); | |
| 823 frame:SetTitle("Mail Opener ALPHA"); | |
| 824 frame:SetWidth(575); | |
| 825 frame:SetHeight(375); | |
| 826 | |
| 827 -- Add a normal description label | |
| 828 local desc = AceGUI:Create("Label"); | |
| 829 desc:SetText("|cff00ff00After you have been using Mail Opener for a while and configured it just as you want it to be, please report your favorite settings by copying the text below at either of the below links. Thanks in advance!|r\n\n"); | |
| 830 desc:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 831 desc:SetFullWidth(true); | |
| 832 frame:AddChild(desc); | |
| 833 | |
| 834 -- Add a MultiLineEditBox | |
| 835 local settingsMLEEB = AceGUI:Create("MultiLineEditBox"); | |
| 836 settingsMLEEB:SetText(cache); | |
| 837 settingsMLEEB:SetLabel("Hit CTRL-A to select all and CTRL-C to copy the text. You can then use CTRL-V to paste."); | |
| 838 settingsMLEEB:SetFullWidth(true); | |
| 839 settingsMLEEB:SetNumLines(8); | |
| 840 settingsMLEEB:DisableButton(true); | |
| 841 settingsMLEEB:SetCallback("OnTextChanged", function() | |
| 842 settingsMLEEB:SetText(cache); | |
| 843 end); | |
| 844 frame:AddChild(settingsMLEEB); | |
| 845 | |
| 846 -- Empty line between the two links | |
| 847 local label = AceGUI:Create("Label"); | |
| 848 label:SetText("Please post the above text at either of these two links:"); | |
| 849 label:SetFullWidth(true); | |
| 850 frame:AddChild(label); | |
| 851 | |
| 852 local desc1 = AceGUI:Create("InteractiveLabel"); | |
| 853 desc1:SetText("|cff00bbbb[http://wow.curseforge.com/addons/mailopener/create-ticket/]|r"); | |
| 854 desc1:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 855 desc1:SetFullWidth(true); | |
| 856 desc1:SetCallback("OnClick", function() | |
| 857 MailOpener.currentPopupContents = "http://wow.curseforge.com/addons/mailopener/create-ticket/"; | |
| 858 | |
| 859 StaticPopup_Show("MailOpenerCopyWindow"); | |
| 860 end); | |
| 861 desc1:SetCallback("OnEnter", function() | |
| 862 frame:SetStatusText("Click to copy this URL."); | |
| 863 end); | |
| 864 desc1:SetCallback("OnLeave", function() | |
| 865 frame:SetStatusText(""); | |
| 866 end); | |
| 867 frame:AddChild(desc1); | |
| 868 | |
| 869 -- Empty line between the two links | |
| 870 local spacer = AceGUI:Create("Label"); | |
| 871 spacer:SetText(" "); | |
| 872 frame:AddChild(spacer); | |
| 873 | |
| 874 local desc2 = AceGUI:Create("InteractiveLabel"); | |
| 875 desc2:SetText("|cff00bbbb[http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403]|r"); | |
| 876 desc2:SetFont(GameFontHighlightSmall:GetFont(), 13); | |
| 877 desc2:SetFullWidth(true); | |
| 878 desc2:SetCallback("OnClick", function() | |
| 879 MailOpener.currentPopupContents = "http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403"; | |
| 880 | |
| 881 StaticPopup_Show("MailOpenerCopyWindow"); | |
| 882 end); | |
| 883 desc2:SetCallback("OnEnter", function() | |
| 884 frame:SetStatusText("Click to copy this URL."); | |
| 885 end); | |
| 886 desc2:SetCallback("OnLeave", function() | |
| 887 frame:SetStatusText(""); | |
| 888 end); | |
| 889 frame:AddChild(desc2); | |
| 890 | |
| 891 -- Empty line between the two links | |
| 892 local label = AceGUI:Create("Label"); | |
| 893 label:SetText("\n\nps. You can always view this window again at a later time by clicking the \"Config\" button in the mail frame.\nps2. The information above is completely Mail Opener related. It will be used to determine the best default settings."); | |
| 894 label:SetFullWidth(true); | |
| 895 frame:AddChild(label); | |
| 896 end | |
| 897 ]] |
