From b0553c132828e0c0a1300ff0f4b08244b81308fb Mon Sep 17 00:00:00 2001 From: dbulatovicx32 Date: Mon, 23 Sep 2024 09:44:20 +0200 Subject: [PATCH] unitframes: add option for text offsets for hp & power bars --- api/config.lua | 12 ++++++++++++ api/unitframes.lua | 24 ++++++++++++------------ modules/gui.lua | 12 ++++++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/api/config.lua b/api/config.lua index 0c3a4eb5..b8c95ee6 100644 --- a/api/config.lua +++ b/api/config.lua @@ -448,11 +448,23 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", unit, "levelcolor", "1") pfUI:UpdateConfig("unitframes", unit, "classcolor", "1") pfUI:UpdateConfig("unitframes", unit, "txthpleft", "unit") + pfUI:UpdateConfig("unitframes", unit, "txthpleftoffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txthpleftoffy", "0") pfUI:UpdateConfig("unitframes", unit, "txthpcenter", "none") + pfUI:UpdateConfig("unitframes", unit, "txthpcenteroffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txthpcenteroffy", "0") pfUI:UpdateConfig("unitframes", unit, "txthpright", "healthdyn") + pfUI:UpdateConfig("unitframes", unit, "txthprightoffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txthprightoffy", "0") pfUI:UpdateConfig("unitframes", unit, "txtpowerleft", "none") + pfUI:UpdateConfig("unitframes", unit, "txtpowerleftoffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txtpowerleftoffy", "0") pfUI:UpdateConfig("unitframes", unit, "txtpowercenter", "none") + pfUI:UpdateConfig("unitframes", unit, "txtpowercenteroffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txtpowercenteroffy", "0") pfUI:UpdateConfig("unitframes", unit, "txtpowerright", "none") + pfUI:UpdateConfig("unitframes", unit, "txtpowerrightoffx", "0") + pfUI:UpdateConfig("unitframes", unit, "txtpowerrightoffy", "0") pfUI:UpdateConfig("unitframes", unit, "hitindicator", "0") pfUI:UpdateConfig("unitframes", unit, "hitindicatorsize", "15") pfUI:UpdateConfig("unitframes", unit, "hitindicatorfont", "Interface\\AddOns\\pfUI\\fonts\\Continuum.ttf") diff --git a/api/unitframes.lua b/api/unitframes.lua index b73f6f1e..6d40655b 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -601,48 +601,48 @@ function pfUI.uf:UpdateConfig() 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.hpLeftText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txthpleftoffx), 1 + tonumber(f.config.txthpleftoffy)) + f.hpLeftText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txthpleftoffx), f.config.txthpleftoffy) 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.hpRightText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txthprightoffx), 1 + tonumber(f.config.txthprightoffy)) + f.hpRightText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txthprightoffx), f.config.txthprightoffy) 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.hpCenterText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txthpcenteroffx), 1 + tonumber(f.config.txthpcenteroffy)) + f.hpCenterText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txthpcenteroffx), f.config.txthpcenteroffy) 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.powerLeftText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txtpowerleftoffx), 1 + tonumber(f.config.txtpowerleftoffy)) + f.powerLeftText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txtpowerleftoffx), f.config.txtpowerleftoffy) 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.powerRightText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txtpowerrightoffx), 1 + tonumber(f.config.txtpowerrightoffy)) + f.powerRightText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txtpowerrightoffx), f.config.txtpowerrightoffy) 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) - f.powerCenterText:SetPoint("BOTTOMRIGHT",f.power.bar, "BOTTOMRIGHT", -2*default_border, 0) + f.powerCenterText:SetPoint("TOPLEFT",f.hp.bar, "TOPLEFT", 2*(default_border + f.config.txtpowercenteroffx) + f.config.poffx, 1 + tonumber(f.config.txtpowercenteroffy)) + f.powerCenterText:SetPoint("BOTTOMRIGHT",f.hp.bar, "BOTTOMRIGHT", -2*(default_border + f.config.txtpowercenteroffx) + f.config.poffx, f.config.txtpowercenteroffy) f.incHeal:SetHeight(f.config.height) f.incHeal:SetWidth(f.config.width) diff --git a/modules/gui.lua b/modules/gui.lua index 367f9fc1..36cc6616 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1727,8 +1727,14 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(U[c], T["Health Bar Width"], C.unitframes[c], "width") CreateConfig(U[c], T["Health Bar Height"], C.unitframes[c], "height") CreateConfig(U[c], T["Left Text"], C.unitframes[c], "txthpleft", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Left Text X Offset"], C.unitframes[c], "txthpleftoffx") + CreateConfig(U[c], T["Left Text Y Offset"], C.unitframes[c], "txthpleftoffy") CreateConfig(U[c], T["Center Text"], C.unitframes[c], "txthpcenter", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Center Text X Offset"], C.unitframes[c], "txthpcenteroffx") + CreateConfig(U[c], T["Center Text Y Offset"], C.unitframes[c], "txthpcenteroffy") CreateConfig(U[c], T["Right Text"], C.unitframes[c], "txthpright", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Right Text X Offset"], C.unitframes[c], "txthprightoffx") + CreateConfig(U[c], T["Right Text Y Offset"], C.unitframes[c], "txthprightoffy") CreateConfig(U[c], T["Invert Health Bar"], C.unitframes[c], "invert_healthbar", "checkbox") CreateConfig(U[c], T["Enable Vertical Health Bar"], C.unitframes[c], "verticalbar", "checkbox") @@ -1738,8 +1744,14 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(U[c], T["Power Bar X-Offset"], C.unitframes[c], "poffx") CreateConfig(U[c], T["Power Bar Y-Offset"], C.unitframes[c], "poffy") CreateConfig(U[c], T["Left Text"], C.unitframes[c], "txtpowerleft", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Left Text X Offset"], C.unitframes[c], "txtpowerleftoffx") + CreateConfig(U[c], T["Left Text Y Offset"], C.unitframes[c], "txtpowerleftoffy") CreateConfig(U[c], T["Center Text"], C.unitframes[c], "txtpowercenter", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Center Text X Offset"], C.unitframes[c], "txtpowercenteroffx") + CreateConfig(U[c], T["Center Text Y Offset"], C.unitframes[c], "txtpowercenteroffy") CreateConfig(U[c], T["Right Text"], C.unitframes[c], "txtpowerright", "dropdown", pfUI.gui.dropdowns.uf_texts) + CreateConfig(U[c], T["Right Text X Offset"], C.unitframes[c], "txtpowerrightoffx") + CreateConfig(U[c], T["Right Text Y Offset"], C.unitframes[c], "txtpowerrightoffy") CreateConfig(U[c], T["Power Bar Anchor"], C.unitframes[c], "panchor", "dropdown", pfUI.gui.dropdowns.uf_powerbar_position) CreateConfig(U[c], T["Combat Text"], nil, nil, "header")