From 3043f2f085a49585228a36be8df76505b94e534b Mon Sep 17 00:00:00 2001 From: shagu Date: Thu, 7 Jan 2021 17:57:11 +0100 Subject: [PATCH] unitframes: add option to use custom fonts --- api/config.lua | 4 ++++ api/unitframes.lua | 35 +++++++++++++++++++++++------------ modules/gui.lua | 6 ++++++ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/api/config.lua b/api/config.lua index 82996dc6..b2aa5916 100644 --- a/api/config.lua +++ b/api/config.lua @@ -445,6 +445,10 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", unit, "focuscolor", "1,1,.75,1") pfUI:UpdateConfig("unitframes", unit, "healcolor", "0,1,0,0.6") pfUI:UpdateConfig("unitframes", unit, "overhealperc", "20") + pfUI:UpdateConfig("unitframes", unit, "customfont", "0") + pfUI:UpdateConfig("unitframes", unit, "customfont_name", "Interface\\AddOns\\pfUI\\fonts\\BigNoodleTitling.ttf") + pfUI:UpdateConfig("unitframes", unit, "customfont_size", "12") + pfUI:UpdateConfig("unitframes", unit, "customfont_style", "OUTLINE") end pfUI:UpdateConfig("bars", "bar1", "pageable", "1") diff --git a/api/unitframes.lua b/api/unitframes.lua index 8ca42ceb..fa6dfbe0 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -430,6 +430,17 @@ function pfUI.uf:UpdateConfig() f.power.bar:SetStatusBarBackgroundTexture(cr,cg,cb,ca) end + local fontname, fontsize, fontstyle + if f.config.customfont == "1" then + fontname = pfUI.media[f.config.customfont_name] + fontsize = tonumber(f.config.customfont_size) + fontstyle = f.config.customfont_style + else + fontname = pfUI.font_unit + fontsize = tonumber(C.global.font_unit_size) + fontstyle = C.global.font_unit_style + end + f.portrait:SetFrameStrata("LOW") f.portrait.tex:SetAllPoints(f.portrait) f.portrait.tex:SetTexCoord(.1, .9, .1, .9) @@ -508,49 +519,49 @@ function pfUI.uf:UpdateConfig() f:UnregisterEvent("UNIT_COMBAT") end - f.hpLeftText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.hpLeftText:SetJustifyH("LEFT") f.hpLeftText:SetFontObject(GameFontWhite) + f.hpLeftText:SetFont(fontname, fontsize, fontstyle) + f.hpLeftText:SetJustifyH("LEFT") f.hpLeftText:SetParent(f.hp.bar) f.hpLeftText:ClearAllPoints() f.hpLeftText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*default_border, 1) f.hpLeftText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*default_border, 0) - f.hpRightText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.hpRightText:SetJustifyH("RIGHT") f.hpRightText:SetFontObject(GameFontWhite) + f.hpRightText:SetFont(fontname, fontsize, fontstyle) + f.hpRightText:SetJustifyH("RIGHT") f.hpRightText:SetParent(f.hp.bar) f.hpRightText:ClearAllPoints() f.hpRightText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*default_border, 1) f.hpRightText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*default_border, 0) - f.hpCenterText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.hpCenterText:SetJustifyH("CENTER") f.hpCenterText:SetFontObject(GameFontWhite) + f.hpCenterText:SetFont(fontname, fontsize, fontstyle) + f.hpCenterText:SetJustifyH("CENTER") f.hpCenterText:SetParent(f.hp.bar) f.hpCenterText:ClearAllPoints() f.hpCenterText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*default_border, 1) f.hpCenterText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*default_border, 0) - f.powerLeftText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.powerLeftText:SetJustifyH("LEFT") f.powerLeftText:SetFontObject(GameFontWhite) + f.powerLeftText:SetFont(fontname, fontsize, fontstyle) + f.powerLeftText:SetJustifyH("LEFT") f.powerLeftText:SetParent(f.power.bar) f.powerLeftText:ClearAllPoints() f.powerLeftText:SetPoint("TOPLEFT",f.power.bar, "TOPLEFT", 2*default_border, 1) f.powerLeftText:SetPoint("BOTTOMRIGHT",f.power.bar, "BOTTOMRIGHT", -2*default_border, 0) - f.powerRightText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.powerRightText:SetJustifyH("RIGHT") f.powerRightText:SetFontObject(GameFontWhite) + f.powerRightText:SetFont(fontname, fontsize, fontstyle) + f.powerRightText:SetJustifyH("RIGHT") f.powerRightText:SetParent(f.power.bar) f.powerRightText:ClearAllPoints() f.powerRightText:SetPoint("TOPLEFT",f.power.bar, "TOPLEFT", 2*default_border, 1) f.powerRightText:SetPoint("BOTTOMRIGHT",f.power.bar, "BOTTOMRIGHT", -2*default_border, 0) - f.powerCenterText:SetFont(pfUI.font_unit, C.global.font_unit_size, C.global.font_unit_style) - f.powerCenterText:SetJustifyH("CENTER") f.powerCenterText:SetFontObject(GameFontWhite) + f.powerCenterText:SetFont(fontname, fontsize, fontstyle) + f.powerCenterText:SetJustifyH("CENTER") f.powerCenterText:SetParent(f.power.bar) f.powerCenterText:ClearAllPoints() f.powerCenterText:SetPoint("TOPLEFT",f.power.bar, "TOPLEFT", 2*default_border, 1) diff --git a/modules/gui.lua b/modules/gui.lua index db8dd7e8..67fdefb6 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1751,6 +1751,12 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(U[c], T["Debuff Limit"], C.unitframes[c], "debufflimit") CreateConfig(U[c], T["Debuffs Per Row"], C.unitframes[c], "debuffperrow") + CreateConfig(U[c], T["Overwrite Fonts"], nil, nil, "header") + CreateConfig(U[c], T["Use Custom Font Settings"], C.unitframes[c], "customfont", "checkbox") + CreateConfig(U[c], T["Custom Font Name"], C.unitframes[c], "customfont_name", "dropdown", pfUI.gui.dropdowns.fonts) + CreateConfig(U[c], T["Custom Font Size"], C.unitframes[c], "customfont_size") + CreateConfig(U[c], T["Custom Font Style"], C.unitframes[c], "customfont_style", "dropdown", pfUI.gui.dropdowns.fontstyle) + CreateConfig(U[c], T["Overwrite Colors"], nil, nil, "header") CreateConfig(U[c], T["Inherit Default Colors"], C.unitframes[c], "defcolor", "checkbox") CreateConfig(U[c], T["Health Bar Color"], C.unitframes[c], "custom", "dropdown", pfUI.gui.dropdowns.uf_color)