Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-06-17, 08:08 PM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
CooldownCount trying to edit the FormatTimes

Hi, i'm trying to edit/add formated times to my cooldown count, although im not getting anywhere anyone that could help out?

Lua Code:
  1. local A, C, M, L = select(2, ...):unpack()
  2.  
  3. A.FormatTime = function(Seconds)
  4.     local Day, Hour, Minutes
  5.     Day, Hour, Minutes = 0, 0, 0
  6.    
  7.     if Seconds >= 86400 then
  8.         Day = Seconds / 86400
  9.         Seconds = Seconds % 86400
  10.     end
  11.  
  12.     if Seconds >= 3600 then
  13.         Hour = Seconds / 3600
  14.         Seconds = Seconds % 3600
  15.     end
  16.    
  17.     if Seconds >= 60 then
  18.         Minutes = Seconds / 60
  19.         Seconds = Seconds % 60
  20.     end
  21.    
  22.     if Day > 0 then
  23.         return format("%.2d:%.2d", Day, Hour)
  24.     elseif Hour > 0 then
  25.         return format("%.2d:%.2d", Hour, Minutes)
  26.     elseif Minutes > 0 then
  27.         return format("%.2d:%.2d", Minutes, Seconds)
  28.     else
  29.         if Seconds < 10 then
  30.             return format("%.1f", Seconds)
  31.         else
  32.             return format("%d", Seconds)
  33.         end
  34.     end
  35. end
  36.  
  37. local function CooldownCountUpdate(self)
  38.     local Now, Start, Duration = GetTime(), self:GetCooldownTimes()
  39.     Start, Duration = Start/1000, Duration/1000
  40.  
  41.     local Elapsed = Now - Start
  42.     local TimeLeft = math.max(0, Duration - Elapsed)
  43.  
  44.     local NumRegions = self:GetNumRegions()
  45.     for i = 1, NumRegions do
  46.         local Region = select(i, self:GetRegions())
  47.         if (Region.GetText) then   
  48.             if (TimeLeft <= 10) then
  49.                 Region:SetTextColor(1, 0, 0)
  50.             elseif (TimeLeft <= 30) then
  51.                 Region:SetTextColor(1, 0.42, 0)
  52.             elseif (TimeLeft <= 60) then
  53.                 Region:SetTextColor(1, 0.82, 0)
  54.             else
  55.                 Region:SetTextColor(unpack(C.Cooldowns.TextColor))
  56.             end
  57.            
  58.             --local TimeText = A.FormatTime() -- Not quite sure how to make it work
  59.             --Region:SetText(TimeText)
  60.         end
  61.     end
  62. end
  63.  
  64. hooksecurefunc("CooldownFrame_Set", function(self, start, duration, enable, forceShowDrawEdge, modRate)
  65.     local CooldownCount = GetCVar("countdownForCooldowns")
  66.    
  67.     if (CooldownCount and not self.IsCooldownEdited) then
  68.         local NumRegions = self:GetNumRegions()
  69.         self:SetFrameStrata("HIGH")
  70.         self:HookScript("OnUpdate", CooldownCountUpdate)
  71.    
  72.         for i = 1, NumRegions do
  73.             local Region = select(i, self:GetRegions())
  74.             if (Region.GetText) then
  75.                 Region:SetPoint("CENTER", 1, 0)
  76.                 Region:SetFontTemplate(C.Media.Font2, C.Cooldowns.FontSize)
  77.             end
  78.         end
  79.  
  80.         self.IsCooldownEdited = true
  81.     end
  82. end)

Cheers!
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » CooldownCount trying to edit the FormatTimes

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off