Mercurial > wow > buffalo2
comparison Modules/BuffFrame.lua @ 94:df10cd0ae949
- Pre-load veneer frames for buffs, set their triggers when the appropriate frames have spawned.
- Fix to background layers remaining on screen during pet battles.
| author | Nenue |
|---|---|
| date | Sun, 01 Jan 2017 19:31:06 -0500 |
| parents | caded2668701 |
| children | 43303398d1b9 |
comparison
equal
deleted
inserted
replaced
| 93:caded2668701 | 94:df10cd0ae949 |
|---|---|
| 46 anchorPoint = 'TOPRIGHT', | 46 anchorPoint = 'TOPRIGHT', |
| 47 Buttons = {}, | 47 Buttons = {}, |
| 48 DetectedFrames = {}, | 48 DetectedFrames = {}, |
| 49 AuraCache = {} | 49 AuraCache = {} |
| 50 } | 50 } |
| 51 VeneerBuffFrameButtonMixin = { | 51 VeneerBuffFrameButtonMixin = {} |
| 52 } | 52 local Facade = VeneerBuffFrameButtonMixin |
| 53 local plugin = VeneerBuffFrameMixin | 53 local plugin = VeneerBuffFrameMixin |
| 54 | 54 |
| 55 local vn = Veneer | 55 local vn = Veneer |
| 56 local print = DEVIAN_WORKSPACE and function(...) _G.print('BuffFrame', ...) end or function() end | 56 local print = DEVIAN_WORKSPACE and function(...) _G.print('BuffFrame', ...) end or function() end |
| 57 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end | 57 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end |
| 174 end | 174 end |
| 175 end | 175 end |
| 176 end | 176 end |
| 177 end | 177 end |
| 178 end | 178 end |
| 179 function VeneerBuffFrameMixin:Acquire(target) | 179 |
| 180 | 180 |
| 181 local frame = self.Buttons[target] | 181 |
| 182 if not (self.Buttons[target]) then | 182 function Facade:OnShow() |
| 183 | 183 self.underlay:Show() |
| 184 local name = target:GetName() | 184 end |
| 185 function Facade:OnHide() | |
| 186 self.underlay:Hide() | |
| 187 end | |
| 188 | |
| 189 function Facade:OnLoad() | |
| 190 | |
| 191 self.duration = self.progress.duration | |
| 192 self.count = self.overlay.count | |
| 193 self.border = self.underlay.bg | |
| 194 | |
| 195 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} | |
| 196 self.configIndex = #VeneerBuffFrame.ConfigLayers | |
| 197 for i, region in ipairs(self.ConfigLayers) do | |
| 198 tinsert(VeneerBuffFrame.ConfigLayers, region) | |
| 199 end | |
| 200 | |
| 201 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers | |
| 202 end | |
| 203 | |
| 204 function Facade:Setup() | |
| 205 self:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) | |
| 206 | |
| 207 self.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](self.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) | |
| 208 --print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) | |
| 209 | |
| 210 self.progress:ClearAllPoints() | |
| 211 self.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or self.border, PROGRESS_ANCHOR, | |
| 212 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1), | |
| 213 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1)) | |
| 214 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0) | |
| 215 self.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], self.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0) | |
| 216 | |
| 217 --print(self.progress:GetPoint(1)) | |
| 218 --print(self.progress:GetPoint(2)) | |
| 219 --print(self.progress:GetPoint(3)) | |
| 220 self.progress:Show() | |
| 221 | |
| 222 self.progress.bg:ClearAllPoints() | |
| 223 self.progress.bg:SetAllPoints(self.progress) | |
| 224 | |
| 225 self.progress.fg:ClearAllPoints() | |
| 226 self.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) | |
| 227 self.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) | |
| 228 --self.count:ClearAllPoints() | |
| 229 --self.count:SetPoint('TOPRIGHT', self,'TOPRIGHT', -3, -3) | |
| 230 | |
| 231 | |
| 232 self.duration:ClearAllPoints() | |
| 233 self.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or self, DURATION_ANCHOR, | |
| 234 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET), | |
| 235 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET)) | |
| 236 | |
| 237 self.count:ClearAllPoints() | |
| 238 self.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or self, COUNT_ANCHOR, | |
| 239 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET), | |
| 240 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET)) | |
| 241 | |
| 242 self.underlay:SetParent(self) | |
| 243 self.underlay:SetFrameStrata('BACKGROUND') | |
| 244 self.border:SetColorTexture(0,0,0,1) | |
| 245 self.border:SetPoint('TOPLEFT', self, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) | |
| 246 self.border:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) | |
| 247 self.border:Show() | |
| 248 end | |
| 249 | |
| 250 function plugin:AcquireConfigButton(name) | |
| 251 print('|cFF88FF00Creating config dummy', name,'Veneer') | |
| 252 local button = self.Buttons[name] | |
| 253 if not button then | |
| 254 button = CreateFrame('Frame', name .. 'Veneer', self, 'VeneerBuffTemplate') | |
| 255 button:Setup() | |
| 256 button:SetShown(true) | |
| 257 self.Buttons[name] = button | |
| 258 end | |
| 259 return button | |
| 260 end | |
| 261 | |
| 262 function plugin:Acquire(name) | |
| 263 local frame = self.Buttons[name] | |
| 264 if not frame then | |
| 265 local target = _G[name] | |
| 185 local id = target:GetID() | 266 local id = target:GetID() |
| 186 print('|cFF88FF00Creating', name,'Veneer') | 267 print('|cFF88FF00Creating', name .. 'Veneer') |
| 187 frame = vn:Acquire(target, 'VeneerBuffTemplate') | 268 frame = vn:Acquire(target, 'VeneerBuffTemplate') |
| 188 | 269 frame:Setup() |
| 189 | 270 self.Buttons[name] = frame |
| 190 frame.progress[OFFSET_PARALLELS[PROGRESS_ANCHOR][3]](frame.progress, BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) | |
| 191 print(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) | |
| 192 | |
| 193 frame.progress:ClearAllPoints() | |
| 194 frame.progress:SetPoint(ANCHOR_OFFSET_POINT[PROGRESS_ANCHOR], PROGRESS_PARENT or frame.border, PROGRESS_ANCHOR, | |
| 195 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][1] * PROGRESS_OFFSET * -1), | |
| 196 (ANCHOR_INSET_DELTA[PROGRESS_ANCHOR][2] * PROGRESS_OFFSET * -1)) | |
| 197 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][1], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][1], 0, 0) | |
| 198 frame.progress:SetPoint(OFFSET_PARALLELS[PROGRESS_ANCHOR][2], frame.border, OFFSET_PARALLELS[PROGRESS_ANCHOR][2], 0, 0) | |
| 199 | |
| 200 print(frame.progress:GetPoint(1)) | |
| 201 print(frame.progress:GetPoint(2)) | |
| 202 print(frame.progress:GetPoint(3)) | |
| 203 frame.progress:Show() | |
| 204 | |
| 205 frame.progress.bg:ClearAllPoints() | |
| 206 frame.progress.bg:SetAllPoints(frame.progress) | |
| 207 | |
| 208 frame.progress.fg:ClearAllPoints() | |
| 209 frame.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) | |
| 210 frame.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) | |
| 211 --frame.count:ClearAllPoints() | |
| 212 --frame.count:SetPoint('TOPRIGHT', frame,'TOPRIGHT', -3, -3) | |
| 213 | |
| 214 | |
| 215 frame.duration:ClearAllPoints() | |
| 216 frame.duration:SetPoint(DURATION_ANCHOR, DURATION_PARENT or frame, DURATION_ANCHOR, | |
| 217 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][1] * DURATION_INSET), | |
| 218 (ANCHOR_INSET_DELTA[DURATION_ANCHOR][2] * DURATION_INSET)) | |
| 219 | |
| 220 frame.count:ClearAllPoints() | |
| 221 frame.count:SetPoint(COUNT_ANCHOR, COUNT_PARENT or frame, COUNT_ANCHOR, | |
| 222 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][1] * COUNT_INSET), | |
| 223 (ANCHOR_INSET_DELTA[COUNT_ANCHOR][2] * COUNT_INSET)) | |
| 224 | |
| 225 frame.underlay:SetParent(UIParent) | |
| 226 frame.underlay:SetFrameStrata('BACKGROUND') | |
| 227 frame.border:SetColorTexture(0,0,0,1) | |
| 228 frame.border:SetPoint('TOPLEFT', frame, 'TOPLEFT', -BORDER_SIZE_L, BORDER_SIZE_U) | |
| 229 frame.border:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMRIGHT', BORDER_SIZE_R, -BORDER_SIZE_D) | |
| 230 frame.border:Show() | |
| 231 | |
| 232 self.Buttons[target] = frame | |
| 233 end | 271 end |
| 234 return frame | 272 return frame |
| 235 end | 273 end |
| 236 | 274 |
| 237 function VeneerBuffFrameMixin:OnLoad() | 275 function plugin:OnLoad() |
| 238 Veneer:AddHandler(self, self.defaultCluster) | 276 Veneer:AddHandler(self, self.defaultCluster) |
| 239 end | 277 end |
| 240 | 278 |
| 241 function VeneerBuffFrameMixin:Setup() | 279 function plugin:Setup() |
| 242 | 280 |
| 243 | 281 |
| 244 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end) | 282 hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end) |
| 245 --hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end) | 283 --hooksecurefunc("AuraButton_UpdateDuration", function(...) self:OnUpdateDuration(...) end) |
| 246 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end) | 284 hooksecurefunc("AuraButton_Update", function(...) self:OnAuraButton_Update(...) end) |
| 250 self:SetupButton('TempEnchant'..i) | 288 self:SetupButton('TempEnchant'..i) |
| 251 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) | 289 _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) |
| 252 end | 290 end |
| 253 end | 291 end |
| 254 | 292 |
| 255 function VeneerBuffFrameMixin:SetHidden(region) | 293 function plugin:SetHidden(region) |
| 256 if not self.hiddenRegions[region] then | 294 if not self.hiddenRegions[region] then |
| 257 self.hiddenRegions[region] = true | 295 self.hiddenRegions[region] = true |
| 258 region:SetShown(false) | 296 region:SetShown(false) |
| 259 hooksecurefunc(region) | 297 hooksecurefunc(region) |
| 260 end | 298 end |
| 261 end | 299 end |
| 262 | 300 |
| 263 function VeneerBuffFrameMixin:SetupButton (name) | 301 function plugin:SetupButton (name) |
| 264 local frame = _G[name ] | 302 local frame = _G[name] |
| 265 if self.DetectedFrames[frame] then | |
| 266 --print('|cFFFF4400Attempting to skin a frame that already went through.|r') | |
| 267 return | |
| 268 end | |
| 269 --print('|cFFFFFF00Adopting', name) | 303 --print('|cFFFFFF00Adopting', name) |
| 270 | 304 |
| 271 local icon = _G[name .. 'Icon'] | 305 local icon = _G[name .. 'Icon'] |
| 272 local border = _G[name .. 'Border'] | 306 local border = _G[name .. 'Border'] |
| 273 local count = _G[name .. 'Count'] | 307 local count = _G[name .. 'Count'] |
| 274 local duration = _G[name .. 'Duration'] | 308 local duration = _G[name .. 'Duration'] |
| 275 local veneer = self:Acquire(frame) | 309 local veneer = self:Acquire(name) |
| 276 local offset = BUFF_BUTTON_ZOOM/2 | 310 local offset = BUFF_BUTTON_ZOOM/2 |
| 277 | 311 |
| 278 self.DetectedFrames[frame] = frame | 312 self.DetectedFrames[frame] = frame |
| 279 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) | 313 frame:SetSize(BUFF_BUTTON_SIZE,BUFF_BUTTON_SIZE) |
| 280 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) | 314 icon:SetTexCoord(offset, 1 - offset, offset, 1 - offset) |
| 281 | |
| 282 | 315 |
| 283 | 316 |
| 284 DoRegionHooks(veneer, border) | 317 DoRegionHooks(veneer, border) |
| 285 if border then | 318 if border then |
| 286 local color = DebuffTypeColor["none"] | 319 local color = DebuffTypeColor["none"] |
| 304 end | 337 end |
| 305 if duration then | 338 if duration then |
| 306 duration:ClearAllPoints() | 339 duration:ClearAllPoints() |
| 307 end | 340 end |
| 308 | 341 |
| 309 | |
| 310 | |
| 311 | |
| 312 hooksecurefunc(frame, "Hide", function(self) | 342 hooksecurefunc(frame, "Hide", function(self) |
| 313 local isVisible = self:IsVisible() | |
| 314 if isVisible ~= visibility[self] then | |
| 315 visibility[self] = isVisible | |
| 316 end | |
| 317 veneer:Hide() | 343 veneer:Hide() |
| 318 veneer.underlay:Hide() | |
| 319 end) | 344 end) |
| 320 | 345 |
| 321 hooksecurefunc(frame, 'Show', function(self) | 346 hooksecurefunc(frame, 'Show', function(self) |
| 322 veneer:Show() | 347 veneer:Show() |
| 323 local isVisible = self:IsVisible() | |
| 324 if isVisible ~= visibility[self] then | |
| 325 print('|cFFFFFF00SHOW|r', self:GetName()) | |
| 326 visibility[self] = isVisible | |
| 327 end | |
| 328 veneer.underlay:Show() | |
| 329 end) | 348 end) |
| 330 | 349 |
| 350 veneer:SetParent(UIParent) | |
| 351 veneer:SetAllPoints(frame) | |
| 352 veneer:SetFrameStrata('BACKGROUND') | |
| 331 end | 353 end |
| 332 | 354 |
| 333 | 355 |
| 334 --- Set widgets to reflect the passed parameters | 356 --- Set widgets to reflect the passed parameters |
| 335 function VeneerBuffFrameMixin:UpdateButton (frame, duration, expires) | 357 function plugin:UpdateButton (name, duration, expires) |
| 336 local veneer = self:Acquire(frame) | 358 local frame = _G[name] |
| 359 local veneer = self:Acquire(name) | |
| 337 -- is it a new button? | 360 -- is it a new button? |
| 338 if not self.DetectedFrames[frame] then | 361 if not self.DetectedFrames[frame] then |
| 339 self:SetupButton(frame:GetName()) | 362 print('|cFFFF4400detected', name) |
| 340 end | 363 self:SetupButton(name) |
| 341 | 364 end |
| 365 print(veneer:GetParent():GetName(), veneer:GetPoint(1)) | |
| 342 --[[ | 366 --[[ |
| 343 if frame.count then | 367 if frame.count then |
| 344 frame.count:SetText('test') | 368 frame.count:SetText('test') |
| 345 frame.count:Show() | 369 frame.count:Show() |
| 346 end | 370 end |
| 404 veneer:Show() | 428 veneer:Show() |
| 405 end | 429 end |
| 406 | 430 |
| 407 | 431 |
| 408 --- Provides the number of changed indices for use in deciding between partial and full veneer updates | 432 --- Provides the number of changed indices for use in deciding between partial and full veneer updates |
| 409 function VeneerBuffFrameMixin:ButtonHasChanged (frame, ...) | 433 function plugin:ButtonHasChanged (frame, ...) |
| 410 aurasCache[frame] = aurasCache[frame] or {} | 434 aurasCache[frame] = aurasCache[frame] or {} |
| 411 local hasChange = 0 | 435 local hasChange = 0 |
| 412 local numVals = select('#',...) | 436 local numVals = select('#',...) |
| 413 for i = 1, numVals do | 437 for i = 1, numVals do |
| 414 local arg = select(i, ...) | 438 local arg = select(i, ...) |
| 418 aurasCache[frame][i] = arg | 442 aurasCache[frame][i] = arg |
| 419 end | 443 end |
| 420 return hasChange | 444 return hasChange |
| 421 end | 445 end |
| 422 | 446 |
| 423 function VeneerBuffFrameMixin:OnAuraButton_Update (name, index, filter) | 447 function plugin:OnAuraButton_Update (name, index, filter) |
| 424 local bName = name..index | 448 local bName = name..index |
| 425 local frame = _G[bName] | 449 local frame = _G[bName] |
| 426 if frame and frame:IsVisible() then | 450 if frame and frame:IsVisible() then |
| 427 -- if the name or expirationTime changed | 451 -- if the name or expirationTime changed |
| 428 | 452 |
| 429 if not skinnedFrames[frame] then | 453 if not skinnedFrames[bName] then |
| 430 tinsert(pendingFrames, frame) | 454 tinsert(pendingFrames, bName) |
| 431 end | 455 end |
| 432 expirationCache[name] = frame.expirationTime | 456 expirationCache[name] = frame.expirationTime |
| 433 self:UpdateButton(frame) | 457 self:UpdateButton(bName) |
| 434 | 458 |
| 435 | 459 |
| 436 end | 460 end |
| 437 end | 461 end |
| 438 | 462 |
| 439 function VeneerBuffFrameMixin:OnUpdateAllBuffAnchors () | 463 function plugin:OnUpdateAllBuffAnchors () |
| 440 local todo = {} | 464 |
| 441 if #pendingFrames >= 1 then | |
| 442 | |
| 443 print('|cFFBBFF00AllBuffAnchors|r', #pendingFrames) | |
| 444 while pendingFrames[1] do | |
| 445 local frame = tremove(pendingFrames) | |
| 446 tinsert(todo, frame:GetName()) | |
| 447 | |
| 448 -- re-apply custom anchors | |
| 449 end | |
| 450 print(tconcat(todo, ', ')) | |
| 451 end | |
| 452 --BuffButton1 | 465 --BuffButton1 |
| 453 --DebuffButton1 | 466 --DebuffButton1 |
| 454 --todo: separate frame groups and iterate over them at appropriate times | 467 --todo: separate frame groups and iterate over them at appropriate times |
| 455 if BuffButton1 then | 468 if BuffButton1 then |
| 456 | 469 |
| 459 | 472 |
| 460 local lastBuff, topBuff | 473 local lastBuff, topBuff |
| 461 local numBuffs = 0 | 474 local numBuffs = 0 |
| 462 local numColumns = 1 | 475 local numColumns = 1 |
| 463 local maxColumn = 1 | 476 local maxColumn = 1 |
| 464 for i = 1, BUFF_ACTUAL_DISPLAY do | 477 local limit = self.configMode and BUFF_MAX_DISPLAY or BUFF_ACTUAL_DISPLAY |
| 465 local buff = _G['BuffButton'..i] | 478 for i = 1, limit do |
| 479 local name = 'BuffButton'..i | |
| 480 local buff = _G[name] or self.Buttons[name] | |
| 481 print(buff:GetName(), self.configMode) | |
| 466 if buff then | 482 if buff then |
| 467 numBuffs = numBuffs + 1 | 483 numBuffs = numBuffs + 1 |
| 468 buff:ClearAllPoints() | 484 buff:ClearAllPoints() |
| 469 if mod(numBuffs,BUFFS_PER_ROW) == 1 then | 485 if mod(numBuffs,BUFFS_PER_ROW) == 1 then |
| 470 if numBuffs == 1 then | 486 if numBuffs == 1 then |
| 486 lastBuff = buff | 502 lastBuff = buff |
| 487 end | 503 end |
| 488 end | 504 end |
| 489 | 505 |
| 490 numBuffs = 0 | 506 numBuffs = 0 |
| 507 limit = self.configMode and DEBUFF_MAX_DISPLAY or DEBUFF_ACTUAL_DISPLAY | |
| 491 for i = 1, DEBUFF_ACTUAL_DISPLAY do | 508 for i = 1, DEBUFF_ACTUAL_DISPLAY do |
| 492 local debuff = _G['DebuffButton'..i] | 509 local name = 'DebuffButton'..i |
| 510 local debuff = _G[name] or self.Buttons[name] | |
| 493 if debuff then | 511 if debuff then |
| 494 numBuffs = numBuffs + 1 | 512 numBuffs = numBuffs + 1 |
| 495 if mod(numBuffs, BUFFS_PER_ROW) == 1 then | 513 if mod(numBuffs, BUFFS_PER_ROW) == 1 then |
| 496 | 514 |
| 497 if topBuff then | 515 if topBuff then |
| 503 | 521 |
| 504 else | 522 else |
| 505 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) | 523 debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) |
| 506 end | 524 end |
| 507 lastBuff = debuff | 525 lastBuff = debuff |
| 526 | |
| 508 end | 527 end |
| 509 end | 528 end |
| 510 | 529 |
| 511 if lastBuff then | 530 if lastBuff then |
| 512 plugin.currentBottom = lastBuff | 531 plugin.currentBottom = lastBuff |
| 515 self.Background:ClearAllPoints() | 534 self.Background:ClearAllPoints() |
| 516 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4) | 535 self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4) |
| 517 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4) | 536 self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4) |
| 518 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0) | 537 self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0) |
| 519 end | 538 end |
| 520 function VeneerBuffFrameMixin:UpdateConfigLayers (configMode) | 539 function plugin:UpdateConfigLayers (configMode) |
| 521 self:SetShown(configMode) | 540 self:SetShown(configMode) |
| 522 for _, button in pairs(self.Buttons) do | 541 self.configMode = configMode |
| 523 button:SetShown(configMode) | 542 for i = 1, BUFF_MAX_DISPLAY do |
| 524 end | 543 local name = 'BuffButton' .. i |
| 525 end | 544 local button = self:AcquireConfigButton(name) |
| 526 function VeneerBuffFrameMixin:OnUpdateDuration (frame, timeLeft) | 545 end |
| 546 for i = 1, DEBUFF_MAX_DISPLAY do | |
| 547 local name = 'DebuffButton' .. i | |
| 548 local button = self:AcquireConfigButton(name) | |
| 549 end | |
| 550 end | |
| 551 function plugin:OnUpdateDuration (frame, timeLeft) | |
| 527 local veneer = self:Acquire(frame) | 552 local veneer = self:Acquire(frame) |
| 528 local hours = floor(timeLeft/3600) | 553 local hours = floor(timeLeft/3600) |
| 529 local minutes = floor(mod(timeLeft, 3600)/60) | 554 local minutes = floor(mod(timeLeft, 3600)/60) |
| 530 local seconds = floor(mod(timeLeft, 60)) | 555 local seconds = floor(mod(timeLeft, 60)) |
| 531 local timeString = '%ds' | 556 local timeString = '%ds' |
| 555 end | 580 end |
| 556 | 581 |
| 557 | 582 |
| 558 -- Obtains the first instance of Tenchant use | 583 -- Obtains the first instance of Tenchant use |
| 559 | 584 |
| 560 function VeneerBuffFrameMixin:OnTemporaryEnchantFrameUpdate (...) | 585 function plugin:OnTemporaryEnchantFrameUpdate (...) |
| 561 local numVals = select('#', ...) | 586 local numVals = select('#', ...) |
| 562 local numItems = numVals / 4 | 587 local numItems = numVals / 4 |
| 563 if numItems >= 1 then | 588 if numItems >= 1 then |
| 564 for itemIndex = numItems, 1, -1 do | 589 for itemIndex = numItems, 1, -1 do |
| 565 local frame = _G['TempEnchant'..itemIndex] | 590 local name = 'TempEnchant'..itemIndex |
| 591 local frame = _G[name] | |
| 566 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...) | 592 local hasEnchant, timeRemaining, enchantCharges = select((4 * (itemIndex -1)) + 1, ...) |
| 567 | 593 |
| 568 | 594 |
| 569 if hasEnchant then | 595 if hasEnchant then |
| 570 local endTime = floor(GetTime()*1000) + timeRemaining | 596 local endTime = floor(GetTime()*1000) + timeRemaining |
| 575 if expirationCache[frame] then | 601 if expirationCache[frame] then |
| 576 print(endTime, expirationCache[frame], endTime - expirationCache[frame]) | 602 print(endTime, expirationCache[frame], endTime - expirationCache[frame]) |
| 577 end | 603 end |
| 578 expirationCache[frame] = endTime | 604 expirationCache[frame] = endTime |
| 579 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000)) | 605 print('push tempenchant timer update', timeRemaining / 1000, GetTime()+(timeRemaining/1000)) |
| 580 UpdateVeneer(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000)) | 606 self:UpdateButton(frame, timeRemaining/1000, GetTime()+(timeRemaining/1000)) |
| 581 end | 607 end |
| 582 else | 608 else |
| 583 self:Acquire(frame):Hide() | 609 self:Acquire(name):Hide() |
| 584 end | 610 end |
| 585 | 611 end |
| 586 end | 612 end |
| 587 | 613 end |
| 588 end | 614 |
| 589 | 615 function plugin:OnBuffFrameUpdate () end |
| 590 end | 616 |
| 591 function VeneerBuffFrameMixin:OnBuffFrameUpdate () | |
| 592 end | |
| 593 | |
| 594 | |
| 595 function VeneerBuffFrameButtonMixin:OnLoad() | |
| 596 | |
| 597 self.duration = self.progress.duration | |
| 598 self.count = self.overlay.count | |
| 599 self.border = self.underlay.bg | |
| 600 | |
| 601 VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} | |
| 602 self.configIndex = #VeneerBuffFrame.ConfigLayers | |
| 603 for i, region in ipairs(self.ConfigLayers) do | |
| 604 tinsert(VeneerBuffFrame.ConfigLayers, region) | |
| 605 end | |
| 606 | |
| 607 self.configIndexEnd = #VeneerBuffFrame.ConfigLayers | |
| 608 end | |
| 609 | 617 |
| 610 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now | 618 -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now |
| 611 | 619 |
