diff --git a/IceBarElement.lua b/IceBarElement.lua index 387001e..f7902d1 100644 --- a/IceBarElement.lua +++ b/IceBarElement.lua @@ -18,11 +18,6 @@ IceBarElement.prototype.CurrScale = 1 -- Constructor -- function IceBarElement.prototype:init(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 @@ -33,6 +28,11 @@ end function IceBarElement.prototype:Enable() 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 local origDefaults = self:GetDefaultSettings() diff --git a/IceCore.lua b/IceCore.lua index 997d13e..75997be 100644 --- a/IceCore.lua +++ b/IceCore.lua @@ -61,6 +61,8 @@ function IceCore.prototype:init() barBlendMode = "BLEND", barBgBlendMode = "BLEND", + + bShouldUseDogTags = true } self:LoadPresets() @@ -450,6 +452,14 @@ function IceCore.prototype:ConfigModeToggle(bWantConfig) 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 -- diff --git a/IceHUD.lua b/IceHUD.lua index 51991ee..b2d6715 100644 --- a/IceHUD.lua +++ b/IceHUD.lua @@ -493,6 +493,34 @@ IceHUD.options = end, 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 + }, } } diff --git a/modules/FocusHealth.lua b/modules/FocusHealth.lua index 993ae63..11e4816 100644 --- a/modules/FocusHealth.lua +++ b/modules/FocusHealth.lua @@ -366,7 +366,7 @@ function FocusHealth.prototype:Update(unit) 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)) -- first see if we have LibMobHealth that we can piggyback on diff --git a/modules/FocusMana.lua b/modules/FocusMana.lua index 4f69626..fb17937 100644 --- a/modules/FocusMana.lua +++ b/modules/FocusMana.lua @@ -85,7 +85,7 @@ function FocusMana.prototype:Update(unit) 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:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color) end diff --git a/modules/PetHealth.lua b/modules/PetHealth.lua index d01452d..7c1cd31 100644 --- a/modules/PetHealth.lua +++ b/modules/PetHealth.lua @@ -112,7 +112,7 @@ function PetHealth.prototype:Update(unit) 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)) end end diff --git a/modules/PetMana.lua b/modules/PetMana.lua index d9a6187..5f26364 100644 --- a/modules/PetMana.lua +++ b/modules/PetMana.lua @@ -123,7 +123,7 @@ function PetMana.prototype:Update(unit) 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)) end end diff --git a/modules/PlayerHealth.lua b/modules/PlayerHealth.lua index 41b308f..8f4a231 100644 --- a/modules/PlayerHealth.lua +++ b/modules/PlayerHealth.lua @@ -726,7 +726,7 @@ function PlayerHealth.prototype:Update(unit) 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:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor) end @@ -755,7 +755,9 @@ end 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:SetTexCoord(left, right, top, bottom) self:SetTexScale(texframe, width, height, scale) @@ -777,6 +779,10 @@ end function PlayerHealth.prototype:DestroyTexFrame(texframe) + if not texframe then + return nil + end + texframe:SetTexture(nil) texframe:Hide() texframe:ClearAllPoints() diff --git a/modules/PlayerMana.lua b/modules/PlayerMana.lua index b783648..1f5a84d 100644 --- a/modules/PlayerMana.lua +++ b/modules/PlayerMana.lua @@ -214,7 +214,7 @@ function PlayerMana.prototype:Update(unit) 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?) local displayPercentage = self.manaPercentage if (self.manaType == 3) then diff --git a/modules/RangeCheck.lua b/modules/RangeCheck.lua index 20240a3..70cbaf7 100644 --- a/modules/RangeCheck.lua +++ b/modules/RangeCheck.lua @@ -14,15 +14,15 @@ function RangeCheck.prototype:init() if AceLibrary:HasInstance("LibRangeCheck-2.0") then LibRange = AceLibrary("LibRangeCheck-2.0") end - - if AceLibrary:HasInstance("LibDogTag-3.0") then - DogTag = AceLibrary("LibDogTag-3.0") - end end function RangeCheck.prototype:Enable(core) RangeCheck.super.prototype.Enable(self, core) + if IceHUD.IceCore:ShouldUseDogTags() then + DogTag = AceLibrary("LibDogTag-3.0") + end + self:RegisterFontStrings() end diff --git a/modules/TargetHealth.lua b/modules/TargetHealth.lua index a02be6d..fd0159f 100644 --- a/modules/TargetHealth.lua +++ b/modules/TargetHealth.lua @@ -5,6 +5,15 @@ IceTargetHealth = AceOO.Class(IceUnitBar) IceTargetHealth.prototype.color = nil IceTargetHealth.prototype.determineColor = 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 -- function IceTargetHealth.prototype:init(moduleName, unit) @@ -35,6 +44,8 @@ function IceTargetHealth.prototype:GetDefaultSettings() settings["raidIconYOffset"] = 0 settings["lockIconAlpha"] = false settings["abbreviateHealth"] = true + settings["classIconOffset"] = {x=0, y=0} + settings["showClassificationIcon"] = false return settings end @@ -191,11 +202,11 @@ function IceTargetHealth.prototype:GetOptions() end, order = 54 } - +if not IceHUD.IceCore:ShouldUseDogTags() then opts["shortenHealth"] = { type = 'toggle', 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() return self.moduleSettings.abbreviateHealth end, @@ -207,6 +218,64 @@ function IceTargetHealth.prototype:GetOptions() end, 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 end @@ -246,7 +315,7 @@ function IceTargetHealth.prototype:Update(unit) return end - if not (UnitExists(unit)) then + if unit and not (UnitExists(unit)) then self:Show(false) return else @@ -255,6 +324,31 @@ function IceTargetHealth.prototype:Update(unit) 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 self.color = "TargetHealthFriendly" -- friendly > 4 @@ -280,7 +374,7 @@ function IceTargetHealth.prototype:Update(unit) 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)) if self.moduleSettings.abbreviateHealth then @@ -297,6 +391,47 @@ function IceTargetHealth.prototype:Update(unit) 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() if (not self.frame.raidIcon) then self.frame.raidIcon = CreateFrame("Frame", nil, self.frame) @@ -329,12 +464,12 @@ function IceTargetHealth.prototype:UpdateRaidTargetIcon() self.frame.raidIcon:SetFrameStrata("LOW") 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() return end - local index = GetRaidTargetIndex(self.unit); + local index = IceHUD.IceCore:IsInConfigMode() and 1 or GetRaidTargetIndex(self.unit); if (index and (index > 0)) then SetRaidTargetIconTexture(self.frame.raidIcon.icon, index) diff --git a/modules/TargetInfo.lua b/modules/TargetInfo.lua index 993c9d4..d664dbc 100644 --- a/modules/TargetInfo.lua +++ b/modules/TargetInfo.lua @@ -33,11 +33,6 @@ function TargetInfo.prototype:init() TargetInfo.super.prototype.init(self, "TargetInfo") self.scalingEnabled = true - - if AceLibrary:HasInstance("LibDogTag-3.0") then - DogTag = AceLibrary("LibDogTag-3.0") - AceLibrary("LibDogTag-Unit-3.0") - end end @@ -48,6 +43,11 @@ end function TargetInfo.prototype:Enable(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_NAME_UPDATE", "TargetName") diff --git a/modules/TargetMana.lua b/modules/TargetMana.lua index 45b7a47..f5b7bad 100644 --- a/modules/TargetMana.lua +++ b/modules/TargetMana.lua @@ -107,7 +107,7 @@ function IceTargetMana.prototype:Update(unit) 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:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color) end diff --git a/textures/Elite.blp b/textures/Elite.blp new file mode 100644 index 0000000..2af1eff Binary files /dev/null and b/textures/Elite.blp differ diff --git a/textures/Rare.blp b/textures/Rare.blp new file mode 100644 index 0000000..5a04cee Binary files /dev/null and b/textures/Rare.blp differ diff --git a/textures/RareElite.blp b/textures/RareElite.blp new file mode 100644 index 0000000..6dfea88 Binary files /dev/null and b/textures/RareElite.blp differ