mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 14:50:13 -05:00
- fixed range check module to work with dogtags disabled
This commit is contained in:
@ -21,15 +21,20 @@ function RangeCheck.prototype:Enable(core)
|
|||||||
|
|
||||||
if IceHUD.IceCore:ShouldUseDogTags() then
|
if IceHUD.IceCore:ShouldUseDogTags() then
|
||||||
DogTag = AceLibrary("LibDogTag-3.0")
|
DogTag = AceLibrary("LibDogTag-3.0")
|
||||||
|
self:RegisterFontStrings()
|
||||||
|
else
|
||||||
|
self:ScheduleRepeatingEvent(self.elementName, self.UpdateRange, 0.1, self)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:RegisterFontStrings()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function RangeCheck.prototype:Disable(core)
|
function RangeCheck.prototype:Disable(core)
|
||||||
RangeCheck.super.prototype.Disable(self, core)
|
RangeCheck.super.prototype.Disable(self, core)
|
||||||
|
|
||||||
self:UnregisterFontStrings()
|
if DogTag then
|
||||||
|
self:UnregisterFontStrings()
|
||||||
|
else
|
||||||
|
self:CancelScheduledEvent(self.elementName)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function RangeCheck.prototype:GetDefaultSettings()
|
function RangeCheck.prototype:GetDefaultSettings()
|
||||||
@ -89,7 +94,7 @@ function RangeCheck.prototype:GetOptions()
|
|||||||
opts["rangeString"] = {
|
opts["rangeString"] = {
|
||||||
type = 'text',
|
type = 'text',
|
||||||
name = 'Range string',
|
name = 'Range string',
|
||||||
desc = 'DogTag-formatted string to use for the range display\n\nType /dogtag for a list of available tags',
|
desc = 'DogTag-formatted string to use for the range display (only available if LibDogTag is being used)\n\nType /dogtag for a list of available tags',
|
||||||
get = function()
|
get = function()
|
||||||
return self.moduleSettings.rangeString
|
return self.moduleSettings.rangeString
|
||||||
end,
|
end,
|
||||||
@ -100,7 +105,7 @@ function RangeCheck.prototype:GetOptions()
|
|||||||
self:Redraw()
|
self:Redraw()
|
||||||
end,
|
end,
|
||||||
disabled = function()
|
disabled = function()
|
||||||
return not self.moduleSettings.enabled or not DogTag or not RangeCheck
|
return not self.moduleSettings.enabled or not DogTag or not LibRange
|
||||||
end,
|
end,
|
||||||
usage = '',
|
usage = '',
|
||||||
order = 33
|
order = 33
|
||||||
@ -136,7 +141,7 @@ function RangeCheck.prototype:CreateFrame(redraw)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function RangeCheck.prototype:RegisterFontStrings()
|
function RangeCheck.prototype:RegisterFontStrings()
|
||||||
if DogTag and RangeCheck then
|
if DogTag and LibRange then
|
||||||
DogTag:AddFontString(self.frame.rangeFontString, self.frame, self.moduleSettings.rangeString, "Unit", { unit = "target" })
|
DogTag:AddFontString(self.frame.rangeFontString, self.frame, self.moduleSettings.rangeString, "Unit", { unit = "target" })
|
||||||
DogTag:UpdateAllForFrame(self.frame)
|
DogTag:UpdateAllForFrame(self.frame)
|
||||||
end
|
end
|
||||||
@ -148,4 +153,22 @@ function RangeCheck.prototype:UnregisterFontStrings()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- this function is called every 0.1 seconds only if LibDogTag is not being used
|
||||||
|
function RangeCheck.prototype:UpdateRange()
|
||||||
|
if LibRange and UnitExists("target") then
|
||||||
|
local min, max = LibRange:getRange("target")
|
||||||
|
if min then
|
||||||
|
if max then
|
||||||
|
self.frame.rangeFontString:SetText("Range: " .. min .. " - " .. max)
|
||||||
|
else
|
||||||
|
self.frame.rangeFontString:SetText("Range: " .. min .. "+")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.frame.rangeFontString:SetText("Unknown")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.frame.rangeFontString:SetText()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
IceHUD.RangeCheck = RangeCheck:new()
|
IceHUD.RangeCheck = RangeCheck:new()
|
Reference in New Issue
Block a user