Advertisement
Guest User

CooldownViewer

a guest
Jan 2nd, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.60 KB | None | 0 0
  1. -- Cooldown Viewer (OmniCC)
  2.  --[[
  3. Cooldown Viewer[Omnicc]
  4.  
  5. cs = actionbar cooldown text size
  6. ps = player/focus/target/raid cooldown text size(disable if ps is 1)
  7. ctp = actionbar cooldown position(DEFAULT : CENTER)
  8. ptp = player cooldown position(DEFAULT : BOTTOMRIGHT)
  9. ct = font
  10.  
  11. -- text position list
  12.  
  13. CETNER / RIGHT / LEFT
  14. TOP / TOPRIGHT / TOPLEFT
  15. BOTTOM / BOTTOMRIGHT / BOTTOMLEFT
  16.  
  17. -- font list
  18.  
  19. DAMAGE_TEXT_FONT
  20. STANDARD_TEXT_FONT
  21. UNIT_NAME_FONT
  22. NAMEPLATE_FONT
  23.  
  24. -- show cooldown text until 1 sec
  25.  
  26. :: insert "elseif(e>0)then" -> "elseif(e>1)" in macro 3
  27.  
  28. -- disable to show 0.x sec with enabling red text
  29.  
  30. :: insert "return"%.1f",e" -> "return"%d",e" in macro 3
  31.  
  32. -- DEATH KNIGHT RUNE COOLDOWN DISABLE
  33.  
  34. instead of macro 6, use this two macro
  35.  
  36. function gct(f)if not cDB[f]then local c=gict(f)c:SetSize(c.s*crt,c.s*crt)sf(c,1)cDB[f]=c;end return cDB[f]end
  37.  
  38. function cvf(f,s,d)if(string.find(f:GetName(),"Rune") ~= nil)then return end local c=gct(f)if(s and d)then c.b=s;c.d=d;if(s>0 and d>1.5)then c.c=0;c.r=d-(GetTime()-s);suc(c)else rt(c)end end end
  39.  
  40. -------------------------------------------------------------------
  41. -------------------------------------------------------------------]]--
  42.     cs=21;
  43.     ps=12;
  44.     ctp="CENTER"
  45.     ptp="CENTER"
  46.     cp=5;
  47.     ct=UNIT_NAME_FONT;
  48.     crt=2;
  49.     cDB={}
  50.     action={}
  51.     ccf=CreateFrame;
  52.     gac=GetActionCooldown;
  53.     ol="OUTLINE"
  54.     cpe="PLAYER_ENTERING_WORLD"
  55.     cau="ACTIONBAR_UPDATE_COOLDOWN"
  56.     co="OnUpdate"
  57.     function rt(f)
  58.         f.e=nil
  59.         f.t:SetText("")
  60.         f:SetScript(co,nil)
  61.     end
  62.     function sf(f,v)
  63.         f.t:SetFont(ct,f.s*v,ol)
  64.     end
  65.     function acv(b)
  66.         local x=b.cooldown
  67.         x.a=b.action   
  68.         action[x]=x
  69.     end
  70.     function scv(p,f,po,s)
  71.         if(s>1)then
  72.             f.t:SetPoint(po,p)
  73.         end
  74.         f.s=s;
  75.     end
  76.     function sr(f,e)
  77.         if(e>60)then
  78.             sf(f,0.7)
  79.             if(f.s==cs)then
  80.                 return"%d:%02d",e,e
  81.             else
  82.                 return"%dm",e+60,e
  83.         end
  84.         elseif(e>=cp)then
  85.             sf(f,1)
  86.             f.t:SetTextColor(1,1,0,1)
  87.             return"%d",e
  88.         elseif(e>0)then
  89.             sf(f,0.9)
  90.             f.t:SetTextColor(1,0,0,1)        
  91.             return"%.1f",e
  92.         else
  93.             return
  94.         end    
  95.     end
  96.     function suc(f)
  97.         if not f.e then
  98.             f.e=1;
  99.             f:SetScript(co,function(s,e)
  100.             f.c=f.c+e;
  101.             local fo,v1,v2=sr(f,f.r-f.c)
  102.             if not fo then
  103.                 rt(f)
  104.             elseif not v2 then
  105.                 f.t:SetFormattedText(fo,v1)
  106.             else
  107.                 f.t:SetTextColor(1,1,1,1)
  108.                 f.t:SetFormattedText(fo,v1/60,v2%60)
  109.             end
  110.             end)
  111.         end
  112.     end
  113.    
  114.     function scs(p,f)    
  115.         if(p:GetSize()<35)then
  116.             scv(p,f,ptp,ps)
  117.         else
  118.             scv(p,f,ctp,cs)
  119.         end
  120.     end
  121.  
  122.     function gict(f)
  123.         local c=ccf("Frame",nil,f)
  124.         c:SetFrameLevel(f:GetFrameLevel()+5)
  125.         c.t=c:CreateFontString(nil,"OVERLAY")
  126.         c.t:SetAllPoints(c)
  127.         scs(f:GetParent(),c)
  128.         return c;
  129.     end
  130.  
  131.     function gct(f)
  132.         if not cDB[f] then
  133.             local c=gict(f)
  134.             c:SetSize(c.s*crt,c.s*crt)
  135.             sf(c,1)
  136.             cDB[f]=c;
  137.         end
  138.         return cDB[f]
  139.     end
  140.  
  141.     function cvf(f,s,d)
  142.     --  if(string.find(f:GetName(),"trinket") ~= nil) then
  143.     --      return
  144.     --  end
  145.         local c=gct(f)
  146.         if(s and d)then
  147.             c.b=s;
  148.             c.d=d;
  149.             if(s>0 and d>1.5)then
  150.                 c.c=0;c.r=d-(GetTime()-s);
  151.                 suc(c)
  152.             else
  153.                 rt(c)
  154.             end
  155.         end
  156.     end
  157.  
  158.  
  159.     function cvc(DB)
  160.         for c in pairs(DB)do
  161.             if c.a then
  162.                 local s,d=gac(c.a)
  163.                 cvf(c,s,d)
  164.             end
  165.         end
  166.     end
  167.     function pcv(_,e)
  168.         if e==cau then
  169.             cvc(action)
  170.         else
  171.             cvc(cDB)
  172.         end
  173.     end
  174.     for _,b in pairs(ActionBarButtonEventsFrame.frames)do
  175.         acv(b)
  176.     end
  177.     vc=ccf("Frame")
  178.     vc:SetScript("OnEvent",pcv)
  179.     vc:RegisterEvent(cpe)
  180.     vc:RegisterEvent(cau)
  181.     hooksecurefunc(getmetatable(ActionButton1Cooldown).__index,"SetCooldown",cvf)
  182.     hooksecurefunc("SetActionUIButton",acv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement