Mercurial > wow > dependencyloader
diff DependencyLoader/Addon.lua @ 15:a46bf694050c
cleaned up Tree's methods a bit and improved documentation
Addon:Exists will now return false for Blizzard addons (needs to be handled better)
Addon.lua will now use the raw hooks from the interface module
fixed the inverted returns from IsForceLoadAvailable
EnableAddOn and LoadAddOn hooks will now skip the extra processing if the addon does not exist or is a Blizzard addon
moved the EnableAddOn queing to the interface
author | mckenziemc |
---|---|
date | Sat, 11 Dec 2010 01:48:39 -0800 |
parents | b230b94d4487 |
children | f825ccf94a89 |
line wrap: on
line diff
--- a/DependencyLoader/Addon.lua Fri Dec 10 05:29:22 2010 -0800 +++ b/DependencyLoader/Addon.lua Sat Dec 11 01:48:39 2010 -0800 @@ -10,14 +10,11 @@ local Addon, addon = addonTable:NewClass("Addon") -Addon.enableAddon = EnableAddOn -- TODO: use raw hook from main module? - Addon.addons = {} Addon.nameToIndex = {} --- Internal function --- Creates a new Addon object +--- (private) Creates a new Addon object -- @param id Name or index of the addon. function Addon:New(id) local instance = {} @@ -55,6 +52,8 @@ -- @param id Name or index of the addon to retrieve. -- @return The Addon object, or nil if not found. function Addon:Get(id) + assert(id) + if not self:Exists(id) then return nil end @@ -94,6 +93,10 @@ return false end elseif type(addon) == "string" then + if addon:match("Blizzard_") then + return false + end + local status = select(6, GetAddOnInfo(addon)) if status == "MISSING" then @@ -102,7 +105,8 @@ return true end else - error() + local message = string.format("Unexpected argument type: \"%s\", value: %s", type(addon), addon or "nil") + error(message) end end @@ -129,6 +133,15 @@ end +function addon:IsLoaded() + if IsAddOnLoaded(self.index) then + return true + else + return false + end +end + + --- Checks if the addon is loadable. -- Considers interface issues, missing, etc. (NYI) -- Does not check dependencies. @@ -148,12 +161,14 @@ end +-- can this addon be force-loaded after the point where the client would enable it? function addon:CanForceLoadAfter() -- TODO: check Errata module return false end +-- can this addon be force-loaded before the point where the client would enable it? function addon:CanForceLoadBefore() -- TODO: check Errata module return false -- TODO: check if there's any reason addons can't be forceloaded @@ -162,13 +177,17 @@ function addon:CanForceLoad() -- FIXME: check if this would've already been loaded - return self:CanForceLoadAfter() + return self:CanForceLoadAfter() or self:CanLoD() + -- FIXME: should CanLoD() be in here? end function addon:Enable() - -- FIXME: delay this till after PLAYER_LOGIN or it'll get force-loaded - Addon.enableAddon(self.name) + if IsLoggedIn() then + addonTable.interface:QueueEnable(self.name) + else + addonTable.interface:RawEnableAddOn(self.name) + end end @@ -176,8 +195,8 @@ function addon:Load() assert(self:CanLoD()) - EnableAddOn(self.name) - LoadAddOn(self.name) + addonTable.interface:RawEnableAddOn(self.name) + addonTable.interface:RawLoadAddOn(self.name) end @@ -185,7 +204,7 @@ assert(self:CanForceLoad()) -- TODO: make sure force-loading is available at this time - EnableAddOn(self.name) -- This should cause the game to also load this addon + addonTable.interface:RawEnableAddOn(self.name) -- This should cause the game to also load this addon end @@ -208,11 +227,3 @@ return unpack(embeds) end - -function addon:IsLoaded() - if IsAddOnLoaded(self.index) then - return true - else - return false - end -end