From 96745d407dfad3bdcc35f7914a2d7f94ce1448a0 Mon Sep 17 00:00:00 2001 From: Christopher Tse Date: Fri, 16 Oct 2020 10:24:14 +1100 Subject: [PATCH] Updated addon for 9.0.1 * Updated TOC Number * Adjusted backdrop code for new backdrop API Changes. * Fixed blizz chat integration as frame data was moved to a child of the chat bubble * Some offsets adjusted to match how the bubbles looked before 9.0.1 API changes --- BlizzChatIntegration.lua | 34 +++++++++++++++++++++++----------- ChatBubblePool.lua | 8 ++++---- MainFrame.lua | 2 ++ MainFrame.xml | 2 +- Settings.lua | 2 ++ Settings.xml | 2 +- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/BlizzChatIntegration.lua b/BlizzChatIntegration.lua index 75108a2..637cc6e 100644 --- a/BlizzChatIntegration.lua +++ b/BlizzChatIntegration.lua @@ -47,8 +47,12 @@ local function printTable(t, depth) end local function getChatBubbleText(chatBubble) - for i = 1, chatBubble:GetNumRegions() do - local region = select(i, chatBubble:GetRegions()) + --9.0.1 put frame data into a child of the bubble. I think this is a part of the backdrop api change. But anyway, + --we're just going to assume that the frame data is the first element of the chat bubble table. + chatBubbleFrame = select(1,chatBubble:GetChildren()); + for i = 1, chatBubbleFrame:GetNumRegions() do + local region = select(i, chatBubbleFrame:GetRegions()) + print("52"..(region:GetObjectType() or "nil")) if region:GetObjectType() == "FontString" then return region:GetText() end @@ -56,8 +60,9 @@ local function getChatBubbleText(chatBubble) end local function getNamedPoint(chatBubble,pointName) - for i = 1, chatBubble:GetNumPoints() do - local point, relativeTo, relativePoint, xOfs, yOfs = chatBubble:GetPoint(i); + local chatBubbleFrame = select(1, chatBubble:GetChildren()); + for i = 1, chatBubbleFrame:GetNumPoints() do + local point, relativeTo, relativePoint, xOfs, yOfs = chatBubbleFrame:GetPoint(i); if point == pointName then return relativeTo, relativePoint, xOfs, yOfs; end @@ -68,6 +73,7 @@ local function skinBubble(chatBubble) local message = getChatBubbleText(chatBubble); local name = messageToSender[message] + local NameText = CreateFrame("EditBox","BlizzBoxNameText",chatBubble); NameText:SetFrameStrata("MEDIUM"); --This is the default but better to be explicit --NameText:SetMultiLine(true); @@ -77,6 +83,7 @@ local function skinBubble(chatBubble) --NameText:SetPoint("CENTER"); NameText:SetPoint("BOTTOMLEFT",chatBubble,"TOPLEFT",13,2); NameText:SetFontObject("GameFontNormal"); + print(name) NameText:SetText(name); --local tex = NameText:CreateTexture(nil,"ARTWORK"); --tex:SetAllPoints() @@ -112,19 +119,24 @@ local function skinBubble(chatBubble) local nameWidth = NameText.stringMeasure:GetWidth(); NameBg:SetWidth(nameWidth); local stringWidth = self.string:GetWidth(); - local expectedWidth = stringWidth + 32; - local requiredWidthForName = nameWidth + 13 + 2 + 16; + local expectedWidth = stringWidth + 32; --32 is adjustment for left and right corners + local requiredWidthForName = nameWidth + 32; local defaultXOfs = self.defaultXOfs; local relativeTo, relativePoint, xOfs, yOfs = getNamedPoint(self,"BOTTOMRIGHT"); local currHeight = self:GetHeight(); + print(xOfs, yOfs) + local frame = select(1, chatBubble:GetChildren()); if ( expectedWidth < requiredWidthForName ) then local adj = (requiredWidthForName - expectedWidth)/2; - self:SetPoint("TOPLEFT",relativeTo,"TOPLEFT",-(defaultXOfs+adj),-yOfs); - self:SetPoint("BOTTOMRIGHT",relativeTo,"BOTTOMRIGHT",defaultXOfs+adj,yOfs); + print("More width needed. adj=" .. adj); + frame:SetPoint("TOPLEFT",relativeTo,"TOPLEFT",-(defaultXOfs+adj),-yOfs); + frame:SetPoint("BOTTOMRIGHT",relativeTo,"BOTTOMRIGHT",defaultXOfs+adj,yOfs); else - self:SetPoint("TOPLEFT",relativeTo,"TOPLEFT",-defaultXOfs,-yOfs); - self:SetPoint("BOTTOMRIGHT",relativeTo,relativePoint,defaultXOfs,yOfs); + frame:SetPoint("TOPLEFT",relativeTo,"TOPLEFT",-defaultXOfs,-yOfs); + frame:SetPoint("BOTTOMRIGHT",relativeTo,relativePoint,defaultXOfs,yOfs); end + local _, _, newX, newY = getNamedPoint(self,"BOTTOMRIGHT"); + print(newX, newY); end chatBubble:fixWidth(); @@ -139,7 +151,7 @@ local function skinBubble(chatBubble) end local function checkBubbles(chatBubbles) - --chatBubbles is an indexed array of frames + --chatBubbles is an indexed array of frames with one or more children bubbles for _, chatBubble in pairs(chatBubbles) do --7.2.5 disabled chatbubble skinning in dungeons and raids if not chatBubble:IsForbidden() then diff --git a/ChatBubblePool.lua b/ChatBubblePool.lua index 401674e..deb71a7 100644 --- a/ChatBubblePool.lua +++ b/ChatBubblePool.lua @@ -281,7 +281,7 @@ function ChatBubblePool.getChatBubble() newChatBubble.editBox = editBox; - local chatBubbleBackground = CreateFrame("Button",frameName.."Background",editBox); + local chatBubbleBackground = CreateFrame("Button",frameName.."Background",editBox, "BackdropTemplate"); chatBubbleBackground:SetBackdrop({ bgFile="Interface\\Tooltips\\CHATBUBBLE-BACKGROUND.BLP", edgeFile="Interface\\Tooltips\\CHATBUBBLE-BACKDROP.BLP", @@ -400,14 +400,14 @@ function ChatBubblePool.getChatBubble() local chatBubbleTail = CreateFrame("Frame",frameName.."-tail",chatBubbleBackground) chatBubbleTail:SetSize(16,16) - chatBubbleTail:SetPoint("TOPLEFT",chatBubbleBackground,"BOTTOMLEFT",8,3) chatBubbleTail.tex = chatBubbleTail:CreateTexture(frameName.."-tailTexture","BACKGROUND"); chatBubbleTail.tex:SetTexture("Interface\\Tooltips\\CHATBUBBLE-TAIL.BLP"); chatBubbleTail.tex:SetAllPoints(); - chatBubbleTail.bottomOffset = 3; + chatBubbleTail.bottomOffset = 5; chatBubbleTail.topOffset = -3; chatBubbleTail.leftOffset = 3; - chatBubbleTail.rightOffset = -3; + chatBubbleTail.rightOffset = -5; + chatBubbleTail:SetPoint("TOPLEFT",chatBubbleBackground,"BOTTOMLEFT",8,chatBubbleTail.bottomOffset) chatBubbleTail.minX = 8; chatBubbleTail.minY = 8; chatBubbleTail.side = "BOTTOM"; diff --git a/MainFrame.lua b/MainFrame.lua index 4310cfa..fcf08c1 100644 --- a/MainFrame.lua +++ b/MainFrame.lua @@ -17,6 +17,8 @@ function RPChatBubbles_OnLoad(self, event,...) self:RegisterEvent("ADDON_LOADED"); self:RegisterEvent("MODIFIER_STATE_CHANGED"); self:RegisterEvent("PLAYER_TARGET_CHANGED"); + self:SetBackdrop(BACKDROP_DIALOG_32_32) + self:OnBackdropLoaded() end function RPChatBubbles_OnEvent(self, event, ...) diff --git a/MainFrame.xml b/MainFrame.xml index 6e1b46c..c1f00b9 100644 --- a/MainFrame.xml +++ b/MainFrame.xml @@ -2,7 +2,7 @@