2022-03-03 23:41:54 +01:00
|
|
|
local pairs, ipairs = pairs, ipairs
|
2021-05-17 16:49:54 +02:00
|
|
|
local floor = math.floor
|
2022-03-03 23:41:54 +01:00
|
|
|
local str_find, str_gsub, str_sub, tinsert = string.find, string.gsub, string.sub, table.insert
|
2021-06-16 14:34:17 +02:00
|
|
|
local UnitHealth, UnitHealthMax, UnitName, UnitExists, UnitIsDeadOrGhost = UnitHealth, UnitHealthMax, UnitName, UnitExists, UnitIsDeadOrGhost
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
local CreateFrame = CreateFrame
|
|
|
|
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
|
|
|
|
|
|
|
local Gladdy = LibStub("Gladdy")
|
|
|
|
local L = Gladdy.L
|
|
|
|
local AceGUIWidgetLSMlists = AceGUIWidgetLSMlists
|
2021-05-24 12:41:21 +02:00
|
|
|
local Healthbar = Gladdy:NewModule("Health Bar", 100, {
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBarFont = "DorisPP",
|
|
|
|
healthBarHeight = 60,
|
|
|
|
healthBarTexture = "Smooth",
|
|
|
|
healthBarBorderStyle = "Gladdy Tooltip round",
|
|
|
|
healthBarBorderSize = 9,
|
|
|
|
healthBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
|
|
|
|
healthBarBgColor = { r = 0, g = 0, b = 0, a = 0.4 },
|
|
|
|
healthBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
|
2021-05-18 16:38:17 +02:00
|
|
|
healthBarNameFontSize = 12,
|
|
|
|
healthBarHealthFontSize = 12,
|
2021-05-19 19:31:13 +02:00
|
|
|
healthNameToArenaId = false,
|
2021-05-18 16:38:17 +02:00
|
|
|
healthName = true,
|
2021-05-17 16:49:54 +02:00
|
|
|
healthActual = false,
|
|
|
|
healthMax = true,
|
|
|
|
healthPercentage = true,
|
2022-01-12 20:21:53 +01:00
|
|
|
healthFrameStrata = "MEDIUM",
|
|
|
|
healthFrameLevel = 1,
|
2022-03-03 23:41:54 +01:00
|
|
|
healthCustomTagsEnabled = false,
|
|
|
|
healthTextRight = "[percent|status]",
|
|
|
|
healthTextLeft = "[name]",
|
|
|
|
healthTextRight = "[percent|status]",
|
|
|
|
healthTextLeftOutline = false,
|
|
|
|
healthTextRightOutline = false,
|
|
|
|
healthTextLeftVOffset = 0,
|
|
|
|
healthTextLeftHOffset = 5,
|
|
|
|
healthTextRightVOffset = 0,
|
|
|
|
healthTextRightHOffset = -5,
|
2021-05-17 16:49:54 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
function Healthbar:Initialize()
|
|
|
|
self.frames = {}
|
2021-05-19 19:31:13 +02:00
|
|
|
self:RegisterMessage("JOINED_ARENA")
|
2021-05-17 16:49:54 +02:00
|
|
|
self:RegisterMessage("ENEMY_SPOTTED")
|
2022-03-03 23:41:54 +01:00
|
|
|
self:RegisterMessage("UNIT_SPEC")
|
2021-05-18 16:38:17 +02:00
|
|
|
self:RegisterMessage("UNIT_DESTROYED")
|
2021-05-17 16:49:54 +02:00
|
|
|
self:RegisterMessage("UNIT_DEATH")
|
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:CreateFrame(unit)
|
|
|
|
local button = Gladdy.buttons[unit]
|
|
|
|
|
|
|
|
local healthBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
|
2021-05-19 19:31:13 +02:00
|
|
|
healthBar:EnableMouse(false)
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "healthBarBorderStyle"),
|
2021-05-17 16:49:54 +02:00
|
|
|
edgeSize = Gladdy.db.healthBarBorderSize })
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar:SetBackdropBorderColor(Gladdy:SetColor(Gladdy.db.healthBarBorderColor))
|
2022-01-12 20:21:53 +01:00
|
|
|
healthBar:SetFrameStrata(Gladdy.db.healthFrameStrata)
|
|
|
|
healthBar:SetFrameLevel(Gladdy.db.healthFrameLevel)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
healthBar.hp = CreateFrame("StatusBar", nil, healthBar)
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.hp:SetStatusBarTexture(Gladdy:SMFetch("statusbar", "healthBarTexture"))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.hp:SetMinMaxValues(0, 100)
|
2022-01-12 20:21:53 +01:00
|
|
|
healthBar.hp:SetFrameStrata(Gladdy.db.healthFrameStrata)
|
|
|
|
healthBar.hp:SetFrameLevel(Gladdy.db.healthFrameLevel - 1)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
healthBar.bg = healthBar.hp:CreateTexture(nil, "BACKGROUND")
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.bg:SetTexture(Gladdy:SMFetch("statusbar", "healthBarTexture"))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.bg:ClearAllPoints()
|
|
|
|
healthBar.bg:SetAllPoints(healthBar.hp)
|
|
|
|
healthBar.bg:SetAlpha(1)
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar.bg:SetVertexColor(Gladdy:SetColor(Gladdy.db.healthBarBgColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
healthBar.nameText = healthBar:CreateFontString(nil, "LOW", "GameFontNormalSmall")
|
2021-05-18 16:38:17 +02:00
|
|
|
if (Gladdy.db.healthBarNameFontSize < 1) then
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.nameText:SetFont(Gladdy:SMFetch("font", "healthBarNameFont"), 1)
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.nameText:Hide()
|
|
|
|
else
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.nameText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), Gladdy.db.healthBarNameFontSize, Gladdy.db.healthTextLeftOutline and "OUTLINE")
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.nameText:Show()
|
|
|
|
end
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar.nameText:SetTextColor(Gladdy:SetColor(Gladdy.db.healthBarFontColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.nameText:SetShadowOffset(1, -1)
|
|
|
|
healthBar.nameText:SetShadowColor(0, 0, 0, 1)
|
|
|
|
healthBar.nameText:SetJustifyH("CENTER")
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.nameText:SetPoint("LEFT", Gladdy.db.healthTextLeftHOffset, Gladdy.db.healthTextLeftVOffset)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
healthBar.healthText = healthBar:CreateFontString(nil, "LOW")
|
2021-05-18 16:38:17 +02:00
|
|
|
if (Gladdy.db.healthBarHealthFontSize < 1) then
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.healthText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), 1)
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.healthText:Hide()
|
|
|
|
else
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.healthText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), Gladdy.db.healthBarHealthFontSize, Gladdy.db.healthTextRightOutline and "OUTLINE")
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.healthText:Hide()
|
|
|
|
end
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar.healthText:SetTextColor(Gladdy:SetColor(Gladdy.db.healthBarFontColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.healthText:SetShadowOffset(1, -1)
|
|
|
|
healthBar.healthText:SetShadowColor(0, 0, 0, 1)
|
|
|
|
healthBar.healthText:SetJustifyH("CENTER")
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.healthText:SetPoint("RIGHT", Gladdy.db.healthTextRightHOffset, Gladdy.db.healthTextRightVOffset)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
healthBar.unit = unit
|
|
|
|
self.frames[unit] = healthBar
|
|
|
|
button.healthBar = healthBar
|
|
|
|
self:ResetUnit(unit)
|
|
|
|
healthBar:RegisterUnitEvent("UNIT_HEALTH", unit)
|
|
|
|
healthBar:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
|
|
|
|
healthBar:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
|
|
|
healthBar:SetScript("OnEvent", Healthbar.OnEvent)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar.OnEvent(self, event, unit)
|
2021-06-16 14:34:17 +02:00
|
|
|
local isDead = UnitExists(unit) and UnitIsDeadOrGhost(unit)
|
2022-03-03 23:41:54 +01:00
|
|
|
if event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" then
|
2021-06-16 14:34:17 +02:00
|
|
|
if isDead then
|
|
|
|
Gladdy:SendMessage("UNIT_DEATH", unit)
|
|
|
|
return
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
local health = UnitHealth(unit)
|
|
|
|
local healthMax = UnitHealthMax(unit)
|
|
|
|
self.hp:SetMinMaxValues(0, healthMax)
|
|
|
|
self.hp:SetValue(health)
|
2022-03-03 23:41:54 +01:00
|
|
|
self.hp.current = health
|
|
|
|
Healthbar:SetText(unit, health, healthMax)
|
|
|
|
--Healthbar:SetHealthText(self, health, healthMax)
|
2021-05-17 16:49:54 +02:00
|
|
|
elseif event == "UNIT_NAME_UPDATE" then
|
|
|
|
local name = UnitName(unit)
|
|
|
|
Gladdy.buttons[unit].name = name
|
2022-03-03 23:41:54 +01:00
|
|
|
Healthbar:SetText(unit, self.hp.current, 100)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
if not Gladdy.buttons[unit].class then
|
|
|
|
Gladdy:SpotEnemy(unit, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:SetHealthText(healthBar, health, healthMax)
|
2022-01-11 03:00:57 +01:00
|
|
|
local healthText = ""
|
2022-03-03 23:41:54 +01:00
|
|
|
local healthPercentage = health and healthMax and floor(health * 100 / healthMax)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-07-26 14:35:20 +02:00
|
|
|
if health == 0 and UnitExists(healthBar.unit) and UnitIsDeadOrGhost(healthBar.unit) then
|
2021-05-17 16:49:54 +02:00
|
|
|
self:UNIT_DEATH(healthBar.unit)
|
|
|
|
return
|
|
|
|
end
|
2022-03-03 23:41:54 +01:00
|
|
|
if (Gladdy.db.healthPercentage and healthPercentage) then
|
2022-01-11 03:00:57 +01:00
|
|
|
healthText = ("%d%%"):format(healthPercentage)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
healthBar.healthText:SetText(healthText)
|
|
|
|
end
|
|
|
|
|
2022-03-03 23:41:54 +01:00
|
|
|
function Healthbar:SetText(unit, health, healthMax, status)
|
|
|
|
local button = Gladdy.buttons[unit]
|
|
|
|
if not Gladdy.buttons[unit] then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if Gladdy.db.healthCustomTagsEnabled then
|
|
|
|
button.healthBar.nameText:SetText(Gladdy:SetTag(unit, Gladdy.db.healthTextLeft, health, healthMax, status))
|
|
|
|
button.healthBar.healthText:SetText(Gladdy:SetTag(unit, Gladdy.db.healthTextRight, health, healthMax, status))
|
|
|
|
else
|
|
|
|
if Gladdy.db.healthName then
|
|
|
|
if Gladdy.db.healthNameToArenaId then
|
|
|
|
button.healthBar.nameText:SetText(str_gsub(unit, "arena", ""))
|
|
|
|
else
|
|
|
|
button.healthBar.nameText:SetText(Gladdy.buttons[unit].name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if status then
|
|
|
|
button.healthBar.healthText:SetText(status)
|
|
|
|
else
|
|
|
|
Healthbar:SetHealthText(button.healthBar, health, healthMax)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
function Healthbar:UpdateFrame(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
if (not healthBar) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-01-12 20:21:53 +01:00
|
|
|
healthBar:SetFrameStrata(Gladdy.db.healthFrameStrata)
|
|
|
|
healthBar:SetFrameLevel(Gladdy.db.healthFrameLevel)
|
|
|
|
healthBar.hp:SetFrameStrata(Gladdy.db.healthFrameStrata)
|
|
|
|
healthBar.hp:SetFrameLevel(Gladdy.db.healthFrameLevel - 1)
|
|
|
|
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.bg:SetTexture(Gladdy:SMFetch("statusbar", "healthBarTexture"))
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar.bg:SetVertexColor(Gladdy:SetColor(Gladdy.db.healthBarBgColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "healthBarBorderStyle"),
|
2021-05-17 16:49:54 +02:00
|
|
|
edgeSize = Gladdy.db.healthBarBorderSize })
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar:SetBackdropBorderColor(Gladdy:SetColor(Gladdy.db.healthBarBorderColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar:ClearAllPoints()
|
2021-05-22 13:41:31 +02:00
|
|
|
healthBar:SetPoint("TOPLEFT", Gladdy.buttons[unit], "TOPLEFT", 0, 0)
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit], "BOTTOMRIGHT")
|
|
|
|
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.hp:SetStatusBarTexture(Gladdy:SMFetch("statusbar", "healthBarTexture"))
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.hp:ClearAllPoints()
|
|
|
|
healthBar.hp:SetPoint("TOPLEFT", healthBar, "TOPLEFT", (Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset), -(Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset))
|
|
|
|
healthBar.hp:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", -(Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset), (Gladdy.db.healthBarBorderSize/Gladdy.db.statusbarBorderOffset))
|
|
|
|
|
2021-05-18 16:38:17 +02:00
|
|
|
if (Gladdy.db.healthBarHealthFontSize < 1) then
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.healthText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), 1)
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.healthText:Hide()
|
|
|
|
else
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.healthText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), Gladdy.db.healthBarHealthFontSize, Gladdy.db.healthTextRightOutline and "OUTLINE")
|
2021-05-17 16:49:54 +02:00
|
|
|
healthBar.healthText:Show()
|
|
|
|
end
|
2021-05-18 16:38:17 +02:00
|
|
|
if (Gladdy.db.healthBarNameFontSize < 1) then
|
2021-09-14 23:55:17 +02:00
|
|
|
healthBar.nameText:SetFont(Gladdy:SMFetch("font", "healthBarNameFont"), 1)
|
2021-05-18 16:38:17 +02:00
|
|
|
healthBar.nameText:Hide()
|
|
|
|
else
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.nameText:SetFont(Gladdy:SMFetch("font", "healthBarFont"), Gladdy.db.healthBarNameFontSize, Gladdy.db.healthTextLeftOutline and "OUTLINE")
|
2021-05-18 16:38:17 +02:00
|
|
|
if Gladdy.db.healthName then
|
|
|
|
healthBar.nameText:Show()
|
|
|
|
else
|
|
|
|
healthBar.nameText:Hide()
|
|
|
|
end
|
|
|
|
end
|
2022-01-12 23:07:23 +01:00
|
|
|
healthBar.nameText:SetTextColor(Gladdy:SetColor(Gladdy.db.healthBarFontColor))
|
|
|
|
healthBar.healthText:SetTextColor(Gladdy:SetColor(Gladdy.db.healthBarFontColor))
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.nameText:SetPoint("LEFT", Gladdy.db.healthTextLeftHOffset, Gladdy.db.healthTextLeftVOffset)
|
|
|
|
healthBar.healthText:SetPoint("RIGHT", Gladdy.db.healthTextRightHOffset, Gladdy.db.healthTextRightVOffset)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:ResetUnit(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
if (not healthBar) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
healthBar.hp:SetStatusBarColor(1, 1, 1, 1)
|
|
|
|
healthBar.nameText:SetText("")
|
|
|
|
healthBar.healthText:SetText("")
|
|
|
|
healthBar.hp:SetValue(0)
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.hp.current = 0
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:Test(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
local button = Gladdy.buttons[unit]
|
|
|
|
if (not healthBar or not button) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2022-03-03 23:41:54 +01:00
|
|
|
--self:JOINED_ARENA()
|
|
|
|
Gladdy:SendMessage("UNIT_HEALTH", unit, button.health, button.healthMax)
|
|
|
|
healthBar.hp.current = button.health
|
2021-05-17 16:49:54 +02:00
|
|
|
self:ENEMY_SPOTTED(unit)
|
2022-03-03 23:41:54 +01:00
|
|
|
self:SetText(unit, button.health, button.healthMax)
|
|
|
|
healthBar.hp:SetValue(button.health)
|
|
|
|
if unit == "arena1" then
|
|
|
|
self:UNIT_DEATH(unit)
|
|
|
|
--self:SetText(unit, button.health, button.healthMax, L["DEAD"])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:UNIT_SPEC(unit)
|
|
|
|
local button = Gladdy.buttons[unit]
|
|
|
|
if not button then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
self:SetText(unit, button.healthBar.hp.current, 100)
|
|
|
|
--button.healthBar.nameText:SetText(Gladdy:SetTag(unit, Gladdy.db.healthTextLeft, button.health, button.healthMax))
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
2021-05-19 19:31:13 +02:00
|
|
|
function Healthbar:JOINED_ARENA()
|
2022-03-03 23:41:54 +01:00
|
|
|
for i=1,Gladdy.curBracket do
|
|
|
|
self:SetText("arena" .. i, nil, nil)
|
2021-05-19 19:31:13 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
function Healthbar:ENEMY_SPOTTED(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
local button = Gladdy.buttons[unit]
|
|
|
|
if (not healthBar or not button) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if UnitExists(unit) then
|
|
|
|
local health = UnitHealth(unit)
|
|
|
|
local healthMax = UnitHealthMax(unit)
|
|
|
|
healthBar.hp:SetMinMaxValues(0, healthMax)
|
|
|
|
healthBar.hp:SetValue(health)
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.hp.current = health
|
|
|
|
Healthbar:SetText(unit, health, healthMax)
|
|
|
|
--Healthbar:SetHealthText(healthBar, health, healthMax)
|
2021-05-19 19:31:13 +02:00
|
|
|
end
|
|
|
|
|
2021-07-27 16:55:00 +02:00
|
|
|
if button.class then
|
|
|
|
healthBar.hp:SetStatusBarColor(RAID_CLASS_COLORS[button.class].r, RAID_CLASS_COLORS[button.class].g, RAID_CLASS_COLORS[button.class].b, 1)
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:UNIT_DEATH(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
if (not healthBar) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
healthBar.hp:SetValue(0)
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.hp.current = 0
|
|
|
|
Healthbar:SetText(unit, 0, 100, L["DEAD"])
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
2021-05-18 16:38:17 +02:00
|
|
|
function Healthbar:UNIT_DESTROYED(unit)
|
|
|
|
local healthBar = self.frames[unit]
|
|
|
|
if (not healthBar) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
healthBar.hp:SetValue(0)
|
2022-03-03 23:41:54 +01:00
|
|
|
healthBar.hp.current = 0
|
2021-05-18 16:38:17 +02:00
|
|
|
healthBar.healthText:SetText(L["LEAVE"])
|
|
|
|
healthBar.nameText:SetText("")
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
local function option(params)
|
|
|
|
local defaults = {
|
|
|
|
get = function(info)
|
|
|
|
local key = info.arg or info[#info]
|
|
|
|
return Gladdy.dbi.profile[key]
|
|
|
|
end,
|
|
|
|
set = function(info, value)
|
|
|
|
local key = info.arg or info[#info]
|
|
|
|
Gladdy.dbi.profile[key] = value
|
2021-05-24 13:11:36 +02:00
|
|
|
Gladdy.options.args["Health Bar"].args.group.args.border.args.healthBarBorderSize.max = Gladdy.db.healthBarHeight/2
|
2021-05-17 16:49:54 +02:00
|
|
|
if Gladdy.db.healthBarBorderSize > Gladdy.db.healthBarHeight/2 then
|
|
|
|
Gladdy.db.healthBarBorderSize = Gladdy.db.healthBarHeight/2
|
|
|
|
end
|
2022-03-03 23:41:54 +01:00
|
|
|
if Gladdy.frame.testing then
|
|
|
|
for i=1,Gladdy.curBracket do
|
|
|
|
Healthbar:Test("arena" .. i)
|
|
|
|
end
|
2021-05-18 16:38:17 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
Gladdy:UpdateFrame()
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
for k, v in pairs(params) do
|
|
|
|
defaults[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
return defaults
|
|
|
|
end
|
|
|
|
|
|
|
|
function Healthbar:GetOptions()
|
|
|
|
return {
|
|
|
|
headerHealthbar = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Health Bar"],
|
|
|
|
order = 2,
|
|
|
|
},
|
|
|
|
group = {
|
|
|
|
type = "group",
|
|
|
|
childGroups = "tree",
|
2021-05-24 12:41:21 +02:00
|
|
|
name = L["Frame"],
|
2021-05-17 16:49:54 +02:00
|
|
|
order = 3,
|
|
|
|
args = {
|
|
|
|
general = {
|
|
|
|
type = "group",
|
|
|
|
name = L["General"],
|
|
|
|
order = 1,
|
|
|
|
args = {
|
|
|
|
headerAuras = {
|
|
|
|
type = "header",
|
|
|
|
name = L["General"],
|
|
|
|
order = 1,
|
|
|
|
},
|
|
|
|
healthBarHeight = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Bar height"],
|
|
|
|
desc = L["Height of the bar"],
|
|
|
|
order = 3,
|
|
|
|
min = 10,
|
|
|
|
max = 100,
|
|
|
|
step = 1,
|
2021-06-15 09:06:50 +02:00
|
|
|
width = "full",
|
2021-05-17 16:49:54 +02:00
|
|
|
}),
|
|
|
|
healthBarTexture = option({
|
|
|
|
type = "select",
|
|
|
|
name = L["Bar texture"],
|
|
|
|
desc = L["Texture of the bar"],
|
|
|
|
order = 4,
|
|
|
|
dialogControl = "LSM30_Statusbar",
|
|
|
|
values = AceGUIWidgetLSMlists.statusbar,
|
|
|
|
}),
|
|
|
|
healthBarBgColor = Gladdy:colorOption({
|
|
|
|
type = "color",
|
|
|
|
name = L["Background color"],
|
|
|
|
desc = L["Color of the status bar background"],
|
|
|
|
order = 5,
|
|
|
|
hasAlpha = true,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
font = {
|
|
|
|
type = "group",
|
|
|
|
name = L["Font"],
|
|
|
|
order = 2,
|
|
|
|
args = {
|
|
|
|
header = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Font"],
|
|
|
|
order = 1,
|
|
|
|
},
|
|
|
|
healthBarFont = option({
|
|
|
|
type = "select",
|
|
|
|
name = L["Font"],
|
|
|
|
desc = L["Font of the bar"],
|
|
|
|
order = 11,
|
|
|
|
dialogControl = "LSM30_Font",
|
|
|
|
values = AceGUIWidgetLSMlists.font,
|
|
|
|
}),
|
|
|
|
healthBarFontColor = Gladdy:colorOption({
|
|
|
|
type = "color",
|
|
|
|
name = L["Font color"],
|
|
|
|
desc = L["Color of the text"],
|
|
|
|
order = 12,
|
|
|
|
hasAlpha = true,
|
|
|
|
}),
|
2022-03-03 23:41:54 +01:00
|
|
|
healthTextLeftOutline = option({
|
|
|
|
type = "toggle",
|
|
|
|
name = L["Left Font Outline"],
|
|
|
|
order = 13,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
healthTextRightOutline = option({
|
|
|
|
type = "toggle",
|
|
|
|
name = L["Right Font Outline"],
|
|
|
|
order = 14,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
headerSize = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Size"],
|
|
|
|
order = 20,
|
|
|
|
},
|
2021-05-18 16:38:17 +02:00
|
|
|
healthBarNameFontSize = option({
|
2021-05-17 16:49:54 +02:00
|
|
|
type = "range",
|
2021-05-18 16:38:17 +02:00
|
|
|
name = L["Name font size"],
|
|
|
|
desc = L["Size of the name text"],
|
2022-03-03 23:41:54 +01:00
|
|
|
order = 21,
|
2021-05-18 16:38:17 +02:00
|
|
|
step = 0.1,
|
|
|
|
min = 0,
|
|
|
|
max = 20,
|
2021-06-15 09:06:50 +02:00
|
|
|
width = "full",
|
2021-05-18 16:38:17 +02:00
|
|
|
}),
|
|
|
|
healthBarHealthFontSize = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Health font size"],
|
|
|
|
desc = L["Size of the health text"],
|
2022-03-03 23:41:54 +01:00
|
|
|
order = 22,
|
2021-05-18 16:38:17 +02:00
|
|
|
step = 0.1,
|
2021-05-17 16:49:54 +02:00
|
|
|
min = 0,
|
|
|
|
max = 20,
|
2021-06-15 09:06:50 +02:00
|
|
|
width = "full",
|
2021-05-17 16:49:54 +02:00
|
|
|
}),
|
2022-03-03 23:41:54 +01:00
|
|
|
headerLeftText = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Offsets"],
|
|
|
|
order = 30,
|
|
|
|
},
|
|
|
|
healthTextLeftVOffset = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Left Text Vertical Offset"],
|
|
|
|
order = 31,
|
|
|
|
step = 0.1,
|
|
|
|
min = -200,
|
|
|
|
max = 200,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
healthTextLeftHOffset = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Left Text Horizontal Offset"],
|
|
|
|
order = 32,
|
|
|
|
step = 0.1,
|
|
|
|
min = -200,
|
|
|
|
max = 200,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
healthTextRightVOffset = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Right Text Vertical Offset"],
|
|
|
|
order = 33,
|
|
|
|
step = 0.1,
|
|
|
|
min = -200,
|
|
|
|
max = 200,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
healthTextRightHOffset = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Right Text Horizontal Offset"],
|
|
|
|
order = 34,
|
|
|
|
step = 0.1,
|
|
|
|
min = -200,
|
|
|
|
max = 200,
|
|
|
|
width = "full",
|
|
|
|
}),
|
2021-05-17 16:49:54 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
border = {
|
|
|
|
type = "group",
|
|
|
|
name = L["Border"],
|
|
|
|
order = 3,
|
|
|
|
args = {
|
|
|
|
header = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Border"],
|
|
|
|
order = 1,
|
|
|
|
},
|
|
|
|
healthBarBorderStyle = option({
|
|
|
|
type = "select",
|
|
|
|
name = L["Border style"],
|
|
|
|
order = 21,
|
|
|
|
dialogControl = "LSM30_Border",
|
|
|
|
values = AceGUIWidgetLSMlists.border,
|
|
|
|
}),
|
|
|
|
healthBarBorderSize = option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Border size"],
|
|
|
|
desc = L["Size of the border"],
|
|
|
|
order = 22,
|
|
|
|
min = 0.5,
|
|
|
|
max = Gladdy.db.healthBarHeight/2,
|
|
|
|
step = 0.5,
|
2021-06-15 09:06:50 +02:00
|
|
|
width = "full",
|
2021-05-17 16:49:54 +02:00
|
|
|
}),
|
|
|
|
healthBarBorderColor = Gladdy:colorOption({
|
|
|
|
type = "color",
|
|
|
|
name = L["Border color"],
|
|
|
|
desc = L["Color of the border"],
|
|
|
|
order = 23,
|
|
|
|
hasAlpha = true,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
2022-01-12 20:21:53 +01:00
|
|
|
frameStrata = {
|
|
|
|
type = "group",
|
|
|
|
name = L["Frame Strata and Level"],
|
|
|
|
order = 4,
|
|
|
|
args = {
|
|
|
|
headerAuraLevel = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Frame Strata and Level"],
|
|
|
|
order = 1,
|
|
|
|
},
|
|
|
|
healthFrameStrata = Gladdy:option({
|
|
|
|
type = "select",
|
|
|
|
name = L["Frame Strata"],
|
|
|
|
order = 2,
|
|
|
|
values = Gladdy.frameStrata,
|
|
|
|
sorting = Gladdy.frameStrataSorting,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
healthFrameLevel = Gladdy:option({
|
|
|
|
type = "range",
|
|
|
|
name = L["Frame Level"],
|
|
|
|
min = 1,
|
|
|
|
max = 500,
|
|
|
|
step = 1,
|
|
|
|
order = 3,
|
|
|
|
width = "full",
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
2021-05-17 16:49:54 +02:00
|
|
|
healthValues = {
|
|
|
|
type = "group",
|
2021-05-18 16:38:17 +02:00
|
|
|
name = L["Health Bar Text"],
|
2022-01-12 20:21:53 +01:00
|
|
|
order = 5,
|
2021-05-17 16:49:54 +02:00
|
|
|
args = {
|
|
|
|
header = {
|
|
|
|
type = "header",
|
2021-05-18 16:38:17 +02:00
|
|
|
name = L["Health Bar Text"],
|
2021-05-17 16:49:54 +02:00
|
|
|
order = 1,
|
|
|
|
},
|
2021-05-18 16:38:17 +02:00
|
|
|
healthName = option({
|
|
|
|
type = "toggle",
|
2021-05-19 19:31:13 +02:00
|
|
|
name = L["Show name text"],
|
2021-05-18 16:38:17 +02:00
|
|
|
desc = L["Show the units name"],
|
2021-05-19 19:31:13 +02:00
|
|
|
order = 2,
|
2021-05-24 12:41:21 +02:00
|
|
|
width = "full",
|
2022-03-03 23:41:54 +01:00
|
|
|
disabled = function() return Gladdy.db.healthCustomTagsEnabled end,
|
2021-05-19 19:31:13 +02:00
|
|
|
}),
|
|
|
|
healthNameToArenaId = option({
|
|
|
|
type = "toggle",
|
|
|
|
name = L["Show ArenaX"],
|
2021-07-26 14:55:23 +02:00
|
|
|
desc = L["Show 1-5 as name instead"],
|
2021-05-19 19:31:13 +02:00
|
|
|
order = 3,
|
2021-05-24 12:41:21 +02:00
|
|
|
width = "full",
|
2022-03-03 23:41:54 +01:00
|
|
|
disabled = function() return not Gladdy.db.healthName or Gladdy.db.healthCustomTagsEnabled end,
|
2021-05-18 16:38:17 +02:00
|
|
|
}),
|
2021-05-17 16:49:54 +02:00
|
|
|
healthPercentage = option({
|
|
|
|
type = "toggle",
|
|
|
|
name = L["Show health percentage"],
|
|
|
|
desc = L["Show health percentage on the health bar"],
|
2021-05-19 19:31:13 +02:00
|
|
|
order = 6,
|
2021-05-24 12:41:21 +02:00
|
|
|
width = "full",
|
2022-03-03 23:41:54 +01:00
|
|
|
disabled = function() return Gladdy.db.healthCustomTagsEnabled end,
|
2021-05-17 16:49:54 +02:00
|
|
|
}),
|
2022-03-03 23:41:54 +01:00
|
|
|
header = {
|
|
|
|
type = "header",
|
|
|
|
name = L["Custom Tags"],
|
|
|
|
order = 10,
|
|
|
|
},
|
|
|
|
healthCustomTagsEnabled = Gladdy:GetTagOption(L["Custom Tags Enabled"], 11, nil, option, true),
|
|
|
|
healthTextLeft = Gladdy:GetTagOption(L["Left Text"], 12, "healthCustomTagsEnabled", option),
|
|
|
|
healthTextRight = Gladdy:GetTagOption(L["Right Text"], 13, "healthCustomTagsEnabled", option),
|
2021-05-17 16:49:54 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|