Mercurial > wow > buffalo2
comparison Veneer.lua @ 115:8c94bee4fdfc
- AddHandler simplified
- Centralized combat start/stop hooks
- WorldState removed
author | Nenue |
---|---|
date | Tue, 28 Mar 2017 07:02:26 -0400 |
parents | 2105b6e5095f |
children | 1f68c46bc4de |
comparison
equal
deleted
inserted
replaced
114:6748c98a6c6c | 115:8c94bee4fdfc |
---|---|
22 Veneer.ConfigMode = true | 22 Veneer.ConfigMode = true |
23 end | 23 end |
24 Veneer:UpdateConfigLayers() | 24 Veneer:UpdateConfigLayers() |
25 end | 25 end |
26 | 26 |
27 Veneer.modules = {} | |
27 Veneer.Frames = {} | 28 Veneer.Frames = {} |
28 Veneer.ConfigLayers = {} | 29 Veneer.ConfigLayers = {} |
29 Veneer.FrameClusters = { | 30 Veneer.FrameClusters = { |
30 [LE_FREE_FRAMES_GROUP] = {} | 31 [LE_FREE_FRAMES_GROUP] = {} |
31 } | 32 } |
92 | 93 |
93 function Veneer:OnLoad() | 94 function Veneer:OnLoad() |
94 print('|cFFFFFF00Veneer!|r') | 95 print('|cFFFFFF00Veneer!|r') |
95 self:RegisterEvent('ADDON_LOADED') | 96 self:RegisterEvent('ADDON_LOADED') |
96 self:RegisterEvent('PLAYER_LOGIN') | 97 self:RegisterEvent('PLAYER_LOGIN') |
98 self:RegisterEvent('PLAYER_REGEN_ENABLED') | |
99 self:RegisterEvent('PLAYER_REGEN_DISABLED') | |
97 | 100 |
98 self.DEVIAN_PNAME = 'Veneer' | 101 self.DEVIAN_PNAME = 'Veneer' |
99 self:RegisterForDrag('LeftButton') | 102 self:RegisterForDrag('LeftButton') |
100 | 103 |
101 | 104 |
131 if not keepChecking then | 134 if not keepChecking then |
132 self.AddOnCheck[addon] = nil | 135 self.AddOnCheck[addon] = nil |
133 end | 136 end |
134 end | 137 end |
135 end | 138 end |
139 elseif event == 'PLAYER_REGEN_ENABLED' then | |
140 for _, module in pairs(self.modules) do | |
141 if module:IsShown() and module.hideCombat then | |
142 module:Hide() | |
143 end | |
144 end | |
145 | |
146 elseif event == 'PLAYER_REGEN_DISABLED' then | |
147 for _, module in pairs(self.modules) do | |
148 if module:IsShown() and module.hideCombat then | |
149 module:Show() | |
150 end | |
151 end | |
136 end | 152 end |
137 end | 153 end |
138 | 154 |
139 function Veneer:OnDragStart() | 155 function Veneer:OnDragStart() |
140 self:StartMoving() | 156 self:StartMoving() |
209 function Veneer:GetClusterFromArgs (...) | 225 function Veneer:GetClusterFromArgs (...) |
210 return primaryAnchor, clusterTable, insertPosition | 226 return primaryAnchor, clusterTable, insertPosition |
211 end | 227 end |
212 | 228 |
213 -- args: frame object, list of anchor groups, true for forced top, number for priority layer | 229 -- args: frame object, list of anchor groups, true for forced top, number for priority layer |
230 local mixins = {} | |
214 function Veneer:AddHandler(handler, ...) | 231 function Veneer:AddHandler(handler, ...) |
215 print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName()) | 232 print('|cFFFFFF00'..handler:GetName()..':|r', handler.moduleName, ...) |
216 | 233 |
217 | 234 wipe(mixins) |
218 for k,v in pairs(VeneerHandlerMixin) do | 235 for k,v in pairs(VeneerHandlerMixin) do |
219 if not handler[k] then | 236 if not handler[k] then |
220 print(' * from mixin:', k) | 237 tinsert(mixins, k) |
221 handler[k] = v | 238 handler[k] = v |
222 end | 239 end |
223 end | 240 end |
241 if #mixins >= 1 then | |
242 print('* Mixins:|cFF00FF88', table.concat(mixins, ', ')) | |
243 end | |
244 | |
245 self.modules[handler] = handler | |
224 | 246 |
225 if not handler.anchorFrame then | 247 if not handler.anchorFrame then |
226 | 248 |
227 local primaryAnchor | 249 local primaryAnchor = handler.anchorPoint or 'CENTER' |
250 local clusterPriority = handler.anchorPriority | |
251 self.FrameClusters[primaryAnchor] = self.FrameClusters[primaryAnchor] or {} | |
252 local clusterTable = self.FrameClusters[primaryAnchor] | |
228 local clusterIndex | 253 local clusterIndex |
229 local clusterPriority = handler.anchorPriority | |
230 local clusterDepth = 0 | |
231 | |
232 local clusterTable = self.FrameClusters | |
233 for i = 1, select('#', ...) do | |
234 local arg = select(i, ...) | |
235 local argType = type(arg) | |
236 if argType == 'string' then | |
237 | |
238 if not primaryAnchor then | |
239 primaryAnchor = arg | |
240 end | |
241 clusterDepth = clusterDepth + 1 | |
242 clusterTable[arg] = clusterTable[arg] or {} | |
243 clusterTable = clusterTable[arg] | |
244 print('clusterGroup =', clusterDepth ..'.'.. arg) | |
245 elseif argType == 'boolean' then | |
246 if arg == true then | |
247 print('anchorFirst =', arg) | |
248 clusterPriority = nil | |
249 end | |
250 elseif argType == 'number' then | |
251 if arg ~= clusterPriority then | |
252 print('anchorPriority =', arg) | |
253 clusterPriority = arg | |
254 end | |
255 | |
256 end | |
257 end | |
258 | 254 |
259 if clusterPriority then | 255 if clusterPriority then |
260 for i = 1, #clusterTable do | 256 for i = 1, #clusterTable do |
261 clusterIndex = i | 257 |
262 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > clusterPriority) then | 258 if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > clusterPriority) then |
259 clusterIndex = i | |
263 print('|cFF00BB00insert position:', clusterPriority, clusterIndex) | 260 print('|cFF00BB00insert position:', clusterPriority, clusterIndex) |
264 break | 261 break |
265 else | 262 else |
266 print('passing lower priority frame:', clusterTable[i]:GetName()) | 263 print('pass', clusterTable[i]) |
264 clusterIndex = i+1 | |
267 end | 265 end |
268 end | 266 end |
269 else | 267 else |
270 print('|cFF00BB00inserting at front') | 268 print('|cFF00BB00inserting at front') |
271 clusterIndex = 1 | |
272 end | |
273 | |
274 | |
275 if not primaryAnchor then | |
276 primaryAnchor = 'CENTER' | |
277 clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} | |
278 clusterTable = clusterTable[primaryAnchor] | |
279 end | |
280 | |
281 if not clusterPriority then | |
282 clusterIndex = #clusterTable + 1 | 269 clusterIndex = #clusterTable + 1 |
283 end | 270 end |
271 | |
284 if not clusterIndex then | 272 if not clusterIndex then |
285 clusterIndex = #clusterTable + 1 | 273 clusterIndex = #clusterTable + 1 |
286 end | 274 end |
287 | 275 |
288 | 276 |
289 tinsert(clusterTable, clusterIndex, handler) | 277 tinsert(clusterTable, clusterIndex, handler) |
290 print(' cluster', primaryAnchor, 'table', clusterTable, 'priority', clusterPriority, 'position', clusterIndex) | 278 print(' cluster', (clusterDepth or 1) .. '.' .. primaryAnchor, clusterTable, 'priority', clusterPriority, 'position', clusterIndex) |
291 | 279 |
292 handler.anchorCluster = clusterTable | 280 handler.anchorCluster = clusterTable |
293 handler.anchorIndex = clusterIndex | 281 handler.anchorIndex = clusterIndex |
294 else | 282 else |
295 local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP] | 283 local clusterTable = self.FrameClusters[LE_FREE_FRAMES_GROUP] |
302 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then | 290 if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then |
303 print('|cFFFF4400 -- dependency:', handler.addonTrigger) | 291 print('|cFFFF4400 -- dependency:', handler.addonTrigger) |
304 self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {} | 292 self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {} |
305 tinsert(self.AddOnCheck[handler.addonTrigger], handler) | 293 tinsert(self.AddOnCheck[handler.addonTrigger], handler) |
306 end | 294 end |
295 | |
307 | 296 |
308 if self.initialized then | 297 if self.initialized then |
309 print(' -- initialization check') | 298 print(' -- initialization check') |
310 if handler.Setup then | 299 if handler.Setup then |
311 local doInit = (not handler.initialized) | 300 local doInit = (not handler.initialized) |
448 VeneerAnimationMixin.OnFinished(frame) | 437 VeneerAnimationMixin.OnFinished(frame) |
449 end) | 438 end) |
450 | 439 |
451 end | 440 end |
452 | 441 |
453 | 442 -- execute a function on all clusters in display order |
454 function Veneer:ExecuteOnClusters(layer, method) | 443 function Veneer:ExecuteOnClusters(layer, method) |
455 local print = eprint | 444 local print = eprint |
456 self.parserDepth = self.parserDepth + 1 | 445 self.parserDepth = self.parserDepth + 1 |
457 if not layer then | 446 if not layer then |
458 if self.parserDepth > 1 then | 447 if self.parserDepth > 1 then |