From 4b221c263625759865ee01e6834ea653cfb19bfc Mon Sep 17 00:00:00 2001 From: "F. Dekker" Date: Sat, 26 Jan 2013 20:47:50 +0100 Subject: [PATCH 1/3] Blizzards incoming heals notification - A darker bar below the healthbar as indication for the incoming heal - A checkbox under config to enable/disable incoming heals display --- PerfectRaid.toc | 1 + PerfectRaid_Config.lua | 9 +++- PerfectRaid_IncomingHeals.lua | 105 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 PerfectRaid_IncomingHeals.lua diff --git a/PerfectRaid.toc b/PerfectRaid.toc index 33a2238..d7046d8 100644 --- a/PerfectRaid.toc +++ b/PerfectRaid.toc @@ -28,3 +28,4 @@ PerfectRaid_Range.lua PerfectRaid_Highlight.lua PerfectRaid_Config.lua PerfectRaid_RaidIcons.lua +PerfectRaid_IncomingHeals.lua diff --git a/PerfectRaid_Config.lua b/PerfectRaid_Config.lua index 5abaf80..2e1a422 100644 --- a/PerfectRaid_Config.lua +++ b/PerfectRaid_Config.lua @@ -86,6 +86,10 @@ function Config:CreateOptions(opt) iconPositionDropDown:SetWidth(200); iconPositionDropDown:SetPoint("LEFT", check, "RIGHT", 100, 0) options.iconposition = iconPositionDropDown; + + local check = CreateFrame("CheckButton", "PRConfig_IncomingHeals", options, "PRCheckTemplate") + check.Label:SetText(L["Show incoming heals"]) + table.insert(options.widgets, check) local cancel = CreateFrame("Button", "PRConfig_Cancel", options, "PRButtonTemplate") cancel:SetText(L["Cancel"]) @@ -105,14 +109,16 @@ function Config:CreateOptions(opt) local clickCast = PRConfig_ClickCast:GetChecked() and true or false local locked = PRConfig_Lock:GetChecked() and true or false local showRaidIcons = PRConfig_RaidIcons:GetChecked() and true or false + local showIncomingHeals = PRConfig_IncomingHeals:GetChecked() and true or false local raidIconPosition = UIDropDownMenu_GetSelectedValue(PRConfig_IconPositionDropDown) - + PerfectRaid.db.profile.hideparty = hideParty PerfectRaid.db.profile.showmanaonly = showMana PerfectRaid.db.profile.clickcast = clickCast PerfectRaid.db.profile.locked = locked PerfectRaid.db.profile.showraidicons = showRaidIcons PerfectRaid.db.profile.raidiconposition = raidIconPosition + PerfectRaid.db.profile.showincomingheals = showIncomingHeals PerfectRaid:TriggerMessage("PERFECTRAID_CONFIG_CHANGED") Config:PartyVisibility() @@ -124,6 +130,7 @@ function Config:CreateOptions(opt) PRConfig_ClickCast:SetChecked(PerfectRaid.db.profile.clickcast) PRConfig_Lock:SetChecked(PerfectRaid.db.profile.locked) PRConfig_RaidIcons:SetChecked(PerfectRaid.db.profile.showraidicons) + PRConfig_IncomingHeals:SetChecked(PerfectRaid.db.profile.showincomingheals) UIDropDownMenu_SetSelectedValue(PRConfig_IconPositionDropDown,PerfectRaid.db.profile.raidiconposition) end diff --git a/PerfectRaid_IncomingHeals.lua b/PerfectRaid_IncomingHeals.lua new file mode 100644 index 0000000..2729dde --- /dev/null +++ b/PerfectRaid_IncomingHeals.lua @@ -0,0 +1,105 @@ +--[[------------------------------------------------------------------------- + * + * IncomingHeals module for PerfectRaid addon. + * + * Written by: Panoramix + * Version: 1.0 + * +---------------------------------------------------------------------------]] + + +local IncomingHeals = PerfectRaid:NewModule("PerfectRaid-IncomingHeals") + +local L = PerfectRaidLocals +local utils, frames + +function IncomingHeals:Initialize() + + frames = PerfectRaid.frames + utils = PerfectRaid.utils + + self:RegisterMessage("DONGLE_PROFILE_CHANGED") + self:RegisterMessage("PERFECTRAID_CONFIG_CHANGED") +end + + +function IncomingHeals:DONGLE_PROFILE_CHANGED(event, addon, svname, name) + if svname == "PerfectRaidDB" then + IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals) + end +end + +function IncomingHeals:PERFECTRAID_CONFIG_CHANGED(event, addon, svname, name) + IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals) +end + +function IncomingHeals:Enable() + IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals) +end + +function IncomingHeals:EnableIncomingHeals(value) + if value then + self:RegisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals") + else + self:UnregisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals") + end +end + + +function IncomingHeals:ConfigureButton( button ) + + local bar = CreateFrame("StatusBar", nil, button) + button.incominghealsbar = bar + +end + +function IncomingHeals:UpdateButtonLayout( button ) + + button.incominghealsbar:ClearAllPoints() + button.incominghealsbar:SetPoint("TOPLEFT", button.leftbox, "TOPRIGHT", 0, -1) + button.incominghealsbar:SetPoint("BOTTOMRIGHT", button.rightbox, "BOTTOMLEFT", 0, 1) + button.incominghealsbar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth") + button.incominghealsbar:SetFrameLevel( button.healthbar:GetFrameLevel()-1 ) + button.incominghealsbar:SetStatusBarColor( 0.3, 0.5, 0.3 ) + button.incominghealsbar:Hide() + +end + +function IncomingHeals:UpdateIncomingHeals( event, target ) + + -- not the right unit + if target == "target" then return end + + local health = UnitHealth(target) + local maxhealth = UnitHealthMax(target) + local healinc = UnitGetIncomingHeals(target) + + -- not correct healinc or health + if health == null or healinc == null then return end + + local healthsum = health + healinc + + -- adjust healthsum to maxhealth + if healthsum > maxhealth then healthsum = maxhealth end + + for unit, tbl in pairs(frames) do + + if UnitIsUnit( target, unit ) then + + for frame in pairs(frames[unit]) do + + if healinc == 0 or health == maxhealth then + frame.incominghealsbar:Hide() + else + frame.incominghealsbar:SetMinMaxValues(0, maxhealth) + frame.incominghealsbar:SetValue(healthsum) + frame.incominghealsbar:Show() + end + end + + break + end + end + + +end \ No newline at end of file -- 1.7.9.5 From f4426506d95dab5fc0b4058ecd5a5b74b10e42a1 Mon Sep 17 00:00:00 2001 From: "F. Dekker" Date: Sat, 16 Mar 2013 13:58:20 +0100 Subject: [PATCH 2/3] Added absorbbar below the health and incoming healbar. Color dark yellow. The absorb bar will show the health that will be absorbed. The absorb bar has the length of the current health + heal inc + absorb bar, up to the max health. --- PerfectRaid_IncomingHeals.lua | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/PerfectRaid_IncomingHeals.lua b/PerfectRaid_IncomingHeals.lua index 2729dde..524c34c 100644 --- a/PerfectRaid_IncomingHeals.lua +++ b/PerfectRaid_IncomingHeals.lua @@ -40,17 +40,21 @@ end function IncomingHeals:EnableIncomingHeals(value) if value then self:RegisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals") + self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateIncomingHeals") else - self:UnregisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals") + self:UnregisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals") + self:UnregisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateIncomingHeals") end end function IncomingHeals:ConfigureButton( button ) - local bar = CreateFrame("StatusBar", nil, button) - button.incominghealsbar = bar + local inchealbar = CreateFrame("StatusBar", nil, button) + button.incominghealsbar = inchealbar + local absorbbar = CreateFrame("StatusBar", nil, button) + button.absorbbar = absorbbar end function IncomingHeals:UpdateButtonLayout( button ) @@ -63,6 +67,14 @@ function IncomingHeals:UpdateButtonLayout( button ) button.incominghealsbar:SetStatusBarColor( 0.3, 0.5, 0.3 ) button.incominghealsbar:Hide() + button.absorbbar:ClearAllPoints() + button.absorbbar:SetPoint("TOPLEFT", button.leftbox, "TOPRIGHT", 0, -1) + button.absorbbar:SetPoint("BOTTOMRIGHT", button.rightbox, "BOTTOMLEFT", 0, 1) + button.absorbbar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth") + button.absorbbar:SetFrameLevel( button.healthbar:GetFrameLevel()-2 ) + button.absorbbar:SetStatusBarColor( 0.83, 0.45, 0.09 ) + button.absorbbar:Hide() + end function IncomingHeals:UpdateIncomingHeals( event, target ) @@ -73,14 +85,17 @@ function IncomingHeals:UpdateIncomingHeals( event, target ) local health = UnitHealth(target) local maxhealth = UnitHealthMax(target) local healinc = UnitGetIncomingHeals(target) + local absorbinc = UnitGetTotalAbsorbs(target) -- not correct healinc or health if health == null or healinc == null then return end - local healthsum = health + healinc + local healthincsum = health + healinc + local healthabsorbsum = health + healinc + absorbinc -- adjust healthsum to maxhealth - if healthsum > maxhealth then healthsum = maxhealth end + if healthincsum > maxhealth then healthincsum = maxhealth end + if healthabsorbsum > maxhealth then healthabsorbsum = maxhealth end for unit, tbl in pairs(frames) do @@ -88,13 +103,24 @@ function IncomingHeals:UpdateIncomingHeals( event, target ) for frame in pairs(frames[unit]) do - if healinc == 0 or health == maxhealth then + -- heal inc + if healinc == 0 or health == maxhealth then frame.incominghealsbar:Hide() else frame.incominghealsbar:SetMinMaxValues(0, maxhealth) - frame.incominghealsbar:SetValue(healthsum) + frame.incominghealsbar:SetValue(healthincsum) frame.incominghealsbar:Show() end + + -- absorb inc + if absorbinc == 0 or health == maxhealth then + frame.absorbbar:Hide() + else + frame.absorbbar:SetMinMaxValues(0, maxhealth) + frame.absorbbar:SetValue(healthabsorbsum) + frame.absorbbar:Show() + end + end break -- 1.7.9.5 From f648bfe253009d5520bbcaaad477b6031d140ecf Mon Sep 17 00:00:00 2001 From: "F. Dekker" Date: Sat, 16 Mar 2013 15:10:48 +0100 Subject: [PATCH 3/3] Bugfix: - removed break so that all frames would get incheal + absorb update --- PerfectRaid_IncomingHeals.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/PerfectRaid_IncomingHeals.lua b/PerfectRaid_IncomingHeals.lua index 524c34c..885185f 100644 --- a/PerfectRaid_IncomingHeals.lua +++ b/PerfectRaid_IncomingHeals.lua @@ -123,7 +123,6 @@ function IncomingHeals:UpdateIncomingHeals( event, target ) end - break end end -- 1.7.9.5