From 36bc7248bd09b577e14f11bce853efc5506050cc Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 19 Oct 2016 22:24:26 +0200 Subject: [PATCH] option to invert raidframes and show missing hp --- modules/config.lua | 2 ++ modules/gui.lua | 2 ++ modules/raid.lua | 16 +++++++++++++++- modules/thirdparty.lua | 12 +++++++++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/config.lua b/modules/config.lua index 66a96cfb..a6d90162 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -15,6 +15,8 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "target", "width", "200") pfUI:UpdateConfig("unitframes", "target", "height", "50") pfUI:UpdateConfig("unitframes", "target", "pheight", "10") + pfUI:UpdateConfig("unitframes", "raid", "invert_healthbar", "0") + pfUI:UpdateConfig("unitframes", "raid", "show_missing", "0") pfUI:UpdateConfig("unitframes", "raid", "clickcast", "") pfUI:UpdateConfig("unitframes", "raid", "clickcast_shift", "") pfUI:UpdateConfig("unitframes", "raid", "clickcast_alt", "") diff --git a/modules/gui.lua b/modules/gui.lua index 8f7798ba..c7c17f59 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -516,6 +516,8 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Target width", pfUI_config.unitframes.target, "width") pfUI.gui:CreateConfig(pfUI.gui.uf, "Target height", pfUI_config.unitframes.target, "height") pfUI.gui:CreateConfig(pfUI.gui.uf, "Target powerbar height", pfUI_config.unitframes.target, "pheight") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Raid-healthbar", pfUI_config.unitframes.raid, "invert_healthbar", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show missing HP on raidframes", pfUI_config.unitframes.raid, "show_missing", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe", pfUI_config.unitframes.raid, "clickcast") pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Shift)", pfUI_config.unitframes.raid, "clickcast_shift") pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Alt)", pfUI_config.unitframes.raid, "clickcast_alt") diff --git a/modules/raid.lua b/modules/raid.lua index 9913506b..aae68ee7 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -54,7 +54,9 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i].hp.bar:SetPoint("BOTTOMRIGHT", pfUI.uf.raid[i].hp, "BOTTOMRIGHT", -3, 3) pfUI.uf.raid[i].hp.bar:SetStatusBarColor(0,1,0) + pfUI.uf.raid[i].hp.bar:SetMinMaxValues(0, 100) + pfUI.uf.raid[i].hp.bar:SetValue(0) pfUI.uf.raid[i].power = CreateFrame("Frame",nil, pfUI.uf.raid[i]) pfUI.uf.raid[i].power:SetBackdrop(pfUI.backdrop) @@ -191,6 +193,12 @@ pfUI:RegisterModule("raid", function () local hpReal = UnitHealth("raid"..this.id) local hpDiff = abs(hpReal - hpDisplay) + if pfUI_config.unitframes.raid.invert_healthbar == "1" then + hpDisplay = this.hp.bar:GetValue() + hpReal = UnitHealthMax("raid"..this.id) - UnitHealth("raid"..this.id) + hpDiff = abs(hpReal - hpDisplay) + end + if hpDisplay < hpReal then this.hp.bar:SetValue(hpDisplay + ceil(hpDiff / pfUI_config.unitframes.animation_speed)) elseif hpDisplay > hpReal then @@ -224,7 +232,13 @@ pfUI:RegisterModule("raid", function () this.power.bar:SetValue(0) end if UnitName("raid"..this.id) then - this.caption:SetText(UnitName("raid"..this.id)) + if UnitHealthMax("raid"..this.id) ~= UnitHealth("raid"..this.id) and pfUI_config.unitframes.raid.show_missing == "1" then + this.caption:SetText("-" .. UnitHealthMax("raid"..this.id) - UnitHealth("raid"..this.id)) + this.caption:SetTextColor(1,.3,.3) + else + this.caption:SetText(UnitName("raid"..this.id)) + this.caption:SetTextColor(1,1,1) + end this.caption:SetAllPoints(this.hp.bar) end end) diff --git a/modules/thirdparty.lua b/modules/thirdparty.lua index 987e9f5a..e47fc253 100644 --- a/modules/thirdparty.lua +++ b/modules/thirdparty.lua @@ -243,6 +243,10 @@ pfUI:RegisterModule("thirdparty", function () local healed = HealComm:getHeal(UnitName(unit)) local health, maxHealth = UnitHealth(unit), UnitHealthMax(unit) + if strsub(unit,0,4) == "raid" and pfUI_config.unitframes.raid.invert_healthbar == "1" then + health = maxHealth - health + end + if( healed > 0 and (health < maxHealth or OVERHEALPERCENT > 0 )) and frame:IsVisible() then frame.incHeal:Show() local healthWidth = frame:GetWidth() * (health / maxHealth) @@ -252,7 +256,13 @@ pfUI:RegisterModule("thirdparty", function () end frame.incHeal:SetWidth(incWidth) frame.incHeal:ClearAllPoints() - frame.incHeal:SetPoint("TOPLEFT", frame, "TOPLEFT", healthWidth-3, -3) + + if strsub(unit,0,4) == "raid" and pfUI_config.unitframes.raid.invert_healthbar == "1" then + frame.incHeal:SetPoint("TOPLEFT", frame, "TOPLEFT", 3, -3) + frame.incHeal:SetFrameStrata("HIGH") + else + frame.incHeal:SetPoint("TOPLEFT", frame, "TOPLEFT", healthWidth-3, -3) + end else frame.incHeal:Hide() end