- made the TargetInfo able to be inherited from

- added a PlayerInfo module (off by default, user requested) that inherits from TargetInfo and adds right-click dismissing buffs functionality
This commit is contained in:
Parnic
2009-04-10 05:23:31 +00:00
parent ab27807fa8
commit c7faba52f8
3 changed files with 154 additions and 105 deletions

View File

@ -56,3 +56,5 @@ modules\MaelstromCount.lua
modules\HungerForBlood.lua modules\HungerForBlood.lua
modules\CustomBar.lua modules\CustomBar.lua
modules\CustomCount.lua modules\CustomCount.lua
# - make sure PlayerInfo loads after TargetInfo since it inherits
modules\PlayerInfo.lua

43
modules/PlayerInfo.lua Normal file
View File

@ -0,0 +1,43 @@
local AceOO = AceLibrary("AceOO-2.0")
local PlayerInfo = AceOO.Class(IceTargetInfo)
-- Constructor --
function PlayerInfo.prototype:init()
PlayerInfo.super.prototype.init(self, "PlayerInfo", "player")
end
function PlayerInfo.prototype:GetDefaultSettings()
local settings = PlayerInfo.super.prototype.GetDefaultSettings(self)
settings["enabled"] = false
settings["vpos"] = -100
return settings
end
function PlayerInfo.prototype:CreateFrame(redraw)
PlayerInfo.super.prototype.CreateFrame(self, redraw)
self.frame.menu = function()
ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor")
end
end
function PlayerInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
local buffs = PlayerInfo.super.prototype.CreateIconFrames(self, parent, direction, buffs, type)
for i = 1, IceCore.BuffLimit do
if (self.moduleSettings.mouseBuff) then
buffs[i]:SetScript("OnMouseUp", function( self, button)
if( button == "RightButton" ) then CancelUnitBuff("player", i) end
end)
else
buffs[i]:SetScript("OnMouseUp", nil)
end
end
return buffs
end
-- Load us up
IceHUD.PlayerInfo = PlayerInfo:new()

View File

@ -1,38 +1,45 @@
local AceOO = AceLibrary("AceOO-2.0") local AceOO = AceLibrary("AceOO-2.0")
local TargetInfo = AceOO.Class(IceElement) IceTargetInfo = AceOO.Class(IceElement)
local DogTag = nil local DogTag = nil
local target = "target"
local internal = "internal" local internal = "internal"
local ValidAnchors = { "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT", "CENTER" } local ValidAnchors = { "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT", "CENTER" }
TargetInfo.prototype.buffSize = nil IceTargetInfo.prototype.unit = "target"
TargetInfo.prototype.ownBuffSize = nil
TargetInfo.prototype.width = nil
TargetInfo.prototype.name = nil IceTargetInfo.prototype.buffSize = nil
TargetInfo.prototype.guild = nil IceTargetInfo.prototype.ownBuffSize = nil
TargetInfo.prototype.realm = nil IceTargetInfo.prototype.width = nil
TargetInfo.prototype.classLocale = nil
TargetInfo.prototype.classEnglish = nil
TargetInfo.prototype.leader = nil
TargetInfo.prototype.targetCombat = nil IceTargetInfo.prototype.name = nil
TargetInfo.prototype.pvp = nil IceTargetInfo.prototype.guild = nil
TargetInfo.prototype.level = nil IceTargetInfo.prototype.realm = nil
TargetInfo.prototype.classification = nil IceTargetInfo.prototype.classLocale = nil
TargetInfo.prototype.reaction = nil IceTargetInfo.prototype.classEnglish = nil
TargetInfo.prototype.tapped = nil IceTargetInfo.prototype.leader = nil
TargetInfo.prototype.isPlayer = nil IceTargetInfo.prototype.targetCombat = nil
IceTargetInfo.prototype.pvp = nil
IceTargetInfo.prototype.level = nil
IceTargetInfo.prototype.classification = nil
IceTargetInfo.prototype.reaction = nil
IceTargetInfo.prototype.tapped = nil
IceTargetInfo.prototype.isPlayer = nil
-- Constructor -- -- Constructor --
function TargetInfo.prototype:init() function IceTargetInfo.prototype:init(moduleName, unit)
TargetInfo.super.prototype.init(self, "TargetInfo") self.unit = unit or "target"
if not moduleName or not unit then
IceTargetInfo.super.prototype.init(self, "TargetInfo")
else
IceTargetInfo.super.prototype.init(self, moduleName)
end
self.scalingEnabled = true self.scalingEnabled = true
end end
@ -42,8 +49,8 @@ end
-- 'Public' methods ----------------------------------------------------------- -- 'Public' methods -----------------------------------------------------------
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:Enable(core) function IceTargetInfo.prototype:Enable(core)
TargetInfo.super.prototype.Enable(self, core) IceTargetInfo.super.prototype.Enable(self, core)
if IceHUD.IceCore:ShouldUseDogTags() then if IceHUD.IceCore:ShouldUseDogTags() then
DogTag = AceLibrary("LibDogTag-3.0") DogTag = AceLibrary("LibDogTag-3.0")
@ -77,8 +84,8 @@ end
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:Disable(core) function IceTargetInfo.prototype:Disable(core)
TargetInfo.super.prototype.Disable(self, core) IceTargetInfo.super.prototype.Disable(self, core)
UnregisterUnitWatch(self.frame) UnregisterUnitWatch(self.frame)
@ -87,8 +94,8 @@ end
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:GetOptions() function IceTargetInfo.prototype:GetOptions()
local opts = TargetInfo.super.prototype.GetOptions(self) local opts = IceTargetInfo.super.prototype.GetOptions(self)
opts["targetInfoHeader"] = { opts["targetInfoHeader"] = {
type = 'header', type = 'header',
@ -576,8 +583,8 @@ end
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:GetDefaultSettings() function IceTargetInfo.prototype:GetDefaultSettings()
local defaults = TargetInfo.super.prototype.GetDefaultSettings(self) local defaults = IceTargetInfo.super.prototype.GetDefaultSettings(self)
defaults["fontSize"] = 13 defaults["fontSize"] = 13
defaults["stackFontSize"] = 11 defaults["stackFontSize"] = 11
@ -608,32 +615,32 @@ function TargetInfo.prototype:GetDefaultSettings()
end end
function TargetInfo.prototype:RegisterFontStrings() function IceTargetInfo.prototype:RegisterFontStrings()
if DogTag ~= nil then if DogTag ~= nil then
if self.frame.targetName then if self.frame.targetName then
if self.moduleSettings.line1Tag ~= '' then if self.moduleSettings.line1Tag ~= '' then
DogTag:AddFontString(self.frame.targetName, self.frame, self.moduleSettings.line1Tag, "Unit", { unit = target }) DogTag:AddFontString(self.frame.targetName, self.frame, self.moduleSettings.line1Tag, "Unit", { unit = self.unit })
else else
DogTag:RemoveFontString(self.frame.targetName) DogTag:RemoveFontString(self.frame.targetName)
end end
end end
if self.frame.targetInfo then if self.frame.targetInfo then
if self.moduleSettings.line2Tag ~= '' then if self.moduleSettings.line2Tag ~= '' then
DogTag:AddFontString(self.frame.targetInfo, self.frame, self.moduleSettings.line2Tag, "Unit", { unit = target }) DogTag:AddFontString(self.frame.targetInfo, self.frame, self.moduleSettings.line2Tag, "Unit", { unit = self.unit })
else else
DogTag:RemoveFontString(self.frame.targetInfo) DogTag:RemoveFontString(self.frame.targetInfo)
end end
end end
if self.frame.targetGuild then if self.frame.targetGuild then
if self.moduleSettings.line3Tag ~= '' then if self.moduleSettings.line3Tag ~= '' then
DogTag:AddFontString(self.frame.targetGuild, self.frame, self.moduleSettings.line3Tag, "Unit", { unit = target }) DogTag:AddFontString(self.frame.targetGuild, self.frame, self.moduleSettings.line3Tag, "Unit", { unit = self.unit })
else else
DogTag:RemoveFontString(self.frame.targetGuild) DogTag:RemoveFontString(self.frame.targetGuild)
end end
end end
if self.frame.targetExtra then if self.frame.targetExtra then
if self.moduleSettings.line4Tag ~= '' then if self.moduleSettings.line4Tag ~= '' then
DogTag:AddFontString(self.frame.targetExtra, self.frame, self.moduleSettings.line4Tag, "Unit", { unit = target }) DogTag:AddFontString(self.frame.targetExtra, self.frame, self.moduleSettings.line4Tag, "Unit", { unit = self.unit })
else else
DogTag:RemoveFontString(self.frame.targetExtra) DogTag:RemoveFontString(self.frame.targetExtra)
end end
@ -644,7 +651,7 @@ function TargetInfo.prototype:RegisterFontStrings()
end end
end end
function TargetInfo.prototype:UnregisterFontStrings() function IceTargetInfo.prototype:UnregisterFontStrings()
if DogTag ~= nil then if DogTag ~= nil then
DogTag:RemoveFontString(self.frame.targetName) DogTag:RemoveFontString(self.frame.targetName)
DogTag:RemoveFontString(self.frame.targetInfo) DogTag:RemoveFontString(self.frame.targetInfo)
@ -655,8 +662,8 @@ end
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:Redraw() function IceTargetInfo.prototype:Redraw()
TargetInfo.super.prototype.Redraw(self) IceTargetInfo.super.prototype.Redraw(self)
if (self.moduleSettings.enabled) then if (self.moduleSettings.enabled) then
self:CreateFrame(true) self:CreateFrame(true)
@ -665,7 +672,7 @@ function TargetInfo.prototype:Redraw()
end end
function TargetInfo.prototype:RedrawBuffs() function IceTargetInfo.prototype:RedrawBuffs()
if (self.moduleSettings.enabled) then if (self.moduleSettings.enabled) then
self:CreateBuffFrame(false) self:CreateBuffFrame(false)
self:CreateDebuffFrame(false) self:CreateDebuffFrame(false)
@ -679,7 +686,7 @@ end
-- 'Protected' methods -------------------------------------------------------- -- 'Protected' methods --------------------------------------------------------
-- OVERRIDE -- OVERRIDE
function TargetInfo.prototype:CreateFrame(redraw) function IceTargetInfo.prototype:CreateFrame(redraw)
if not (self.frame) then if not (self.frame) then
self.frame = CreateFrame("Button", "IceHUD_"..self.elementName, self.parent, "SecureUnitButtonTemplate") self.frame = CreateFrame("Button", "IceHUD_"..self.elementName, self.parent, "SecureUnitButtonTemplate")
end end
@ -688,9 +695,6 @@ function TargetInfo.prototype:CreateFrame(redraw)
self.width = math.max(200, self.settings.gap + 50) self.width = math.max(200, self.settings.gap + 50)
self.frame:SetScale(self.moduleSettings.scale) self.frame:SetScale(self.moduleSettings.scale)
-- set showing/hiding the frame depending on current target
self.frame:SetAttribute("unit", target)
self.frame:SetFrameStrata("BACKGROUND") self.frame:SetFrameStrata("BACKGROUND")
self.frame:SetWidth(self.width) self.frame:SetWidth(self.width)
@ -698,7 +702,7 @@ function TargetInfo.prototype:CreateFrame(redraw)
self.frame:ClearAllPoints() self.frame:ClearAllPoints()
self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos) self.frame:SetPoint("TOP", self.parent, "BOTTOM", self.moduleSettings.hpos, self.moduleSettings.vpos)
self.frame:SetScale(self.moduleSettings.scale) self.frame:SetScale(self.moduleSettings.scale)
if (self.moduleSettings.mouseTarget) then if (self.moduleSettings.mouseTarget) then
self.frame:EnableMouse(true) self.frame:EnableMouse(true)
self.frame:RegisterForClicks("AnyUp") self.frame:RegisterForClicks("AnyUp")
@ -710,19 +714,19 @@ function TargetInfo.prototype:CreateFrame(redraw)
self.frame:SetScript("OnEnter", nil) self.frame:SetScript("OnEnter", nil)
self.frame:SetScript("OnLeave", nil) self.frame:SetScript("OnLeave", nil)
end end
self.frame.unit = target
self.frame.unit = self.unit
-- set up stuff for clicking -- set up stuff for clicking
self.frame:SetAttribute("type1", "target") self.frame:SetAttribute("type1", "target")
self.frame:SetAttribute("type2", "menu") self.frame:SetAttribute("type2", "menu")
self.frame:SetAttribute("unit", target) self.frame:SetAttribute("unit", self.unit)
self.frame.menu = function() self.frame.menu = function()
ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor") ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor")
end end
-- create a fancy highlight frame for mouse over -- create a fancy highlight frame for mouse over
if (not self.frame.highLight) then if (not self.frame.highLight) then
self.frame.highLight = self.frame:CreateTexture(nil, "OVERLAY") self.frame.highLight = self.frame:CreateTexture(nil, "OVERLAY")
@ -744,15 +748,15 @@ function TargetInfo.prototype:CreateFrame(redraw)
self:CreateDebuffFrame(redraw) self:CreateDebuffFrame(redraw)
self:CreateRaidIconFrame() self:CreateRaidIconFrame()
-- set up click casting -- set up click casting
ClickCastFrames = ClickCastFrames or {} ClickCastFrames = ClickCastFrames or {}
ClickCastFrames[self.frame] = true ClickCastFrames[self.frame] = true
end end
function TargetInfo.prototype:CreateTextFrame() function IceTargetInfo.prototype:CreateTextFrame()
self.frame.targetName = self:FontFactory(self.moduleSettings.fontSize+1, nil, self.frame.targetName) self.frame.targetName = self:FontFactory(self.moduleSettings.fontSize+1, nil, self.frame.targetName)
self.frame.targetName:SetJustifyH("CENTER") self.frame.targetName:SetJustifyH("CENTER")
@ -762,7 +766,7 @@ function TargetInfo.prototype:CreateTextFrame()
end end
function TargetInfo.prototype:CreateInfoTextFrame() function IceTargetInfo.prototype:CreateInfoTextFrame()
self.frame.targetInfo = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetInfo) self.frame.targetInfo = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetInfo)
-- self.frame.targetInfo:SetWidth(self.width) -- self.frame.targetInfo:SetWidth(self.width)
@ -775,7 +779,7 @@ function TargetInfo.prototype:CreateInfoTextFrame()
end end
function TargetInfo.prototype:CreateGuildTextFrame() function IceTargetInfo.prototype:CreateGuildTextFrame()
self.frame.targetGuild = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetGuild) self.frame.targetGuild = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetGuild)
-- self.frame.targetInfo:SetWidth(self.width) -- self.frame.targetInfo:SetWidth(self.width)
@ -788,7 +792,7 @@ function TargetInfo.prototype:CreateGuildTextFrame()
end end
function TargetInfo.prototype:CreateExtraTextFrame() function IceTargetInfo.prototype:CreateExtraTextFrame()
self.frame.targetExtra = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetExtra) self.frame.targetExtra = self:FontFactory(self.moduleSettings.fontSize, nil, self.frame.targetExtra)
self.frame.targetExtra:SetHeight(14) self.frame.targetExtra:SetHeight(14)
@ -800,7 +804,7 @@ function TargetInfo.prototype:CreateExtraTextFrame()
end end
function TargetInfo.prototype:CreateRaidIconFrame() function IceTargetInfo.prototype:CreateRaidIconFrame()
if (not self.frame.raidIcon) then if (not self.frame.raidIcon) then
self.frame.raidIcon = CreateFrame("Frame", nil, self.frame) self.frame.raidIcon = CreateFrame("Frame", nil, self.frame)
end end
@ -820,7 +824,7 @@ function TargetInfo.prototype:CreateRaidIconFrame()
end end
function TargetInfo.prototype:CreateBuffFrame(redraw) function IceTargetInfo.prototype:CreateBuffFrame(redraw)
if (not self.frame.buffFrame) then if (not self.frame.buffFrame) then
self.frame.buffFrame = CreateFrame("Frame", nil, self.frame) self.frame.buffFrame = CreateFrame("Frame", nil, self.frame)
@ -843,7 +847,7 @@ function TargetInfo.prototype:CreateBuffFrame(redraw)
end end
function TargetInfo.prototype:CreateDebuffFrame(redraw) function IceTargetInfo.prototype:CreateDebuffFrame(redraw)
if (not self.frame.debuffFrame) then if (not self.frame.debuffFrame) then
self.frame.debuffFrame = CreateFrame("Frame", nil, self.frame) self.frame.debuffFrame = CreateFrame("Frame", nil, self.frame)
@ -866,7 +870,7 @@ function TargetInfo.prototype:CreateDebuffFrame(redraw)
end end
function TargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type) function IceTargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
local lastX = 0 local lastX = 0
local lastBuffSize = 0 local lastBuffSize = 0
@ -966,11 +970,11 @@ function TargetInfo.prototype:CreateIconFrames(parent, direction, buffs, type)
return buffs return buffs
end end
function TargetInfo.prototype:SetBuffSize(buff) function IceTargetInfo.prototype:SetBuffSize(buff)
end end
function TargetInfo.prototype:UpdateBuffs() function IceTargetInfo.prototype:UpdateBuffs()
local zoom = self.moduleSettings.zoom local zoom = self.moduleSettings.zoom
local filter = false local filter = false
@ -982,17 +986,17 @@ function TargetInfo.prototype:UpdateBuffs()
end end
end end
local hostile = UnitCanAttack("player", "target") local hostile = UnitCanAttack("player", self.unit)
for i = 1, IceCore.BuffLimit do for i = 1, IceCore.BuffLimit do
local buffName, buffRank, buffTexture, buffApplications, buffType, buffDuration, buffTimeLeft, isFromMe; local buffName, buffRank, buffTexture, buffApplications, buffType, buffDuration, buffTimeLeft, isFromMe;
if IceHUD.WowVer >= 30000 then if IceHUD.WowVer >= 30000 then
buffName, buffRank, buffTexture, buffApplications, buffType, buffDuration, buffTimeLeft, isFromMe buffName, buffRank, buffTexture, buffApplications, buffType, buffDuration, buffTimeLeft, isFromMe
= UnitAura("target", i, "HELPFUL" .. (filter and "|PLAYER" or "")) --UnitBuff("target", i, filter and not hostile) = UnitAura(self.unit, i, "HELPFUL" .. (filter and "|PLAYER" or "")) --UnitBuff(self.unit, i, filter and not hostile)
else else
buffName, buffRank, buffTexture, buffApplications, buffDuration, buffTimeLeft buffName, buffRank, buffTexture, buffApplications, buffDuration, buffTimeLeft
= UnitBuff("target", i, filter and not hostile) = UnitBuff(self.unit, i, filter and not hostile)
isFromMe = buffDuration and buffTimeLeft isFromMe = buffDuration and buffTimeLeft
end end
@ -1040,7 +1044,7 @@ function TargetInfo.prototype:UpdateBuffs()
for i = 1, IceCore.BuffLimit do for i = 1, IceCore.BuffLimit do
local buffName, buffRank, buffTexture, buffApplications, debuffDispelType, local buffName, buffRank, buffTexture, buffApplications, debuffDispelType,
debuffDuration, debuffTimeLeft, isFromMe = UnitAura("target", i, "HARMFUL" .. (filter and "|PLAYER" or "")) --UnitDebuff("target", i, filter and not hostile) debuffDuration, debuffTimeLeft, isFromMe = UnitAura(self.unit, i, "HARMFUL" .. (filter and "|PLAYER" or "")) --UnitDebuff(self.unit, i, filter and not hostile)
if (buffTexture and (not hostile or not filter or (filter and debuffDuration))) then if (buffTexture and (not hostile or not filter or (filter and debuffDuration))) then
@ -1089,20 +1093,20 @@ end
function TargetInfo.prototype:AuraChanged(unit) function IceTargetInfo.prototype:AuraChanged(unit)
if (unit == target) then if (unit == self.unit) then
self:UpdateBuffs() self:UpdateBuffs()
end end
end end
function TargetInfo.prototype:UpdateRaidTargetIcon() function IceTargetInfo.prototype:UpdateRaidTargetIcon()
if not (UnitExists(target)) then if not (UnitExists(self.unit)) then
self.frame.raidIcon:Hide() self.frame.raidIcon:Hide()
return return
end end
local index = GetRaidTargetIndex(target); local index = GetRaidTargetIndex(self.unit);
if (index and (index > 0)) then if (index and (index > 0)) then
SetRaidTargetIconTexture(self.frame.raidIcon.icon, index) SetRaidTargetIconTexture(self.frame.raidIcon.icon, index)
@ -1113,10 +1117,10 @@ function TargetInfo.prototype:UpdateRaidTargetIcon()
end end
function TargetInfo.prototype:TargetChanged() function IceTargetInfo.prototype:TargetChanged()
TargetInfo.super.prototype.TargetChanged(self) IceTargetInfo.super.prototype.TargetChanged(self)
if (not UnitExists(target)) then if (not UnitExists(self.unit)) then
--self.frame:Hide() --self.frame:Hide()
--self.frame.target:Hide() --self.frame.target:Hide()
@ -1144,18 +1148,18 @@ function TargetInfo.prototype:TargetChanged()
self:UpdateBuffs() self:UpdateBuffs()
self:UpdateRaidTargetIcon() self:UpdateRaidTargetIcon()
self:Update(target) self:Update(self.unit)
end end
function TargetInfo.prototype:TargetName(unit) function IceTargetInfo.prototype:TargetName(unit)
if (unit == target or unit == internal) then if (unit == self.unit or unit == internal) then
self.name, self.realm = UnitName(target) self.name, self.realm = UnitName(self.unit)
self.classLocale, self.classEnglish = UnitClass(target) self.classLocale, self.classEnglish = UnitClass(self.unit)
self.isPlayer = UnitIsPlayer(target) self.isPlayer = UnitIsPlayer(self.unit)
local classification = UnitClassification(target) or "" local classification = UnitClassification(self.unit) or ""
if (string.find(classification, "boss")) then if (string.find(classification, "boss")) then
self.classification = " |cffcc1111Boss|r" self.classification = " |cffcc1111Boss|r"
elseif(string.find(classification, "rare")) then elseif(string.find(classification, "rare")) then
@ -1165,31 +1169,31 @@ function TargetInfo.prototype:TargetName(unit)
end end
local guildName, guildRankName, guildRankIndex = GetGuildInfo(target); local guildName, guildRankName, guildRankIndex = GetGuildInfo(self.unit);
self.guild = guildName and "<" .. guildName .. ">" or "" self.guild = guildName and "<" .. guildName .. ">" or ""
if (self.classLocale and self.isPlayer) then if (self.classLocale and self.isPlayer) then
self.classLocale = "|c" .. self:GetHexColor(self.classEnglish) .. self.classLocale .. "|r" self.classLocale = "|c" .. self:GetHexColor(self.classEnglish) .. self.classLocale .. "|r"
else else
self.classLocale = UnitCreatureType(target) self.classLocale = UnitCreatureType(self.unit)
end end
self.leader = UnitIsPartyLeader(target) and " |cffcccc11Leader|r" or "" self.leader = UnitIsPartyLeader(self.unit) and " |cffcccc11Leader|r" or ""
self:Update(unit) self:Update(unit)
end end
end end
function TargetInfo.prototype:TargetLevel(unit) function IceTargetInfo.prototype:TargetLevel(unit)
if (unit == target or unit == internal) then if (unit == self.unit or unit == internal) then
self.level = UnitLevel(target) self.level = UnitLevel(self.unit)
local color = GetDifficultyColor((self.level > 0) and self.level or 100) local color = GetDifficultyColor((self.level > 0) and self.level or 100)
if (self.level > 0) then if (self.level > 0) then
if (UnitClassification(target) == "elite") then if (UnitClassification(self.unit) == "elite") then
self.level = self.level .. "+" self.level = self.level .. "+"
end end
else else
@ -1203,9 +1207,9 @@ function TargetInfo.prototype:TargetLevel(unit)
end end
function TargetInfo.prototype:TargetReaction(unit) function IceTargetInfo.prototype:TargetReaction(unit)
if (unit == target or unit == internal) then if (unit == self.unit or unit == internal) then
self.reaction = UnitReaction(target, "player") self.reaction = UnitReaction(self.unit, "player")
-- if we don't get reaction, unit is out of range - has to be friendly -- if we don't get reaction, unit is out of range - has to be friendly
-- to be targettable (party/raid) -- to be targettable (party/raid)
@ -1218,12 +1222,12 @@ end
-- PVP status -- PVP status
function TargetInfo.prototype:TargetFaction(unit) function IceTargetInfo.prototype:TargetFaction(unit)
if (unit == target or unit == internal) then if (unit == self.unit or unit == internal) then
if (self.isPlayer) then if (self.isPlayer) then
if (UnitIsPVP(target)) then if (UnitIsPVP(self.unit)) then
local color = "ff10ff10" -- friendly local color = "ff10ff10" -- friendly
if (UnitFactionGroup(target) ~= UnitFactionGroup("player")) then if (UnitFactionGroup(self.unit) ~= UnitFactionGroup("player")) then
color = "ffff1010" -- hostile color = "ffff1010" -- hostile
end end
self.pvp = " |c" .. color .. "PvP|r" self.pvp = " |c" .. color .. "PvP|r"
@ -1240,24 +1244,24 @@ function TargetInfo.prototype:TargetFaction(unit)
end end
function TargetInfo.prototype:TargetFlags(unit) function IceTargetInfo.prototype:TargetFlags(unit)
if (unit == target or unit == internal) then if (unit == self.unit or unit == internal) then
self.tapped = UnitIsTapped(target) and (not UnitIsTappedByPlayer(target)) self.tapped = UnitIsTapped(self.unit) and (not UnitIsTappedByPlayer(self.unit))
self.targetCombat = UnitAffectingCombat(target) and " |cffee4030Combat|r" or "" self.targetCombat = UnitAffectingCombat(self.unit) and " |cffee4030Combat|r" or ""
self:UpdateBuffs() self:UpdateBuffs()
self:Update(unit) self:Update(unit)
end end
end end
function TargetInfo.prototype:Update(unit) function IceTargetInfo.prototype:Update(unit)
if (unit ~= target) then if (unit ~= self.unit) then
return return
end end
if DogTag == nil then if DogTag == nil then
self.frame.targetName:SetText(self.name or '') self.frame.targetName:SetText(self.name or '')
self.frame.targetName:SetVertexColor(UnitSelectionColor("target")) self.frame.targetName:SetVertexColor(UnitSelectionColor(self.unit))
local line2 = string.format("%s %s%s%s%s%s", local line2 = string.format("%s %s%s%s%s%s",
self.level or '', self.classLocale or '', self.pvp or '', self.leader or '', self.classification or '', self.targetCombat or '') self.level or '', self.classLocale or '', self.pvp or '', self.leader or '', self.classification or '', self.targetCombat or '')
@ -1282,31 +1286,31 @@ function TargetInfo.prototype:Update(unit)
end end
function TargetInfo.prototype:OnEnter(frame) function IceTargetInfo.prototype:OnEnter(frame)
UnitFrame_OnEnter(frame) UnitFrame_OnEnter(frame)
self.frame.highLight:Show() self.frame.highLight:Show()
end end
function TargetInfo.prototype:OnLeave(frame) function IceTargetInfo.prototype:OnLeave(frame)
UnitFrame_OnLeave(frame) UnitFrame_OnLeave(frame)
self.frame.highLight:Hide() self.frame.highLight:Hide()
end end
function TargetInfo.prototype:BuffOnEnter(type) function IceTargetInfo.prototype:BuffOnEnter(type)
if (not this:IsVisible()) then if (not this:IsVisible()) then
return return
end end
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
if (type == "buff") then if (type == "buff") then
GameTooltip:SetUnitBuff(target, this.id) GameTooltip:SetUnitBuff(self.unit, this.id)
else else
GameTooltip:SetUnitDebuff(target, this.id) GameTooltip:SetUnitDebuff(self.unit, this.id)
end end
end end
-- Load us up -- Load us up
IceHUD.TargetInfo = TargetInfo:new() IceHUD.TargetInfo = IceTargetInfo:new()