Advertisement
Guest User

Untitled

a guest
Apr 20th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local myPostCreateIcon = function(self, button)
  2.     self.showDebuffType = true
  3.     self.disableCooldown = true
  4.     button.cd.noOCC = true
  5.     button.cd.noCooldownCount = true
  6.     button.icon:SetTexCoord(.07, .93, .07, .93)
  7.     button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
  8.     button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
  9.     button.overlay:SetTexture(border)
  10.     button.overlay:SetTexCoord(0,1,0,1)
  11.     button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
  12.     button.time = lib.gen_fontstring(button, cfg.font, 8, "OUTLINEMONOCHROME")
  13.     button.time:SetPoint("CENTER", button, 2, 0)
  14.     button.time:SetJustifyH('CENTER')
  15.     button.time:SetVertexColor(1,1,1)
  16.     button.count = lib.gen_fontstring(button, cfg.font, 8, "OUTLINEMONOCHROME")
  17.     button.count:ClearAllPoints()
  18.     button.count:SetPoint("BOTTOMRIGHT", button, 7, -5)
  19.     button.count:SetVertexColor(1,1,1) 
  20.     local h = CreateFrame("Frame", nil, button)
  21.     h:SetFrameLevel(0)
  22.     h:SetPoint("TOPLEFT",-5,5)
  23.     h:SetPoint("BOTTOMRIGHT",5,-5)
  24.     frame1px1(h)
  25.     CreateShadow(h)
  26. end
  27.  
  28. local formatTime = function(s)
  29.     local day, hour, minute = 86400, 3600, 60
  30.     if s >= day then
  31.         return format("%dd", floor(s/day + 0.5)), s % day
  32.     elseif s >= hour then
  33.         return format("%dh", floor(s/hour + 0.5)), s % hour
  34.     elseif s >= minute then
  35.         return format("%dm", floor(s/minute + 0.5)), s % minute
  36.     elseif s >= minute / 1200 then
  37.         return floor(s), (s * 100 - floor(s * 100))/100
  38.     end
  39.     return format("%.1f", s), (s * 100 - floor(s * 100))/100
  40. end
  41. local setTimer = function (self, elapsed)
  42.     if self.timeLeft then
  43.         self.elapsed = (self.elapsed or 0) + elapsed
  44.         if self.elapsed >= 0.1 then
  45.             if not self.first then
  46.                 self.timeLeft = self.timeLeft - self.elapsed
  47.             else
  48.                 self.timeLeft = self.timeLeft - GetTime()
  49.                 self.first = false
  50.             end
  51.             if self.timeLeft > 0 then
  52.                 local time = formatTime(self.timeLeft)
  53.                     self.time:SetText(time)
  54.                 if self.timeLeft < 10 then
  55.                     self.time:SetTextColor(1, 0.5, 0.5)
  56.                 else
  57.                     self.time:SetTextColor(1, 0.8, 0)
  58.                 end
  59.             else
  60.                 self.time:Hide()
  61.                 self:SetScript("OnUpdate", nil)
  62.             end
  63.             self.elapsed = 0
  64.         end
  65.     end
  66. end
  67.  
  68. local postCreateIcon = function(element, button)
  69.     local diffPos = 0
  70.     local self = element:GetParent()
  71.     if self.mystyle == "target" then diffPos = 1 end
  72.    
  73.     element.disableCooldown = true
  74.     button.cd.noOCC = true
  75.     button.cd.noCooldownCount = true
  76.    
  77.     local h = CreateFrame("Frame", nil, button)
  78.     h:SetFrameLevel(0)
  79.     h:SetPoint("TOPLEFT",-5,5)
  80.     h:SetPoint("BOTTOMRIGHT",5,-5)
  81.     frame1px1(h)
  82.     CreateShadow(h)
  83.    
  84.     local time = lib.gen_fontstring(button, cfg.font, 11, "THINOUTLINE")
  85.     time:SetPoint("CENTER", button, "CENTER", 1, -5)
  86.     time:SetJustifyH("CENTER")
  87.     time:SetVertexColor(1,1,1)
  88.     button.time = time
  89.    
  90.     local count = lib.gen_fontstring(button, cfg.font, 11, "THINOUTLINE")
  91.     count:SetPoint("CENTER", button, "BOTTOMRIGHT", 0, 3)
  92.     count:SetJustifyH("RIGHT")
  93.     button.count = count
  94.    
  95.     button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  96.     button.icon:SetDrawLayer("ARTWORK")
  97. end
  98. local postUpdateIcon = function(element, unit, button, index)
  99.     local _, _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, button.filter)
  100.    
  101.     if duration and duration > 0 then
  102.         button.time:Show()
  103.         button.timeLeft = expirationTime   
  104.         button:SetScript("OnUpdate", setTimer)         
  105.     else
  106.         button.time:Hide()
  107.         button.timeLeft = math.huge
  108.         button:SetScript("OnUpdate", nil)
  109.     end
  110.  
  111.     button:SetScript('OnMouseUp', function(self, mouseButton)
  112.         if mouseButton == 'RightButton' then
  113.             CancelUnitBuff('player', index)
  114.     end end)
  115.     button.first = true
  116. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement