From 95b91e5697181d53610ecd6eb89d353b625f628d Mon Sep 17 00:00:00 2001 From: d87 Date: Wed, 23 Mar 2022 11:07:26 +0700 Subject: [PATCH] HealComm disabled by default in classic --- Aptechka.lua | 60 +++++++++++++++++++------------------- Options/GlobalSettings.lua | 13 +++++++++ 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Aptechka.lua b/Aptechka.lua index 90e06db..670de8e 100644 --- a/Aptechka.lua +++ b/Aptechka.lua @@ -37,7 +37,6 @@ if apiLevel <= 2 then UnitHasVehicleUI = dummyFalse UnitInVehicle = dummyFalse UnitUsingVehicle = dummyFalse - UnitGetIncomingHeals = dummy0 UnitGetTotalAbsorbs = dummy0 UnitGetTotalHealAbsorbs = dummy0 UnitPhaseReason = dummyFalse @@ -140,6 +139,7 @@ local tankUnits = {} local staggerUnits = {} local LibTranslit = LibStub("LibTranslit-1.0") +local GetIncomingHealsCustom -- upvalue to swap based on HealComm usage -- Classic things local HealComm local LibClassicDurations = LibStub("LibClassicDurations", true) @@ -159,6 +159,7 @@ _G.BINDING_NAME_APTECHKA_DEBUFF_TOOLTIP_HOLD = L"Debuff Tooltip Toggle(Hold)" local defaults = { global = { + useHealComm = false, disableBlizzardPlayer = false, disableBlizzardParty = true, hideBlizzardRaid = true, @@ -377,7 +378,7 @@ function Aptechka.PLAYER_LOGIN(self,event,arg1) end if config.enableIncomingHeals then - if apiLevel <= 2 then + if apiLevel <= 2 and Aptechka.db.global.useHealComm then HealComm = LibStub:GetLibrary("LibHealComm-4.0",true); local incomingHealIgnoreHots = false if HealComm then @@ -390,6 +391,32 @@ function Aptechka.PLAYER_LOGIN(self,event,arg1) HealComm.RegisterCallback(self, "HealComm_HealStarted", "HealUpdated"); HealComm.RegisterCallback(self, "HealComm_HealStopped", "HealUpdated"); end + + function Aptechka:HealUpdated(event, casterGUID, spellID, healType, endTime, ...) + for i=1,select('#', ...) do + local targetGUID = select(i, ...) + local unit = guidMap[targetGUID] + if unit then + Aptechka:UNIT_HEAL_PREDICTION(nil, unit, targetGUID) + end + end + end + + local incomingHealTimeframe = 3.5 + + GetIncomingHealsCustom = function (unit, excludePlayer) + local guid = UnitGUID(unit) + local heal = HealComm:GetHealAmount(guid, HealComm.AptechkaHealType, GetTime()+incomingHealTimeframe) + return heal or 0 + end + + function Aptechka.UNIT_HEAL_PREDICTION(self,event,unit) + self:UNIT_HEALTH(event, unit) + + local heal = GetIncomingHealsCustom(unit, false) + local showHeal = (heal and heal > threshold) + SetJob(unit, config.IncomingHealStatus, showHeal, "INCOMING_HEAL", heal) + end else self:RegisterEvent("UNIT_HEAL_PREDICTION") end @@ -999,7 +1026,7 @@ function Aptechka:ReconfigureProtected() Aptechka:UpdateBorder() end -local function GetIncomingHealsCustom(unit, excludePlayer) +GetIncomingHealsCustom = function(unit, excludePlayer) local heal = UnitGetIncomingHeals(unit) if excludePlayer then local myheal = UnitGetIncomingHeals(unit, "player") @@ -1014,33 +1041,6 @@ function Aptechka.UNIT_HEAL_PREDICTION(self,event,unit) self:UNIT_HEALTH(event, unit) end -if apiLevel <= 2 then - function Aptechka:HealUpdated(event, casterGUID, spellID, healType, endTime, ...) - for i=1,select('#', ...) do - local targetGUID = select(i, ...) - local unit = guidMap[targetGUID] - if unit then - Aptechka:UNIT_HEAL_PREDICTION(nil, unit, targetGUID) - end - end - end - - local incomingHealTimeframe = 3.5 - - GetIncomingHealsCustom = function (unit, excludePlayer) - local guid = UnitGUID(unit) - local heal = HealComm:GetHealAmount(guid, HealComm.AptechkaHealType, GetTime()+incomingHealTimeframe) - return heal or 0 - end - - function Aptechka.UNIT_HEAL_PREDICTION(self,event,unit) - self:UNIT_HEALTH(event, unit) - - local heal = GetIncomingHealsCustom(unit, false) - local showHeal = (heal and heal > threshold) - SetJob(unit, config.IncomingHealStatus, showHeal, "INCOMING_HEAL", heal) - end -end function Aptechka:GetIncomingHeals(...) return GetIncomingHealsCustom(...) end diff --git a/Options/GlobalSettings.lua b/Options/GlobalSettings.lua index 57d456d..95a39d3 100644 --- a/Options/GlobalSettings.lua +++ b/Options/GlobalSettings.lua @@ -243,6 +243,19 @@ function ns.MakeGlobalSettings() Aptechka:UpdateDebuffScanningMethod() end }, + useHealComm = { + name = L"Use LibHealComm"..newFeatureIcon, + desc = L"Gives hots in incoming healing, may cause errors", + type = "toggle", + disabled = not isClassic, + width = "full", + order = 17, + get = function(info) return Aptechka.db.global.useHealComm end, + set = function(info, v) + Aptechka.db.global.useHealComm = not Aptechka.db.global.useHealComm + Aptechka:PrintReloadUIWarning() + end + }, useCLH = { name = L"Use LibCLHealth", desc = L"More frequent health updates based combat log",