Mercurial > wow > buffalo2
comparison 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 |
comparison
equal
deleted
inserted
replaced
59:07ef62fe201f | 60:2a636b00c31e |
---|---|
1 -- Veneer | 1 -- Veneer |
2 -- BuffFrame.lua | 2 -- BuffFrame.lua |
3 -- Created: 7/27/2016 8:08 PM | 3 -- Created: 7/27/2016 8:08 PM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- | 5 -- |
6 | |
6 local PLUGIN_NAME = 'BuffFrame' | 7 local PLUGIN_NAME = 'BuffFrame' |
7 local plugin = {} | 8 local plugin = {} |
8 local vn, print = LibStub("LibKraken").register(VeneerController, plugin) | 9 local vn, print = LibStub("LibKraken").register(VeneerController, plugin) |
9 | |
10 | 10 |
11 | 11 |
12 local buttons = {} | 12 local buttons = {} |
13 local buffTypes = { | 13 local buffTypes = { |
14 { | 14 { |
42 local expirationCache = {} | 42 local expirationCache = {} |
43 | 43 |
44 local VeneerButton_OnHide = function(self) | 44 local VeneerButton_OnHide = function(self) |
45 self:SetScript('OnDragStart', self.StartMoving) | 45 self:SetScript('OnDragStart', self.StartMoving) |
46 self:SetScript('OnDragStop', self.StopMovingOrSizing) | 46 self:SetScript('OnDragStop', self.StopMovingOrSizing) |
47 self:SetMovable(true) | 47 self:SetMovable(false) |
48 self:EnableMouse(true) | 48 self:EnableMouse(false) |
49 self:RegisterForDrag('LeftButton') | 49 self:RegisterForDrag('LeftButton') |
50 end | 50 end |
51 local VeneerButton_OnShow = function(self) | 51 local VeneerButton_OnShow = function(self) |
52 self:SetScript('OnDragStart', self.StartMoving) | 52 self:SetScript('OnDragStart', self.StartMoving) |
53 self:SetScript('OnDragStop', self.StopMovingOrSizing) | 53 self:SetScript('OnDragStop', self.StopMovingOrSizing) |
54 self:SetMovable(true) | 54 self:SetMovable(false) |
55 self:EnableMouse(true) | 55 self:EnableMouse(false) |
56 self:RegisterForDrag('LeftButton') | 56 self:RegisterForDrag('LeftButton') |
57 end | 57 end |
58 | 58 |
59 | 59 |
60 local GetVeneer = function(frame) | 60 local GetVeneer = function(frame) |
61 local name = frame:GetName() | 61 local name = frame:GetName() |
62 if not _G[name..'Veneer'] then | 62 if not _G[name..'Veneer'] then |
63 | 63 |
64 local veneer = CreateFrame('Frame', name..'Veneer', UIParent) | 64 local veneer = CreateFrame('Frame', name..'Veneer', UIParent) |
65 local id = frame:GetID() | |
65 veneer:SetAllPoints(frame) | 66 veneer:SetAllPoints(frame) |
67 veneer:SetParent(frame) | |
66 veneer.bg = veneer:CreateTexture() | 68 veneer.bg = veneer:CreateTexture() |
67 veneer.bg:SetColorTexture(0,1,0,0.5) | 69 veneer.bg:SetColorTexture((id / 16),0,1-(id/16),0.5) |
70 print(id, id/16) | |
68 veneer.bg:SetAllPoints(veneer) | 71 veneer.bg:SetAllPoints(veneer) |
69 veneer.bg:Hide() | 72 veneer.bg:Show() |
70 veneer:Hide() | 73 veneer:Hide() |
74 veneer:EnableMouse(false) | |
71 | 75 |
72 veneer:SetScript('OnShow', VeneerButton_OnShow) | 76 veneer:SetScript('OnShow', VeneerButton_OnShow) |
73 veneer:SetScript('OnHide', VeneerButton_OnHide) | 77 veneer:SetScript('OnHide', VeneerButton_OnHide) |
74 | 78 |
75 local position = tonumber(name:match("%d")) | 79 local position = tonumber(name:match("%d")) |
102 end | 106 end |
103 | 107 |
104 local UpdateVeneer = function (frame, duration, expires) | 108 local UpdateVeneer = function (frame, duration, expires) |
105 local veneer = GetVeneer(frame) | 109 local veneer = GetVeneer(frame) |
106 | 110 |
107 if expires and duration then | 111 if expires and (duration ~= 0) then |
108 veneer.progress:Show() | 112 veneer.progress:Show() |
109 | 113 |
110 local startTime = (expires - duration) | 114 local startTime = (expires - duration) |
111 local endTime = expires or 0 | 115 local endTime = expires or 0 |
112 print('|cFF0088FF'..frame:GetName()..'|r', 'has expiration', startTime, 'to', endTime, 'over', duration, 'frame', veneer.progress:GetWidth()) | 116 print('|cFF0088FF'..frame:GetName()..'|r', 'has expiration', startTime, 'to', endTime, 'over', duration, 'frame', veneer.progress:GetWidth()) |
113 veneer.progress:SetScript('OnUpdate', function(self) | 117 veneer.progress:SetScript('OnUpdate', function(self) |
114 local w = floor(veneer.progress:GetWidth()+.5) | 118 local w = floor(veneer.progress:GetWidth()+.5) |
115 local t = GetTime() | 119 local t = GetTime() |
116 local progress = (t - startTime) / duration | 120 local progress = (t - startTime) / duration |
117 if t >= endTime or not frame:IsVisible() then | 121 |
122 local nw = w - ceil(w * progress) | |
123 print(progress, nw, w) | |
124 if (progress >= 1) or not frame:IsVisible() then | |
118 veneer.startTime = nil | 125 veneer.startTime = nil |
126 self:Hide() | |
119 self:SetScript('OnUpdate', nil) | 127 self:SetScript('OnUpdate', nil) |
120 self:Hide() | |
121 else | 128 else |
122 self.fg:SetWidth(w - ceil(w * progress) - 2) | 129 self.fg:SetWidth(nw) |
123 end | 130 end |
124 end) | 131 end) |
125 end | 132 end |
126 | 133 |
127 | 134 |
225 end | 232 end |
226 print(table.concat(todo, ', ')) | 233 print(table.concat(todo, ', ')) |
227 end | 234 end |
228 --BuffButton1 | 235 --BuffButton1 |
229 --DebuffButton1 | 236 --DebuffButton1 |
230 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0) | 237 if BuffButton1 then |
238 TempEnchant1:SetPoint('TOPRIGHT', BuffButton1, 'TOPRIGHT', BuffButton1:GetWidth()+4, 0) | |
239 end | |
240 | |
231 end | 241 end |
232 | 242 |
233 local AuraButton_UpdateDuration = function(frame, timeLeft) | 243 local AuraButton_UpdateDuration = function(frame, timeLeft) |
234 local ts = '' | 244 local hours = floor(timeLeft/3600) |
245 local minutes = floor(mod(timeLeft, 3600)/60) | |
246 local seconds = floor(mod(timeLeft, 60)) | |
247 local timeString = '%ds' | |
235 if timeLeft > 3600 then | 248 if timeLeft > 3600 then |
236 ts = ts .. floor(timeLeft/3600) .. ':' | 249 timeString = format('%d:%02d', hours, minutes) |
237 timeLeft = mod(timeLeft, 3600) | 250 elseif timeLeft > 60 then |
238 end | 251 timeString = format('%d:%02d', minutes, seconds) |
239 if timeLeft > 60 then | 252 elseif timeLeft > 10 then |
240 ts = ts .. floor(timeLeft/60) .. '\'' | 253 timeString = format('%d', seconds) |
241 timeLeft = mod(timeLeft, 60) | 254 else |
242 end | 255 timeString = format('%0.1f', mod(timeLeft, 60)) |
243 ts = ts .. floor(timeLeft)..'"' | 256 end |
244 | 257 |
245 frame.duration:SetText(ts) | 258 |
259 frame.duration:SetText(timeString) | |
246 frame.duration:SetVertexColor(1,1,1) | 260 frame.duration:SetVertexColor(1,1,1) |
247 | 261 |
248 end | 262 end |
249 | 263 |
250 local visibility = {} | 264 local visibility = {} |