Improve QuestFrame font handling
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
All checks were successful
forgejo/Czech Quests/addon/pipeline/head This commit looks good
This commit is contained in:
parent
d90715c2cc
commit
7a12abeda3
8 changed files with 96 additions and 181 deletions
|
@ -15,6 +15,12 @@ local function CreateCzechFont(frame, name, size, flags)
|
|||
end
|
||||
addon.API.CreateCzechFont = CreateCzechFont
|
||||
|
||||
local function UpdateCzechFont(FontString, name, size)
|
||||
local _, _, flags = FontString:GetFont()
|
||||
FontString:SetFont(FontPath .. name, size, flags)
|
||||
end
|
||||
addon.API.UpdateCzechFont = UpdateCzechFont
|
||||
|
||||
local function GetFontContainer()
|
||||
local container = Settings.CreateControlTextContainer()
|
||||
container:Add("morpheus_cz.ttf", "Morpheus (cz)")
|
||||
|
|
|
@ -110,6 +110,10 @@ local function InitSpeeches()
|
|||
addon.SpeechFrame:UpdateSettings()
|
||||
end)
|
||||
|
||||
CreateButton('Zobrazit testovaci zpravu', "Zobrazit", function()
|
||||
addon.API.AddSpeechMessage("Test", "Text message")
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
local function InitOthers()
|
||||
|
|
|
@ -49,6 +49,9 @@ local function ShowQuestTranslation(event)
|
|||
if data then
|
||||
local title = GetQuestTitle(data.title, questId)
|
||||
local xOffset = hasModel and 210 or 10
|
||||
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
||||
xOffset = -20
|
||||
end
|
||||
if event == "QUEST_PROGRESS" then
|
||||
frame:SetData(title, data.progress, "", "", QuestFrame, -20, xOffset)
|
||||
elseif event == "QUEST_COMPLETE" then
|
||||
|
@ -109,13 +112,21 @@ local function InitQuests()
|
|||
if event == "PLAYER_LOGIN" then
|
||||
-- classic
|
||||
if QuestLogFrame then
|
||||
QuestLogFrame:SetScript("OnEnter", function() ShowQuestTranslation() end)
|
||||
QuestLogFrame:SetScript("OnLeave", function() frame:Hide() end)
|
||||
QuestLogFrame:SetScript("OnEnter", function()
|
||||
ShowQuestTranslation()
|
||||
end)
|
||||
QuestLogFrame:SetScript("OnLeave", function()
|
||||
frame:Hide()
|
||||
end)
|
||||
end
|
||||
-- retail
|
||||
if QuestMapDetailsScrollFrame then
|
||||
QuestMapDetailsScrollFrame:SetScript("OnEnter", function() ShowQuestTranslation() end)
|
||||
QuestMapDetailsScrollFrame:SetScript("OnLeave", function() frame:Hide() end)
|
||||
QuestMapDetailsScrollFrame:SetScript("OnEnter", function()
|
||||
ShowQuestTranslation()
|
||||
end)
|
||||
QuestMapDetailsScrollFrame:SetScript("OnLeave", function()
|
||||
frame:Hide()
|
||||
end)
|
||||
end
|
||||
|
||||
frame:Init()
|
||||
|
|
|
@ -35,30 +35,43 @@ function QuestFrame:Init()
|
|||
self.Texture:SetAllPoints(true)
|
||||
self.Texture:SetHorizTile(true)
|
||||
|
||||
-- Load settings
|
||||
self:UpdateSettings()
|
||||
end
|
||||
|
||||
function QuestFrame:UpdateSettings()
|
||||
-- Create fonts
|
||||
self.Title = self:CreateHeader()
|
||||
self.Text1 = self:CreateText()
|
||||
self.Header = self:CreateHeader()
|
||||
self.Text2 = self:CreateText()
|
||||
|
||||
self:ApplyTheme()
|
||||
-- Load settings
|
||||
self:UpdateSettings()
|
||||
end
|
||||
|
||||
function QuestFrame:UpdateSettings()
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Title,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||
)
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Text1,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||
)
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Header,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||
)
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Text2,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||
)
|
||||
|
||||
if not CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA_ONLY_MOVING then
|
||||
self.Texture:SetAlpha(CzechQuestsAddon_Store.config.QUEST_TEXTURE_ALPHA / 100)
|
||||
end
|
||||
end
|
||||
|
||||
function QuestFrame:ResetText()
|
||||
self.Title:SetText("")
|
||||
self.Header:SetText("")
|
||||
self.Text1:SetText("")
|
||||
self.Text2:SetText("")
|
||||
end
|
||||
|
||||
function QuestFrame:SetTextColor(r, g, b, a)
|
||||
self.Title:SetTextColor(r, g, b, a)
|
||||
self.Header:SetTextColor(r, g, b, a)
|
||||
|
@ -69,56 +82,53 @@ end
|
|||
function QuestFrame:ApplyTheme()
|
||||
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
||||
self.Texture:SetTexture("Interface/QUESTFRAME/QuestBG");
|
||||
self.Texture:SetTexCoord(0, .58, 0.005, 0.66)
|
||||
self:SetTextColor(0, 0, 0, 1)
|
||||
if CzechQuestsAddon_Store.config.QUEST_DARK_MODE then
|
||||
self:SetBackdropColor(0, 0, 0, 1)
|
||||
self.Texture:SetColorTexture(0, 0, 0, 1)
|
||||
self:SetTextColor(255, 255, 255, 1)
|
||||
else
|
||||
self.Texture:SetTexCoord(0, .58, 0.005, 0.66)
|
||||
self:SetTextColor(0, 0, 0, 1)
|
||||
end
|
||||
else
|
||||
self.Texture:SetTexture("Interface/QUESTFRAME/QuestBackgroundParchment");
|
||||
self.Texture:SetTexCoord(0, .01, 0, 0.4)
|
||||
self:SetTextColor(0, 0, 0, 1)
|
||||
local questTextContrast = C_CVar.GetCVar("questTextContrast")
|
||||
if questTextContrast == "1" then -- Brown
|
||||
if questTextContrast == "1" then
|
||||
-- Brown
|
||||
self.Texture:SetTexCoord(0, .01, .4, .8)
|
||||
elseif questTextContrast == "2" or questTextContrast == "3" then -- Gray
|
||||
elseif questTextContrast == "2" or questTextContrast == "3" then
|
||||
-- Gray
|
||||
self.Texture:SetColorTexture(255, 255, 255, 1)
|
||||
elseif questTextContrast == "4" then -- Black
|
||||
elseif questTextContrast == "4" then
|
||||
-- Black
|
||||
self.Texture:SetColorTexture(0, 0, 0, 1)
|
||||
self:SetTextColor(0, 0, 0, 1)
|
||||
self:SetTextColor(255, 255, 255, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function QuestFrame:CalculateHeight()
|
||||
local height = 0;
|
||||
local heights = {
|
||||
self.Title:GetHeight() ,
|
||||
self.Text1:GetHeight(),
|
||||
self.Header:GetHeight(),
|
||||
self.Text2:GetHeight(),
|
||||
10
|
||||
}
|
||||
for _, value in ipairs(heights) do
|
||||
height = height + value + 10
|
||||
end
|
||||
self:SetHeight(height)
|
||||
function QuestFrame:ResetFontText()
|
||||
self.Title:SetText("")
|
||||
self.Text1:SetText("")
|
||||
self.Header:SetText("")
|
||||
self.Text2:SetText("")
|
||||
end
|
||||
|
||||
function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xOffset)
|
||||
-- Reset previously values
|
||||
self:ResetText()
|
||||
self:ResetFontText()
|
||||
self:ApplyTheme()
|
||||
|
||||
-- Set parent
|
||||
self:SetParent(parentFrame)
|
||||
|
||||
-- set text to labels
|
||||
self.Title:SetText(name)
|
||||
self.Text1:SetText(text1)
|
||||
self.Header:SetText(header)
|
||||
self.Text2:SetText(text2)
|
||||
self.Title:SetText(name or "")
|
||||
self.Text1:SetText(text1 or "")
|
||||
self.Header:SetText(header or "")
|
||||
self.Text2:SetText(text2 or "")
|
||||
|
||||
-- apply text positions
|
||||
self.Title:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10)
|
||||
|
@ -127,11 +137,7 @@ function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xO
|
|||
self.Text2:SetPoint("TOPLEFT", self.Header, "BOTTOMLEFT", 0, -5)
|
||||
|
||||
-- apply frame position
|
||||
if (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) then
|
||||
self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
|
||||
else
|
||||
self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
|
||||
end
|
||||
self:SetPoint("TOPLEFT", parentFrame, "TOPRIGHT", xOffset, yOffset)
|
||||
|
||||
self:Show()
|
||||
|
||||
|
@ -144,4 +150,19 @@ function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xO
|
|||
else
|
||||
self:CalculateHeight()
|
||||
end
|
||||
end
|
||||
|
||||
function QuestFrame:CalculateHeight()
|
||||
local height = 0;
|
||||
local heights = {
|
||||
self.Title:GetHeight(),
|
||||
self.Text1:GetHeight(),
|
||||
self.Header:GetHeight(),
|
||||
self.Text2:GetHeight(),
|
||||
10
|
||||
}
|
||||
for _, value in ipairs(heights) do
|
||||
height = height + value + 10
|
||||
end
|
||||
self:SetHeight(height)
|
||||
end
|
|
@ -73,6 +73,7 @@ local function AddMessage(sender, message)
|
|||
RemoveMessage(MessageFrame)
|
||||
end)
|
||||
end
|
||||
addon.API.AddSpeechMessage = AddMessage
|
||||
|
||||
local function ShowSpeechTranslation(sender, message)
|
||||
local text = CzechQuestsAddon:GetData("speech", message)
|
||||
|
|
|
@ -28,6 +28,7 @@ function SpeechFrame:UpdateSettings()
|
|||
self:SetWidth(CzechQuestsAddon_Store.config.SPEECH_FRAME_WIDTH)
|
||||
|
||||
-- Set position
|
||||
self:ClearAllPoints()
|
||||
self:SetPoint(
|
||||
"BOTTOMLEFT", UIParent, "BOTTOMLEFT",
|
||||
CzechQuestsAddon_Store.config.SPEECH_FRAME_POSITION_X,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue