Commit 6c5cb5f9 authored by Azilroka's avatar Azilroka
Browse files

ChatBubbles

parent 6cb8264f
local AS = unpack(AddOnSkins)
-- Cache global variables
--Lua functions
local pairs, select = pairs, select
local twipe = table.wipe
--WoW API / Variables
local wipe = wipe
local Ambiguate = Ambiguate
local C_ChatBubbles_GetAllChatBubbles = C_ChatBubbles.GetAllChatBubbles
local CreateFrame = CreateFrame
local GetPlayerInfoByGUID = GetPlayerInfoByGUID
-- GLOBALS:
function AS:Blizzard_ChatBubbles()
local messageToGUID, messageToSender = {}, {}
......@@ -22,55 +18,52 @@ function AS:Blizzard_ChatBubbles()
EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
EventFrame:SetScript("OnEvent", function(self, event, msg, sender, _, _, _, _, _, _, _, _, _, guid)
if event == 'PLAYER_ENTERING_WORLD' then
twipe(messageToGUID)
twipe(messageToSender)
wipe(messageToGUID)
wipe(messageToSender)
else
messageToGUID[msg] = guid
messageToSender[msg] = Ambiguate(sender, "none")
end
end)
local function SkinChatBubble(frame)
for i = 1, frame:GetNumRegions() do
local region = select(i, frame:GetRegions())
if region:GetObjectType() == "Texture" then
region:SetTexture()
elseif region:GetObjectType() == "FontString" then
frame.text = region
end
end
AS:SetTemplate(frame)
frame.name = frame:CreateFontString(nil, "BORDER")
frame.name:SetPoint("TOPLEFT", 5, 5)
frame.name:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -5, -5)
frame.name:SetJustifyH("LEFT")
frame.name:SetFont(AS.Font, 14, 'OUTLINE')
frame:HookScript("OnUpdate", function(self)
local r, g, b = self.text:GetTextColor()
local function ChatBubbleName(frame)
local chatBubble = frame:GetChildren()
if chatBubble and not chatBubble:IsForbidden() then
local r, g, b = chatBubble.String:GetTextColor()
frame:SetBackdropBorderColor(r, g, b, .8)
local text = self.text:GetText()
if self.name then
self.name:SetText("")
local color = 'ffffffff'
local guid = messageToGUID[text]
local text = chatBubble.String:GetText()
if chatBubble.name then
chatBubble.name:SetText('')
local guid, class = messageToGUID[text]
if guid ~= nil and guid ~= "" then
local _, class = GetPlayerInfoByGUID(guid)
if class then
local classcolor = AS:GetClassColor(class)
if classcolor then color = classcolor.colorStr end
end
class = select(2, GetPlayerInfoByGUID(guid))
end
if messageToSender[text] then
self.name:SetFormattedText("|c%s%s|r", color, messageToSender[text])
local color = AS:GetClassColor(class)
chatBubble.name:SetFormattedText("|c%s%s|r", color.colorStr, messageToSender[text])
end
end
end)
end
end
local function SkinChatBubble(frame)
local chatBubble = frame:GetChildren()
if chatBubble and not chatBubble:IsForbidden() then
chatBubble:ClearBackdrop()
AS:SkinFrame(frame)
chatBubble.Tail:SetTexture('')
chatBubble.name = chatBubble:CreateFontString(nil, "BORDER")
chatBubble.name:SetPoint("TOPLEFT", 5, 5)
chatBubble.name:SetPoint("BOTTOMRIGHT", chatBubble, "TOPRIGHT", -5, -5)
chatBubble.name:SetJustifyH("LEFT")
chatBubble.name:SetFont(AS.Font, 14, 'OUTLINE')
frame.isSkinned = true
frame:HookScript("OnShow", ChatBubbleName)
ChatBubbleName(frame)
frame.isSkinned = true
end
end
AS:ScheduleRepeatingTimer(function()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment