Skip to content

Commit

Permalink
Added an option to health-current status to include shields values in…
Browse files Browse the repository at this point in the history
…to health amount (github issue #202)
  • Loading branch information
michaelnpsp committed Feb 9, 2024
1 parent 8dd16a9 commit 3a37998
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 33 deletions.
1 change: 1 addition & 0 deletions Options/locales/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ L["Frequent Updates"] = "Häufigere Aktualisierungen"
-- L["Update frequency"] = ""
-- L["Select the health update frequency."] = ""
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
-- L["Use Health Percent"] = ""
Expand Down
1 change: 1 addition & 0 deletions Options/locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ L["Instant"] = true
L["Update frequency"] = true
L["Select the health update frequency."] = true
L["Add shields to health percent"] = true
L["Add shields to health amount"] = true

-- health-low status
L["Use Health Percent"] = true
Expand Down
1 change: 1 addition & 0 deletions Options/locales/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ L["Instant"] = "Instantaneo"
L["Update frequency"] = "Frecuencia de actualizaciones"
L["Select the health update frequency."] = "Elige la frequencia de actualización de las vidas."
L["Add shields to health percent"] = "Añade escudos al porcentaje de vida"
L["Add shields to health amount"] = "Añade escudos al valor de vida"

-- health-low status
L["Use Health Percent"] = "Usar Porcentajes"
Expand Down
1 change: 1 addition & 0 deletions Options/locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ L["Frequent Updates"] = "Mises à jour fréquentes"
-- L["Update frequency"] = ""
-- L["Select the health update frequency."] = ""
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
-- L["Use Health Percent"] = ""
Expand Down
1 change: 1 addition & 0 deletions Options/locales/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ L["Normal"] = "Normale"
-- L["Update frequency"] = ""
-- L["Select the health update frequency."] = ""
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
-- L["Use Health Percent"] = ""
Expand Down
1 change: 1 addition & 0 deletions Options/locales/koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ L["Instant"] = "즉시"
L["Update frequency"] = "업데이트 빈도"
L["Select the health update frequency."] = "생명력 업데이트 빈도 선택"
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
L["Use Health Percent"] = "생명력 비율(%) 사용"
Expand Down
1 change: 1 addition & 0 deletions Options/locales/ptBR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ L["%s Color"] = "%s"
-- L["Update frequency"] = ""
-- L["Select the health update frequency."] = ""
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
-- L["Use Health Percent"] = ""
Expand Down
1 change: 1 addition & 0 deletions Options/locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ L["Instant"] = "мгновенно"
L["Update frequency"] = "Частота обновления"
L["Select the health update frequency."] = "Выберите частоту обновления здоровья."
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
L["Use Health Percent"] = "Использовать процент здоровья"
Expand Down
1 change: 1 addition & 0 deletions Options/locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ L["Instant"] = "立刻"
L["Update frequency"] = "更新的频率"
L["Select the health update frequency."] = "选择生命值更新频率"
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
L["Use Health Percent"] = "使用生命值的百分比"
Expand Down
1 change: 1 addition & 0 deletions Options/locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ L["Normal"] = "一般"
-- L["Update frequency"] = ""
-- L["Select the health update frequency."] = ""
-- L["Add shields to health percent"] = ""
-- L["Add shields to health amount"] = ""

-- health-low status
-- L["Use Health Percent"] = ""
Expand Down
15 changes: 14 additions & 1 deletion Options/modules/statuses/StatusHealth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Grid2Options:RegisterStatusOptions("health-current", "health", function(self, st
end,
}
else
options.healthShield = {
options.healthPercentShield = {
type = "toggle",
tristate = false,
width = "full",
Expand All @@ -126,6 +126,19 @@ Grid2Options:RegisterStatusOptions("health-current", "health", function(self, st
status:Refresh()
end,
}
options.healthAmountShield = {
type = "toggle",
tristate = false,
width = "full",
order = 51,
name = L["Add shields to health amount"],
desc = L["Add shields to health amount"],
get = function () return status.dbx.addAmountShield end,
set = function (_, v)
status.dbx.addAmountShield = v or nil
status:Refresh()
end,
}
end
options.deadAsFullHealth = {
type = "toggle",
Expand Down
73 changes: 41 additions & 32 deletions modules/StatusHealth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ end
-- health-current status
HealthCurrent.IsActive = Grid2.statusLibrary.IsActive

-- percent health
local function HealthCurrent_ShieldUpdate(unit)
if unit_is_valid[unit] then
HealthCurrent:UpdateIndicators(unit)
Expand All @@ -241,20 +242,6 @@ local function HealthCurrent_GetPercentTextShield(self, unit)
return fmt( fmtPercent, m == 0 and 0 or (UnitHealth(unit)+UnitGetTotalAbsorbs(unit))*100/m )
end

function HealthCurrent:OnEnable()
Health_Enable(self)
if self.addShield then
RegisterEvent( "UNIT_ABSORB_AMOUNT_CHANGED", HealthCurrent_ShieldUpdate )
end
end

function HealthCurrent:OnDisable()
Health_Disable(self)
if self.addShield then
UnregisterEvent( "UNIT_ABSORB_AMOUNT_CHANGED" )
end
end

local function HealthCurrent_GetPercentSTD(self,unit)
local m = UnitHealthMax(unit)
return m == 0 and 0 or UnitHealth(unit) / m
Expand All @@ -266,20 +253,37 @@ local function HealthCurrent_GetPercentDFH(self, unit)
return m == 0 and 1 or UnitHealth(unit) / m
end

if Grid2.isClassic then
function HealthCurrent:GetText1(unit)
local h = UnitHealth(unit)
return h<1000 and fmt("%d",h) or fmt("%.1fk",h/1000)
end
function HealthCurrent:GetText2(unit)
return tostring(UnitHealth(unit))
-- text health
local function HealthCurrent_GetTextClassic(self, unit)
local h = UnitHealth(unit)
return h<1000 and fmt("%d",h) or fmt("%.1fk",h/1000)
end

local function HealthCurrent_GetTextClassicRaw(self, unit)
return tostring(UnitHealth(unit))
end

local function HealthCurrent_GetTextRetail(self, unit)
return fmt("%.1fk", UnitHealth(unit) / 1000)
end

local function HealthCurrent_GetTextRetailShield(self, unit)
return fmt("%.1fk", (UnitHealth(unit)+UnitGetTotalAbsorbs(unit)) / 1000)
end

function HealthCurrent:OnEnable()
Health_Enable(self)
if self.addShield then
RegisterEvent( "UNIT_ABSORB_AMOUNT_CHANGED", HealthCurrent_ShieldUpdate )
end
else
function HealthCurrent:GetText1(unit)
return fmt("%.1fk", UnitHealth(unit) / 1000)
end

function HealthCurrent:OnDisable()
Health_Disable(self)
if self.addShield then
UnregisterEvent( "UNIT_ABSORB_AMOUNT_CHANGED" )
end
end
HealthCurrent.GetText = HealthCurrent.GetText1

function HealthCurrent:GetColor(unit)
local f,t
Expand All @@ -293,14 +297,19 @@ function HealthCurrent:GetColor(unit)
end

function HealthCurrent:UpdateDB()
local dbx = self.dbx
fmtPercent = Grid2.db.profile.formatting.percentFormat
self.addShield = Grid2.isWoW90 and self.dbx.addPercentShield or nil
self.GetText = self.dbx.displayRawNumbers and self.GetText2 or self.GetText1
self.GetPercent = self.dbx.deadAsFullHealth and HealthCurrent_GetPercentDFH or HealthCurrent_GetPercentSTD
self.GetPercentText = self.addShield and HealthCurrent_GetPercentTextShield or nil
self.color1 = Grid2:MakeColor(self.dbx.color1)
self.color2 = Grid2:MakeColor(self.dbx.color2)
self.color3 = Grid2:MakeColor(self.dbx.color3)
if Grid2.isClassic then
self.GetText = dbx.displayRawNumbers and HealthCurrent_GetTextClassicRaw or HealthCurrent_GetTextClassic
else
self.addShield = (dbx.addPercentShield or dbx.addAmountShield) or nil
self.GetText = dbx.addAmountShield and HealthCurrent_GetTextRetailShield or HealthCurrent_GetTextRetail
self.GetPercentText = dbx.addPercentShield and HealthCurrent_GetPercentTextShield or nil
end
self.GetPercent = dbx.deadAsFullHealth and HealthCurrent_GetPercentDFH or HealthCurrent_GetPercentSTD
self.color1 = Grid2:MakeColor(dbx.color1)
self.color2 = Grid2:MakeColor(dbx.color2)
self.color3 = Grid2:MakeColor(dbx.color3)
Health_UpdateStatuses()
end

Expand Down

0 comments on commit 3a37998

Please sign in to comment.