Quantcast

Fixed an issue where the chat bubbles remained on screen during movies

Christopher Tse [05-23-20 - 07:34]
Fixed an issue where the chat bubbles remained on screen during movies
and cinematics
Filename
ChatBubblePool.lua
diff --git a/ChatBubblePool.lua b/ChatBubblePool.lua
index c1cc6c3..dbcad0b 100644
--- a/ChatBubblePool.lua
+++ b/ChatBubblePool.lua
@@ -111,6 +111,26 @@ local function subtractVector(a, b)
 	return { x=a.x - b.x, y=a.y - b.y};
 end

+local function closeBubbles()
+	for _, bubble in pairs(pool) do
+		closeBubble(bubble);
+	end
+end
+
+local function hideBubbles()
+	for _, bubble in pairs(pool) do
+		bubble:Hide()
+	end
+end
+
+local function showBubbles()
+	for _, bubble in pairs(pool) do
+		if not bubble.isAvailable then
+			bubble:Show()
+		end
+	end
+end
+
 local function moveTail(tail)
 	--Note: Since the chat bubble is anchored to the WorldFrame, we shouldn't adjust for UIParent's scale
 	local cursorX, cursorY = GetCursorPosition();
@@ -403,4 +423,20 @@ function ChatBubblePool.getChatBubble()
 	newChatBubble.ResetNameColor = function(self) self:SetNameColor(origR,origG,origB); end;

 	return newChatBubble
-end
\ No newline at end of file
+end
+
+local function doEvent(self, event, ...)
+	if event == "PLAY_MOVIE" then
+		closeBubbles()
+	elseif event == "CINEMATIC_START" then
+		hideBubbles()
+	elseif event == "CINEMATIC_STOP" then
+		showBubbles()
+	end
+end
+
+local frame = CreateFrame("FRAME","ChatBubbleEventHandler");
+frame:RegisterEvent("PLAY_MOVIE");
+frame:RegisterEvent("CINEMATIC_START");
+frame:RegisterEvent("CINEMATIC_STOP");
+frame:SetScript("OnEvent",doEvent);
\ No newline at end of file