Thread Tools Display Modes
06-14-14, 03:11 PM   #1
MiRai
A Warpwood Thunder Caller
Join Date: Jul 2011
Posts: 96
BubbleBobble Help

I really like the add-on BubbleBobble, but I do have a few questions about it and I figured I'd ask on the forum since I'm not sure I'd get a reply in the comments section.

1) Currently, the width of the chat bubbles seems to be dependent on what is being said rather than the name of the character speaking (example). Is it possible to change that so that the name of the character speaking doesn't get chopped off like shown in the image?

2) The size of the chat bubbles seems to be dependent on the resolution of the game client (not the scale of the UI). Is there anyway to increase the size/scale of the chat bubbles without increasing the resolution of the game client?

Thanks!

Here's the BubbleBobble.lua file:
lua Code:
  1. -- *****************************************************
  2. -- ** BubbleBobble by hankthetank
  3. -- *****************************************************
  4.  
  5. local settings = {
  6.     bg = {
  7.         texture = "Interface\\AddOns\\BubbleBobble\\textures\\background",
  8.         color = {0.10, 0.10, 0.10, 0.9},
  9.         tile = false,
  10.     },
  11.     bd = {
  12.         texture = "Interface\\AddOns\\BubbleBobble\\textures\\border",
  13.         size = 3,
  14.         color = {0.20, 0.20, 0.20},
  15.     },
  16.     tail = {
  17.         bgTexture = "Interface\\AddOns\\BubbleBobble\\textures\\tailbg",
  18.         bdTexture = "Interface\\AddOns\\BubbleBobble\\textures\\tailbd",
  19.     },
  20.     fontText = {"Fonts\\FRIZQT__.TTF", 9},
  21.     fontSender = {"Fonts\\ARIALN.TTF", 12, "OUTLINE"},
  22.     showSender = true,
  23. }
  24.  
  25. -- *****************************************************
  26. -- ** End of settings
  27. -- *****************************************************
  28.  
  29. -- Events & corresponding cVars
  30. local events = {
  31.     CHAT_MSG_SAY = "chatBubbles", CHAT_MSG_YELL = "chatBubbles",
  32.     CHAT_MSG_PARTY = "chatBubblesParty", CHAT_MSG_PARTY_LEADER = "chatBubblesParty",
  33.     CHAT_MSG_MONSTER_SAY = "chatBubbles", CHAT_MSG_MONSTER_YELL = "chatBubbles", CHAT_MSG_MONSTER_PARTY = "chatBubblesParty",
  34. }
  35.  
  36. -- WorldFrame frames are always uiScaled it seems
  37. local function FixedScale(len)
  38.     return GetScreenHeight() * len / 768
  39. end
  40.  
  41. local function RotateCoordPair(x, y, ox, oy, a, asp)
  42.     y = y / asp
  43.     oy = oy / asp
  44.     return ox + (x - ox) * math.cos(a) - (y - oy) * math.sin(a),
  45.         (oy + (y - oy) * math.cos(a) + (x - ox) * math.sin(a)) * asp
  46. end
  47.  
  48. -- Clip + rotate texture
  49. local function SetRotatedTexCoords(tex, left, right, top, bottom, width, height, angle, originx, originy)
  50.     local ratio, angle, originx, originy = width / height, math.rad(angle), originx or 0.5, originy or 1
  51.     local LRx, LRy = RotateCoordPair(left, top, originx, originy, angle, ratio)
  52.     local LLx, LLy = RotateCoordPair(left, bottom, originx, originy, angle, ratio)
  53.     local ULx, ULy = RotateCoordPair(right, top, originx, originy, angle, ratio)
  54.     local URx, URy = RotateCoordPair(right, bottom, originx, originy, angle, ratio)
  55.     tex:SetTexCoord(LRx, LRy, LLx, LLy, ULx, ULy, URx, URy)
  56. end
  57.  
  58. -- Skin a new frame
  59. local function SkinFrame(frame)
  60.     for i = 1, select("#", frame:GetRegions()) do
  61.         local region = select(i, frame:GetRegions())
  62.         if region:GetObjectType() == "FontString" then
  63.             frame.text = region
  64.         end
  65.     end
  66.    
  67.     -- Chat text
  68.     frame.text:SetFont(unpack(settings.fontText))
  69.     frame.text:SetJustifyH("LEFT")
  70.    
  71.     -- Sender text
  72.     if settings.showSender then
  73.         frame.sender = frame:CreateFontString()
  74.         frame.sender:SetPoint("TOP", 0, -10)
  75.         frame.sender:SetPoint("LEFT", frame.text)
  76.         frame.sender:SetPoint("RIGHT", frame.text)
  77.         frame.sender:SetFont(unpack(settings.fontSender))
  78.         frame.sender:SetJustifyH("LEFT")
  79.     end
  80.    
  81.     -- Border
  82.     frame:ClearAllPoints()
  83.     frame:SetPoint("TOPLEFT", frame.text, -10, settings.showSender and 10 + FixedScale(settings.fontSender[2]) or 10)
  84.     frame:SetPoint("BOTTOMRIGHT", frame.text, 10, -10)
  85.     frame:SetBackdrop({
  86.         edgeFile = settings.bd.texture,
  87.         edgeSize = settings.bd.size,
  88.         insets = {
  89.             top = settings.bd.inset,
  90.             bottom = settings.bd.inset,
  91.             left = settings.bd.inset,
  92.             right = settings.bd.inse
  93.         }
  94.     })
  95.     frame:SetBackdropBorderColor(unpack(settings.bd.color))
  96.    
  97.     -- Backdrops have no actual tiling
  98.     local bg = frame:CreateTexture(nil, "BACKGROUND")
  99.     bg:SetAllPoints()
  100.     bg:SetTexture(settings.bg.texture, settings.bg.tile)
  101.     bg:SetVertexColor(unpack(settings.bg.color))
  102.     bg:SetHorizTile(settings.bg.tile)
  103.     bg:SetVertTile(settings.bg.tile)
  104.    
  105.     -- Rework tail / bottom edge
  106.     local bottom, tail
  107.     for i = 1, select("#", frame:GetRegions()) do
  108.         local region = select(i, frame:GetRegions())
  109.         if region:GetObjectType() == "Texture" then
  110.             if ({region:GetPoint()})[1] == "BOTTOMLEFT" and region:GetPoint(2) then
  111.                 bottom = region
  112.             elseif region:GetTexture() == "Interface\\Tooltips\\ChatBubble-Tail" then
  113.                 tail = region
  114.             end
  115.         end
  116.     end
  117.    
  118.     tail:ClearAllPoints()
  119.     tail:SetSize(FixedScale(16), FixedScale(16))
  120.     tail:SetPoint("TOP", frame, "BOTTOM",0, 1 / FixedScale(1))
  121.     tail:SetTexture(settings.tail.bgTexture)
  122.     tail:SetVertexColor(unpack(settings.bg.color))
  123.    
  124.     tailBd = frame:CreateTexture()
  125.     tailBd:SetAllPoints(tail)
  126.     tailBd:SetTexture(settings.tail.bdTexture)
  127.     tailBd:SetVertexColor(unpack(settings.bd.color))
  128.    
  129.     -- Make tail break bottom edge
  130.     bottom:SetPoint("BOTTOMRIGHT", tail, "TOPLEFT")
  131.     local bottom2 = frame:CreateTexture(nil, "BORDER")
  132.     bottom2:SetTexture(settings.bd.texture)
  133.     SetRotatedTexCoords(bottom2, 0.375, 0.5, 0, 1, 64, 8, -90, 0.5, 1)
  134.     bottom2:SetVertexColor(unpack(settings.bd.color))
  135.     bottom2:SetHeight(bottom:GetHeight())
  136.     bottom2:SetPoint("LEFT", tail, "RIGHT", -FixedScale(8), 0)
  137.     bottom2:SetPoint("BOTTOMRIGHT", frame, -settings.bd.size, 0)
  138.    
  139.     frame:HookScript("OnHide", function() frame.inUse = false end)
  140. end
  141.  
  142. -- Update a frame
  143. local function UpdateFrame(frame, guid, name)
  144.     if not frame.text then SkinFrame(frame) end
  145.     frame.inUse = true
  146.    
  147.     if settings.showSender then
  148.         local class
  149.         if guid ~= nil and guid ~= "" then
  150.             _, class, _, _, _, _ = GetPlayerInfoByGUID(guid)
  151.         end
  152.        
  153.         if name then
  154.             local color = RAID_CLASS_COLORS[class] or { r = 1, g = 1, b = 1 }
  155.             frame.sender:SetText(("|cFF%2x%2x%2x%s|r"):format(color.r * 255, color.g * 255, color.b * 255, name))
  156.             if frame.text:GetWidth() < frame.sender:GetWidth() then
  157.                 frame.text:SetWidth(frame.sender:GetWidth())
  158.             end
  159.         end
  160.     end
  161. end
  162.  
  163. -- Find chat bubble with given message
  164. local function FindFrame(msg)
  165.     for i = 1, WorldFrame:GetNumChildren() do
  166.         local frame = select(i, WorldFrame:GetChildren())
  167.         if not frame:GetName() and not frame.inUse then
  168.             for i = 1, select("#", frame:GetRegions()) do
  169.                 local region = select(i, frame:GetRegions())
  170.                 if region:GetObjectType() == "FontString" and region:GetText() == msg then
  171.                     return frame
  172.                 end
  173.             end
  174.  
  175.         end
  176.     end
  177. end
  178.  
  179. local f = CreateFrame("Frame")
  180. for event, cvar in pairs(events) do f:RegisterEvent(event) end
  181.  
  182. f:SetScript("OnEvent", function(self, event, msg, sender, _, _, _, _, _, _, _, _, _, guid)
  183.     if GetCVarBool(events[event]) then
  184.         f.elapsed = 0
  185.         f:SetScript("OnUpdate", function(self, elapsed)
  186.             self.elapsed = self.elapsed + elapsed
  187.             local frame = FindFrame(msg)
  188.             if frame or self.elapsed > 0.3 then
  189.                 f:SetScript("OnUpdate", nil)
  190.                 if frame then UpdateFrame(frame, guid, sender) end
  191.             end
  192.         end)
  193.     end
  194. end)
  Reply With Quote
06-26-14, 12:59 AM   #2
sylvanaar
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 92
I wrote a similar addon a while back. You might find some code in it that will help you.

The chat bubble is sized based on the message text. You can just set the width of the message text to be equal to or greater than the name text if you want to stop it from being truncated. You will have to figure out what that width should be.

You can set the font size to simulate changing the scale of the bubble.

http://www.wowinterface.com/download...bblicious.html
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » BubbleBobble Help


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off