Skip to content

Instantly share code, notes, and snippets.

@Wetxius
Created August 27, 2019 09:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wetxius/bfa004988936886086d00480b29617be to your computer and use it in GitHub Desktop.
Save Wetxius/bfa004988936886086d00480b29617be to your computer and use it in GitHub Desktop.
ShestakUI\Modules\Skins\Blizzard\Bubbles.lua
local T, C, L, _ = unpack(select(2, ...))
if C.chat.bubbles ~= true then return end
----------------------------------------------------------------------------------------
-- ChatBubbles skin(by Haleth)
----------------------------------------------------------------------------------------
local function styleBubble(frame)
for i = 1, frame:GetNumRegions() do
local region = select(i, frame:GetRegions())
if region:GetObjectType() == "Texture" then
region:SetTexture(nil)
elseif region:GetObjectType() == "FontString" then
region:SetFontObject(SystemFont_Shadow_Huge1)
end
end
frame:SetTemplate("Transparent")
frame:SetClampedToScreen(false)
frame:SetFrameStrata("BACKGROUND")
frame:SetScale(_G.UIParent:GetScale())
frame.skinned = true
end
local function FindChatBubble(msg)
local chatbubbles = _G.C_ChatBubbles.GetAllChatBubbles()
for index = 1, #chatbubbles do
local chatbubble = chatbubbles[index]
for i = 1, _G.select("#", chatbubble:GetRegions()) do
local region = _G.select(i, chatbubble:GetRegions())
if region:GetObjectType() == "FontString" and region:GetText() == msg then
return chatbubble
end
end
end
end
local events = {
CHAT_MSG_SAY = "chatBubbles",
CHAT_MSG_YELL = "chatBubbles",
CHAT_MSG_MONSTER_SAY = "chatBubbles",
CHAT_MSG_MONSTER_YELL = "chatBubbles",
CHAT_MSG_PARTY = "chatBubblesParty",
CHAT_MSG_PARTY_LEADER = "chatBubblesParty",
CHAT_MSG_MONSTER_PARTY = "chatBubblesParty",
}
local bubbleHook = _G.CreateFrame("Frame")
bubbleHook:SetScript("OnEvent", function(self, event, msg)
if _G.GetCVarBool(events[event]) then
self.elapsed = 0
self.msg = msg
self:Show()
end
end)
bubbleHook:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed + elapsed
local chatbubble = FindChatBubble(self.msg)
if chatbubble or self.elapsed > 0.3 then
self:Hide()
if chatbubble then
-- if not chatbubble.skinned then
styleBubble(chatbubble)
-- end
end
end
end)
bubbleHook:Hide()
for event in next, events do
bubbleHook:RegisterEvent(event)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment