Theory, Treat TemporaryEnchants as buff auras.
practice:
Code:
local function PreUpdateAura(self, event, unit)
if(unit == 'player')then
local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo();
TemporaryEnchantFrameWidth = ( (hasMainHandEnchant and 1 or 0) + (hasOffHandEnchant and 1 or 0) )*self.Buffs.size
TemporaryEnchantFrame:SetWidth((TemporaryEnchantFrameWidth > 0) and TemporaryEnchantFrameWidth or 1)
end
end
Somewhere in style func both can be found :
Code:
self.PreUpdateAura = PreUpdateAura
Code:
if unit == "player" then
TemporaryEnchantFrame:ClearAllPoints()
TemporaryEnchantFrame:SetPoint("RIGHT",self,"LEFT",-5,0)
TemporaryEnchantFrame:Show()
TempEnchant2Duration:ClearAllPoints()
TempEnchant2Duration:SetPoint("CENTER",TempEnchant2,"CENTER",0,0)
TempEnchant2Border:Hide()
TempEnchant1Duration:ClearAllPoints()
TempEnchant1Duration:SetPoint("CENTER",TempEnchant1,"CENTER",0,0)
TempEnchant1Border:Hide()
self.Buffs:SetPoint(self.Buffs.anchorFrom, TemporaryEnchantFrame, self.Buffs.anchorTo,self.Buffs.anchorX,self.Buffs.anchorY)
TempEnchant1:SetHeight(self.Buffs.size)
TempEnchant1:SetWidth(self.Buffs.size)
TempEnchant2:SetHeight(self.Buffs.size)
TempEnchant2:SetWidth(self.Buffs.size)
TemporaryEnchantFrame:SetHeight(self.Buffs.size)
end
These are variables used in m createBuffFrame function i repeat throughout my layout.
Code:
self.Buffs.anchorFrom, self.Buffs.anchorTo, self.Buffs.anchorX,self.Buffs.anchorY
Idea is to have the TemporaryEnchantFrame inline with my buffs and only visible when there are weapon buffs.
I also had some other code to remove various fluff on the TemporaryEnchantFrame but the above code should give you an idea of what i was trying to achieve without modifying any of hastes aura.lua
I also wanted cooldown/time-remaining timers on debuffs/buffs without running another mod, unfortunatly unless I modified the aura.lua the time remaining would be incorrect when i recalled UnitAura withingh the update function in my layout :
+ have the count fontString created on the cooldown texture
Code:
local count = cd:CreateFontString(nil, "OVERLAY")
+ create three additional variables on each icon within aura.lua:update():
Code:
icon.isPlayer = isPlayer
icon.duration = duration
icon.timeLeft = timeLeft
and then use a function similar to :
Code:
local DAY, HOUR, MINUTE, SHORT = 86400, 3600, 60, 5 --values for time
local UsingMMSS = false
local useCooldownTimers = true
local useEnlargedFonts = true
local cooldownTimerStyle = {
short = {r = 1, g = 0, b = 0, s = 1.025}, -- <= 5 seconds
secs = {r = 1, g = 1, b = 0.4, s = 1}, -- < 1 minute
mins = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 minute
hrs = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 hr
days = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 day
}
local function GetFormattedTime(s)
if s >= DAY then
return format('%dd', floor(s/DAY + 0.5)), s % DAY
elseif s >= HOUR then
return format('%dh', floor(s/HOUR + 0.5)), s % HOUR
elseif s >= MINUTE then
if s <= MINUTE*3 and UsingMMSS then
return format('%d:%02d', floor(s/60), s % MINUTE), s - floor(s)
end
return format('%dm', floor(s/MINUTE + 0.5)), s % MINUTE
elseif s > 2 then
return floor(s + 0.5), s - floor(s)
end
return format("%0.1f", s), 0.1
end
local function GetFormattedFont(s)
local style = cooldownTimerStyle
if s > DAY then
style = style.days
elseif s > HOUR then
style = style.hrs
elseif s > MINUTE then
style = style.mins
elseif s > SHORT then
style = style.secs
else
style = style.short
end
return style.s, style.r, style.g, style.b
end
local function PostCreateAuraIcon(self, button, icons, index, debuff)
button.cd:SetReverse()
button.overlay:SetTexture(border)
button.overlay:SetTexCoord(0, 1, 0, 1)
button.overlay.Hide = function(self) self:SetVertexColor(0.25, 0.25, 0.25) end
if(button.isPlayer)then
button:SetWidth((button.debuff and self.Debuffs.mySize or self.Buffs.mySize))
end
button.count:SetFont(font, '10', "OUTLINE")
button.count:SetPoint("CENTER",button,"BOTTOM",0,-2)
if (not debuff) then
button:SetScript('OnMouseUp', function(self, mouseButton)
if mouseButton == 'RightButton' then
CancelUnitBuff('player', index)
end
end)
end
if(useCooldownTimers)then
local remaining = button.cd:CreateFontString(nil, "OVERLAY")
remaining:SetFont(font, '10', "OUTLINE")
remaining:SetPoint("CENTER", button, 4, 4)
remaining:SetJustifyH("CENTER")
remaining:SetText('')
button.remaining = remaining
button:SetScript('OnUpdate', function(self,event)
if(self.duration > 0 or self.timeLeft > 0) then
local timeLeft = self.timeLeft - GetTime()
local _,fontSize,_ = remaining:GetFont()
local size, r, g, b = GetFormattedFont(timeLeft)
remaining:SetText(GetFormattedTime(timeLeft))
remaining:SetFont(font, (useEnlargedFonts and fontSize * size or fontSize), 'outline')
remaining:SetTextColor(r,g,b)
end
end)
end
end
haste :
If you are aware of a way that i can retrieve the info for those three variables i created inside 'aura.lua:updateIcon()' without having to call UnitAura a second time, i would be greatful.
I found that my temporaryEnchant hack didn't update when weapon buffs were present or not due to them not firing the unit_aura event, any suggestions on this ?