- added a global toggle for DogTags so they can be enabled or disabled for the mod

- added an optional rare/elite/rare-elite indicator to the target health bar (off by default)
- made configuration mode show target raid icons (and the new elite indicator as well)
This commit is contained in:
Parnic
2008-10-26 23:02:13 +00:00
parent f9de9f8c92
commit 49a590e879
16 changed files with 207 additions and 28 deletions

View File

@ -18,11 +18,6 @@ IceBarElement.prototype.CurrScale = 1
-- Constructor -- -- Constructor --
function IceBarElement.prototype:init(name) function IceBarElement.prototype:init(name)
IceBarElement.super.prototype.init(self, name) IceBarElement.super.prototype.init(self, name)
if AceLibrary:HasInstance("LibDogTag-3.0") then
DogTag = AceLibrary("LibDogTag-3.0")
AceLibrary("LibDogTag-Unit-3.0")
end
end end
@ -33,6 +28,11 @@ end
function IceBarElement.prototype:Enable() function IceBarElement.prototype:Enable()
IceBarElement.super.prototype.Enable(self) IceBarElement.super.prototype.Enable(self)
if IceHUD.IceCore:ShouldUseDogTags() and AceLibrary:HasInstance("LibDogTag-3.0") then
DogTag = AceLibrary("LibDogTag-3.0")
AceLibrary("LibDogTag-Unit-3.0")
end
if self.moduleSettings.myTagVersion < IceHUD.CurrTagVersion then if self.moduleSettings.myTagVersion < IceHUD.CurrTagVersion then
local origDefaults = self:GetDefaultSettings() local origDefaults = self:GetDefaultSettings()

View File

@ -61,6 +61,8 @@ function IceCore.prototype:init()
barBlendMode = "BLEND", barBlendMode = "BLEND",
barBgBlendMode = "BLEND", barBgBlendMode = "BLEND",
bShouldUseDogTags = true
} }
self:LoadPresets() self:LoadPresets()
@ -450,6 +452,14 @@ function IceCore.prototype:ConfigModeToggle(bWantConfig)
end end
end end
function IceCore.prototype:ShouldUseDogTags()
return AceLibrary:HasInstance("LibDogTag-3.0") and self.settings.bShouldUseDogTags
end
function IceCore.prototype:SetShouldUseDogTags(should)
self.settings.bShouldUseDogTags = should
end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Presets -- -- Presets --

View File

@ -493,6 +493,34 @@ IceHUD.options =
end, end,
order = 95 order = 95
}, },
useDogTags = {
type = 'toggle',
name = 'Use Dog Tags',
desc = 'Whether or not the addon should use the DogTag library (this will increase the CPU usage of the mod)\n\nNOTE: after changing this option, you must reload the UI or else bad things happen',
get = function()
return IceHUD.IceCore:ShouldUseDogTags()
end,
set = function(v)
StaticPopupDialogs["ICEHUD_CHANGED_DOGTAG"] = {
text = "This option requires the UI to be reloaded. Do you wish to reload it now?",
button1 = "Yes",
OnAccept = function()
ReloadUI()
end,
button2 = "No",
timeout = 0,
whileDead = 1,
hideOnEscape = 1
};
IceHUD.IceCore:SetShouldUseDogTags(v)
StaticPopup_Show("ICEHUD_CHANGED_DOGTAG")
end,
hidden = function()
return not AceLibrary:HasInstance("LibDogTag-3.0")
end,
order = 96
},
} }
} }

View File

@ -366,7 +366,7 @@ function FocusHealth.prototype:Update(unit)
self:UpdateBar(self.health/self.maxHealth, self.color) self:UpdateBar(self.health/self.maxHealth, self.color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText1(math.floor(self.healthPercentage * 100))
-- first see if we have LibMobHealth that we can piggyback on -- first see if we have LibMobHealth that we can piggyback on

View File

@ -85,7 +85,7 @@ function FocusMana.prototype:Update(unit)
self:UpdateBar(self.mana/self.maxMana, color) self:UpdateBar(self.mana/self.maxMana, color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.manaPercentage * 100)) self:SetBottomText1(math.floor(self.manaPercentage * 100))
self:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color) self:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color)
end end

View File

@ -112,7 +112,7 @@ function PetHealth.prototype:Update(unit)
self:UpdateBar(self.health/self.maxHealth, color) self:UpdateBar(self.health/self.maxHealth, color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText1(math.floor(self.healthPercentage * 100))
end end
end end

View File

@ -123,7 +123,7 @@ function PetMana.prototype:Update(unit)
self:UpdateBar(self.mana/self.maxMana, color) self:UpdateBar(self.mana/self.maxMana, color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.manaPercentage * 100)) self:SetBottomText1(math.floor(self.manaPercentage * 100))
end end
end end

View File

@ -726,7 +726,7 @@ function PlayerHealth.prototype:Update(unit)
self:UpdateBar(self.health/self.maxHealth, color) self:UpdateBar(self.health/self.maxHealth, color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText1(math.floor(self.healthPercentage * 100))
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor) self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor)
end end
@ -755,7 +755,9 @@ end
function PlayerHealth.prototype:CreateTexCoord(texframe, icon, width, height, scale, left, right, top, bottom) function PlayerHealth.prototype:CreateTexCoord(texframe, icon, width, height, scale, left, right, top, bottom)
texframe = self.frame:CreateTexture(nil, "BACKGROUND") if not texframe then
texframe = self.frame:CreateTexture(nil, "BACKGROUND")
end
texframe:SetTexture(icon) texframe:SetTexture(icon)
texframe:SetTexCoord(left, right, top, bottom) texframe:SetTexCoord(left, right, top, bottom)
self:SetTexScale(texframe, width, height, scale) self:SetTexScale(texframe, width, height, scale)
@ -777,6 +779,10 @@ end
function PlayerHealth.prototype:DestroyTexFrame(texframe) function PlayerHealth.prototype:DestroyTexFrame(texframe)
if not texframe then
return nil
end
texframe:SetTexture(nil) texframe:SetTexture(nil)
texframe:Hide() texframe:Hide()
texframe:ClearAllPoints() texframe:ClearAllPoints()

View File

@ -214,7 +214,7 @@ function PlayerMana.prototype:Update(unit)
end end
end end
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
-- extra hack for whiny rogues (are there other kind?) -- extra hack for whiny rogues (are there other kind?)
local displayPercentage = self.manaPercentage local displayPercentage = self.manaPercentage
if (self.manaType == 3) then if (self.manaType == 3) then

View File

@ -14,15 +14,15 @@ function RangeCheck.prototype:init()
if AceLibrary:HasInstance("LibRangeCheck-2.0") then if AceLibrary:HasInstance("LibRangeCheck-2.0") then
LibRange = AceLibrary("LibRangeCheck-2.0") LibRange = AceLibrary("LibRangeCheck-2.0")
end end
if AceLibrary:HasInstance("LibDogTag-3.0") then
DogTag = AceLibrary("LibDogTag-3.0")
end
end end
function RangeCheck.prototype:Enable(core) function RangeCheck.prototype:Enable(core)
RangeCheck.super.prototype.Enable(self, core) RangeCheck.super.prototype.Enable(self, core)
if IceHUD.IceCore:ShouldUseDogTags() then
DogTag = AceLibrary("LibDogTag-3.0")
end
self:RegisterFontStrings() self:RegisterFontStrings()
end end

View File

@ -5,6 +5,15 @@ IceTargetHealth = AceOO.Class(IceUnitBar)
IceTargetHealth.prototype.color = nil IceTargetHealth.prototype.color = nil
IceTargetHealth.prototype.determineColor = true IceTargetHealth.prototype.determineColor = true
IceTargetHealth.prototype.registerEvents = true IceTargetHealth.prototype.registerEvents = true
IceTargetHealth.prototype.texWidth = 128
IceTargetHealth.prototype.texHeight = 128
IceTargetHealth.prototype.classLeft = 0
IceTargetHealth.prototype.classRight = 0.9375
IceTargetHealth.prototype.classTop = 0
IceTargetHealth.prototype.classBottom = 0.78125
IceTargetHealth.prototype.EliteTexture = IceElement.TexturePath .. "Elite"
IceTargetHealth.prototype.RareEliteTexture = IceElement.TexturePath .. "RareElite"
IceTargetHealth.prototype.RareTexture = IceElement.TexturePath .. "Rare"
-- Constructor -- -- Constructor --
function IceTargetHealth.prototype:init(moduleName, unit) function IceTargetHealth.prototype:init(moduleName, unit)
@ -35,6 +44,8 @@ function IceTargetHealth.prototype:GetDefaultSettings()
settings["raidIconYOffset"] = 0 settings["raidIconYOffset"] = 0
settings["lockIconAlpha"] = false settings["lockIconAlpha"] = false
settings["abbreviateHealth"] = true settings["abbreviateHealth"] = true
settings["classIconOffset"] = {x=0, y=0}
settings["showClassificationIcon"] = false
return settings return settings
end end
@ -191,11 +202,11 @@ function IceTargetHealth.prototype:GetOptions()
end, end,
order = 54 order = 54
} }
if not IceHUD.IceCore:ShouldUseDogTags() then
opts["shortenHealth"] = { opts["shortenHealth"] = {
type = 'toggle', type = 'toggle',
name = 'Abbreviate estimated health', name = 'Abbreviate estimated health',
desc = 'If this is checked, then a health value of 1100 will display as 1.1k, otherwise it shows the number\n\nNote: this only applies if you are NOT using DogTag', desc = 'If this is checked, then a health value of 1100 will display as 1.1k, otherwise it shows the number',
get = function() get = function()
return self.moduleSettings.abbreviateHealth return self.moduleSettings.abbreviateHealth
end, end,
@ -207,6 +218,64 @@ function IceTargetHealth.prototype:GetOptions()
end, end,
order = 40.1 order = 40.1
} }
end
opts["showClassificationIcon"] = {
type = "toggle",
name = "Show Elite Icon",
desc = "Whether or not to show the rare/elite icon above this bar",
get = function()
return self.moduleSettings.showClassificationIcon
end,
set = function(value)
self.moduleSettings.showClassificationIcon = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 60
}
opts["classIconXOffset"] = {
type = "range",
name = "Elite Icon X Offset",
desc = "How far to push the elite icon right or left",
min = -300,
max = 300,
step = 1,
get = function()
return self.moduleSettings.classIconOffset['x']
end,
set = function(value)
self.moduleSettings.classIconOffset['x'] = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 61
}
opts["classIconYOffset"] = {
type = "range",
name = "Elite Icon Y Offset",
desc = "How far to push the elite icon up or down",
min = -300,
max = 300,
step = 1,
get = function()
return self.moduleSettings.classIconOffset['y']
end,
set = function(value)
self.moduleSettings.classIconOffset['y'] = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 62
}
return opts return opts
end end
@ -246,7 +315,7 @@ function IceTargetHealth.prototype:Update(unit)
return return
end end
if not (UnitExists(unit)) then if unit and not (UnitExists(unit)) then
self:Show(false) self:Show(false)
return return
else else
@ -255,6 +324,31 @@ function IceTargetHealth.prototype:Update(unit)
self:UpdateRaidTargetIcon() self:UpdateRaidTargetIcon()
local classification = UnitClassification(self.unit);
if not self.moduleSettings.showClassificationIcon then
self:DestroyTexFrame(self.frame.classIcon)
else
if not self.frame.classIcon then
self.frame.classIcon = self:CreateTexCoord(self.frame.classIcon, self.EliteTexture, self.texWidth, self.texHeight,
self.moduleSettings.scale / 3.0, self.classLeft, self.classRight, self.classTop, self.classBottom)
end
self:SetTexLoc(self.frame.classIcon, self.moduleSettings.classIconOffset['x'], self.moduleSettings.classIconOffset['y'])
self.frame.classIcon:Show()
self.frame.classIcon:SetAlpha(self.alpha == 0 and 0 or math.min(1, self.alpha + 0.2))
if IceHUD.IceCore:IsInConfigMode() or classification == "worldboss" or classification == "elite" then
self.frame.classIcon:SetTexture(self.EliteTexture)
elseif classification == "rareelite" then
self.frame.classIcon:SetTexture(self.RareEliteTexture)
elseif classification == "rare" then
self.frame.classIcon:SetTexture(self.RareTexture)
else
self:DestroyTexFrame(self.frame.classIcon)
self.frame.classIcon:Hide()
end
end
if self.determineColor then if self.determineColor then
self.color = "TargetHealthFriendly" -- friendly > 4 self.color = "TargetHealthFriendly" -- friendly > 4
@ -280,7 +374,7 @@ function IceTargetHealth.prototype:Update(unit)
self:UpdateBar(self.health/self.maxHealth, self.color) self:UpdateBar(self.health/self.maxHealth, self.color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText1(math.floor(self.healthPercentage * 100))
if self.moduleSettings.abbreviateHealth then if self.moduleSettings.abbreviateHealth then
@ -297,6 +391,47 @@ function IceTargetHealth.prototype:Update(unit)
end end
function IceTargetHealth.prototype:CreateTexCoord(texframe, icon, width, height, scale, left, right, top, bottom)
if not texframe then
texframe = self.frame:CreateTexture(nil, "BACKGROUND")
end
texframe:SetTexture(icon)
if left and right and top and bottom then
texframe:SetTexCoord(left, right, top, bottom)
end
self:SetTexScale(texframe, width, height, scale or 1)
return texframe
end
function IceTargetHealth.prototype:SetTexLoc(texframe, xpos, ypos, anchorFrom, anchorTo)
texframe:ClearAllPoints()
texframe:SetPoint(anchorFrom or "TOPLEFT", self.frame, anchorTo or "TOPLEFT", xpos or 0, ypos or 0)
end
function IceTargetHealth.prototype:SetTexScale(texframe, width, height, scale)
texframe:SetWidth(width * scale)
texframe:SetHeight(height * scale)
end
function IceTargetHealth.prototype:DestroyTexFrame(texframe)
if not texframe then
return nil
end
texframe:SetTexture(nil)
texframe:Hide()
texframe:ClearAllPoints()
return texframe
end
function IceTargetHealth.prototype:CreateRaidIconFrame() function IceTargetHealth.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)
@ -329,12 +464,12 @@ function IceTargetHealth.prototype:UpdateRaidTargetIcon()
self.frame.raidIcon:SetFrameStrata("LOW") self.frame.raidIcon:SetFrameStrata("LOW")
end end
if not (UnitExists(self.unit)) or not self.moduleSettings.showRaidIcon then if not self.moduleSettings.showRaidIcon or (not UnitExists(self.unit) and not IceHUD.IceCore:IsInConfigMode()) then
self.frame.raidIcon:Hide() self.frame.raidIcon:Hide()
return return
end end
local index = GetRaidTargetIndex(self.unit); local index = IceHUD.IceCore:IsInConfigMode() and 1 or 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)

View File

@ -33,11 +33,6 @@ function TargetInfo.prototype:init()
TargetInfo.super.prototype.init(self, "TargetInfo") TargetInfo.super.prototype.init(self, "TargetInfo")
self.scalingEnabled = true self.scalingEnabled = true
if AceLibrary:HasInstance("LibDogTag-3.0") then
DogTag = AceLibrary("LibDogTag-3.0")
AceLibrary("LibDogTag-Unit-3.0")
end
end end
@ -48,6 +43,11 @@ end
function TargetInfo.prototype:Enable(core) function TargetInfo.prototype:Enable(core)
TargetInfo.super.prototype.Enable(self, core) TargetInfo.super.prototype.Enable(self, core)
if IceHUD.IceCore:ShouldUseDogTags() then
DogTag = AceLibrary("LibDogTag-3.0")
AceLibrary("LibDogTag-Unit-3.0")
end
self:RegisterEvent("UNIT_AURA", "AuraChanged") self:RegisterEvent("UNIT_AURA", "AuraChanged")
self:RegisterEvent("UNIT_NAME_UPDATE", "TargetName") self:RegisterEvent("UNIT_NAME_UPDATE", "TargetName")

View File

@ -107,7 +107,7 @@ function IceTargetMana.prototype:Update(unit)
self:UpdateBar(self.mana/self.maxMana, color) self:UpdateBar(self.mana/self.maxMana, color)
if not AceLibrary:HasInstance("LibDogTag-3.0") then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.manaPercentage * 100)) self:SetBottomText1(math.floor(self.manaPercentage * 100))
self:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color) self:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color)
end end

BIN
textures/Elite.blp Normal file

Binary file not shown.

BIN
textures/Rare.blp Normal file

Binary file not shown.

BIN
textures/RareElite.blp Normal file

Binary file not shown.