Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: Lua  |  size: 3.11 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. cs=20;
  2. ps=10;
  3. ctp="CENTER"
  4. ptp="BOTTOMRIGHT"
  5. cp=5;
  6. ct=UNIT_NAME_FONT;
  7.  
  8. crt=2;
  9. cDB={}
  10. action={}
  11. ccf=CreateFrame;
  12. gac=GetActionCooldown;
  13. ol="OUTLINE"
  14. cpe="PLAYER_ENTERING_WORLD"
  15. cau="ACTIONBAR_UPDATE_COOLDOWN"
  16. co="OnUpdate"
  17. ----------------------------------------------:: 1
  18.  
  19. function rt(f)
  20.     f.e=nil
  21.     f.t:SetText("")
  22.     f:SetScript(co,nil)
  23. end
  24.  
  25. function sf(f,v)
  26.     f.t:SetFont(ct,f.s*v,ol)
  27. end
  28.  
  29. function acv(b)
  30.     local x=b.cooldown
  31.     x.a=b.action
  32.    
  33.     action[x]=x
  34. end
  35.  
  36. function scv(p,f,po,s)
  37.     if(s>1)then
  38.         f.t:SetPoint(po,p)
  39.     end
  40.     f.s=s;
  41. end
  42.  
  43. ----------------------------------------------:: 2
  44.  
  45. function sr(f,e)
  46.     if(e>60)then
  47.         sf(f,0.7)
  48.         if(f.s==cs)then
  49.             return"%d:%02d",e,e
  50.         else
  51.             return"%dm",e+60,e
  52.         end
  53.     elseif(e>=cp)then
  54.         sf(f,1)
  55.         f.t:SetTextColor(1,1,0,1)
  56.         return"%d",e
  57.     elseif(e>0)then
  58.         sf(f,0.9)
  59.         f.t:SetTextColor(1,0,0,1)        
  60.         return"%.1f",e
  61.     else
  62.         return
  63.     end    
  64. end
  65.  
  66. ----------------------------------------------:: 3
  67. function suc(f)
  68.     if not f.e then
  69.         f.e=1;
  70.         f:SetScript(co,function(s,e)
  71.             f.c=f.c+e;
  72.             local fo,v1,v2=sr(f,f.r-f.c)
  73.             if not fo then
  74.                 rt(f)
  75.             elseif not v2 then
  76.                 f.t:SetFormattedText(fo,v1)
  77.             else
  78.                 f.t:SetTextColor(1,1,1,1)
  79.                 f.t:SetFormattedText(fo,v1/60,v2%60)
  80.             end
  81.         end)
  82.     end
  83. end
  84. ----------------------------------------------:: 4
  85. function scs(p,f)    
  86.     if(p:GetSize()<35)then
  87.         scv(p,f,ptp,ps)
  88.     else
  89.         scv(p,f,ctp,cs)
  90.     end
  91. end
  92.  
  93. function gict(f)
  94.     local c=ccf("Frame",nil,f)
  95.     c:SetFrameLevel(f:GetFrameLevel()+5)
  96.     c.t=c:CreateFontString(nil,"OVERLAY")
  97.     c.t:SetAllPoints(c)
  98.     scs(f:GetParent(),c)
  99.     return c;
  100. end
  101. ----------------------------------------------:: 5
  102.  
  103. function gct(f)
  104.     if not cDB[f]then
  105.         local c=gict(f)
  106.         c:SetSize(c.s*crt,c.s*crt)
  107.         sf(c,1)    
  108.         cDB[f]=c;
  109.     end
  110.     return cDB[f]
  111. end
  112.  
  113. function cvf(f,s,d)
  114.     local c=gct(f)
  115.    
  116.     if(s and d)then
  117.         c.b=s;
  118.         c.d=d;
  119.         if(s>0 and d>1.5)then            
  120.             c.c=0;
  121.             c.r=d-(GetTime()-s);
  122.             suc(c)
  123.         else
  124.             rt(c)
  125.         end
  126.     end
  127. end
  128. ----------------------------------------------:: 6
  129. function cvc(DB)
  130.     for c in pairs(DB)do
  131.         if c.a then
  132.             local s,d=gac(c.a)
  133.             cvf(c,s,d)
  134.         end
  135.     end
  136. end
  137.  
  138. function pcv(_,e)
  139.     if e==cau then
  140.         cvc(action)
  141.     else
  142.         cvc(cDB)
  143.     end
  144. end
  145.  
  146. for _,b in pairs(ActionBarButtonEventsFrame.frames)do
  147.     acv(b)
  148. end
  149.  
  150. ----------------------------------------------:: 7
  151.  
  152. vc=ccf("Frame")
  153. vc:SetScript("OnEvent",pcv)
  154. vc:RegisterEvent(cpe)
  155. vc:RegisterEvent(cau)
  156.  
  157. hooksecurefunc(getmetatable(ActionButton1Cooldown).__index,"SetCooldown",cvf)
  158. hooksecurefunc("SetActionUIButton",acv)
  159.  
  160. ----------------------------------------------:: 8