Skip to content

Commit

Permalink
Option to format missing health with incoming healing
Browse files Browse the repository at this point in the history
  • Loading branch information
d87 committed Nov 17, 2021
1 parent 3794785 commit 57c1363
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Aptechka.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ local ignoreplayer
local fgShowMissing
local gradientHealthColor
local damageEffect
local mergedIncomingHealing -- Show incoimng healing text in the same widget as missing health

local config = AptechkaDefaultConfig
Aptechka.loadedAuras = {}
Expand Down Expand Up @@ -898,6 +899,7 @@ function Aptechka:UpdateUnprotectedUpvalues()
fgShowMissing = Aptechka.db.profile.fgShowMissing
gradientHealthColor = Aptechka.db.profile.gradientHealthColor
damageEffect = Aptechka.db.profile.damageEffect
mergedIncomingHealing = AptechkaConfigMerged.HealthTextStatus.formatType == "MISSING_HEALING_SHORT"
enableTraceheals = config.enableTraceHeals and next(traceheals)
enableAuraEvents = Aptechka.db.profile.auraUpdateEffect
enableFloatingIcon = Aptechka.db.profile.showFloatingIcons
Expand Down Expand Up @@ -1105,7 +1107,9 @@ function Aptechka.FrameUpdateHealth(self, unit, event)
if gradientHealthColor then
FrameSetJob(self, config.HealthBarColor, true, "HealthBar", h)
end
FrameSetJob(self, config.HealthTextStatus, ((hm-h) > hm*0.05), nil, h, hm )
incomingHeal = mergedIncomingHealing and incomingHeal or 0
-- h-hm-incomingHeal-h is not the missing+incoming, but kind of a flag if either deviate more than 5% from max
FrameSetJob(self, config.HealthTextStatus, ((h-hm-incomingHeal) < hm*-0.05), nil, h, hm, incomingHeal)

if not event then return end -- no death checks on CLH

Expand Down
3 changes: 3 additions & 0 deletions Options/StatusConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function ns.MakeStatusConfig()
AptechkaConfigCustom.WIDGET[status] = nil
end
AptechkaConfigMerged[status] = CopyTable(AptechkaDefaultConfig[status])
Aptechka:UpdateUnprotectedUpvalues() -- for health text formatting
end,
order = 16,
},
Expand All @@ -172,6 +173,7 @@ function ns.MakeStatusConfig()
PERCENTAGE = L"Percentage",
PERCENTAGE_NOSIGN = L"Percentage No Sign",
MISSING_VALUE_SHORT = L"Missing Value",
MISSING_HEALING_SHORT = L"Missing Health excl. Incoming Healing",
-- VALUE_SHORT = L"Value",
},
get = function() return AptechkaConfigMerged[status].formatType end,
Expand All @@ -180,6 +182,7 @@ function ns.MakeStatusConfig()
Aptechka.util.MakeTables(AptechkaConfigCustom, "WIDGET", status)
AptechkaConfigCustom.WIDGET[status].formatType = value

Aptechka:UpdateUnprotectedUpvalues()
Aptechka:ReapplyJob(AptechkaConfigMerged[status])
end,
order = 3.5,
Expand Down
2 changes: 2 additions & 0 deletions config.classic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ local set = helpers.set
local apiLevel = math.floor(select(4,GetBuildInfo())/10000)
if not apiLevel == 1 then return end

config.HealthTextStatus.formatType = "MISSING_HEALING_SHORT"

if apiLevel <= 3 then
config.DefaultWidgets.totemCluster1 = { type = "Indicator", width = 5, height = 5, point = "TOPLEFT", x = pixelperfect(6), y = 0 }
config.DefaultWidgets.totemCluster2 = { type = "Indicator", width = 5, height = 5, point = "TOPLEFT", x = pixelperfect(12), y = 0 }
Expand Down
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ config.DeadStatus = { name = "Dead", assignto = set("text2","healthColor"), colo
config.GhostStatus = { name = "Ghost", assignto = set("text2","healthColor"), color = {.05,.05,.05}, textcolor = {0,1,0}, text = "GHOST", priority = 62}
config.OfflineStatus = { name = "Offline", assignto = set("text2","text3","healthColor"), color = {0.5,0.5,0.5}, textcolor = {0,1,0}, text = "OFFLINE", priority = 70}
config.AwayStatus = { name = "AFK", assignto = set("text2","text3"), color = {0.4,0.4,0.4}, textcolor = {1,0.8,0}, text = "AFK", priority = 15}
config.IncomingHealStatus = { name = "IncHealText", assignto = set("text2"), color = { 0, 1, 0}, priority = 15 }
config.IncomingHealStatus = { name = "IncHealText", assignto = set(), color = { 0, 1, 0}, priority = 15 }
-- config.AbsorbTextStatus = { name = "AbsorbText", assignto = set("text2"), color = { 0.7, 0.7, 1 }, priority = 11, formatType = "PERCENTAGE" }
config.HealthTextStatus = { name = "HealthText", assignto = set("text2"), color = { 54/255, 201/255, 99/256 }, priority = 10, formatType = "MISSING_VALUE_SHORT" }
config.UnitNameStatus = { name = "UnitName", assignto = set("text1"), classcolor = true, priority = 20 }
Expand Down
2 changes: 2 additions & 0 deletions config.tbc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ local apiLevel = math.floor(select(4,GetBuildInfo())/10000)
local isBC = apiLevel == 2
if not isBC then return end

config.HealthTextStatus.formatType = "MISSING_HEALING_SHORT"

if apiLevel <= 3 then
config.DefaultWidgets.totemCluster1 = { type = "Indicator", width = 5, height = 5, point = "TOPLEFT", x = pixelperfect(6), y = 0 }
config.DefaultWidgets.totemCluster2 = { type = "Indicator", width = 5, height = 5, point = "TOPLEFT", x = pixelperfect(12), y = 0 }
Expand Down
31 changes: 25 additions & 6 deletions frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ end

local function formatMissingHealth(mh)
if mh < 1000 then
return "-%d", mh
return "%d", mh
elseif mh < 10000 then
return "-%.1fk", mh / 1000
return "%.1fk", mh / 1000
else
return "-%.0fk", mh / 1000
return "%.0fk", mh / 1000
end
end

Expand All @@ -263,9 +263,27 @@ local function formatShorten(v)
end
end

local function formatShortenPositiveHealing(v)
if v < 1000 then
return "|cff00ff00+%d|r", v
elseif v < 10000 then
return "|cff00ff00+%.1fk|r", v / 1000
else
return "|cff00ff00+%.0fk|r", v / 1000
end
end

local TextFormatters = {
MISSING_VALUE_SHORT = function(cur, max)
return string_format(formatMissingHealth(max - cur))
return string_format(formatMissingHealth(cur-max))
end,
MISSING_HEALING_SHORT = function(cur, max, incomingHeal)
local diff = cur-max+incomingHeal
if diff < 0 then
return string_format(formatShorten(cur-max+incomingHeal))
else
return string_format(formatShortenPositiveHealing(cur-max+incomingHeal))
end
end,
VALUE = function(cur, max)
return cur
Expand All @@ -288,8 +306,9 @@ end
local contentNormalizers = {}
function contentNormalizers.HealthText(job, state, contentType, ...)
local timerType, cur, max, count, icon, text, r,g,b, texture, texCoords
cur, max = ...
text = FormatText(job, cur, max)
local incomingHeal
cur, max, incomingHeal = ...
text = FormatText(job, cur, max, incomingHeal)
r,g,b = GetClassOrTextColor(job, state)
return timerType, cur, max, count, icon, text, r,g,b, texture, texCoords
end
Expand Down

0 comments on commit 57c1363

Please sign in to comment.