local messages = {} local function ReflowMessages() local offsetY = 5 for i = #messages, 1, -1 do local msg = messages[i] msg:ClearAllPoints() msg:SetPoint( "BOTTOMLEFT", CzechQuestsAddon.translationSpeechFrame.content, "BOTTOMLEFT", 10, offsetY ) offsetY = offsetY + msg:GetHeight() end CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY + 5) end local function RemoveMessage(frame) local emptyMessages = true for i, fs in ipairs(messages) do emptyMessages = false if fs == frame then local fadeAnimationGroup = fs:CreateAnimationGroup() local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha") fadeOut:SetFromAlpha(1) fadeOut:SetToAlpha(0) fadeOut:SetDuration(0.2) fadeOut:SetStartDelay(0) fadeAnimationGroup:SetScript("OnFinished", function() table.remove(messages, i) fs:Hide() ReflowMessages() end) fs:Show() fadeAnimationGroup:Play() break end end if emptyMessages then CzechQuestsAddon.translationSpeechFrame:Hide() end end local function AddMessage(sender, message) local formattedText = string.format("|cffffd200%s|r\n%s", sender, message) local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText) CzechQuestsAddon.translationSpeechFrame:Show() table.insert(messages, frame) ReflowMessages() C_Timer.After(30, function() RemoveMessage(frame) end) end function CzechQuestsAddon:ShowSpeechTranslation(sender, message) local text = CzechQuestsAddon:GetData("speech", message) or message AddMessage(sender, text) end