/Tukui/modules/actionbars/BarPet.lua
Lua | 57 lines | 48 code | 5 blank | 4 comment | 19 complexity | 2d774768dbeb6a76c35339c5636f9a14 MD5 | raw file
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- if not C["actionbar"].enable == true then return end
- ---------------------------------------------------------------------------
- -- setup PetActionBar
- ---------------------------------------------------------------------------
- local bar = TukuiPetBar
-
- bar:RegisterEvent("PLAYER_LOGIN")
- bar:RegisterEvent("PLAYER_CONTROL_LOST")
- bar:RegisterEvent("PLAYER_CONTROL_GAINED")
- bar:RegisterEvent("PLAYER_ENTERING_WORLD")
- bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
- bar:RegisterEvent("PET_BAR_UPDATE")
- bar:RegisterEvent("PET_BAR_UPDATE_USABLE")
- bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
- bar:RegisterEvent("PET_BAR_HIDE")
- bar:RegisterEvent("UNIT_PET")
- bar:RegisterEvent("UNIT_FLAGS")
- bar:RegisterEvent("UNIT_AURA")
- bar:SetScript("OnEvent", function(self, event, arg1)
- if event == "PLAYER_LOGIN" then
- -- bug reported by Affli on t12 BETA
- PetActionBarFrame.showgrid = 1 -- hack to never hide pet button. :X
-
- local button
- for i = 1, 10 do
- button = _G["PetActionButton"..i]
- button:ClearAllPoints()
- button:SetParent(TukuiPetBar)
- button:SetSize(T.petbuttonsize, T.petbuttonsize)
- if i == 1 then
- button:SetPoint("TOPLEFT", 5, -5)
- else
- if C["actionbar"].vertical_rightbars == true then
- button:SetPoint("TOP", _G["PetActionButton"..(i - 1)], "BOTTOM", 0, -T.buttonspacing)
- else
- button:SetPoint("LEFT", _G["PetActionButton"..(i - 1)], "RIGHT", T.buttonspacing, 0)
- end
- end
- button:Show()
- self:SetAttribute("addchild", button)
- end
- RegisterStateDriver(self, "visibility", "[pet,novehicleui,nobonusbar:5] show; hide")
- hooksecurefunc("PetActionBar_Update", T.TukuiPetBarUpdate)
- elseif event == "PET_BAR_UPDATE" or event == "UNIT_PET" and arg1 == "player"
- or event == "PLAYER_CONTROL_LOST" or event == "PLAYER_CONTROL_GAINED" or event == "PLAYER_FARSIGHT_FOCUS_CHANGED" or event == "UNIT_FLAGS"
- or arg1 == "pet" and (event == "UNIT_AURA") then
- T.TukuiPetBarUpdate()
- elseif event == "PET_BAR_UPDATE_COOLDOWN" then
- PetActionBar_UpdateCooldowns()
- else
- T.StylePet()
- end
- end)