2025-03-01 21:46:55 +01:00
|
|
|
local messages = {}
|
2025-03-04 07:49:19 +01:00
|
|
|
|
2025-03-01 21:46:55 +01:00
|
|
|
local function ReflowMessages()
|
|
|
|
local offsetY = 5
|
|
|
|
for i = #messages, 1, -1 do
|
2025-03-04 07:49:19 +01:00
|
|
|
local fs = messages[i]
|
|
|
|
fs:ClearAllPoints()
|
|
|
|
fs:SetPoint(
|
2025-03-01 21:46:55 +01:00
|
|
|
"BOTTOMLEFT",
|
|
|
|
CzechQuestsAddon.translationSpeechFrame.content,
|
|
|
|
"BOTTOMLEFT",
|
2025-03-04 07:49:19 +01:00
|
|
|
5,
|
2025-03-01 21:46:55 +01:00
|
|
|
offsetY
|
|
|
|
)
|
2025-03-04 07:49:19 +01:00
|
|
|
fs:Show()
|
|
|
|
offsetY = offsetY + fs:GetHeight()
|
2025-03-01 21:46:55 +01:00
|
|
|
end
|
|
|
|
|
2025-03-02 13:25:40 +01:00
|
|
|
if #messages == 0 then
|
|
|
|
CzechQuestsAddon.translationSpeechFrame:Hide()
|
|
|
|
end
|
|
|
|
|
2025-03-04 07:49:19 +01:00
|
|
|
offsetY = offsetY + 5
|
|
|
|
if offsetY < 150 then
|
|
|
|
offsetY = 150
|
|
|
|
end
|
|
|
|
|
|
|
|
CzechQuestsAddon.translationSpeechFrame.content:SetHeight(offsetY)
|
2025-03-02 13:25:40 +01:00
|
|
|
|
2025-03-04 07:49:19 +01:00
|
|
|
CzechQuestsAddon.translationSpeechFrame:UpdateScrollChildRect()
|
2025-03-02 13:25:40 +01:00
|
|
|
local maxScroll = CzechQuestsAddon.translationSpeechFrame:GetVerticalScrollRange()
|
2025-03-04 07:49:19 +01:00
|
|
|
CzechQuestsAddon.translationSpeechFrame:SetVerticalScroll(maxScroll)
|
2025-03-02 13:25:40 +01:00
|
|
|
|
2025-03-01 21:46:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local function RemoveMessage(frame)
|
|
|
|
for i, fs in ipairs(messages) do
|
|
|
|
if fs == frame then
|
|
|
|
local fadeAnimationGroup = fs:CreateAnimationGroup()
|
|
|
|
local fadeOut = fadeAnimationGroup:CreateAnimation("Alpha")
|
|
|
|
fadeOut:SetFromAlpha(1)
|
|
|
|
fadeOut:SetToAlpha(0)
|
2025-03-04 07:49:19 +01:00
|
|
|
fadeOut:SetDuration(1)
|
2025-03-01 21:46:55 +01:00
|
|
|
fadeOut:SetStartDelay(0)
|
|
|
|
|
|
|
|
fadeAnimationGroup:SetScript("OnFinished", function()
|
|
|
|
table.remove(messages, i)
|
|
|
|
fs:Hide()
|
|
|
|
ReflowMessages()
|
|
|
|
end)
|
|
|
|
|
|
|
|
fadeAnimationGroup:Play()
|
|
|
|
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function AddMessage(sender, message)
|
|
|
|
local formattedText = string.format("|cffffd200%s|r\n%s", sender, message)
|
|
|
|
local frame = CzechQuestsAddon:CreateTranslationSpeechFrameMessage(formattedText)
|
|
|
|
|
|
|
|
table.insert(messages, frame)
|
|
|
|
ReflowMessages()
|
|
|
|
|
2025-03-02 13:25:40 +01:00
|
|
|
C_Timer.After(20, function()
|
2025-03-01 21:46:55 +01:00
|
|
|
RemoveMessage(frame)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
function CzechQuestsAddon:ShowSpeechTranslation(sender, message)
|
2025-03-02 13:25:40 +01:00
|
|
|
local text = CzechQuestsAddon:GetData("speech", message)
|
2025-03-04 07:49:19 +01:00
|
|
|
if text == nil and CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_ORIGINAL_WHEN_MISSING then
|
|
|
|
text = message
|
|
|
|
end
|
|
|
|
|
2025-03-02 13:25:40 +01:00
|
|
|
if text ~= nil then
|
2025-03-04 07:49:19 +01:00
|
|
|
CzechQuestsAddon.translationSpeechFrame:Show()
|
2025-03-02 13:25:40 +01:00
|
|
|
AddMessage(sender, text)
|
|
|
|
end
|
2025-03-01 21:46:55 +01:00
|
|
|
end
|