Power-/HealthBar customize texts added and UNIT_DESTROYED added
This commit is contained in:
parent
a152cb6045
commit
1fb3fce980
@ -17,7 +17,9 @@ local Healthbar = Gladdy:NewModule("Healthbar", 100, {
|
||||
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 },
|
||||
healthBarFontSize = 12,
|
||||
healthBarNameFontSize = 12,
|
||||
healthBarHealthFontSize = 12,
|
||||
healthName = true,
|
||||
healthActual = false,
|
||||
healthMax = true,
|
||||
healthPercentage = true,
|
||||
@ -26,6 +28,7 @@ local Healthbar = Gladdy:NewModule("Healthbar", 100, {
|
||||
function Healthbar:Initialize()
|
||||
self.frames = {}
|
||||
self:RegisterMessage("ENEMY_SPOTTED")
|
||||
self:RegisterMessage("UNIT_DESTROYED")
|
||||
self:RegisterMessage("UNIT_DEATH")
|
||||
end
|
||||
|
||||
@ -51,11 +54,11 @@ function Healthbar:CreateFrame(unit)
|
||||
healthBar.bg:SetVertexColor(Gladdy.db.healthBarBgColor.r, Gladdy.db.healthBarBgColor.g, Gladdy.db.healthBarBgColor.b, Gladdy.db.healthBarBgColor.a)
|
||||
|
||||
healthBar.nameText = healthBar:CreateFontString(nil, "LOW", "GameFontNormalSmall")
|
||||
if (Gladdy.db.healthBarFontSize < 1) then
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
|
||||
if (Gladdy.db.healthBarNameFontSize < 1) then
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarNameFont), 1)
|
||||
healthBar.nameText:Hide()
|
||||
else
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarNameFontSize)
|
||||
healthBar.nameText:Show()
|
||||
end
|
||||
healthBar.nameText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
|
||||
@ -65,11 +68,11 @@ function Healthbar:CreateFrame(unit)
|
||||
healthBar.nameText:SetPoint("LEFT", 5, 0)
|
||||
|
||||
healthBar.healthText = healthBar:CreateFontString(nil, "LOW")
|
||||
if (Gladdy.db.healthBarFontSize < 1) then
|
||||
if (Gladdy.db.healthBarHealthFontSize < 1) then
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
|
||||
healthBar.healthText:Hide()
|
||||
else
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarHealthFontSize)
|
||||
healthBar.healthText:Hide()
|
||||
end
|
||||
healthBar.healthText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
|
||||
@ -166,17 +169,24 @@ function Healthbar:UpdateFrame(unit)
|
||||
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))
|
||||
|
||||
if (Gladdy.db.healthBarFontSize < 1) then
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
|
||||
if (Gladdy.db.healthBarHealthFontSize < 1) then
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), 1)
|
||||
healthBar.nameText:Hide()
|
||||
healthBar.healthText:Hide()
|
||||
else
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
|
||||
healthBar.nameText:Show()
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarFontSize)
|
||||
healthBar.healthText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarHealthFontSize)
|
||||
healthBar.healthText:Show()
|
||||
end
|
||||
if (Gladdy.db.healthBarNameFontSize < 1) then
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarNameFont), 1)
|
||||
healthBar.nameText:Hide()
|
||||
else
|
||||
healthBar.nameText:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.healthBarFont), Gladdy.db.healthBarNameFontSize)
|
||||
if Gladdy.db.healthName then
|
||||
healthBar.nameText:Show()
|
||||
else
|
||||
healthBar.nameText:Hide()
|
||||
end
|
||||
end
|
||||
healthBar.nameText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
|
||||
healthBar.healthText:SetTextColor(Gladdy.db.healthBarFontColor.r, Gladdy.db.healthBarFontColor.g, Gladdy.db.healthBarFontColor.b, Gladdy.db.healthBarFontColor.a)
|
||||
end
|
||||
@ -270,6 +280,17 @@ function Healthbar:UNIT_DEATH(unit)
|
||||
healthBar.healthText:SetText(L["DEAD"])
|
||||
end
|
||||
|
||||
function Healthbar:UNIT_DESTROYED(unit)
|
||||
local healthBar = self.frames[unit]
|
||||
if (not healthBar) then
|
||||
return
|
||||
end
|
||||
|
||||
healthBar.hp:SetValue(0)
|
||||
healthBar.healthText:SetText(L["LEAVE"])
|
||||
healthBar.nameText:SetText("")
|
||||
end
|
||||
|
||||
local function option(params)
|
||||
local defaults = {
|
||||
get = function(info)
|
||||
@ -283,6 +304,9 @@ local function option(params)
|
||||
if Gladdy.db.healthBarBorderSize > Gladdy.db.healthBarHeight/2 then
|
||||
Gladdy.db.healthBarBorderSize = Gladdy.db.healthBarHeight/2
|
||||
end
|
||||
for i=1,Gladdy.curBracket do
|
||||
Healthbar:Test("arena" .. i)
|
||||
end
|
||||
Gladdy:UpdateFrame()
|
||||
end,
|
||||
}
|
||||
@ -368,11 +392,21 @@ function Healthbar:GetOptions()
|
||||
order = 12,
|
||||
hasAlpha = true,
|
||||
}),
|
||||
healthBarFontSize = option({
|
||||
healthBarNameFontSize = option({
|
||||
type = "range",
|
||||
name = L["Font size"],
|
||||
desc = L["Size of the text"],
|
||||
name = L["Name font size"],
|
||||
desc = L["Size of the name text"],
|
||||
order = 13,
|
||||
step = 0.1,
|
||||
min = 0,
|
||||
max = 20,
|
||||
}),
|
||||
healthBarHealthFontSize = option({
|
||||
type = "range",
|
||||
name = L["Health font size"],
|
||||
desc = L["Size of the health text"],
|
||||
order = 14,
|
||||
step = 0.1,
|
||||
min = 0,
|
||||
max = 20,
|
||||
}),
|
||||
@ -415,14 +449,20 @@ function Healthbar:GetOptions()
|
||||
},
|
||||
healthValues = {
|
||||
type = "group",
|
||||
name = L["Health Values"],
|
||||
name = L["Health Bar Text"],
|
||||
order = 4,
|
||||
args = {
|
||||
header = {
|
||||
type = "header",
|
||||
name = L["Health Values"],
|
||||
name = L["Health Bar Text"],
|
||||
order = 1,
|
||||
},
|
||||
healthName = option({
|
||||
type = "toggle",
|
||||
name = L["Show the name"],
|
||||
desc = L["Show the units name"],
|
||||
order = 30,
|
||||
}),
|
||||
healthActual = option({
|
||||
type = "toggle",
|
||||
name = L["Show the actual health"],
|
||||
|
@ -16,6 +16,8 @@ local Powerbar = Gladdy:NewModule("Powerbar", 90, {
|
||||
powerBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
|
||||
powerBarBgColor = { r = 0.3, g = 0.3, b = 0.3, a = 0.7 },
|
||||
powerBarFontSize = 10,
|
||||
powerShowSpec = true,
|
||||
powerShowRace = true,
|
||||
powerActual = true,
|
||||
powerMax = true,
|
||||
powerPercentage = false,
|
||||
@ -27,6 +29,7 @@ function Powerbar:Initialize()
|
||||
self:RegisterMessage("ENEMY_SPOTTED")
|
||||
self:RegisterMessage("UNIT_SPEC")
|
||||
self:RegisterMessage("UNIT_DEATH")
|
||||
self:RegisterMessage("UNIT_DESTROYED")
|
||||
end
|
||||
|
||||
function Powerbar:CreateFrame(unit)
|
||||
@ -185,9 +188,9 @@ function Powerbar:ENEMY_SPOTTED(unit)
|
||||
return
|
||||
end
|
||||
|
||||
local raceText = button.raceLoc
|
||||
local raceText = Gladdy.db.powerShowRace and button.raceLoc or ""
|
||||
|
||||
if (button.spec) then
|
||||
if (button.spec and Gladdy.db.powerShowSpec) then
|
||||
raceText = button.spec .. " " .. raceText
|
||||
end
|
||||
|
||||
@ -263,6 +266,15 @@ function Powerbar:UNIT_DEATH(unit)
|
||||
powerBar.powerText:SetText("0%")
|
||||
end
|
||||
|
||||
function Powerbar:UNIT_DESTROYED(unit)
|
||||
local powerBar = self.frames[unit]
|
||||
if (not powerBar) then
|
||||
return
|
||||
end
|
||||
powerBar.energy:SetValue(0)
|
||||
powerBar.powerText:SetText("0%")
|
||||
end
|
||||
|
||||
local function option(params)
|
||||
local defaults = {
|
||||
get = function(info)
|
||||
@ -272,10 +284,13 @@ local function option(params)
|
||||
set = function(info, value)
|
||||
local key = info.arg or info[#info]
|
||||
Gladdy.dbi.profile[key] = value
|
||||
Gladdy.options.args.Powerbar.args.group.args.border.arg.powerBarBorderSize.max = Gladdy.db.powerBarHeight/2
|
||||
Gladdy.options.args.Powerbar.args.group.args.border.args.powerBarBorderSize.max = Gladdy.db.powerBarHeight/2
|
||||
if Gladdy.db.powerBarBorderSize > Gladdy.db.powerBarHeight/2 then
|
||||
Gladdy.db.powerBarBorderSize = Gladdy.db.powerBarHeight/2
|
||||
end
|
||||
for i=1,Gladdy.curBracket do
|
||||
Powerbar:Test("arena" .. i)
|
||||
end
|
||||
Gladdy:UpdateFrame()
|
||||
end,
|
||||
}
|
||||
@ -366,6 +381,7 @@ function Powerbar:GetOptions()
|
||||
name = L["Font size"],
|
||||
desc = L["Size of the text"],
|
||||
order = 13,
|
||||
step = 0.1,
|
||||
min = 1,
|
||||
max = 20,
|
||||
}),
|
||||
@ -408,14 +424,26 @@ function Powerbar:GetOptions()
|
||||
},
|
||||
powerValues = {
|
||||
type = "group",
|
||||
name = L["Power Values"],
|
||||
name = L["Power Bar Text"],
|
||||
order = 4,
|
||||
args = {
|
||||
header = {
|
||||
type = "header",
|
||||
name = L["Power Values"],
|
||||
name = L["Power Texts"],
|
||||
order = 1,
|
||||
},
|
||||
powerShowRace = option({
|
||||
type = "toggle",
|
||||
name = L["Show race"],
|
||||
desc = L["Show race"],
|
||||
order = 2,
|
||||
}),
|
||||
powerShowSpec= option({
|
||||
type = "toggle",
|
||||
name = L["Show spec"],
|
||||
desc = L["Show spec"],
|
||||
order = 3,
|
||||
}),
|
||||
powerActual = option({
|
||||
type = "toggle",
|
||||
name = L["Show the actual power"],
|
||||
|
Loading…
Reference in New Issue
Block a user