PageRenderTime 33ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/Tukui/modules/actionbars/BarPet.lua

http://github.com/Asphyxia/Tukui
Lua | 57 lines | 48 code | 5 blank | 4 comment | 19 complexity | 2d774768dbeb6a76c35339c5636f9a14 MD5 | raw file
  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. if not C["actionbar"].enable == true then return end
  3. ---------------------------------------------------------------------------
  4. -- setup PetActionBar
  5. ---------------------------------------------------------------------------
  6. local bar = TukuiPetBar
  7. bar:RegisterEvent("PLAYER_LOGIN")
  8. bar:RegisterEvent("PLAYER_CONTROL_LOST")
  9. bar:RegisterEvent("PLAYER_CONTROL_GAINED")
  10. bar:RegisterEvent("PLAYER_ENTERING_WORLD")
  11. bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
  12. bar:RegisterEvent("PET_BAR_UPDATE")
  13. bar:RegisterEvent("PET_BAR_UPDATE_USABLE")
  14. bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
  15. bar:RegisterEvent("PET_BAR_HIDE")
  16. bar:RegisterEvent("UNIT_PET")
  17. bar:RegisterEvent("UNIT_FLAGS")
  18. bar:RegisterEvent("UNIT_AURA")
  19. bar:SetScript("OnEvent", function(self, event, arg1)
  20. if event == "PLAYER_LOGIN" then
  21. -- bug reported by Affli on t12 BETA
  22. PetActionBarFrame.showgrid = 1 -- hack to never hide pet button. :X
  23. local button
  24. for i = 1, 10 do
  25. button = _G["PetActionButton"..i]
  26. button:ClearAllPoints()
  27. button:SetParent(TukuiPetBar)
  28. button:SetSize(T.petbuttonsize, T.petbuttonsize)
  29. if i == 1 then
  30. button:SetPoint("TOPLEFT", 5, -5)
  31. else
  32. if C["actionbar"].vertical_rightbars == true then
  33. button:SetPoint("TOP", _G["PetActionButton"..(i - 1)], "BOTTOM", 0, -T.buttonspacing)
  34. else
  35. button:SetPoint("LEFT", _G["PetActionButton"..(i - 1)], "RIGHT", T.buttonspacing, 0)
  36. end
  37. end
  38. button:Show()
  39. self:SetAttribute("addchild", button)
  40. end
  41. RegisterStateDriver(self, "visibility", "[pet,novehicleui,nobonusbar:5] show; hide")
  42. hooksecurefunc("PetActionBar_Update", T.TukuiPetBarUpdate)
  43. elseif event == "PET_BAR_UPDATE" or event == "UNIT_PET" and arg1 == "player"
  44. or event == "PLAYER_CONTROL_LOST" or event == "PLAYER_CONTROL_GAINED" or event == "PLAYER_FARSIGHT_FOCUS_CHANGED" or event == "UNIT_FLAGS"
  45. or arg1 == "pet" and (event == "UNIT_AURA") then
  46. T.TukuiPetBarUpdate()
  47. elseif event == "PET_BAR_UPDATE_COOLDOWN" then
  48. PetActionBar_UpdateCooldowns()
  49. else
  50. T.StylePet()
  51. end
  52. end)