view Templates.lua @ 102:1e511e9aaca5

- clean up handler loading inconsistencies; exclude free frames from anchor cluster iterations, and remove extraneous PLAYER_LOGIN handling - added a Setup method to the handler template that creates and reconciles a SavedVariables table for that module
author Nenue
date Wed, 25 Jan 2017 23:11:27 -0500
parents 74d6d97a2d24
children 8df154a2bfd6
line wrap: on
line source
-- Veneer
-- Templates.lua
-- Created: 10/24/2016 9:16 AM
-- %file-revision%
--
-- Mover Widget base
local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop
local debugTemplates = {}

VeneerConfigLayerMixin = {}
VeneerAnimationMixin = {}
VeneerHandlerMixin = {
  anchorPoint = 'CENTER',
  data = {},
}

function VeneerConfigLayerMixin:OnLoad()
  local handler = self:GetParent()
  print(handler:GetName(), 'configLayers')
  handler.ConfigLayers = handler.ConfigLayers or {}
  for i, region in ipairs(handler.ConfigLayers) do
    region:SetShown(Veneer.ConfigMode)
  end
end

function VeneerConfigLayerMixin:OnUpdate()
  local handler = self:GetParent()
  handler.ConfigLayers = handler.ConfigLayers or {}

  self.ConfigName:SetText(handler:GetName())
  self.ConfigID:SetText(handler:GetID())
end

function VeneerAnimationMixin:OnPlay()
  PlaySoundKitID(229)
  self.animating = true
  print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint))
end
function VeneerAnimationMixin:OnStop()
  PlaySoundKitID(229)
  self.animating = nil
  print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint))
end
function VeneerAnimationMixin:OnFinished()
  PlaySoundKitID(229)
  self.animating = nil
  print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint))
end

function VeneerHandlerMixin:OnShow()
  self:Reanchor()
  Veneer:StaticReanchor(self)
end
function VeneerHandlerMixin:OnHide()
  Veneer:DynamicReanchor()
end
function VeneerHandlerMixin:Reanchor (anchorAll)
  Veneer:DynamicReanchor()
end
function VeneerHandlerMixin:Setup()
  local configName = self:GetName():gsub('^Veneer', '')
  VeneerData[configName] = VeneerData[configName] 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)
      VeneerData[configName][k] = v
    end
  end

  self.data = VeneerData[configName]
  print('data table loaded:', configName)
  self.initialized = true
end

function VeneerHandlerMixin:Print(...)
  local txt = '|cFFFFFF00'..self:GetName()..'|r:'
  for i = 1, select('#', ...) do
    txt = txt .. ' '.. tostring(select(i, ...))
  end



  DEFAULT_CHAT_FRAME:AddMessage(txt)
end