view SkeletonKey/Events.lua @ 6:f6d1c192afc6

Refactored file layout: - frame display logic in UI.lua - player data in Cache.lua - event responses in Events.lua a lot of local tables are now stored members of KeyBinder for that to work
author Nenue
date Thu, 28 Jul 2016 16:45:56 -0400
parents
children 8f8917d111c9
line wrap: on
line source
-- KrakTool
-- Events.lua
-- Created: 7/24/2016 11:10 PM
-- %file-revision%
-- Event handlers, and the init block that sets them up; nothing else should be here

local kb = LibStub("LibKraken").register(KeyBinder)

kb.init = function()
  kb:RegisterEvent('PLAYER_ENTERING_WORLD')
  kb:RegisterEvent('UPDATE_MACROS')
  kb:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player', 'pet')
  kb:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player', 'pet')
  kb:RegisterUnitEvent('TALENT_UPDATE', 'player', 'pet')
  kb:RegisterEvent('PLAYER_REGEN_DISABLED')
  kb:RegisterEvent('PLAYER_REGEN_ENABLED')
end

kb.event = function(event, ...)
  if kb[event] then
    kb[event](kb, event, ...)
  end
end

kb.PLAYER_REGEN_DISABLED = function()
  kb.ui()
end

kb.UNIT_PORTRAIT_UPDATE = function()
  SetPortraitTexture(KeyBinderCharacterTab.icon, 'player')
end

kb.PLAYER_REGEN_ENABLED = function()
  kb.ui()
end

kb.PLAYER_SPECIALIZATION_CHANGED =  function()
  kb.UpdateSpecInfo()
  kb.UpdateTalentInfo()
  kb.ApplyAllBindings()
  kb.ui(true)
end
kb.PLAYER_TALENT_UPDATE = function()
  kb.UpdateTalentInfo()
  kb.ApplyAllBindings()
  kb.ui()
end
kb.ACTIONBAR_SLOT_CHANGED = function(self, event, slot)
  kb.HotKeyText(slot)
  return true
end

kb.UNIT_PET = function(self, event, unit)
  if unit ~= 'player' then
    return
  end

  kb.UpdatePetInfo()
end