Created
October 28, 2010 15:22
-
-
Save martinjlowm/651568 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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