Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local FormatTime = function(s)
- local day, hour, minute = 86400, 3600, 60
- if s >= day then
- return format("%dd", ceil(s / day))
- elseif s >= hour then
- return format("%dh", ceil(s / hour))
- elseif s >= minute then
- return format("%dm", ceil(s / minute))
- elseif s >= minute / 12 then
- return floor(s)
- end
- return format("%.1f", s)
- end
- local CreateAuraTimer = function(self, elapsed)
- if self.timeLeft then
- self.elapsed = (self.elapsed or 0) + elapsed
- if self.elapsed >= 0.1 then
- if not self.first then
- self.timeLeft = self.timeLeft - self.elapsed
- else
- self.timeLeft = self.timeLeft - GetTime()
- self.first = false
- end
- if self.timeLeft > 0 then
- local time = FormatTime(self.timeLeft)
- self.remaining:SetText(time)
- if self.timeLeft <= 5 then
- self.remaining:SetTextColor(0.99, 0.31, 0.31)
- else
- self.remaining:SetTextColor(1, 1, 1)
- end
- else
- self.remaining:Hide()
- self:SetScript("OnUpdate", nil)
- end
- self.elapsed = 0
- end
- end
- end
- lib.PostCreateAura = function(element, button)
- button:SetBackdrop(backdrop)
- button:SetBackdropBorderColor(0,0,0)
- button.remaining = lib.SetFontString(button, font, fs, "OUTLINE, MONOCHROME")
- button.remaining:SetPoint("CENTER", 1, 0)
- button.cd.noOCC = true -- hide OmniCC CDs
- button.cd.noCooldownCount = true -- hide CDC CDs
- button.cd:SetReverse()
- button.icon:SetPoint("TOPLEFT", 1, -1)
- button.icon:SetPoint("BOTTOMRIGHT", -1, 1)
- button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
- button.icon:SetDrawLayer('ARTWORK')
- button.count:SetPoint("BOTTOMRIGHT", 2, 0)
- button.count:SetJustifyH("RIGHT")
- button.count:SetFont(font, fs, "OUTLINE, MONOCHROME")
- button.count:SetTextColor(0, .8, 0)
- button.overlayFrame = CreateFrame("frame", nil, button, nil)
- button.cd:SetFrameLevel(button:GetFrameLevel() + 1)
- button.cd:ClearAllPoints()
- button.cd:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
- button.cd:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
- button.cd:SetAlpha(0)
- button.overlayFrame:SetFrameLevel(button.cd:GetFrameLevel() + 1)
- button.overlay:SetParent(button.overlayFrame)
- button.count:SetParent(button.overlayFrame)
- button.remaining:SetParent(button.overlayFrame)
- end
- lib.PostUpdateAura = function(icons, unit, icon, index, offset, filter, isDebuff, duration, timeLeft)
- local _, _, _, _, dtype, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, icon.filter)
- if(icon.debuff) then
- if(not UnitIsFriend("player", unit) and icon.owner ~= "player" and icon.owner ~= "vehicle") then
- icon:SetBackdropBorderColor(.7, .7, .7)
- icon.icon:SetDesaturated(true)
- else
- local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
- icon:SetBackdropBorderColor(color.r * 0.6, color.g * 0.6, color.b * 0.6)
- icon.icon:SetDesaturated(false)
- end
- end
- if duration and duration > 0 then
- icon.remaining:Show()
- else
- icon.remaining:Hide()
- end
- icon.duration = duration
- icon.timeLeft = expirationTime
- icon.first = true
- icon:SetScript("OnUpdate", CreateAuraTimer)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement