addon/Quests/Frames/TranslationFrame.lua

70 lines
No EOL
2.9 KiB
Lua
Executable file

local headerFont = "Interface\\AddOns\\CzechQuests\\morpheus_cz.ttf"
local textFont = "Interface\\AddOns\\CzechQuests\\frizquadratatt_cz.ttf"
function CzechQuestsAddon:CreateTranslationFrame()
local frame = {};
-- Main Translation Frame
frame = CreateFrame("Frame", "CzechQuestTranslationFrame", 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)
-- Apply correct texture for wow version
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
frame.texture:SetTexture("Interface/QUESTFRAME/QuestBG");
frame.texture:SetTexCoord(0, .58, 0.005, 0.66)
else
frame.texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment");
CzechQuestsAddon:SetTextureFromSettings(frame)
end
frame.primaryHeader = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationPrimaryHeader", headerFont, 18)
frame.secondaryHeader = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationSecondaryHeader", headerFont, 16)
frame.primaryText = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationPrimaryText", textFont, 14)
frame.secondaryText = CzechQuestsAddon:CreateTranslationFont(frame,"CzechQuestTranslationSecondaryText", textFont, 14)
return frame;
end
function CzechQuestsAddon:CreateTranslationFont(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:ResetTranslationText(frame)
frame.primaryHeader:SetText("")
frame.secondaryHeader:SetText("")
frame.primaryText:SetText("")
frame.secondaryText:SetText("")
end
function CzechQuestsAddon:SetTextureFromSettings(frame)
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
if CzechQuestsAddon.options.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
-- TODO add DARK MODE support for retail
-- Read CVar from settings to setup same parchment as Quest frame
if C_CVar.GetCVar("questTextContrast") == "0" then
frame.texture:SetTexCoord(0, .01, 0, 0.4) -- Parchment (brown)
else
frame.texture:SetTexCoord(0, .01, .4, .8) -- Parchment (white)
end
end
end