Mercurial > wow > buffalo2
diff Modules/BuffFrame.lua @ 60:2a636b00c31e
- buff time progress bars touched up
author | Nenue |
---|---|
date | Mon, 15 Aug 2016 07:23:56 -0400 |
parents | 07ef62fe201f |
children | 3f083d389c18 |
line wrap: on
line diff
--- a/Modules/BuffFrame.lua Thu Jul 28 18:27:56 2016 -0400 +++ b/Modules/BuffFrame.lua Mon Aug 15 07:23:56 2016 -0400 @@ -3,12 +3,12 @@ -- Created: 7/27/2016 8:08 PM -- %file-revision% -- + local PLUGIN_NAME = 'BuffFrame' local plugin = {} local vn, print = LibStub("LibKraken").register(VeneerController, plugin) - local buttons = {} local buffTypes = { { @@ -44,15 +44,15 @@ local VeneerButton_OnHide = function(self) self:SetScript('OnDragStart', self.StartMoving) self:SetScript('OnDragStop', self.StopMovingOrSizing) - self:SetMovable(true) - self:EnableMouse(true) + self:SetMovable(false) + self:EnableMouse(false) self:RegisterForDrag('LeftButton') end local VeneerButton_OnShow = function(self) self:SetScript('OnDragStart', self.StartMoving) self:SetScript('OnDragStop', self.StopMovingOrSizing) - self:SetMovable(true) - self:EnableMouse(true) + self:SetMovable(false) + self:EnableMouse(false) self:RegisterForDrag('LeftButton') end @@ -62,12 +62,16 @@ if not _G[name..'Veneer'] then local veneer = CreateFrame('Frame', name..'Veneer', UIParent) + local id = frame:GetID() veneer:SetAllPoints(frame) + veneer:SetParent(frame) veneer.bg = veneer:CreateTexture() - veneer.bg:SetColorTexture(0,1,0,0.5) + veneer.bg:SetColorTexture((id / 16),0,1-(id/16),0.5) + print(id, id/16) veneer.bg:SetAllPoints(veneer) - veneer.bg:Hide() + veneer.bg:Show() veneer:Hide() + veneer:EnableMouse(false) veneer:SetScript('OnShow', VeneerButton_OnShow) veneer:SetScript('OnHide', VeneerButton_OnHide) @@ -104,7 +108,7 @@ local UpdateVeneer = function (frame, duration, expires) local veneer = GetVeneer(frame) - if expires and duration then + if expires and (duration ~= 0) then veneer.progress:Show() local startTime = (expires - duration) @@ -114,12 +118,15 @@ local w = floor(veneer.progress:GetWidth()+.5) local t = GetTime() local progress = (t - startTime) / duration - if t >= endTime or not frame:IsVisible() then + + local nw = w - ceil(w * progress) + print(progress, nw, w) + if (progress >= 1) or not frame:IsVisible() then veneer.startTime = nil + self:Hide() self:SetScript('OnUpdate', nil) - self:Hide() else - self.fg:SetWidth(w - ceil(w * progress) - 2) + self.fg:SetWidth(nw) end end) end @@ -227,22 +234,29 @@ end --BuffButton1 --DebuffButton1 - TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0) + if BuffButton1 then + TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0) + end + end local AuraButton_UpdateDuration = function(frame, timeLeft) - local ts = '' + local hours = floor(timeLeft/3600) + local minutes = floor(mod(timeLeft, 3600)/60) + local seconds = floor(mod(timeLeft, 60)) + local timeString = '%ds' if timeLeft > 3600 then - ts = ts .. floor(timeLeft/3600) .. ':' - timeLeft = mod(timeLeft, 3600) + timeString = format('%d:%02d', hours, minutes) + elseif timeLeft > 60 then + timeString = format('%d:%02d', minutes, seconds) + elseif timeLeft > 10 then + timeString = format('%d', seconds) + else + timeString = format('%0.1f', mod(timeLeft, 60)) end - if timeLeft > 60 then - ts = ts .. floor(timeLeft/60) .. '\'' - timeLeft = mod(timeLeft, 60) - end - ts = ts .. floor(timeLeft)..'"' - frame.duration:SetText(ts) + + frame.duration:SetText(timeString) frame.duration:SetVertexColor(1,1,1) end