Bundle of fixes #10
@@ -46,7 +46,8 @@ end
|
|||||||
---@param showStacks boolean
|
---@param showStacks boolean
|
||||||
---@param doFade nil|number
|
---@param doFade nil|number
|
||||||
---@param doFlash nil|number
|
---@param doFlash nil|number
|
||||||
function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime, flashTime)
|
---@param showTooltip nil|boolean
|
||||||
|
function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime, flashTime, showTooltip)
|
||||||
self.unitframe = unitframe
|
self.unitframe = unitframe
|
||||||
self.frameParent = unitframe.overlays
|
self.frameParent = unitframe.overlays
|
||||||
self.size = size
|
self.size = size
|
||||||
@@ -57,13 +58,21 @@ function IconIndicator:Init(unitframe, size, point, x, y, showStacks, fadeTime,
|
|||||||
self.showStacks = showStacks
|
self.showStacks = showStacks
|
||||||
self.fadeTime = fadeTime
|
self.fadeTime = fadeTime
|
||||||
self.flashTime = flashTime
|
self.flashTime = flashTime
|
||||||
|
self.showTooltip = showTooltip or false
|
||||||
|
|
||||||
|
self.instanceId = 0
|
||||||
|
self.spellId = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Show the square indicator
|
--- Show the square indicator
|
||||||
---@param data table
|
---@param data table
|
||||||
function IconIndicator:Show(data)
|
function IconIndicator:Show(data)
|
||||||
local frame, stacks = self:GetFrame()
|
local frame, stacks = self:GetFrame()
|
||||||
local numStacks = data.stacks or 0
|
local numStacks = data.applications or 0
|
||||||
|
|
||||||
|
self.auraInstanceID = data.auraInstanceID
|
||||||
|
self.spellId = data.spellId
|
||||||
|
|
||||||
self.frame = frame
|
self.frame = frame
|
||||||
self.stacks = stacks
|
self.stacks = stacks
|
||||||
if self.showStacks and numStacks > 0 then
|
if self.showStacks and numStacks > 0 then
|
||||||
@@ -77,12 +86,23 @@ function IconIndicator:Show(data)
|
|||||||
self.expirationTime = data.expirationTime
|
self.expirationTime = data.expirationTime
|
||||||
self.updateThrottle = 0
|
self.updateThrottle = 0
|
||||||
end
|
end
|
||||||
|
if self.showTooltip then
|
||||||
|
frame:SetScript("OnEnter", function()
|
||||||
|
GameTooltip:SetOwner(frame, "ANCHOR_RIGHT")
|
||||||
|
GameTooltip:SetSpellByID(self.spellId)
|
||||||
|
GameTooltip:Show()
|
||||||
|
end)
|
||||||
|
frame:SetScript("OnLeave", function()
|
||||||
|
GameTooltip:Hide()
|
||||||
|
end)
|
||||||
|
end
|
||||||
if data.icon then
|
if data.icon then
|
||||||
self:SetIcon(data.icon)
|
self:SetIcon(data.icon)
|
||||||
else
|
else
|
||||||
self:SetIcon(self.icon)
|
self:SetIcon(self.icon)
|
||||||
end
|
end
|
||||||
frame:Show()
|
frame:Show()
|
||||||
|
self:UpdateAlpha()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the icon of the Icon Indicator
|
--- Set the icon of the Icon Indicator
|
||||||
@@ -131,22 +151,23 @@ function IconIndicator:Update(data)
|
|||||||
if data.icon then
|
if data.icon then
|
||||||
self:SetIcon(data.icon)
|
self:SetIcon(data.icon)
|
||||||
end
|
end
|
||||||
local numStacks = data.stacks or 0
|
local numStacks = data.applications or 0
|
||||||
if numStacks > 0 then
|
if numStacks > 0 then
|
||||||
self.stacks:SetText(numStacks)
|
self.stacks:SetText(numStacks)
|
||||||
self.stacks:Show()
|
self.stacks:Show()
|
||||||
end
|
end
|
||||||
self.expirationTime = data.expirationTime
|
self.expirationTime = data.expirationTime
|
||||||
self.frame:SetAlpha(1)
|
|
||||||
|
self.auraInstanceID = data.auraInstanceID
|
||||||
|
self.spellId = data.spellId
|
||||||
|
|
||||||
|
self:UpdateAlpha()
|
||||||
end
|
end
|
||||||
|
|
||||||
function IconIndicator:OnUpdate(dt)
|
function IconIndicator:UpdateAlpha()
|
||||||
dt = self.updateThrottle + dt
|
if self.expirationTime == 0 then
|
||||||
if dt < 0.04 then
|
self.frame:SetAlpha(1)
|
||||||
self.updateThrottle = dt
|
|
||||||
return
|
return
|
||||||
else
|
|
||||||
self.updateThrottle = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local timeLeft = self.expirationTime - GetTime()
|
local timeLeft = self.expirationTime - GetTime()
|
||||||
@@ -159,15 +180,36 @@ function IconIndicator:OnUpdate(dt)
|
|||||||
elseif timeLeft < fadeTime then
|
elseif timeLeft < fadeTime then
|
||||||
local alpha = timeLeft / fadeTime
|
local alpha = timeLeft / fadeTime
|
||||||
self.frame:SetAlpha(alpha)
|
self.frame:SetAlpha(alpha)
|
||||||
|
else
|
||||||
|
self.frame:SetAlpha(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IconIndicator:OnUpdate(dt)
|
||||||
|
dt = self.updateThrottle + dt
|
||||||
|
if dt < 0.04 then
|
||||||
|
self.updateThrottle = dt
|
||||||
|
return
|
||||||
|
else
|
||||||
|
self.updateThrottle = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
self:UpdateAlpha()
|
||||||
|
end
|
||||||
|
|
||||||
--- Hide the square indicator.
|
--- Hide the square indicator.
|
||||||
function IconIndicator:Hide()
|
function IconIndicator:Hide()
|
||||||
local frame = self.frame
|
local frame = self.frame
|
||||||
|
if frame == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
self.stacks:Hide()
|
self.stacks:Hide()
|
||||||
self.frame = nil
|
self.frame = nil
|
||||||
self.stacks = nil
|
self.stacks = nil
|
||||||
|
self.instanceId = nil
|
||||||
|
self.spellId = nil
|
||||||
frame:SetScript("OnUpdate", nil)
|
frame:SetScript("OnUpdate", nil)
|
||||||
|
frame:SetScript("OnLeave", nil)
|
||||||
|
frame:SetScript("OnEnter", nil)
|
||||||
iconPool:Release(frame)
|
iconPool:Release(frame)
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user