PageRenderTime 219ms CodeModel.GetById 126ms app.highlight 4ms RepoModel.GetById 87ms app.codeStats 0ms

/Tukui/modules/skins/bubbles.lua

http://github.com/Asphyxia/Tukui
Lua | 72 lines | 58 code | 12 blank | 2 comment | 15 complexity | 4267ef411d17f2a50c8850f2f515584d MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2if (IsAddOnLoaded("BossEncounter2")) then return end --> i don't know wtf this addon is doing but it broke my bubble script.
 3
 4local chatbubblehook = CreateFrame("Frame", nil, UIParent)
 5local noscalemult = T.mult * C["general"].uiscale
 6local tslu = 0
 7local numkids = 0
 8local bubbles = {}
 9
10if T.eyefinity then
11	-- hide options, disable bubbles, not compatible eyefinity
12	InterfaceOptionsSocialPanelChatBubbles:SetScale(0.00001)
13	InterfaceOptionsSocialPanelPartyChat:SetScale(0.00001)
14	SetCVar("chatBubbles", 0)
15	SetCVar("chatBubblesParty", 0)
16end
17
18local function skinbubble(frame)
19	for i=1, frame:GetNumRegions() do
20		local region = select(i, frame:GetRegions())
21		if region:GetObjectType() == "Texture" then
22			region:SetTexture(nil)
23		elseif region:GetObjectType() == "FontString" then
24			frame.text = region
25		end
26	end
27	
28	frame:SetBackdrop({
29		bgFile = C["media"].blank,
30		edgeFile = C["media"].blank,
31		tile = false, tileSize = 0, edgeSize = noscalemult,
32		insets = {left = -noscalemult, right = -noscalemult, top = -noscalemult, bottom = -noscalemult}
33	})
34	frame:SetBackdropBorderColor(unpack(C["media"].bordercolor))
35	frame:SetBackdropColor(.1, .1, .1, .8)
36	
37	tinsert(bubbles, frame)
38end
39
40local function ischatbubble(frame)
41	if frame:GetName() then return end
42	if not frame:GetRegions() then return end
43	return frame:GetRegions():GetTexture() == [[Interface\Tooltips\ChatBubble-Background]]
44end
45
46chatbubblehook:SetScript("OnUpdate", function(chatbubblehook, elapsed)
47	tslu = tslu + elapsed
48
49	if tslu > .05 then
50		tslu = 0
51
52		local newnumkids = WorldFrame:GetNumChildren()
53		if newnumkids ~= numkids then
54			for i=numkids + 1, newnumkids do
55				local frame = select(i, WorldFrame:GetChildren())
56
57				if ischatbubble(frame) then
58					skinbubble(frame)
59				end
60			end
61			numkids = newnumkids
62		end
63		
64		for i, frame in next, bubbles do
65			local r, g, b = frame.text:GetTextColor()
66			frame:SetBackdropBorderColor(r, g, b, .8)
67			
68			-- bubbles is unfortunatly not compatible with eyefinity, we hide it event if they are enabled. :(
69			if T.eyefinity then frame:SetScale(0.00001) end
70		end
71	end
72end)