mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 22:51:53 -05:00
- added configurable raid icons to the target health bar
This commit is contained in:
@ -31,6 +31,10 @@ function TargetHealth.prototype:GetDefaultSettings()
|
|||||||
settings["hideBlizz"] = true
|
settings["hideBlizz"] = true
|
||||||
settings["upperText"] = "[PercentHP:Round]"
|
settings["upperText"] = "[PercentHP:Round]"
|
||||||
settings["lowerText"] = "[FractionalHP:HPColor:Bracket]"
|
settings["lowerText"] = "[FractionalHP:HPColor:Bracket]"
|
||||||
|
settings["raidIconOnTop"] = true
|
||||||
|
settings["showRaidIcon"] = true
|
||||||
|
settings["raidIconXOffset"] = 12
|
||||||
|
settings["raidIconYOffset"] = 0
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
end
|
end
|
||||||
@ -112,6 +116,82 @@ function TargetHealth.prototype:GetOptions()
|
|||||||
order = 43
|
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
|
return opts
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -123,11 +203,14 @@ function TargetHealth.prototype:Enable(core)
|
|||||||
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
||||||
self:RegisterEvent("UNIT_FLAGS", "Update")
|
self:RegisterEvent("UNIT_FLAGS", "Update")
|
||||||
self:RegisterEvent("UNIT_FACTION", "Update")
|
self:RegisterEvent("UNIT_FACTION", "Update")
|
||||||
|
self:RegisterEvent("RAID_TARGET_UPDATE", "UpdateRaidTargetIcon")
|
||||||
|
|
||||||
if (self.moduleSettings.hideBlizz) then
|
if (self.moduleSettings.hideBlizz) then
|
||||||
self:HideBlizz()
|
self:HideBlizz()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:CreateRaidIconFrame()
|
||||||
|
|
||||||
self:Update(self.unit)
|
self:Update(self.unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -151,6 +234,8 @@ function TargetHealth.prototype:Update(unit)
|
|||||||
self.frame:Show()
|
self.frame:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:UpdateRaidTargetIcon()
|
||||||
|
|
||||||
self.color = "TargetHealthFriendly" -- friendly > 4
|
self.color = "TargetHealthFriendly" -- friendly > 4
|
||||||
|
|
||||||
local reaction = UnitReaction("target", "player")
|
local reaction = UnitReaction("target", "player")
|
||||||
@ -203,6 +288,54 @@ function TargetHealth.prototype:Update(unit)
|
|||||||
end
|
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)
|
function TargetHealth.prototype:Round(health)
|
||||||
if (health > 1000000) then
|
if (health > 1000000) then
|
||||||
return self:MathRound(health/1000000, 1) .. "M"
|
return self:MathRound(health/1000000, 1) .. "M"
|
||||||
|
Reference in New Issue
Block a user