comparison DependencyLoader/Addon.lua @ 10:e0a4a8b5b389

lots more modifications...
author mckenziemc
date Sun, 05 Dec 2010 03:10:07 -0800
parents 5362e308c3eb
children b230b94d4487
comparison
equal deleted inserted replaced
9:5362e308c3eb 10:e0a4a8b5b389
1 -- Addon 1 -- Addon
2 -- Represents individual addon modules 2 -- Represents individual addon modules.
3 3
4 4
5 local addonName, addonTable = ... 5 local addonName, addonTable = ...
6 6
7 7
8 -- NOTE: I assume that the API addon functions are 8 -- TODO: test if the API functions are quicker with indexes than names.
9 -- slightly quicker with an index than with a number. 9 -- TODO: modify the dependency stuff to check the Errata module.
10
11 -- TODO: modify the dependency stuff to use the Errata module if available
12 10
13 local Addon, addon = addonTable:NewClass("Addon") 11 local Addon, addon = addonTable:NewClass("Addon")
14
15
16 -- load ability masks
17 Addon.loadMasks = {
18 reload = bit.lshift(1, 0), -- can load after reloadui
19 ondemand = bit.lshift(1, 1), -- can load on demand
20 forceafter = bit.lshift(1, 2), -- force load after it would normally be loaded
21 forcebefore = bit.lshift(1, 3), -- force load before it would normally be loaded
22 }
23 12
24 13
25 Addon.addons = {} 14 Addon.addons = {}
26 Addon.nameToIndex = {} 15 Addon.nameToIndex = {}
27 16
88 self.nameToIndex[id] = new:GetIndex() 77 self.nameToIndex[id] = new:GetIndex()
89 78
90 return new 79 return new
91 end 80 end
92 end 81 end
82
93 83
94 -- Checks if an addon exists with the specified name. 84 -- Checks if an addon exists with the specified name.
95 -- @param addon Name of the addon. 85 -- @param addon Name of the addon.
96 -- @return True if the addon is present, false otherwise. 86 -- @return True if the addon is present, false otherwise.
97 function Addon:Exists(addon) 87 function Addon:Exists(addon)
113 error() 103 error()
114 end 104 end
115 end 105 end
116 106
117 107
118 function Addon:GetLoadMasks()
119 return self.masks
120 end
121
122
123 function addon:GetName() 108 function addon:GetName()
124 return self.name 109 return self.name
125 end 110 end
126 111
127 112
137 if status == "DISABLED" then 122 if status == "DISABLED" then
138 return false 123 return false
139 else 124 else
140 return true 125 return true
141 end 126 end
142 end
143
144
145 function addon:GetLoadBitfield()
146 local bitfield = 0
147
148 if self:CanLoad() then
149 bitfield = bitfield + self.masks.reload
150 end
151
152 if self:CanLoD() then
153 bitfield = bitfield + self.masks.ondemand
154 end
155
156 if self:CanForceLoadAfter() then
157 bitfield = bitfield + self.masks.forceafter
158 end
159
160 if self:CanForceLoadBefore() then
161 bitfield = bitfield + self.masks.forcebefore
162 end
163
164 return bitfield
165 end 127 end
166 128
167 129
168 --- Checks if the addon is loadable. 130 --- Checks if the addon is loadable.
169 -- Considers interface issues, missing, etc. (NYI) 131 -- Considers interface issues, missing, etc. (NYI)
194 -- TODO: check Errata module 156 -- TODO: check Errata module
195 return false -- TODO: check if there's any reason addons can't be forceloaded 157 return false -- TODO: check if there's any reason addons can't be forceloaded
196 end 158 end
197 159
198 160
161 function addon:CanForceLoad()
162 -- FIXME: check if this would've already been loaded
163 return self:CanForceLoadAfter()
164 end
165
166
199 function addon:Enable() 167 function addon:Enable()
200 -- FIXME: delay this till after PLAYER_LOGIN or it'll get force-loaded 168 -- FIXME: delay this till after PLAYER_LOGIN or it'll get force-loaded
201 EnableAddOn(self.name) 169 EnableAddOn(self.name)
202 end 170 end
203 171