Mercurial > wow > mailopener
diff Modules/OpenAll.lua @ 0:823e33465b6e
Initial commit
| author | Zerotorescue |
|---|---|
| date | Fri, 03 Sep 2010 12:43:36 +0200 |
| parents | |
| children | 6f17035de058 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/OpenAll.lua Fri Sep 03 12:43:36 2010 +0200 @@ -0,0 +1,818 @@ +local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); +local OpenAll = MailOpener:NewModule("OpenAll", "AceEvent-3.0", "AceTimer-3.0"); + +local MAIL_ITEM_INDEX, mailTimer, inventoryFull, inventoryFullSoundPlayed, opening, lastSync, numCurrentMail, numHiddenMail, continue; + +function OpenAll:OnInitialize() + local defaults = { + profile = { + speed = 0.05, + keepFreeSpace = 0, + filter = { + AH = { + canceled = true, + expired = true, + outbid = true, + success = true, + won = true, + }, + normalAttachments = false, + normalMoney = true, + }, + }, + }; + + -- Register our saved variables NameSpace + self.db = MailOpener.db:RegisterNamespace("OpenAll", defaults); +end + +function OpenAll:OnEnable() + self:RegisterEvent("MAIL_SHOW"); + + if not self.btnOpenAll then + -- Open all button + local button = CreateFrame("Button", "btnMailOpenerOpenAll", InboxFrame, "UIPanelButtonTemplate") + button:SetText("Open all") + button:SetHeight(26) + button:SetWidth(120) + button:SetPoint("BOTTOM", InboxFrame, "CENTER", -10, -165) + button:SetScript("OnClick", function() OpenAll:Open(true) end) + + self.btnOpenAll = button; + end + + self.btnOpenAll:Show(); + + if not self.timeLeftFrame then + -- If the timeLeftFrame doesn't exist we will have to build it + + self:Debug("Building text frame"); + + local frame = CreateFrame("Button", "MailOpenerTimeLeftButton", InboxFrame); + + -- Mail counter + frame.text = frame:CreateFontString("MailOpenerTimeLeftFrameMailCount", "OVERLAY", "GameFontHighlight"); + frame.text:SetPoint("CENTER", MailFrame, "TOPLEFT", 40, -35); + + -- Long time left indicator + frame.smallText = frame:CreateFontString("MailOpenerTimeLeftFrameTimeRemaining", "OVERLAY", "GameFontNormal"); + frame.smallText:SetFont(GameFontHighlight:GetFont(), 11, "OUTLINE"); + frame.smallText:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 75, -38); + frame.smallText:SetWidth(270); + frame.smallText:SetJustifyH("LEFT"); + frame.smallText:SetJustifyV("MIDDLE"); + + frame:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 75, -38); + frame:SetWidth(270); + frame:SetHeight(35); + frame:SetScript("OnClick", function(self) + local timeRemainingUntillOpened = frame.smallText:GetText(); + if timeRemainingUntillOpened then + MailOpener.currentPopupContents = "|cffffd700" .. timeRemainingUntillOpened .. "|r"; + + StaticPopup_Show("MailOpenerCopyWindow"); + end + end); + + self.timeLeftFrame = frame; + end + + self.timeLeftFrame:Show(); + + -- Go through all children of the mail frame to find QA's elements and hide these + local kids = { MailFrame:GetChildren() }; + + for _, child in ipairs(kids) do + if child and child.text then + child.text:Hide(); + end + end + + -- If we were toggling this module on while the mailbox is opened we must register all events again + if MailFrame:IsVisible() then + self:MAIL_SHOW(); + end +end + +function OpenAll:OnDisable() + self:UnregisterEvent("MAIL_SHOW"); + + if self.btnOpenAll then + self.btnOpenAll:Hide(); + end + + if self.timeLeftFrame then + self.timeLeftFrame:Hide(); + end + + if MailOpener.PostalEnabled then + -- Enable Postal's openers again + + MailOpener:TogglePostalModule("OpenAll", true); + MailOpener:TogglePostalModule("Select", true); + end + + -- Go through all children of the mail frame to find QA's elements and SHOW these + local kids = { MailFrame:GetChildren() }; + + for _, child in ipairs(kids) do + if child and child.text then + child.text:Show(); + end + end + + self:Stop(); +end + +function OpenAll:MAIL_SHOW() + self:Debug("MAIL_SHOW"); + + self:StopOpening(false); + + if MailOpener.PostalEnabled then + -- Disable Postal's openers so we can do it ourselves + + MailOpener:TogglePostalModule("OpenAll", false); + MailOpener:TogglePostalModule("Select", false); + end + + -- Keep an eye for closing of the mailbox + self:RegisterEvent("MAIL_CLOSED", "Stop"); + self:RegisterEvent("PLAYER_LEAVING_WORLD", "Stop"); + + -- Look if the mailbox is full + 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:CancelTimer(self.tmrTimeRemaining, true); + self.tmrTimeRemaining = self:ScheduleRepeatingTimer("UpdateTimer", 1); + self:UpdateTimer(); +end + +function OpenAll:Stop() + self:Debug("Stop"); + + -- We shutdown, so nothing to do when the mailbox is closed anymore + self:UnregisterEvent("MAIL_CLOSED"); + self:UnregisterEvent("PLAYER_LEAVING_WORLD"); + + -- 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:CancelTimer(self.tmrMailOpener, true); + self:CancelTimer(self.tmrTimeRemaining, true); + + self:SetOpeningStatus(false); +end + +function OpenAll:MO_SERVER_SYNCED() + self:Debug("MO_SERVER_SYNCED"); + + lastSync = GetTime(); + + local numItems, totalItems = GetInboxNumItems(); + + numCurrentMail = numItems; + numHiddenMail = ( totalItems - numItems ); +end + +function OpenAll:BAG_UPDATE() + -- If the bags are updated we should check if the inventory is full again + inventoryFull = false; +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 + -- Inventory is full. + + if not inventoryFull then + inventoryFull = true; + + -- Play the sound + if MailOpener.db.profile.notifications.bagsFullSound and (not MailOpener.db.profile.notifications.bagsFullSoundOnlyOnce or not inventoryFullSoundPlayed) then + PlaySoundFile(MailOpener.db.profile.notifications.bagsFullSoundFile); + inventoryFullSoundPlayed = true; + end + end + + -- Continue opening mail (we still want to open gold mail) + continue = true; + elseif errorMessage == ERR_ITEM_MAX_COUNT or errorMessage == ERR_MAIL_DATABASE_ERROR then + -- Can't carry more of this item OR mail database error + + -- Continue opening mail (we still want to retrieve other items or gold) + continue = true; + end +end + +function OpenAll:Open(forced) + self:Debug("Open"); + + if not opening or forced == true then + local numItems, totalItems = GetInboxNumItems(); + -- Start at the end, add one because OpenNext will take it away again + local newMailItemIndex = ( ( numItems or 0 ) + 1 ); + + if newMailItemIndex > 1 then + self:Debug("Open succes"); + + -- Stop the previous opening and restart + if forced == true then + self:StopOpening(false); -- this is not a "simple" stop, so also reset inventory full warning + else + self:StopOpening(true); -- forced is false - automated action - simple reset, skip inventory full reset to avoid sound spam + end + + -- Update the caret + MAIL_ITEM_INDEX = newMailItemIndex; + + -- We're now going to be busy again + self:SetOpeningStatus(true); + + -- Open the next mail in line + self:OpenNext(); + else + if MailOpener.db.profile.notifications.mailboxIsEmpty then + print("|cffff0000There is currently no mail available.|r"); + end + + self:Debug("MO_OPEN_COMPLETE"); + + -- Report that we're all done + self:SendMessage("MO_OPEN_COMPLETE"); + end + end +end + +-- Return the type of mail a message subject is +local knownAHSubjectPatterns = { + canceled = AUCTION_REMOVED_MAIL_SUBJECT:replace("%s", ""), + expired = AUCTION_EXPIRED_MAIL_SUBJECT:replace("%s", ""), + outbid = AUCTION_OUTBID_MAIL_SUBJECT:replace("%s", ""), + success = AUCTION_SOLD_MAIL_SUBJECT:replace("%s", ""), + won = AUCTION_WON_MAIL_SUBJECT:replace("%s", ""), +}; +function OpenAll:GetAuctionMailType(subject) + if subject then + -- Check if any of our patterns match, sorted by most likely matches first (if one is true the rest shouldn't be evaluated) + if subject:find(knownAHSubjectPatterns.expired) then + return "expired"; + elseif subject:find(knownAHSubjectPatterns.success) then + return "success"; + elseif subject:find(knownAHSubjectPatterns.won) then + return "won"; + elseif subject:find(knownAHSubjectPatterns.canceled) then + return "canceled"; + elseif subject:find(knownAHSubjectPatterns.outbid) then + return "outbid"; + end + end + + return; -- not auction mail +end + +function OpenAll:OpenMail(index) + if index > 0 then + -- LUA arrays start at 1, so mail with index 0 doesn't exist, so we're finished + + local sender, subject, gold, cod, _, items, _, _, _, _, isGM = select(3, GetInboxHeaderInfo(index)); + local auctionMailType = self:GetAuctionMailType(subject); + + if isGM then + -- GM Mail + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.GMMail then + print("Skipping " .. index .. ": " .. subject .. " (GM mail)"); + end + + self:OpenNext(); + + return; + elseif cod and cod > 0 then + -- Cost on delivery + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.COD then + print("Skipping " .. index .. ": " .. subject .. " (C.O.D.)"); + end + + self:OpenNext(); + + return; + elseif ((gold and gold > 0) or (items and items > 0)) then + -- Mail with some sort of attachments + + local slotsAvailable = 0; + if self.db.profile.keepFreeSpace > 0 then + for bag = 0, 4 do + local numberOfFreeSlots = GetContainerNumFreeSlots(bag); + slotsAvailable = ( slotsAvailable + numberOfFreeSlots ); + end + end + + if inventoryFull and not MailOpener.db.profile.general.continueOpeningStackableItems and items and items > 0 then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.inventoryFull then + print("Skipping " .. index .. ": " .. subject .. " (inventory is full)"); + end + + self:OpenNext(); + + return; + elseif self.db.profile.keepFreeSpace > 0 and items and ( slotsAvailable - items ) < self.db.profile.keepFreeSpace then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.keepFreeSpaceLimit then + print("Skipping " .. index .. ": " .. subject .. " (keep free space limit)"); + end + + self:OpenNext(); + + return; + else + -- This string will hold the mailtype, MailOpener.db.profile.notifications.skipped/processed[mailType] will be checked if this should be announced + local mailType = "other"; + + if not auctionMailType then + -- This is a normal mail + + if gold and gold > 0 then + mailType = "normalGoldMail"; + elseif items and items > 0 then + mailType = "normalItemsMail"; + end + else + -- This is an auction house mail + + mailType = "AH" .. auctionMailType; + end + + if not self.db.profile.filter.normalMoney and mailType == "normalGoldMail" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (normal mail with gold)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.normalAttachments and mailType == "normalItemsMail" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (normal mail with attachments)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.AH.expired and mailType == "AHexpired" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (expired auction)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.AH.success and mailType == "AHsuccess" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (successful auction)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.AH.won and mailType == "AHwon" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (auction won)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.AH.canceled and mailType == "AHcanceled" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (canceled auction)"); + end + + self:OpenNext(); + + return; + elseif not self.db.profile.filter.AH.outbid and mailType == "AHoutbid" then + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped[mailType] then + print("Skipping " .. index .. ": " .. subject .. " (outbid on auction)"); + end + + self:OpenNext(); + + return; + else + continue = false; + + -- Open current mail + AutoLootMailItem(index); + + if MailOpener.db.profile.notifications.processed.all and MailOpener.db.profile.notifications.processed[mailType] then + if gold and gold > 0 then + print("Processing " .. index .. ": " .. subject .. " (" .. MailOpener:FormatMoney(gold) .. ")"); + else + print("Processing " .. index .. ": " .. subject); + end + end + + -- And prepare for the next + self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); + end + end + else + -- Unknown, probably just text + if MailOpener.db.profile.notifications.skipped.all and MailOpener.db.profile.notifications.skipped.other then + if subject then + print("Skipping " .. index .. ": " .. subject); + else + print("Skipping " .. index); + end + end + + self:OpenNext(); + end + else + -- Finished! + if MailOpener.db.profile.notifications.finishedCurrentBatch then + print("Finished opening the current batch."); + end + + self:SetOpeningStatus(false); + + self:Debug("MO_OPEN_COMPLETE"); + + -- Report that we're all done + self:SendMessage("MO_OPEN_COMPLETE"); + end +end + +function OpenAll:OpenNext() + if continue then + -- If the previous mail was opened successful, open the next + + -- Next mail in line + MAIL_ITEM_INDEX = ( MAIL_ITEM_INDEX - 1 ); + + -- Open it + self:OpenMail(MAIL_ITEM_INDEX); + else + -- Try again at the next interval + + self.tmrMailOpener = self:ScheduleTimer("OpenNext", self.db.profile.speed); + end +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)"; + seconds = "|cffffffff%d|r/|cffffffff%d|r mail remaining, opening everything will take about |cffffffff%d|r seconds (next refresh in |cffffffff%d|r seconds)"; + waitingBatch = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for something from the current batch to be opened..."; + waitingSync = "|cffffffff%d|r/|cffffffff%d|r mail remaining - waiting for the next mailbox refresh..."; + soon = "|cffffffff%d|r/|cffffffff%d|r mail remaining - everything will be opened soon..."; +}; + +function OpenAll:UpdateTimer() + if lastSync then + -- Calculate the total amount of mail waiting + local numTotalMail = ( numHiddenMail + numCurrentMail ); + + -- Resize the font based on mail left so the counter always fits perfectly + if numTotalMail < 100 then + self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 30, "THICKOUTLINE"); + elseif numTotalMail < 1000 then + self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 24, "THICKOUTLINE"); + else + self.timeLeftFrame.text:SetFont(GameFontHighlight:GetFont(), 18, "THICKOUTLINE"); + end + self.timeLeftFrame.text:SetText(numTotalMail); + + if numHiddenMail > 0 then + -- Calculate the next server sync based on the last server sync plus sync interval + local nextSync = ( lastSync + 61 ); + + -- Calculate the timer remaining untill the next sync + local timeRemaining = floor( nextSync - GetTime() ); + -- If the next sync was already due, our nextSync calculation was wrong and we must wait a little longer (lag?) + local syncTimeOut = false; + -- If time remaining is below 0, next sync should be soon + if timeRemaining < 0 then + timeRemaining = 0; + syncTimeOut = true; + end + + -- Calculate the amount of server syncs required to open all mail + local syncsRequired = ceil( numHiddenMail / 50 ); + -- Calculate the time required to execute all these syncs + local timeRequired = ( ( syncsRequired - 1 ) * 61 ) + timeRemaining; + + local minutes = floor( timeRequired / 60 ); + local seconds = floor( timeRequired % 60 ); + + local remainingText; + if syncTimeOut then + if numCurrentMail == 50 then + remainingText = format(mailRemainingPatterns.waitingBatch, numCurrentMail, numTotalMail); + else + remainingText = format(mailRemainingPatterns.waitingSync, numCurrentMail, numTotalMail); + end + elseif minutes ~= 0 then + if seconds ~= 0 then + remainingText = format(mailRemainingPatterns.minutesSeconds, numCurrentMail, numTotalMail, minutes, seconds, timeRemaining); + else + remainingText = format(mailRemainingPatterns.minutes, numCurrentMail, numTotalMail, minutes, timeRemaining); + end + elseif seconds ~= 0 then + remainingText = format(mailRemainingPatterns.seconds, numCurrentMail, numTotalMail, seconds, timeRemaining); + else + remainingText = format(mailRemainingPatterns.soon, numCurrentMail, numTotalMail); + end + + self.timeLeftFrame.smallText:SetText(remainingText); + elseif numHiddenMail == 0 then + self.timeLeftFrame.smallText:SetText(""); + end + end +end + +function OpenAll:StopOpening(simple) + if not simple then + -- 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 + continue = true; + self:SetOpeningStatus(false); +end + +function OpenAll:SetOpeningStatus(openingStatus) + opening = openingStatus; + + if openingStatus then + self.btnOpenAll:SetText("Opening..."); + else + self.btnOpenAll:SetText("Open all"); + end +end + +function OpenAll:GetOptionsGroup() + local configGroup = { + order = 300, + type = "group", + name = "Open All", + desc = "Change open all settings.", + args = { + filters = { + order = 10, + type = "group", + inline = true, + name = "Filters", + args = { + description = { + order = 10, + type = "description", + name = "Toggle which mail the opener should autoloot.", + }, + AHHeader = { + order = 15, + type = "header", + name = "Auction House Mail", + }, + canceled = { + order = 20, + type = "toggle", + name = "Open all |cfffed000auction canceled|r mail", + desc = "Automatically loot all auction canceled mails from the auction house.", + set = function(i, v) self.db.profile.filter.AH.canceled = v; end, + get = function() return self.db.profile.filter.AH.canceled; end, + width = "double", + }, + expired = { + order = 21, + type = "toggle", + name = "Open all |cfffed000auction expired|r mail", + desc = "Automatically loot all auction canceled mails from the auction house.", + set = function(i, v) self.db.profile.filter.AH.expired = v; end, + get = function() return self.db.profile.filter.AH.expired; end, + width = "double", + }, + outbid = { + order = 22, + type = "toggle", + name = "Open all |cfffed000outbid on|r mail", + desc = "Automatically loot all auction outbid mails from the auction house.", + set = function(i, v) self.db.profile.filter.AH.outbid = v; end, + get = function() return self.db.profile.filter.AH.outbid; end, + width = "double", + }, + success = { + order = 23, + type = "toggle", + name = "Open all |cfffed000auction successful|r mail", + desc = "Automatically loot all auction successful mails from the auction house.", + set = function(i, v) self.db.profile.filter.AH.success = v; end, + get = function() return self.db.profile.filter.AH.success; end, + width = "double", + }, + won = { + order = 24, + type = "toggle", + name = "Open all |cfffed000auction won|r mail", + desc = "Automatically loot all auction won mails from the auction house.", + set = function(i, v) self.db.profile.filter.AH.won = v; end, + get = function() return self.db.profile.filter.AH.won; end, + width = "double", + }, + normalHeader = { + order = 30, + type = "header", + name = "Remaining Mail", + }, + normalAttachments = { + order = 40, + type = "toggle", + name = "Other mail with |cfffed000attachments|r", + desc = "Automatically loot all mails with attachments not sent by any of the above sources.", + set = function(i, v) self.db.profile.filter.normalAttachments = v; end, + get = function() return self.db.profile.filter.normalAttachments; end, + width = "double", + }, + normalMoney = { + order = 50, + type = "toggle", + name = "Other mail with |cfffed000gold|r", + desc = "Automatically loot all mails with gold not sent by any of the above sources.", + set = function(i, v) self.db.profile.filter.normalMoney = v; end, + get = function() return self.db.profile.filter.normalMoney; end, + width = "double", + }, + }, + }, + -- Continuous opening config inline group + continuousOpening = { + order = 20, + type = "group", + inline = true, + name = "Opening Interval", + args = { + description = { + order = 10, + type = "description", + name = function() + local defaultString = "The default behaviour for opening mail is to only do so right after new mail was received from the server. If you close the mailbox or your inventory is full before everything is opened you will have to click the open all button manually or wait for a next mailbox refresh.\n\n"; + + local currentSettings = ""; + if MailOpener.db.profile.general.continueOpening then + currentSettings = currentSettings .. "Mail Opener will |cff00ff00continue|r to attempt to open the remaining mail every |cfffed000" .. MailOpener.db.profile.general.waitTime .. " seconds|r. "; + else + currentSettings = currentSettings .. "Mail Opener will |cffff0000not|r continue to attempt to open the remaining mail and will only start opening when new mail has just been received from the server. "; + end + currentSettings = currentSettings .. "The first batch after each server refresh will be opened after waiting |cfffed000" .. MailOpener.db.profile.general.initialDelay .. " seconds|r."; + return defaultString .. currentSettings; + end, + }, + header = { + order = 15, + type = "header", + name = "", + }, + continueOpening = { + order = 20, + type = "toggle", + name = "Continue opening mail", + desc = "Continue opening mail at the interval set below, even if the mailbox wasn't refreshed recently.", + width = "full", + get = function() return MailOpener.db.profile.general.continueOpening; end, + set = function(i, v) MailOpener.db.profile.general.continueOpening = v; end, + }, + waitTime = { + order = 30, + type = "range", + width = "double", + min = 0.5, + max = 60, + step = 0.5, + name = "Continued Mail Opening Interval", + desc = "Change the interval at which Mail Opener tries to continue opening mail after opening the mailbox. Please note that this setting does not reduce the game's normal 60 seconds wait time for mail.\n\nThe default value is 5 seconds", + get = function() return MailOpener.db.profile.general.waitTime; end, + set = function(i, v) MailOpener.db.profile.general.waitTime = v; end, + disabled = function() return (not MailOpener.db.profile.general.continueOpening); end, + }, + initialDelay = { + order = 40, + type = "range", + width = "double", + min = 0.5, + max = 60, + step = 0.5, + name = "Initial Mail Opening Delay", + desc = "Change the delay before Mail Opener tries opening mail after opening the mailbox or new mail has been received from the server.\n\nThe default value is 0.5 seconds.", + get = function() return MailOpener.db.profile.general.initialDelay; end, + set = function(i, v) MailOpener.db.profile.general.initialDelay = v; end, + }, + }, + }, -- end Continuous opening config inline group + keepFree = { + order = 30, + type = "group", + inline = true, + name = "Keep Free Space", + args = { + description = { + order = 10, + type = "description", + name = "You can set an amount of bag space you wish to reserve when opening mail. Mail with a higher amount of attachments than available space will be skipped completely with this option set above 0.", + }, + header = { + order = 15, + type = "header", + name = "", + }, + keepFreeSpace = { + order = 20, + type = "range", + min = 0, + max = 100, + step = 1, + width = "double", + name = "Keep free space", + desc = "Change the amount of space to reserve for other things when opening mail. If this option is set higher than 0, mail with a higher amount of attachments than available space will be skipped completely.\n\nE.g. If this is set to 1 and you have a total of 12 slots left then any mail with 12 attachments will be skipped while one with 11 attachments would be opened.", + set = function(i, v) self.db.profile.keepFreeSpace = v; end, + get = function() return self.db.profile.keepFreeSpace; end, + }, + }, + }, + speed = { + order = 40, + type = "group", + inline = true, + name = "Opening Speed", + args = { + description = { + order = 10, + type = "description", + name = "Change the speed at which mail is opened. You should set the opening speed to the lowest latency you have in a city or experiment with setting it to the minimum.", + }, + header = { + order = 15, + type = "header", + name = "", + }, + openMailInterval = { + order = 20, + type = "range", + min = 5, + max = 2500, + step = 5, + width = "double", + name = "Open single mail interval", + desc = "Change the mail opening speed (in microseconds) for each mail. Lower may not always be faster.", + get = function() return ( self.db.profile.speed * 1000 ); end, + set = function(i, v) self.db.profile.speed = ( v / 1000 ); end, + }, + }, + }, + }, + }; + + return configGroup; +end + +function OpenAll:Debug(t) + return MailOpener:Debug("|cff00ff00OpenAll|r:" .. t); +end \ No newline at end of file
