Mercurial > wow > buffalo2
diff Templates.lua @ 109:26938ae258b7
- Re-use the basic addon table for core mixin
- add /rl command
author | Nick@Zahhak |
---|---|
date | Mon, 06 Mar 2017 02:30:22 -0500 |
parents | a41f6b74709a |
children | 8c94bee4fdfc |
line wrap: on
line diff
--- a/Templates.lua Sat Feb 25 11:42:07 2017 -0500 +++ b/Templates.lua Mon Mar 06 02:30:22 2017 -0500 @@ -4,18 +4,26 @@ -- %file-revision% -- -- Mover Widget base +local ADDON, Veneer = ... local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop -local debugTemplates = {} +local PlaySoundKitID = DEVIAN_WORKSPACE and PlaySoundKitID or nop +local ipairs, pairs = ipairs, pairs +local pack, unpack = pack, unpack -VeneerConfigLayerMixin = {} -VeneerAnimationMixin = {} -VeneerHandlerMixin = { - anchorPoint = 'CENTER', - anchorPriority = 4, - data = {}, -} +local Handler, ConfigLayer, Animation = {}, {}, {} -function VeneerConfigLayerMixin:OnLoad() +VeneerConfigLayerMixin = ConfigLayer +VeneerAnimationMixin = Animation +VeneerHandlerMixin = Handler +Handler.anchorPoint = 'CENTER' +Handler.anchorPriority = 4 +Handler.data = {} +Veneer.HandlerBase = Handler +Veneer.ConfigLayerBase = ConfigLayer +Veneer.AnimationBase = Animation + + +function ConfigLayer:OnLoad() local handler = self:GetParent() print(handler:GetName(), 'configLayers') handler.ConfigLayers = handler.ConfigLayers or {} @@ -24,7 +32,7 @@ end end -function VeneerConfigLayerMixin:OnUpdate() +function ConfigLayer:OnUpdate() local handler = self:GetParent() handler.ConfigLayers = handler.ConfigLayers or {} @@ -32,37 +40,40 @@ self.ConfigID:SetText(handler:GetID()) end -function VeneerAnimationMixin:OnPlay() +-- Sets a state flag for use in OnUpdate conditionals +function Animation:OnPlay() PlaySoundKitID(229) self.animating = true print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint)) end -function VeneerAnimationMixin:OnStop() +function Animation:OnStop() PlaySoundKitID(229) self.animating = nil print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) end -function VeneerAnimationMixin:OnFinished() +function Animation:OnFinished() PlaySoundKitID(229) self.animating = nil print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) end -function VeneerHandlerMixin:OnShow() +-- Replace if module requires anything besides fixing frame anchors +function Handler:OnShow() self:Reanchor() Veneer:StaticReanchor(self) end -function VeneerHandlerMixin:OnHide() +function Handler:OnHide() Veneer:DynamicReanchor() end -function VeneerHandlerMixin:Reanchor (anchorAll) +function Handler:Reanchor (anchorAll) Veneer:DynamicReanchor() end -function VeneerHandlerMixin:Setup() + +-- Replace if module needs to do more than reconcile SavedVariables pointers +function Handler:Setup() local configName = self:GetName():gsub('^Veneer', '') VeneerData[configName] = VeneerData[configName] or self.defaultSettings or {} - -- reconcile any data accumulated before login trigger for k,v in pairs(self.data) do if not VeneerData[configName][k] then print('reconciling pre-data:', k, v) @@ -77,18 +88,17 @@ self.initialized = true end -function VeneerHandlerMixin:Print(...) +-- Replace to stop collated outputs. +function Handler:Print(...) local txt = '|cFFFFFF00'..self:GetName()..'|r:' for i = 1, select('#', ...) do txt = txt .. ' '.. tostring(select(i, ...)) end - - - DEFAULT_CHAT_FRAME:AddMessage(txt) end -function VeneerHandlerMixin:UpdateConfigLayers (configMode) +-- Replace if not using the ConfigLayer template +function Handler:UpdateConfigLayers (configMode) -- Override to manage config visual elements when a config update is fired from /vn or login if not self:IsShown() then self:SetShown(configMode)