Mercurial > wow > buffalo2
diff 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 |
line wrap: on
line diff
--- a/Veneer.lua Mon Mar 27 00:39:29 2017 -0400 +++ b/Veneer.lua Tue Mar 28 07:02:26 2017 -0400 @@ -24,6 +24,7 @@ Veneer:UpdateConfigLayers() end +Veneer.modules = {} Veneer.Frames = {} Veneer.ConfigLayers = {} Veneer.FrameClusters = { @@ -94,6 +95,8 @@ print('|cFFFFFF00Veneer!|r') self:RegisterEvent('ADDON_LOADED') self:RegisterEvent('PLAYER_LOGIN') + self:RegisterEvent('PLAYER_REGEN_ENABLED') + self:RegisterEvent('PLAYER_REGEN_DISABLED') self.DEVIAN_PNAME = 'Veneer' self:RegisterForDrag('LeftButton') @@ -133,6 +136,19 @@ end end end + elseif event == 'PLAYER_REGEN_ENABLED' then + for _, module in pairs(self.modules) do + if module:IsShown() and module.hideCombat then + module:Hide() + end + end + + elseif event == 'PLAYER_REGEN_DISABLED' then + for _, module in pairs(self.modules) do + if module:IsShown() and module.hideCombat then + module:Show() + end + end end end @@ -211,83 +227,55 @@ end -- args: frame object, list of anchor groups, true for forced top, number for priority layer +local mixins = {} function Veneer:AddHandler(handler, ...) - print('|cFFFFFF00*** Adding handler:', handler.moduleName or handler:GetName()) + print('|cFFFFFF00'..handler:GetName()..':|r', handler.moduleName, ...) - + wipe(mixins) for k,v in pairs(VeneerHandlerMixin) do if not handler[k] then - print(' * from mixin:', k) + tinsert(mixins, k) handler[k] = v end end + if #mixins >= 1 then + print('* Mixins:|cFF00FF88', table.concat(mixins, ', ')) + end + + self.modules[handler] = handler if not handler.anchorFrame then - local primaryAnchor + local primaryAnchor = handler.anchorPoint or 'CENTER' + local clusterPriority = handler.anchorPriority + self.FrameClusters[primaryAnchor] = self.FrameClusters[primaryAnchor] or {} + local clusterTable = self.FrameClusters[primaryAnchor] local clusterIndex - local clusterPriority = handler.anchorPriority - local clusterDepth = 0 - - local clusterTable = self.FrameClusters - for i = 1, select('#', ...) do - local arg = select(i, ...) - local argType = type(arg) - if argType == 'string' then - - if not primaryAnchor then - primaryAnchor = arg - end - clusterDepth = clusterDepth + 1 - clusterTable[arg] = clusterTable[arg] or {} - clusterTable = clusterTable[arg] - print('clusterGroup =', clusterDepth ..'.'.. arg) - elseif argType == 'boolean' then - if arg == true then - print('anchorFirst =', arg) - clusterPriority = nil - end - elseif argType == 'number' then - if arg ~= clusterPriority then - print('anchorPriority =', arg) - clusterPriority = arg - end - - end - end if clusterPriority then for i = 1, #clusterTable do - clusterIndex = i + if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > clusterPriority) then + clusterIndex = i print('|cFF00BB00insert position:', clusterPriority, clusterIndex) break else - print('passing lower priority frame:', clusterTable[i]:GetName()) + print('pass', clusterTable[i]) + clusterIndex = i+1 end end else print('|cFF00BB00inserting at front') - clusterIndex = 1 + clusterIndex = #clusterTable + 1 end - - if not primaryAnchor then - primaryAnchor = 'CENTER' - clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} - clusterTable = clusterTable[primaryAnchor] - end - - if not clusterPriority then - clusterIndex = #clusterTable + 1 - end if not clusterIndex then clusterIndex = #clusterTable + 1 end tinsert(clusterTable, clusterIndex, handler) - print(' cluster', primaryAnchor, 'table', clusterTable, 'priority', clusterPriority, 'position', clusterIndex) + print(' cluster', (clusterDepth or 1) .. '.' .. primaryAnchor, clusterTable, 'priority', clusterPriority, 'position', clusterIndex) handler.anchorCluster = clusterTable handler.anchorIndex = clusterIndex @@ -305,6 +293,7 @@ tinsert(self.AddOnCheck[handler.addonTrigger], handler) end + if self.initialized then print(' -- initialization check') if handler.Setup then @@ -450,7 +439,7 @@ end - +-- execute a function on all clusters in display order function Veneer:ExecuteOnClusters(layer, method) local print = eprint self.parserDepth = self.parserDepth + 1