PageRenderTime 122ms CodeModel.GetById 60ms app.highlight 5ms RepoModel.GetById 55ms app.codeStats 1ms

/Tukui/modules/unitframes/core/oUF/blizzard.lua

http://github.com/Asphyxia/Tukui
Lua | 92 lines | 80 code | 10 blank | 2 comment | 23 complexity | 19c81bfb4488fff870bea5b070681f7e MD5 | raw file
 1local parent, ns = ...
 2local oUF = ns.oUF
 3
 4local HandleFrame = function(baseName)
 5	local frame
 6	if(type(baseName) == 'string') then
 7		frame = _G[baseName]
 8	else
 9		frame = baseName
10	end
11
12	if(frame) then
13		frame:UnregisterAllEvents()
14		frame.Show = frame.Hide
15		frame:Hide()
16
17		local health = frame.healthbar
18		if(health) then
19			health:UnregisterAllEvents()
20		end
21
22		local power = frame.manabar
23		if(power) then
24			power:UnregisterAllEvents()
25		end
26
27		local spell = frame.spellbar
28		if(spell) then
29			spell:UnregisterAllEvents()
30		end
31
32		local altpowerbar = frame.powerBarAlt
33		if(altpowerbar) then
34			altpowerbar:UnregisterAllEvents()
35		end
36	end
37end
38
39function oUF:DisableBlizzard(unit)
40	if(not unit) then return end
41
42	if(unit == 'player') then
43		HandleFrame(PlayerFrame)
44
45		-- For the damn vehicle support:
46		PlayerFrame:RegisterEvent('UNIT_ENTERING_VEHICLE')
47		PlayerFrame:RegisterEvent('UNIT_ENTERED_VEHICLE')
48		PlayerFrame:RegisterEvent('UNIT_EXITING_VEHICLE')
49		PlayerFrame:RegisterEvent('UNIT_EXITED_VEHICLE')
50	elseif(unit == 'pet') then
51		HandleFrame(PetFrame)
52	elseif(unit == 'target') then
53		HandleFrame(TargetFrame)
54		HandleFrame(ComboFrame)
55	elseif(unit == 'focus') then
56		HandleFrame(FocusFrame)
57		HandleFrame(TargetofFocusFrame)
58	elseif(unit == 'targettarget') then
59		HandleFrame(TargetFrameToT)
60	elseif(unit:match'(boss)%d?$' == 'boss') then
61		local id = unit:match'boss(%d)'
62		if(id) then
63			HandleFrame('Boss' .. id .. 'TargetFrame')
64		else
65			for i=1, 4 do
66				HandleFrame(('Boss%dTargetFrame'):format(i))
67			end
68		end
69	elseif(unit:match'(party)%d?$' == 'party') then
70		local id = unit:match'party(%d)'
71		if(id) then
72			HandleFrame('PartyMemberFrame' .. id)
73		else
74			for i=1, 4 do
75				HandleFrame(('PartyMemberFrame%d'):format(i))
76			end
77		end
78	elseif(unit:match'(arena)%d?$' == 'arena') then
79		local id = unit:match'arena(%d)'
80		if(id) then
81			HandleFrame('ArenaEnemyFrame' .. id)
82		else
83			for i=1, 4 do
84				HandleFrame(('ArenaEnemyFrame%d'):format(i))
85			end
86		end
87
88		-- Blizzard_ArenaUI should not be loaded
89		Arena_LoadUI = function() end
90		SetCVar('showArenaEnemyFrames', '0', 'SHOW_ARENA_ENEMY_FRAMES_TEXT')
91	end
92end