194 lines
No EOL
8.9 KiB
Lua
Executable file
194 lines
No EOL
8.9 KiB
Lua
Executable file
function CzechQuestsAddon:CreateTranslationQuestFrame()
|
|
local frame = {};
|
|
|
|
-- Quest Translation Frame
|
|
frame = CreateFrame("Frame", "CzechQuestTranslationQuestFrame", nil, BackdropTemplateMixin and "BackdropTemplate")
|
|
frame:SetWidth(300)
|
|
frame:SetBackdrop({ edgeFile = "Interface/Tooltips/UI-Tooltip-Border", edgeSize = 8 })
|
|
frame:Hide()
|
|
|
|
-- Background Parchment texture
|
|
frame.texture = frame:CreateTexture(nil, "BACKGROUND", nil, -1);
|
|
frame.texture:SetAllPoints(true)
|
|
frame.texture:SetHorizTile(true)
|
|
|
|
frame.primaryHeader = CzechQuestsAddon:CreateTranslationQuestFont(
|
|
frame,
|
|
"CzechQuestTranslationQuestPrimaryHeader",
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_PRIMARY_HEADER_FONT_SIZE
|
|
)
|
|
frame.secondaryHeader = CzechQuestsAddon:CreateTranslationQuestFont(
|
|
frame,
|
|
"CzechQuestTranslationQuestSecondaryHeader",
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_SECONDARY_HEADER_FONT_SIZE
|
|
)
|
|
frame.primaryText = CzechQuestsAddon:CreateTranslationQuestFont(
|
|
frame,
|
|
"CzechQuestTranslationQuestPrimaryText",
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE
|
|
)
|
|
frame.secondaryText = CzechQuestsAddon:CreateTranslationQuestFont(
|
|
frame,
|
|
"CzechQuestTranslationQuestSecondaryText",
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE
|
|
)
|
|
|
|
-- Apply correct texture for wow version
|
|
CzechQuestsAddon:SetTranslationQuestFrameTextureFromSettings(frame)
|
|
|
|
return frame;
|
|
end
|
|
|
|
function CzechQuestsAddon:CreateTranslationQuestFont(frame, name, font, size)
|
|
local label = frame:CreateFontString(name, "OVERLAY")
|
|
label:SetWidth(frame:GetWidth() - 20)
|
|
label:SetJustifyH("LEFT")
|
|
label:SetTextColor(0, 0, 0, 1)
|
|
label:SetFont(font, size, nil)
|
|
return label;
|
|
end
|
|
|
|
function CzechQuestsAddon:ResetTranslationQuestText(frame)
|
|
frame.primaryHeader:SetText("")
|
|
frame.secondaryHeader:SetText("")
|
|
frame.primaryText:SetText("")
|
|
frame.secondaryText:SetText("")
|
|
end
|
|
|
|
function CzechQuestsAddon:SetTranslationQuestFrameTextureFromSettings(frame)
|
|
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
|
-- setup default
|
|
frame.texture:SetTexture("Interface/QUESTFRAME/QuestBG");
|
|
frame.texture:SetTexCoord(0, .58, 0.005, 0.66)
|
|
frame.primaryHeader:SetTextColor(0, 0, 0, 1)
|
|
frame.secondaryHeader:SetTextColor(0, 0, 0, 1)
|
|
frame.primaryText:SetTextColor(0, 0, 0, 1)
|
|
frame.secondaryText:SetTextColor(0, 0, 0, 1)
|
|
|
|
if CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_DARK_MODE then
|
|
frame:SetBackdropColor(0, 0, 0, 1)
|
|
frame.texture:SetColorTexture(0, 0, 0, 1)
|
|
frame.primaryHeader:SetTextColor(255, 255, 255, 1)
|
|
frame.secondaryHeader:SetTextColor(255, 255, 255, 1)
|
|
frame.primaryText:SetTextColor(255, 255, 255, 1)
|
|
frame.secondaryText:SetTextColor(255, 255, 255, 1)
|
|
end
|
|
else
|
|
-- setup default
|
|
frame.texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment");
|
|
frame.texture:SetTexCoord(0, .01, 0, 0.4)
|
|
frame.primaryHeader:SetTextColor(0, 0, 0, 1)
|
|
frame.secondaryHeader:SetTextColor(0, 0, 0, 1)
|
|
frame.primaryText:SetTextColor(0, 0, 0, 1)
|
|
frame.secondaryText:SetTextColor(0, 0, 0, 1)
|
|
|
|
-- Read CVar from settings to setup same parchment as Quest frame
|
|
if C_CVar.GetCVar("questTextContrast") == "1" then -- Brown
|
|
frame.texture:SetTexCoord(0, .01, .4, .8)
|
|
elseif C_CVar.GetCVar("questTextContrast") == "2"
|
|
or C_CVar.GetCVar("questTextContrast") == "3" then -- Gray
|
|
frame.texture:SetColorTexture(255, 255, 255, 1)
|
|
elseif C_CVar.GetCVar("questTextContrast") == "4" then -- Black
|
|
frame.texture:SetColorTexture(0, 0, 0, 1)
|
|
frame.primaryHeader:SetTextColor(255, 255, 255, 1)
|
|
frame.secondaryHeader:SetTextColor(255, 255, 255, 1)
|
|
frame.primaryText:SetTextColor(255, 255, 255, 1)
|
|
frame.secondaryText:SetTextColor(255, 255, 255, 1)
|
|
end
|
|
end
|
|
|
|
if not CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA_ONLY_MOVING then
|
|
frame.texture:SetAlpha(CzechQuestsAddon_Store.config.TRANSLATION_FRAME_TEXTURE_ALPHA / 100)
|
|
end
|
|
end
|
|
|
|
function CzechQuestsAddon:UpdateTranslationQuestFrameFontSettings()
|
|
CzechQuestsAddon.translationQuestFrame.primaryHeader:SetFont(
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_PRIMARY_HEADER_FONT_SIZE,
|
|
nil
|
|
)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryHeader:SetFont(
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_HEADER_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_SECONDARY_HEADER_FONT_SIZE,
|
|
nil
|
|
)
|
|
CzechQuestsAddon.translationQuestFrame.primaryText:SetFont(
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE,
|
|
nil
|
|
)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryText:SetFont(
|
|
CzechQuestsAddon.fontPath .. CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_FAMILY,
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXT_FONT_SIZE,
|
|
nil
|
|
)
|
|
CzechQuestsAddon.translationQuestFrame.texture:SetAlpha(
|
|
CzechQuestsAddon_Store.config.TRANSLATION_QUEST_FRAME_TEXTURE_ALPHA / 100
|
|
)
|
|
end
|
|
|
|
function CzechQuestsAddon:ShowTranslationQuestFrame(primaryHeader, primaryText, secondaryHeader, secondaryText, parentFrame, yOffset, xOffset)
|
|
-- when user change own setting, does not require reload, just apply it
|
|
CzechQuestsAddon:SetTranslationQuestFrameTextureFromSettings(CzechQuestsAddon.translationQuestFrame)
|
|
|
|
-- reset all texts
|
|
CzechQuestsAddon:ResetTranslationQuestText(CzechQuestsAddon.translationQuestFrame)
|
|
|
|
-- set text to labels
|
|
CzechQuestsAddon.translationQuestFrame.primaryHeader:SetText(primaryHeader)
|
|
CzechQuestsAddon.translationQuestFrame.primaryText:SetText(primaryText)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryHeader:SetText(secondaryHeader)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryText:SetText(secondaryText)
|
|
|
|
local primaryTextTopMargin = -CzechQuestsAddon.translationQuestFrame.primaryHeader:GetHeight() - 15
|
|
local secondaryHeaderTopMargin = primaryTextTopMargin - CzechQuestsAddon.translationQuestFrame.primaryText:GetHeight() - 20
|
|
local secondaryTextTopMargin = secondaryHeaderTopMargin - CzechQuestsAddon.translationQuestFrame.secondaryHeader:GetHeight() - 5
|
|
|
|
-- apply gap between headers and texts
|
|
local gap = 10
|
|
local function addPadding(text, value)
|
|
if text ~= "" then
|
|
gap = gap + value
|
|
end
|
|
end
|
|
|
|
addPadding(primaryHeader, 10)
|
|
addPadding(primaryText, 5)
|
|
addPadding(secondaryHeader, 25)
|
|
addPadding(secondaryText, 5)
|
|
|
|
-- apply positions
|
|
CzechQuestsAddon.translationQuestFrame.primaryHeader:SetPoint("TOPLEFT", 10, -10)
|
|
CzechQuestsAddon.translationQuestFrame.primaryText:SetPoint("TOPLEFT", 10, primaryTextTopMargin)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryHeader:SetPoint("TOPLEFT", 10, secondaryHeaderTopMargin)
|
|
CzechQuestsAddon.translationQuestFrame.secondaryText:SetPoint("TOPLEFT", 10, secondaryTextTopMargin)
|
|
|
|
-- apply changes per wow
|
|
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
|
CzechQuestsAddon.translationQuestFrame:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", -8 + xOffset, yOffset)
|
|
else
|
|
CzechQuestsAddon.translationQuestFrame:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", 8 + xOffset, yOffset)
|
|
end
|
|
|
|
-- calculate height
|
|
local height = 0;
|
|
local heights = {
|
|
CzechQuestsAddon.translationQuestFrame.primaryHeader:GetHeight(),
|
|
CzechQuestsAddon.translationQuestFrame.primaryText:GetHeight(),
|
|
CzechQuestsAddon.translationQuestFrame.secondaryHeader:GetHeight(),
|
|
CzechQuestsAddon.translationQuestFrame.secondaryText:GetHeight(),
|
|
gap,
|
|
10
|
|
}
|
|
for _, value in ipairs(heights) do
|
|
height = height + value
|
|
end
|
|
|
|
CzechQuestsAddon.translationQuestFrame:SetParent(parentFrame)
|
|
CzechQuestsAddon.translationQuestFrame:SetHeight(height < 200 and 200 or height)
|
|
end |