96 lines
No EOL
3.1 KiB
Lua
Executable file
96 lines
No EOL
3.1 KiB
Lua
Executable file
function CzechQuestsAddon:CreateTranslationSpeechFrame()
|
|
local scroll = {};
|
|
|
|
-- Speech Translation Frame
|
|
scroll = CreateFrame("ScrollFrame", "CzechQuestsTranslationSpeechFrame", UIParent, "MinimalScrollFrameTemplate")
|
|
scroll:SetSize(CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_WIDTH, 120)
|
|
|
|
-- Make movable
|
|
scroll:SetMovable(true)
|
|
scroll:EnableMouse(true)
|
|
scroll:RegisterForDrag("LeftButton")
|
|
|
|
scroll:SetScript("OnDragStart", function()
|
|
scroll:StartMoving()
|
|
end)
|
|
|
|
scroll:SetScript("OnDragStop", function(self)
|
|
scroll:StopMovingOrSizing()
|
|
local finalLeft, finalTop = self:GetLeft(), self:GetTop()
|
|
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION = {
|
|
x = finalLeft,
|
|
y = finalTop
|
|
}
|
|
end)
|
|
|
|
-- Hide sidebar
|
|
scroll.ScrollBar:Hide()
|
|
scroll.ScrollBar.Show = function() end
|
|
|
|
-- Speech Translation Content Frame
|
|
scroll.content = CreateFrame("Frame", nil, scroll)
|
|
scroll.content:SetSize(scroll:GetWidth(), 1)
|
|
|
|
scroll:SetScrollChild(scroll.content)
|
|
|
|
-- Texture for control color and alpha
|
|
scroll.content.texture = scroll.content:CreateTexture(nil, "ARTWORK")
|
|
scroll.content.texture:SetTexture("Interface\\Buttons\\WHITE8x8")
|
|
scroll.content.texture:SetVertexColor(0, 0, 0, 0.2)
|
|
|
|
-- Set points to edges
|
|
scroll.content.texture:SetPoint("TOPLEFT", scroll.content ,"TOPLEFT", 0, 0)
|
|
scroll.content.texture:SetPoint("BOTTOMRIGHT", scroll.content ,"BOTTOMRIGHT", 0, 0)
|
|
|
|
scroll:SetScript("OnEnter", function()
|
|
scroll.content.texture:SetAlpha(0.8)
|
|
end)
|
|
scroll:SetScript("OnLeave", function()
|
|
scroll.content.texture:SetAlpha(0.2)
|
|
end)
|
|
|
|
-- Set position
|
|
scroll:ClearAllPoints()
|
|
scroll:SetPoint(
|
|
"TOPLEFT", UIParent, "TOPLEFT",
|
|
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.x,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_POSITION.y
|
|
)
|
|
|
|
scroll:Hide()
|
|
|
|
scroll.content:SetPoint("BOTTOMLEFT", scroll, "BOTTOMLEFT", 0, 0)
|
|
|
|
return scroll;
|
|
end
|
|
|
|
function CzechQuestsAddon:CreateTranslationSpeechFrameMessage(message)
|
|
local frame = {};
|
|
|
|
-- Create content for messages
|
|
frame = CreateFrame("Frame", nil, CzechQuestsAddon.translationSpeechFrame.content)
|
|
frame:SetSize(CzechQuestsAddon.translationSpeechFrame.content:GetWidth() - 20, 1)
|
|
|
|
-- Message
|
|
frame.string = frame:CreateFontString(nil, "OVERLAY")
|
|
frame.string:SetWidth(frame:GetWidth())
|
|
frame.string:SetTextColor(1, 1, 1)
|
|
frame.string:SetWordWrap(true)
|
|
|
|
frame.string:SetPoint("TOPLEFT", frame, "TOPLEFT", 5, -5)
|
|
frame.string:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -5, 5)
|
|
|
|
frame.string:SetJustifyH("LEFT")
|
|
|
|
frame.string:SetFont(
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_SPEECH_FRAME_TEXT_FONT_SIZE,
|
|
"OUTLINE"
|
|
)
|
|
|
|
frame.string:SetText(message)
|
|
|
|
frame:SetHeight(frame.string:GetHeight() + 10)
|
|
|
|
return frame;
|
|
end |