Mercurial > wow > mailopener
changeset 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 | 5fe1f61452a1 |
| children | 71e2a651d667 |
| files | Core.lua Modules/Config.lua |
| diffstat | 2 files changed, 38 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Thu Sep 30 14:34:17 2010 +0200 +++ b/Core.lua Thu Sep 30 15:21:38 2010 +0200 @@ -6,7 +6,7 @@ -- MailAddonBusy will be nil when nothing is happening or filled with the addon name when MO is working -- Another addon can use this variable to indicate they're working too, MailOpener will then wait for that to finish -local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit; +local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed, mailboxEmptySoundPlayedThisVisit, hasOpenedMailAlready; function MailOpener:OnInitialize() self:Debug("OnInitialize"); @@ -33,6 +33,7 @@ continueOpening = false, waitTime = 5, initialDelay = 0.5, + overrideCheckInbox = false, }, modules = { BeanCounterSupport = true, @@ -430,6 +431,7 @@ end end + hasOpenedMailAlready = nil; mailboxEmptySoundPlayed = nil; mailboxEmptySoundPlayedThisVisit = nil; @@ -577,6 +579,8 @@ MailAddonBusy = nil; end + hasOpenedMailAlready = true; + -- Try a recheck self:Recheck(); @@ -660,6 +664,8 @@ MailAddonBusy = nil; end + hasOpenedMailAlready = nil; + -- We won't need this anymore self:UnregisterEvent("MAIL_CLOSED"); self:UnregisterEvent("PLAYER_LEAVING_WORLD"); @@ -781,117 +787,32 @@ maxLetters = 1024, }; ---BETA: The below either has to be removed or changed when releasing ---[[ -BETA/ALPHA request box -function MailOpener:ShowBetaPopup() - function TableDump(key, val, jumps) - local cache = ""; +-- The idea for this is to wait with refresing while there is still mail remaining which can be opened +-- This should speed things up a tiny bit, but might become buggy if coded wrong +local originalCheckInbox = CheckInbox; +function CheckInbox(...) + if not MailOpener.db.profile.general.overrideCheckInbox or not MailOpener.db.profile.general.continueOpening or lastAmount == 0 then + -- If the override Check Inbox option is off + -- or continuous opening is off + -- or there's currently no mail visible - if not jumps then - jumps = 0; - end + MailOpener:Debug("CheckInbox:" .. tostring(MailOpener.db.profile.general.overrideCheckInbox) .. "/" .. tostring(MailOpener.db.profile.general.continueOpening) .. "/" .. tostring(lastAmount == 0)); - local spacer = ""; - if jumps > 0 then - for i = 1, jumps do - spacer = spacer .. " "; - end - end - - if type(val) == "table" then - cache = cache .. spacer .. key .. " = {\n"; - foreach(val, function(k, v) - cache = cache .. TableDump(k, v, (jumps + 1)); - end); - cache = cache .. spacer .. "},\n"; - else - cache = cache .. spacer .. key .. " = " .. tostring(val) .. ",\n"; - end - - return cache; + -- Just call the original function + return originalCheckInbox(...); end - local cache = ""; - foreach(MailOpener.db.profile, function(k, v) - cache = cache .. TableDump(k, v, 0); - end); - - local AceGUI = LibStub("AceGUI-3.0"); - local frame = AceGUI:Create("Frame"); - frame:SetTitle("Mail Opener ALPHA"); - frame:SetWidth(575); - frame:SetHeight(375); - - -- Add a normal description label - local desc = AceGUI:Create("Label"); - 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"); - desc:SetFont(GameFontHighlightSmall:GetFont(), 13); - desc:SetFullWidth(true); - frame:AddChild(desc); - - -- Add a MultiLineEditBox - local settingsMLEEB = AceGUI:Create("MultiLineEditBox"); - settingsMLEEB:SetText(cache); - settingsMLEEB:SetLabel("Hit CTRL-A to select all and CTRL-C to copy the text. You can then use CTRL-V to paste."); - settingsMLEEB:SetFullWidth(true); - settingsMLEEB:SetNumLines(8); - settingsMLEEB:DisableButton(true); - settingsMLEEB:SetCallback("OnTextChanged", function() - settingsMLEEB:SetText(cache); - end); - frame:AddChild(settingsMLEEB); - - -- Empty line between the two links - local label = AceGUI:Create("Label"); - label:SetText("Please post the above text at either of these two links:"); - label:SetFullWidth(true); - frame:AddChild(label); - - local desc1 = AceGUI:Create("InteractiveLabel"); - desc1:SetText("|cff00bbbb[http://wow.curseforge.com/addons/mailopener/create-ticket/]|r"); - desc1:SetFont(GameFontHighlightSmall:GetFont(), 13); - desc1:SetFullWidth(true); - desc1:SetCallback("OnClick", function() - MailOpener.currentPopupContents = "http://wow.curseforge.com/addons/mailopener/create-ticket/"; + if not hasOpenedMailAlready then + -- If MO hasn't opened mail yet, we wait. + -- MO will call this function when mail opening is done - StaticPopup_Show("MailOpenerCopyWindow"); - end); - desc1:SetCallback("OnEnter", function() - frame:SetStatusText("Click to copy this URL."); - end); - desc1:SetCallback("OnLeave", function() - frame:SetStatusText(""); - end); - frame:AddChild(desc1); - - -- Empty line between the two links - local spacer = AceGUI:Create("Label"); - spacer:SetText(" "); - frame:AddChild(spacer); - - local desc2 = AceGUI:Create("InteractiveLabel"); - desc2:SetText("|cff00bbbb[http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403]|r"); - desc2:SetFont(GameFontHighlightSmall:GetFont(), 13); - desc2:SetFullWidth(true); - desc2:SetCallback("OnClick", function() - MailOpener.currentPopupContents = "http://20kleveling.com/JMTCforum/posting.php?mode=reply&f=9&t=1403"; + MailOpener:Debug("CheckInbox:Waiting..."); - StaticPopup_Show("MailOpenerCopyWindow"); - end); - desc2:SetCallback("OnEnter", function() - frame:SetStatusText("Click to copy this URL."); - end); - desc2:SetCallback("OnLeave", function() - frame:SetStatusText(""); - end); - frame:AddChild(desc2); - - -- Empty line between the two links - local label = AceGUI:Create("Label"); - 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."); - label:SetFullWidth(true); - frame:AddChild(label); -end -]] \ No newline at end of file + return false; + else + MailOpener:Debug("CheckInbox:Refresh!"); + + return originalCheckInbox(...); + end +end \ No newline at end of file
--- a/Modules/Config.lua Thu Sep 30 14:34:17 2010 +0200 +++ b/Modules/Config.lua Thu Sep 30 15:21:38 2010 +0200 @@ -402,6 +402,15 @@ set = function(i, v) MailOpener.db.profile.general.defaultQAStatus = v; end, hidden = (not MailOpener.QuickAuctionsEnabled), }, + overrideCheckInbox = { + order = 12, + type = "toggle", + name = "|cffff0000Experimental|r: Don't refresh the mailbox while there is still mail waiting to be opened", + desc = "|cffff0000Note:|r This functionality is still very experimental. Your mailbox might not update properly if you enable this.\n\nToggling this on will prevent the mailbox from automatically refreshing while there is still openable mail remaining.\n\nIf you close the mailbox while there is still mail remaining, your client will always try to refresh the inbox when you reopen it. This feature will wait with refreshing until there is no openable mail remaining, possibly saving a few seconds.", + width = "full", + get = function() return MailOpener.db.profile.general.overrideCheckInbox; end, + set = function(i, v) MailOpener.db.profile.general.overrideCheckInbox = v; end, + }, continueOpeningStackableItems = { order = 15, type = "toggle",
