Refactor font update logic
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
af6e63dfe6
commit
b019a6f99a
2 changed files with 18 additions and 9 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)")
|
||||
|
|
|
@ -45,28 +45,23 @@ function QuestFrame:Init()
|
|||
self:UpdateSettings()
|
||||
end
|
||||
|
||||
function QuestFrame:UpdateFontSettings(FontString, newFont, newSize)
|
||||
local _, _, flags = FontString:GetFont()
|
||||
FontString:SetFont(newFont, newSize, flags)
|
||||
end
|
||||
|
||||
function QuestFrame:UpdateSettings()
|
||||
self:UpdateFontSettings(
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Title,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||
)
|
||||
self:UpdateFontSettings(
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Text1,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||
)
|
||||
self:UpdateFontSettings(
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Header,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||
)
|
||||
self:UpdateFontSettings(
|
||||
addon.API.UpdateCzechFont(
|
||||
self.Text2,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||
|
@ -114,8 +109,16 @@ function QuestFrame:ApplyTheme()
|
|||
end
|
||||
end
|
||||
|
||||
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:ResetFontText()
|
||||
self:ApplyTheme()
|
||||
|
||||
-- Set parent
|
||||
|
|
Loading…
Add table
Reference in a new issue