From 03eb6a737c7a9007c4aa7e8b6f2724d8e9e386db Mon Sep 17 00:00:00 2001 From: stokbaek Date: Tue, 5 Dec 2017 21:01:54 +0100 Subject: [PATCH] unitframes: add option for vertical health bars --- api/config.lua | 10 ++++++++++ api/unitframes.lua | 3 +++ env/translations_deDE.lua | 1 + env/translations_enUS.lua | 1 + env/translations_esES.lua | 1 + env/translations_frFR.lua | 1 + env/translations_koKR.lua | 1 + env/translations_ruRU.lua | 1 + env/translations_zhCN.lua | 1 + env/translations_zhTW.lua | 1 + modules/gui.lua | 10 ++++++++++ modules/thirdparty.lua | 30 ++++++++++++++++++++++++------ 12 files changed, 55 insertions(+), 6 deletions(-) diff --git a/api/config.lua b/api/config.lua index bb240e9e..71d7b6ed 100644 --- a/api/config.lua +++ b/api/config.lua @@ -120,6 +120,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "debufflimit", "32") pfUI:UpdateConfig("unitframes", "player", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "player", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "player", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "player", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "player", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "player", "clickcast", "0") @@ -157,6 +158,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "target", "debufflimit", "32") pfUI:UpdateConfig("unitframes", "target", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "target", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "target", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "target", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "target", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "target", "clickcast", "0") @@ -191,6 +193,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "focus", "debufflimit", "32") pfUI:UpdateConfig("unitframes", "focus", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "focus", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "focus", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "focus", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "focus", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "focus", "clickcast", "0") @@ -224,6 +227,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "group", "debufflimit", "8") pfUI:UpdateConfig("unitframes", "group", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "group", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "group", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "group", "buff_indicator", "1") pfUI:UpdateConfig("unitframes", "group", "debuff_indicator", "1") pfUI:UpdateConfig("unitframes", "group", "clickcast", "0") @@ -258,6 +262,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "grouptarget", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "grouptarget", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "grouptarget", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "grouptarget", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "clickcast", "0") @@ -291,6 +296,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "grouppet", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "grouppet", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "grouppet", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "grouppet", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "grouppet", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouppet", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouppet", "clickcast", "0") @@ -324,6 +330,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "raid", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "raid", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "raid", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "raid", "buff_indicator", "1") pfUI:UpdateConfig("unitframes", "raid", "debuff_indicator", "1") pfUI:UpdateConfig("unitframes", "raid", "clickcast", "0") @@ -357,6 +364,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "ttarget", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "ttarget", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "ttarget", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "ttarget", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "ttarget", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "ttarget", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "ttarget", "clickcast", "0") @@ -390,6 +398,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "pet", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "pet", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "pet", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "pet", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "pet", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "pet", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "pet", "clickcast", "0") @@ -423,6 +432,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "fallback", "debufflimit", "16") pfUI:UpdateConfig("unitframes", "fallback", "debuffperrow", "8") pfUI:UpdateConfig("unitframes", "fallback", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "fallback", "verticalbar", "0") pfUI:UpdateConfig("unitframes", "fallback", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "fallback", "debuff_indicator", "0") pfUI:UpdateConfig("unitframes", "fallback", "clickcast", "0") diff --git a/api/unitframes.lua b/api/unitframes.lua index 6cb8ff27..46dca25f 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -94,6 +94,9 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick) f.hp.bar = CreateFrame("StatusBar", nil, f.hp) f.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") f.hp.bar:SetAllPoints(f.hp) + if f.config.verticalbar == "1" then + f.hp.bar:SetOrientation("VERTICAL") + end f.hp.bar:SetMinMaxValues(0, 100) if pfUI_config.unitframes.custombg == "1" then diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index 03ad4004..ceb36ebe 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -231,6 +231,7 @@ pfUI_translation["deDE"] = { ["Inputbox Width"] = nil, ["Instant"] = nil, ["Invert Health Bar"] = nil, + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = nil, ["Item Durability"] = nil, ["KLH Threat Meter (Dock)"] = nil, diff --git a/env/translations_enUS.lua b/env/translations_enUS.lua index 654eff43..dee9a74d 100644 --- a/env/translations_enUS.lua +++ b/env/translations_enUS.lua @@ -231,6 +231,7 @@ pfUI_translation["enUS"] = { ["Inputbox Width"] = nil, ["Instant"] = nil, ["Invert Health Bar"] = nil, + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = nil, ["Item Durability"] = nil, ["KLH Threat Meter (Dock)"] = nil, diff --git a/env/translations_esES.lua b/env/translations_esES.lua index a80ad19a..df6cd731 100644 --- a/env/translations_esES.lua +++ b/env/translations_esES.lua @@ -231,6 +231,7 @@ pfUI_translation["esES"] = { ["Inputbox Width"] = "Ancho de Inputbox", ["Instant"] = "Instantáneo", ["Invert Health Bar"] = "Invertir la Barra de Salud", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "no se permite en el nombe de perfil", ["Item Durability"] = "Durabilidad del Objeto", ["KLH Threat Meter (Dock)"] = "KLH Threat Meter (Dársena)", diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 80e2db1b..7066f90d 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -231,6 +231,7 @@ pfUI_translation["frFR"] = { ["Inputbox Width"] = "Largeur du champ de saisie du texte", ["Instant"] = "Instantané", ["Invert Health Bar"] = "Inverser les barres de vie", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "n'est pas autorisé comme nom de profil", ["Item Durability"] = "Durabilité des objets", ["KLH Threat Meter (Dock)"] = "KLH Threat Meter (Accroche)", diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 5897d436..3448e92f 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -231,6 +231,7 @@ pfUI_translation["koKR"] = { ["Inputbox Width"] = "챗팅 입력창 넓이", ["Instant"] = "즉시", ["Invert Health Bar"] = "체력바 반전", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "프로필 이름에 허용되지 않습니다.", ["Item Durability"] = "아이템 내구도", ["KLH Threat Meter (Dock)"] = "KLH 어그로 미터기 (독)", diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index 78cf6ffa..0451f319 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -231,6 +231,7 @@ pfUI_translation["ruRU"] = { ["Inputbox Width"] = "Ширина поля ввода", ["Instant"] = "Мгновенно", ["Invert Health Bar"] = "Инвертировать панель здоровья", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "не разрешено в имени профиля", ["Item Durability"] = "Прочность предметов", ["KLH Threat Meter (Dock)"] = "KLH Threat Meter (панель)", diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index 77c2e9ed..7e6de874 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -231,6 +231,7 @@ pfUI_translation["zhCN"] = { ["Inputbox Width"] = "输入框宽度", ["Instant"] = "极快", ["Invert Health Bar"] = "血量反色显示", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "在配置文件名中不允许", ["Item Durability"] = "装备耐久", ["KLH Threat Meter (Dock)"] = "KLH Threat Meter (停靠)", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index 61a3a14b..2591f025 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -231,6 +231,7 @@ pfUI_translation["zhTW"] = { ["Inputbox Width"] = "輸入框寬度", ["Instant"] = "極快", ["Invert Health Bar"] = "血量反色顯示", + ["Enable Vertical Health Bar"] = nil, ["is not allowed in profile name"] = "在設定檔名中不允許", ["Item Durability"] = "裝備耐久", ["KLH Threat Meter (Dock)"] = "KLH Threat Meter (停靠)", diff --git a/modules/gui.lua b/modules/gui.lua index 05c3cae6..06417c4e 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -425,6 +425,7 @@ pfUI:RegisterModule("gui", function () "off:" .. T["Disabled"] } + pfUI.gui.dropdowns.uf_layout = { "default:" .. T["Default"], "tukui:TukUI" @@ -733,6 +734,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.player, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.player, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.player, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.player, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.player, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.player, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.player, "clickcast", "checkbox") @@ -776,6 +778,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.target, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.target, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.target, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.target, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.target, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.target, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.target, "clickcast", "checkbox") @@ -818,6 +821,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.ttarget, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.ttarget, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.ttarget, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.ttarget, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.ttarget, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.ttarget, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.ttarget, "clickcast", "checkbox") @@ -860,6 +864,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.pet, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.pet, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.pet, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.pet, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.pet, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.pet, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.pet, "clickcast", "checkbox") @@ -902,6 +907,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.focus, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.focus, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.focus, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.focus, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.focus, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.focus, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.focus, "clickcast", "checkbox") @@ -970,6 +976,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.raid, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.raid, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.raid, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.raid, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.raid, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.raid, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.raid, "clickcast", "checkbox") @@ -1012,6 +1019,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.group, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.group, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.group, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.group, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.group, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.group, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.group, "clickcast", "checkbox") @@ -1054,6 +1062,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.grouptarget, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.grouptarget, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.grouptarget, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.grouptarget, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.grouptarget, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.grouptarget, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.grouptarget, "clickcast", "checkbox") @@ -1096,6 +1105,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Debuff Limit"], C.unitframes.grouppet, "debufflimit") CreateConfig(this, T["Debuffs Per Row"], C.unitframes.grouppet, "debuffperrow") CreateConfig(this, T["Invert Health Bar"], C.unitframes.grouppet, "invert_healthbar", "checkbox") + CreateConfig(this, T["Enable Vertical Health Bar"], C.unitframes.grouppet, "verticalbar", "checkbox") CreateConfig(this, T["Enable Buff Indicators"], C.unitframes.grouppet, "buff_indicator", "checkbox") CreateConfig(this, T["Enable Debuff Indicators"], C.unitframes.grouppet, "debuff_indicator", "checkbox") CreateConfig(this, T["Enable Clickcast"], C.unitframes.grouppet, "clickcast", "checkbox") diff --git a/modules/thirdparty.lua b/modules/thirdparty.lua index fc9c269d..81733dc1 100644 --- a/modules/thirdparty.lua +++ b/modules/thirdparty.lua @@ -624,14 +624,32 @@ pfUI:RegisterModule("thirdparty", function () if healthWidth + incWidth > width * (1+(OVERHEALPERCENT/100)) then incWidth = width * (1+OVERHEALPERCENT/100) - healthWidth end - frame.incHeal:ClearAllPoints() - frame.incHeal:SetPoint("TOPLEFT", frame.hp.bar, "TOPLEFT", 0, 0) - if frame.config.invert_healthbar == "1" then - frame.incHeal:SetWidth(incWidth) - frame.incHeal:SetFrameStrata("HIGH") - else + local height = frame.hp.bar:GetHeight() / frame.hp.bar:GetEffectiveScale() + local healthHeight = height * (health / maxHealth) + local incHeight = height * healed / maxHealth + if healthHeight + incHeight > height * (1+(OVERHEALPERCENT/100)) then + incHeight = height * (1+OVERHEALPERCENT/100) - healthHeight + end + + frame.incHeal:ClearAllPoints() + if frame.config.verticalbar == "0" then + frame.incHeal:SetPoint("TOPLEFT", frame.hp.bar, "TOPLEFT", 0, 0) frame.incHeal:SetWidth(incWidth + healthWidth) + else + frame.incHeal:SetPoint("BOTTOM", frame.hp.bar, "BOTTOM", 0, 0) + frame.incHeal:SetWidth(width) + frame.incHeal:SetHeight(incHeight + healthHeight) + end + if frame.config.invert_healthbar == "1" then + if frame.config.verticalbar == "0" then + frame.incHeal:SetWidth(incWidth) + frame.incHeal:SetFrameStrata("HIGH") + else + frame.incHeal:SetHeight(incHeight) + frame.incHeal:SetFrameStrata("HIGH") + end + else frame.incHeal:SetFrameStrata("BACKGROUND") end else