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