Skip to content

Instantly share code, notes, and snippets.

@martinjlowm
Created October 28, 2010 15:22
Show Gist options
  • Save martinjlowm/651568 to your computer and use it in GitHub Desktop.
Save martinjlowm/651568 to your computer and use it in GitHub Desktop.
function Timer:UpdateText(forceStyleUpdate)
--if there's time left on the clock, then update the timer text
--otherwise stop the timer
local remain = self.duration - (GetTime() - self.start)
if remain > 0 then
--hide text if it's too small to display
--check again in one second
if (self:GetEffectiveScale() * self.fontSize / UIParent:GetScale()) < OmniCC:GetMinFontSize() then
self.text:Hide()
self.nextUpdate = 1
else
--update font text
local time, nextUpdate = self:GetTimeText(remain)
self.text:SetText(time)
self.text:Show()
--update text scale/color info if the time period has changed
--of we're forcing an update (used for config live updates)
local period = self:GetPeriodStyle(remain)
if (period ~= self.textStyle) or forceStyleUpdate then
self.textStyle = period
self.text:SetTextColor(OmniCC:GetPeriodColor(period))
self:SetScale(OmniCC:GetPeriodScale(period))
self.textStyle = textStyle
end
self.nextUpdate = nextUpdate
end
end
if remain <= OmniCC:GetEffectTimeOffset() then
if self.duration >= OmniCC:GetMinEffectDuration() and self.text:IsShown() and not self.effectTriggered then
OmniCC:TriggerEffect(self.cooldown, self.duration)
self.effectTriggered = true
end
end
if remain <= 0 then
self:Stop()
end
return self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment