Mercurial > wow > mailopener
diff Core.lua @ 31:90d58723ac0a
- Removed all BeanCounter checks in files.
+ Added a new module: BeanCounter Support. This module will now take care of preventing mail opening while BeanCounter is scanning.
+ Added AceHook library for the BeanCounter Support module.
~ Sorted the Core.lua OnInitialize to properly toggle modules before doing time consuming things.
~ All module comments are now a property of the modules themselves and can be retrieved with (string)?.moduleDescription? and (bool)?.moduleRequired?.
~ All module references are now called ?mod?.
! Added a new config group: Modules. This group will show the module statuses and descriptions and it will contain all optional modules (with their settings) as subgroups.
- Removed all libraries from the repository.
| author | Zerotorescue |
|---|---|
| date | Fri, 10 Sep 2010 18:59:58 +0200 |
| parents | d52e64bd048f |
| children | 8168280420ae |
line wrap: on
line diff
--- a/Core.lua Thu Sep 09 22:16:50 2010 +0200 +++ b/Core.lua Fri Sep 10 18:59:58 2010 +0200 @@ -8,6 +8,13 @@ local AutoOpenMail, MailOpenerConfig, lastAmount, lastQuickAuctionsStatus, freshList, mailboxEmptySoundPlayed; function MailOpener:OnInitialize() + self:Debug("OnInitialize"); + + + + + -- SAVED VARIABLES + local defaults = { profile = { uses = 0, @@ -23,6 +30,8 @@ initialDelay = 0.5, }, modules = { + BeanCounterSupport = true, + Config = false, Collected = true, FailSafe = true, }, @@ -74,30 +83,15 @@ -- Register our saved variables database self.db = LibStub("AceDB-3.0"):New("MailOpenerDB", defaults, true); - -- Set these as object variables so we can use them in our modules - if select(6, GetAddOnInfo("Postal")) == nil then - self.PostalEnabled = true; - - -- Ensure this addon is loaded if AddonLoader is installed - if AddonLoader and AddonLoader.LoadAddOn and not Postal then - AddonLoader:LoadAddOn("Postal"); - end - end - if select(6, GetAddOnInfo("QuickAuctions")) == nil then - self.QuickAuctionsEnabled = true; - - -- Ensure this addon is loaded if AddonLoader is installed - if AddonLoader and AddonLoader.LoadAddOn then - AddonLoader:LoadAddOn("QuickAuctions"); - end - end + + + + -- MODULE TOGGLING -- Don't enable the config module until we need it for name, module in self:IterateModules() do - if name == "Config" then - module:SetEnabledState(false); - elseif self.db.profile.modules[name] ~= nil then + if self.db.profile.modules[name] ~= nil then if self.db.profile.modules[name] then self:Debug("|cff00ff00Enabling|r module: " .. name); else @@ -108,6 +102,61 @@ end end + + + + + -- SLASH COMMANDS + + -- Disable the AddonLoader slash commands + SLASH_MO1 = nil; + SLASH_MAILOPEN1 = nil; + SLASH_MAILOPENER1 = nil; + + -- Register our own slash commands + SLASH_MAILOPENER1 = "/mo"; + SLASH_MAILOPENER2 = "/mailopen"; + SLASH_MAILOPENER3 = "/mailopener"; + SlashCmdList["MAILOPENER"] = function(msg) + MailOpener:EnableConfigModule(); + + MailOpenerConfig:CommandHandler(msg); + end + + + + + + -- INTERFACE OPTIONS + + -- Attempt to remove the interface options added by AddonLoader (if enabled) + if AddonLoader and AddonLoader.RemoveInterfaceOptions then + AddonLoader:RemoveInterfaceOptions("Mail Opener"); + end + + -- Now create our own options frame + local frame = CreateFrame("Frame", nil, UIParent); + frame:Hide(); + frame.name = "Mail Opener"; + frame:HookScript("OnShow", function(self) + -- Enable the config module + MailOpener:EnableConfigModule(); + + -- Load the options and add it to the blizzard interface list + MailOpenerConfig:Load(); + + -- Refresh the frame to instantly show the right options + InterfaceOptionsFrame_OpenToCategory(self.name) + end); + -- And add it to the interface options + InterfaceOptions_AddCategory(frame); + + + + + + -- ADDON / MAIL OPENING STATUS TOGGLER + -- Make the open all checkbox local check = CreateFrame("CheckButton", "cbMailOpenerEnable", MailFrame, "ChatConfigCheckButtonTemplate"); check:SetHeight(26); @@ -150,13 +199,7 @@ end end); check.tooltip = "Toggle automatic mail opening on or off (you can force this by holding shift when opening the mailbox.\n\nHold the |cffffffffSHIFT|r key to disable the entire addon."; - check:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 68, -13) - - if self.QuickAuctionsEnabled then - -- QA is enabled so move the checkbox further to the right - - check:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 155, -13); - end + check:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 68, -13); -- Get reference to the text field local checkboxText = _G[check:GetName() .. "Text"]; @@ -166,16 +209,17 @@ self.cbOpenAll = check; + + + + -- CONFIG BUTTON + -- Make the config button local button = CreateFrame("Button", "btnMailOpenerConfig", MailFrame, "UIPanelButtonTemplate") button:SetText("Config") button:SetHeight(23) button:SetWidth(55) - if self.PostalEnabled then - button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -75, -13); - else - button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -55, -13); - end + button:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -55, -13); button:SetScript("OnClick", function() MailOpener:EnableConfigModule(); @@ -187,43 +231,47 @@ end); self.btnConfig = button; - - -- Disable the AddonLoader slash commands - SLASH_MO1 = nil; - SLASH_MAILOPEN1 = nil; - SLASH_MAILOPENER1 = nil; - -- Register our own slash commands - SLASH_MAILOPENER1 = "/mo"; - SLASH_MAILOPENER2 = "/mailopen"; - SLASH_MAILOPENER3 = "/mailopener"; - SlashCmdList["MAILOPENER"] = function(msg) - MailOpener:EnableConfigModule(); + + + + + -- ADDON LOADING + -- THE BELOW WILL TAKE SOME TIME; WE WILL BE LOADING OTHER ADDONS + + if select(6, GetAddOnInfo("Postal")) == nil then + self.PostalEnabled = true; -- Set this as an object variable so we can use it in our modules - MailOpenerConfig:CommandHandler(msg); - end - - -- Attempt to remove the interface options added by AddonLoader (if enabled) - if AddonLoader and AddonLoader.RemoveInterfaceOptions then - AddonLoader:RemoveInterfaceOptions("Mail Opener"); + -- Ensure this addon is loaded if AddonLoader is installed + if AddonLoader and AddonLoader.LoadAddOn and not Postal then + AddonLoader:LoadAddOn("Postal"); + end end - -- Now create our own options frame - local frame = CreateFrame("Frame", nil, UIParent); - frame:Hide(); - frame.name = "Mail Opener"; - frame:HookScript("OnShow", function(self) - -- Enable the config module - MailOpener:EnableConfigModule(); + if select(6, GetAddOnInfo("QuickAuctions")) == nil then + self.QuickAuctionsEnabled = true; -- Set this as an object variable so we can use it in our modules - -- Load the options and add it to the blizzard interface list - MailOpenerConfig:Load(); + -- Ensure this addon is loaded if AddonLoader is installed + if AddonLoader and AddonLoader.LoadAddOn then + AddonLoader:LoadAddOn("QuickAuctions"); + end + end + + + + + + -- ADJUST POSITIONS + + if self.QuickAuctionsEnabled then + -- QA is enabled so move the checkbox further to the right - -- Refresh the frame to instantly show the right options - InterfaceOptionsFrame_OpenToCategory(self.name) - end); - -- And add it to the interface options - InterfaceOptions_AddCategory(frame); + self.cbOpenAll:SetPoint("TOPLEFT", MailFrame, "TOPLEFT", 155, -13); + end + + if self.PostalEnabled then + self.btnConfig:SetPoint("TOPRIGHT", MailFrame, "TOPRIGHT", -75, -13); + end end function MailOpener:OnEnable() @@ -455,9 +503,10 @@ self:Debug("OpenNow"); -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that - local BeanCounterActive = not InboxCloseButton:IsVisible(); + --local BeanCounterActive = not InboxCloseButton:IsVisible(); - if not BeanCounterActive and not MailAddonBusy then + --if not BeanCounterActive and not MailAddonBusy then + if not MailAddonBusy then -- No other addon is currently active self:CancelTimer(self.tmrTryAgain, true); -- Insurance @@ -483,7 +532,7 @@ self:SendMessage("MO_OPEN_MAIL"); else -- Another addon is ACTIVE - self:Debug("Another addon active, waiting .5 seconds..."); + self:Debug("Another addon active, waiting .5 seconds... (" .. MailAddonBusy .. ")"); self:CancelTimer(self.tmrTryAgain, true); -- Insurance -- Try again every 0.5 seconds @@ -556,9 +605,10 @@ -- If this isn't a fresh list (so messages weren't received within the last 60 seconds) and the mailbox wasn't closed -- BeanCounter is the only addon hiding the mail close button while busy, so we can look for that - local BeanCounterActive = not InboxCloseButton:IsVisible(); + --local BeanCounterActive = not InboxCloseButton:IsVisible(); - if not BeanCounterActive and AutoOpenMail and not MailAddonBusy then + --if not BeanCounterActive and AutoOpenMail and not MailAddonBusy then + if AutoOpenMail and not MailAddonBusy then -- Query the server CheckInbox(); end
