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
|
end
|
||||||
addon.API.CreateCzechFont = CreateCzechFont
|
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 function GetFontContainer()
|
||||||
local container = Settings.CreateControlTextContainer()
|
local container = Settings.CreateControlTextContainer()
|
||||||
container:Add("morpheus_cz.ttf", "Morpheus (cz)")
|
container:Add("morpheus_cz.ttf", "Morpheus (cz)")
|
||||||
|
|
|
@ -45,28 +45,23 @@ function QuestFrame:Init()
|
||||||
self:UpdateSettings()
|
self:UpdateSettings()
|
||||||
end
|
end
|
||||||
|
|
||||||
function QuestFrame:UpdateFontSettings(FontString, newFont, newSize)
|
|
||||||
local _, _, flags = FontString:GetFont()
|
|
||||||
FontString:SetFont(newFont, newSize, flags)
|
|
||||||
end
|
|
||||||
|
|
||||||
function QuestFrame:UpdateSettings()
|
function QuestFrame:UpdateSettings()
|
||||||
self:UpdateFontSettings(
|
addon.API.UpdateCzechFont(
|
||||||
self.Title,
|
self.Title,
|
||||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||||
)
|
)
|
||||||
self:UpdateFontSettings(
|
addon.API.UpdateCzechFont(
|
||||||
self.Text1,
|
self.Text1,
|
||||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||||
)
|
)
|
||||||
self:UpdateFontSettings(
|
addon.API.UpdateCzechFont(
|
||||||
self.Header,
|
self.Header,
|
||||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_NAME,
|
||||||
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
CzechQuestsAddon_Store.config.QUEST_HEADER_FONT_SIZE
|
||||||
)
|
)
|
||||||
self:UpdateFontSettings(
|
addon.API.UpdateCzechFont(
|
||||||
self.Text2,
|
self.Text2,
|
||||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_NAME,
|
||||||
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
CzechQuestsAddon_Store.config.QUEST_TEXT_FONT_SIZE
|
||||||
|
@ -114,8 +109,16 @@ function QuestFrame:ApplyTheme()
|
||||||
end
|
end
|
||||||
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)
|
function QuestFrame:SetData(name, text1, header, text2, parentFrame, yOffset, xOffset)
|
||||||
-- Reset previously values
|
-- Reset previously values
|
||||||
|
self:ResetFontText()
|
||||||
self:ApplyTheme()
|
self:ApplyTheme()
|
||||||
|
|
||||||
-- Set parent
|
-- Set parent
|
||||||
|
|
Loading…
Add table
Reference in a new issue