- added configurable raid icons to the target health bar

This commit is contained in:
Parnic
2008-02-08 02:58:26 +00:00
parent eed1e2dd6f
commit 7965b83468

View File

@ -31,6 +31,10 @@ function TargetHealth.prototype:GetDefaultSettings()
settings["hideBlizz"] = true
settings["upperText"] = "[PercentHP:Round]"
settings["lowerText"] = "[FractionalHP:HPColor:Bracket]"
settings["raidIconOnTop"] = true
settings["showRaidIcon"] = true
settings["raidIconXOffset"] = 12
settings["raidIconYOffset"] = 0
return settings
end
@ -111,6 +115,82 @@ function TargetHealth.prototype:GetOptions()
end,
order = 43
}
opts["showRaidIcon"] = {
type = "toggle",
name = "Show Raid Icon",
desc = "Whether or not to show the raid icon above this bar",
get = function()
return self.moduleSettings.showRaidIcon
end,
set = function(value)
self.moduleSettings.showRaidIcon = value
self:UpdateRaidTargetIcon()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 50
}
opts["raidIconOnTop"] = {
type = "toggle",
name = "Draw Raid Icon On Top",
desc = "Whether to draw the raid icon in front of or behind this bar",
get = function()
return self.moduleSettings.raidIconOnTop
end,
set = function(value)
self.moduleSettings.raidIconOnTop = value
self:UpdateRaidTargetIcon()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 51
}
opts["raidIconXOffset"] = {
type = "range",
name = "Raid Icon X Offset",
desc = "How far to push the raid icon right or left",
min = -50,
max = 50,
step = 1,
get = function()
return self.moduleSettings.raidIconXOffset
end,
set = function(value)
self.moduleSettings.raidIconXOffset = value
self:SetRaidIconPlacement()
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 52
}
opts["raidIconYOffset"] = {
type = "range",
name = "Raid Icon Y Offset",
desc = "How far to push the raid icon up or down",
min = -300,
max = 50,
step = 1,
get = function()
return self.moduleSettings.raidIconYOffset
end,
set = function(value)
self.moduleSettings.raidIconYOffset = value
self:SetRaidIconPlacement()
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 53
}
return opts
end
@ -118,16 +198,19 @@ end
function TargetHealth.prototype:Enable(core)
TargetHealth.super.prototype.Enable(self, core)
self:RegisterEvent("UNIT_HEALTH", "Update")
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
self:RegisterEvent("UNIT_FLAGS", "Update")
self:RegisterEvent("UNIT_FACTION", "Update")
self:RegisterEvent("RAID_TARGET_UPDATE", "UpdateRaidTargetIcon")
if (self.moduleSettings.hideBlizz) then
self:HideBlizz()
end
self:CreateRaidIconFrame()
self:Update(self.unit)
end
@ -143,7 +226,7 @@ function TargetHealth.prototype:Update(unit)
if (unit and (unit ~= self.unit)) then
return
end
if not (UnitExists(unit)) then
self.frame:Hide()
return
@ -151,6 +234,8 @@ function TargetHealth.prototype:Update(unit)
self.frame:Show()
end
self:UpdateRaidTargetIcon()
self.color = "TargetHealthFriendly" -- friendly > 4
local reaction = UnitReaction("target", "player")
@ -203,6 +288,54 @@ function TargetHealth.prototype:Update(unit)
end
function TargetHealth.prototype:CreateRaidIconFrame()
if (not self.frame.raidIcon) then
self.frame.raidIcon = CreateFrame("Frame", nil, self.frame)
end
if (not self.frame.raidIcon.icon) then
self.frame.raidIcon.icon = self.frame.raidIcon:CreateTexture(nil, "BACKGROUND")
self.frame.raidIcon.icon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons")
end
self:SetRaidIconPlacement()
self.frame.raidIcon:SetWidth(16)
self.frame.raidIcon:SetHeight(16)
self.frame.raidIcon.icon:SetAllPoints(self.frame.raidIcon)
SetRaidTargetIconTexture(self.frame.raidIcon.icon, 0)
self.frame.raidIcon:Hide()
end
function TargetHealth.prototype:SetRaidIconPlacement()
self.frame.raidIcon:ClearAllPoints()
self.frame.raidIcon:SetPoint("BOTTOM", self.frame, "TOPLEFT", self.moduleSettings.raidIconXOffset, self.moduleSettings.raidIconYOffset)
end
function TargetHealth.prototype:UpdateRaidTargetIcon()
if self.moduleSettings.raidIconOnTop then
self.frame.raidIcon:SetFrameStrata("MEDIUM")
else
self.frame.raidIcon:SetFrameStrata("LOW")
end
if not (UnitExists(self.unit)) or not self.moduleSettings.showRaidIcon then
self.frame.raidIcon:Hide()
return
end
local index = GetRaidTargetIndex(self.unit);
if (index and (index > 0)) then
SetRaidTargetIconTexture(self.frame.raidIcon.icon, index)
self.frame.raidIcon:Show()
else
self.frame.raidIcon:Hide()
end
end
function TargetHealth.prototype:Round(health)
if (health > 1000000) then
return self:MathRound(health/1000000, 1) .. "M"