PageRenderTime 29ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Tukui/modules/addonskins/combat_toggle.lua

http://github.com/Asphyxia/Tukui
Lua | 61 lines | 54 code | 2 blank | 5 comment | 24 complexity | ef0042e08bc0f3b0021e0f7c61e706d8 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2
 3if C.Addon_Skins.background then
 4	-- Addons Background (same size as right chat background)
 5	local bg = CreateFrame("Frame", "AddonBGPanel", UIParent)
 6	bg:CreatePanel("Default", TukuiChatBackgroundRight:GetWidth(), TukuiChatBackgroundRight:GetHeight(), "BOTTOMRIGHT", TukuiChatBackgroundRight, "BOTTOMRIGHT", 0, 0)
 7	bg:SetFrameStrata("MEDIUM")
 8
 9	-- toggle in-/outfight (NOTE: This will only toggle ChatFrameX (chat config))
10	bg:RegisterEvent("PLAYER_ENTERING_WORLD")
11	bg:RegisterEvent("PLAYER_LOGIN")
12	if C.Addon_Skins.combat_toggle then
13		bg:RegisterEvent("PLAYER_REGEN_ENABLED")
14		bg:RegisterEvent("PLAYER_REGEN_DISABLED")
15	end
16	bg:SetScript("OnEvent", function(self, event)
17		if C.chat.rightchatbackground or C.Addon_Skins.combat_toggle then
18			if event == "PLAYER_LOGIN" then
19				-- Hide
20				bg:Hide()
21				if IsAddOnLoaded("Recount") then Recount_MainWindow:Hide() end
22				if IsAddOnLoaded("Omen") then OmenAnchor:Hide() end
23				if IsAddOnLoaded("Skada") then Skada:SetActive(false) end
24				if IsAddOnLoaded("TinyDPS") then tdpsFrame:Hide() end
25				if ChatBG2 then ChatBG2:Show() end
26				_G["ChatFrame"..C.chat.rightchatnumber]:Show()
27				_G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Show()
28			elseif event == "PLAYER_ENTERING_WORLD" then
29				-- yeah set all chats for ChatFrameX again cause we lose them after /rl when chat is hidden ..dunno how to prevent this atm
30				-- ChatFrame_RemoveAllMessageGroups(_G["ChatFrame"..C.chat.rightchatnumber])
31				ChatFrame_AddChannel(_G["ChatFrame"..C.chat.rightchatnumber], L.chat_trade)
32				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_XP_GAIN")
33				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_HONOR_GAIN")
34				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "COMBAT_FACTION_CHANGE")
35				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "LOOT")
36				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "MONEY")
37				ChatFrame_AddMessageGroup(_G["ChatFrame"..C.chat.rightchatnumber], "SKILL")
38			end
39		end
40		if C.Addon_Skins.combat_toggle then
41			if event == "PLAYER_REGEN_ENABLED" then
42				self:Hide()
43				if ChatBG2 then ChatBG2:Show() end
44				_G["ChatFrame"..C.chat.rightchatnumber]:Show()
45				_G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Show()
46				if IsAddOnLoaded("Recount") then Recount_MainWindow:Hide() end
47				if IsAddOnLoaded("Omen") then OmenAnchor:Hide() end
48				if IsAddOnLoaded("Skada") then Skada:SetActive(false) end
49				if IsAddOnLoaded("TinyDPS") then tdpsFrame:Hide() end
50			elseif event == "PLAYER_REGEN_DISABLED" then
51				self:Show()
52				if ChatBG2 then ChatBG2:Hide() end
53				_G["ChatFrame"..C.chat.rightchatnumber]:Hide()
54				_G["ChatFrame"..C.chat.rightchatnumber.."Tab"]:Hide()
55				if IsAddOnLoaded("Recount") then Recount_MainWindow:Show() end
56				if IsAddOnLoaded("Omen") then OmenAnchor:Show() end
57				if IsAddOnLoaded("Skada") then Skada:SetActive(true) end	
58			end
59		end
60	end)
61end