Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 111:1196c2bad31c
- obtain World Quest AP via WorldPlan
- artifact button text adjustments
- removed from UISpecialFrames to fix hiding on map open
author | Nick@Zahhak |
---|---|
date | Tue, 21 Mar 2017 16:33:51 -0400 |
parents | a41f6b74709a |
children | 7c77fde36287 |
comparison
equal
deleted
inserted
replaced
110:73316951ce73 | 111:1196c2bad31c |
---|---|
33 191500, 2010000, 2110000, 2215000, 2325000, | 33 191500, 2010000, 2110000, 2215000, 2325000, |
34 2440000, 2560000, 2690000, 2825000, 2965000, | 34 2440000, 2560000, 2690000, 2825000, 2965000, |
35 3115000, 3270000, 3435000, 3605000, 3785000, | 35 3115000, 3270000, 3435000, 3605000, 3785000, |
36 3975000, 4175000, 4385000, 4605000 | 36 3975000, 4175000, 4385000, 4605000 |
37 } | 37 } |
38 | 38 local FISHING_MAX_TRAITS = 24 |
39 local WEAPON_MAX_TRAITS = 54 | |
40 local BUTTON_SIZE = 48 | |
39 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'} | 41 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'} |
40 local BAG_FRAMES = {'ContainerFrame1'} | 42 local BAG_FRAMES = {'ContainerFrame1'} |
41 local BANK_FRAMES = {'BankFrame'} | 43 local BANK_FRAMES = {'BankFrame'} |
42 | 44 |
43 function ap:OnLoad() | 45 function ap:OnLoad() |
74 self:Show() | 76 self:Show() |
75 end | 77 end |
76 end | 78 end |
77 | 79 |
78 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') | 80 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') |
79 tinsert(UISpecialFrames, self:GetName()) | |
80 | 81 |
81 | 82 |
82 end | 83 end |
83 local ShortNumberString = function (value) | 84 local ShortNumberString = function (value) |
84 if value >= 100000 then | 85 if value >= 100000 then |
117 tinsert(queued_hooks, {...}) | 118 tinsert(queued_hooks, {...}) |
118 end | 119 end |
119 if not InCombatLockdown() then | 120 if not InCombatLockdown() then |
120 local info = tremove(queued_hooks) | 121 local info = tremove(queued_hooks) |
121 while info do | 122 while info do |
122 print('hooking', unpack(info)) | 123 --[[local oFunc = tremove(info, #info) |
124 local args = info | |
125 | |
126 local func = function(...) | |
127 print('|cFFFF0088Callback:|r', unpack(args)) | |
128 | |
129 oFunc(...) | |
130 end | |
131 print('hooking', unpack(info), oFunc, func) | |
132 hooksecurefunc(unpack(info), func) | |
133 --]] | |
123 hooksecurefunc(unpack(info)) | 134 hooksecurefunc(unpack(info)) |
124 info = tremove(queued_hooks) | 135 info = tremove(queued_hooks) |
125 end | 136 end |
126 | 137 |
127 end | 138 end |
129 | 140 |
130 local function AddFrameHooks(frame, args) | 141 local function AddFrameHooks(frame, args) |
131 for funcName, func in pairs(args.FrameMethods) do | 142 for funcName, func in pairs(args.FrameMethods) do |
132 print('binding', frame:GetName(), funcName, 'to', tostring(func)) | 143 print('binding', frame:GetName(), funcName, 'to', tostring(func)) |
133 CreateHook(frame, funcName, function() | 144 CreateHook(frame, funcName, function() |
145 print(frame:GetName(), funcName, 'hook') | |
134 VeneerArtifactPower:TryToShow() | 146 VeneerArtifactPower:TryToShow() |
135 end) | 147 end) |
136 end | 148 end |
137 end | 149 end |
138 local PENDING_HOOKS = {} | 150 local PENDING_HOOKS = {} |
180 VeneerArtifactPowerTimer:SetScript('OnUpdate', function() | 192 VeneerArtifactPowerTimer:SetScript('OnUpdate', function() |
181 self:OnUpdate() | 193 self:OnUpdate() |
182 end) | 194 end) |
183 | 195 |
184 local DoTryToShow = function() | 196 local DoTryToShow = function() |
197 | |
185 self:TryToShow() | 198 self:TryToShow() |
186 end | 199 end |
187 CreateHook("OpenBackpack", DoTryToShow) | 200 CreateHook("OpenBackpack", DoTryToShow) |
188 CreateHook("CloseBackpack", DoTryToShow) | 201 CreateHook("CloseBackpack", DoTryToShow) |
189 | 202 |
225 end | 238 end |
226 end | 239 end |
227 | 240 |
228 local UNDERLIGHT_ANGLER_ID = 133755 | 241 local UNDERLIGHT_ANGLER_ID = 133755 |
229 | 242 |
243 function ap:ResetCache() | |
244 table.wipe(self.cache.items) | |
245 table.wipe(self.cache.fishing) | |
246 table.wipe(self.cache.bags) | |
247 table.wipe(self.cache.bagItems) | |
248 self:ScanAllBags() | |
249 end | |
250 | |
230 function ap:QueueBag(containerID) | 251 function ap:QueueBag(containerID) |
231 containerID = tonumber(containerID) | 252 containerID = tonumber(containerID) |
232 if not containerID then | 253 if not containerID then |
233 return | 254 return |
234 end | 255 end |
259 self.enabled = true | 280 self.enabled = true |
260 self:ScanAllBags() | 281 self:ScanAllBags() |
261 self:Reanchor() | 282 self:Reanchor() |
262 end | 283 end |
263 function ap:OnHide() | 284 function ap:OnHide() |
264 print('|cFF88FF00OnHide()|r') | 285 print('|cFF88FF00OnHide()|r', debugstack()) |
265 self:Reanchor() | 286 self:Reanchor() |
266 end | 287 end |
267 function ap:OnEnter() | 288 function ap:OnEnter() |
268 | 289 |
269 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 290 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
279 print('|cFFFFFF00TryToShow()') | 300 print('|cFFFFFF00TryToShow()') |
280 | 301 |
281 if not InCombatLockdown() then | 302 if not InCombatLockdown() then |
282 for _, name in ipairs(FRAME_LIST) do | 303 for _, name in ipairs(FRAME_LIST) do |
283 print('test:', name, (_G[name] and _G[name]:IsShown())) | 304 print('test:', name, (_G[name] and _G[name]:IsShown())) |
284 if _G[name] and _G[name]:IsShown() then | 305 if _G[name] and _G[name]:IsVisible() then |
285 if self:IsShown() then | 306 if self:IsShown() then |
286 self:Update() | 307 self:Update() |
287 else | 308 else |
288 self:Show() | 309 self:Show() |
289 end | 310 end |
290 return | 311 return |
291 end | 312 end |
292 end | 313 end |
293 end | 314 end |
294 | 315 |
295 | 316 print('failed tests') |
296 self:Hide() | 317 self:Hide() |
297 end | 318 end |
298 | 319 |
299 | 320 |
300 function ap:OnEvent(event, ...) | 321 function ap:OnEvent(event, ...) |
357 end | 378 end |
358 | 379 |
359 function ap:OnUpdate() | 380 function ap:OnUpdate() |
360 if #self.scanQueue >= 1 then | 381 if #self.scanQueue >= 1 then |
361 local scanInfo = tremove(self.scanQueue, 1) | 382 local scanInfo = tremove(self.scanQueue, 1) |
362 | 383 end |
363 end | 384 if IsShiftKeyDown() then |
385 self.Refresh:Show() | |
386 else | |
387 self.Refresh:Hide() | |
388 end | |
389 | |
364 end | 390 end |
365 | 391 |
366 function ap:OnMouseDown() | 392 function ap:OnMouseDown() |
367 self.enabled = nil | 393 self.enabled = nil |
368 self:Hide() | 394 self:Hide() |
379 if not self.profile.knowledgeMultiplier then | 405 if not self.profile.knowledgeMultiplier then |
380 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.' | 406 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.' |
381 elseif not (self.bankAP and self.bagAP) then | 407 elseif not (self.bankAP and self.bagAP) then |
382 bankText = '|cFFFF0000Open bank frame to count all AP|r ' | 408 bankText = '|cFFFF0000Open bank frame to count all AP|r ' |
383 else | 409 else |
384 if (self.bagAP + self.bankAP) == 0 then | 410 |
385 bankText = '|cFFFF4400No Artifact Power tokens on hand|r' | 411 if self.bagAP and (self.bagAP > 0) then |
386 else | 412 bankText = 'Inventory: |cFFFFFFFF' .. ShortNumberString(self.bagAP) .. '|r' |
387 if self.bagAP and (self.bagAP > 0) then | 413 end |
388 bankText = '|cFFFFFFFF' .. tostring(self.bagAP) .. '|r' | 414 if self.bankAP and (self.bankAP > 0) then |
389 end | 415 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..ShortNumberString(self.bankAP)..' banked|r' |
390 if self.bankAP and (self.bankAP > 0) then | 416 end |
391 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r' | 417 if self.fishingAP and self.fishingAP > 0 then |
392 end | 418 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFF0088FF' .. ShortNumberString(self.fishingAP) .. ' fishing|r' |
393 end | 419 end |
394 end | 420 end |
395 if self.fishingAP and self.fishingAP > 0 then | 421 |
396 bankText = (bankText and (bankText .. ' ') or '') .. '|cFF0088FF' .. tostring(self.fishingAP) .. ' fishing AP|r' | 422 self.worldQuestAP = 0 |
423 if WorldPlan then | |
424 | |
425 if not self.worldPlanHooked then | |
426 WorldPlan:RegisterDataCallback(function() | |
427 self:Update() | |
428 end) | |
429 end | |
430 | |
431 | |
432 local showWQ | |
433 print('world plan is loaded') | |
434 local worldQuests = WorldPlan:GetQuestPins() | |
435 for index, pin in ipairs(worldQuests) do | |
436 if pin.dataLoaded and (pin.rewardType == WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER) then | |
437 showWQ = true | |
438 print(pin.itemNumber) | |
439 self.worldQuestAP = self.worldQuestAP + pin.itemNumber | |
440 end | |
441 end | |
442 | |
443 if showWQ then | |
444 bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. '' | |
445 end | |
446 | |
397 end | 447 end |
398 | 448 |
399 self.SummaryHeader:SetText(bankText) | 449 self.SummaryHeader:SetText(bankText) |
400 | 450 |
401 local numButtons = 0 | 451 local numButtons = 0 |
402 local contentsHeight = 16 + self.SummaryHeader:GetHeight() + 64 | 452 local contentsHeight = 16 + self.SummaryHeader:GetHeight() |
403 local contentsWidth = 64 | 453 local contentsWidth = self.SummaryHeader:GetWidth() + 16 |
404 if self.profile.knowledgeMultiplier then | 454 if self.profile.knowledgeMultiplier then |
405 numButtons = self:UpdateArtifactButtons() | 455 numButtons = self:UpdateArtifactButtons() |
406 | 456 |
407 contentsWidth = 64*numButtons + 4 * (numButtons+1) | 457 if numButtons ~= 0 then |
458 contentsHeight = contentsHeight + 64 | |
459 end | |
460 | |
461 contentsWidth = max(contentsWidth, 64*numButtons + 4 * (numButtons+1)) | |
408 | 462 |
409 local itemsWidth, itemsHeight = self:UpdateItemButtons() | 463 local itemsWidth, itemsHeight = self:UpdateItemButtons() |
410 contentsHeight = contentsHeight + itemsHeight | 464 contentsHeight = contentsHeight + itemsHeight |
411 contentsWidth = max(contentsWidth, itemsWidth) | 465 contentsWidth = max(contentsWidth, itemsWidth) |
412 end | 466 end |
413 | 467 |
414 | 468 |
469 if not self.hasArtifacts then | |
470 self:SetShown(false) | |
471 end | |
472 | |
415 | 473 |
416 self:SetWidth(contentsWidth) | 474 self:SetWidth(contentsWidth) |
417 self:SetHeight(contentsHeight) | 475 self:SetHeight(contentsHeight) |
418 self:Reanchor() | 476 self:Reanchor() |
419 end | 477 end |
420 | 478 |
421 function ap:UpdateArtifactButtons() | 479 function ap:UpdateArtifactButtons() |
422 | 480 |
423 -- Artifact icons, in no particular order | 481 -- Artifact icons, in no particular order |
424 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() | 482 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() |
483 self.canAddAP = nil | |
484 self.canAddFishingAP = nil | |
485 local hasArtifacts | |
425 local numButtons = 0 | 486 local numButtons = 0 |
426 local lastFrame = self | 487 local lastFrame = self |
427 local fishingID, fishingData | 488 local fishingID, fishingData |
428 local index, button | 489 local index, button |
429 for itemID, artifact in pairs(self.profile.artifacts) do | 490 for itemID, artifact in pairs(self.profile.artifacts) do |
431 if VeneerData.ArtifactPower.EnableFishing then | 492 if VeneerData.ArtifactPower.EnableFishing then |
432 fishingID = itemID | 493 fishingID = itemID |
433 fishingData = artifact | 494 fishingData = artifact |
434 end | 495 end |
435 | 496 |
497 if artifact.level < FISHING_MAX_TRAITS then | |
498 if itemID == self.equippedID then | |
499 self.canAddFishingAP = true | |
500 end | |
501 end | |
502 | |
503 | |
436 else | 504 else |
437 if artifact.level ~= 54 then | 505 if artifact.level < WEAPON_MAX_TRAITS then |
506 | |
507 if itemID == self.equippedID then | |
508 self.canAddAP = true | |
509 end | |
510 hasArtifacts = true | |
438 numButtons = numButtons + 1 | 511 numButtons = numButtons + 1 |
439 button = self.Artifact[numButtons] | 512 button = self.Artifact[numButtons] |
440 button.relativeFrame = lastFrame | 513 button.relativeFrame = lastFrame |
441 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID)) | 514 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID), nil) |
442 end | 515 end |
443 end | 516 end |
444 | 517 end |
445 end | 518 |
446 | 519 |
447 if fishingData and (self.fishingAP and self.fishingAP > 0) then | 520 if fishingData and (self.fishingAP and self.fishingAP > 0) then |
448 numButtons = numButtons + 1 | 521 numButtons = numButtons + 1 |
522 hasArtifacts = true | |
449 local button = self.Artifact[numButtons] | 523 local button = self.Artifact[numButtons] |
450 button.relativeFrame = lastFrame | 524 button.relativeFrame = lastFrame |
525 button.isFishing = true | |
451 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) | 526 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) |
452 end | 527 end |
453 | 528 |
529 self.hasArtifacts = hasArtifacts | |
454 for i = numButtons+ 1, #self.Artifact do | 530 for i = numButtons+ 1, #self.Artifact do |
455 print('hide', i) | 531 print('hide', i) |
456 self.Artifact[i]:Hide() | 532 self.Artifact[i]:Hide() |
457 end | 533 end |
458 | 534 |
535 | |
459 return numButtons | 536 return numButtons |
460 end | 537 end |
461 | 538 |
462 | 539 |
463 function ap:UpdateItemButtons() | 540 function ap:UpdateItemButtons() |
464 print('|cFF00FFFFUpdateItemButtons()|r') | 541 print('|cFF00FFFFUpdateItemButtons()|r') |
542 | |
543 local apType | |
544 if self.canAddFishingAP then | |
545 apType = true | |
546 elseif not self.canAddAP then | |
547 for index, button in ipairs(self.Tokens) do | |
548 button:Hide() | |
549 end | |
550 return 0, 0 | |
551 end | |
552 | |
553 | |
465 local lastFrame, upFrame | 554 local lastFrame, upFrame |
466 local numButtons = 0 | 555 local numButtons = 0 |
467 local buttonsHeight = 0 | 556 local buttonsHeight = 0 |
468 local buttonsWidth = 0 | 557 local buttonsWidth = 0 |
558 | |
469 for index, button in ipairs(self.Tokens) do | 559 for index, button in ipairs(self.Tokens) do |
470 if button.numItems >= 1 then | 560 if (button.numItems >= 1) and (button.isFishingAP == apType) then |
471 if button.itemName then | 561 if button.itemName then |
472 self:SetItemAction(button) | 562 self:SetItemAction(button) |
473 end | 563 end |
474 | 564 |
475 button:ClearAllPoints() | 565 button:ClearAllPoints() |
476 numButtons = numButtons + 1 | 566 numButtons = numButtons + 1 |
567 local col = mod(numButtons,8) | |
477 print(index, button:GetID(), button.Icon:GetTexture()) | 568 print(index, button:GetID(), button.Icon:GetTexture()) |
478 if numButtons == 1 then | 569 if numButtons == 1 then |
479 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76) | 570 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76) |
480 upFrame = button | 571 upFrame = button |
481 buttonsHeight = 52 | 572 buttonsHeight = 52 |
482 buttonsWidth = 50 | |
483 else | 573 else |
484 local col = mod(numButtons,8) | |
485 if col == 1 then | 574 if col == 1 then |
486 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2) | 575 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2) |
487 upFrame = button | 576 upFrame = button |
488 buttonsHeight = buttonsHeight + 52 | 577 buttonsHeight = buttonsHeight + 52 |
489 | 578 |
490 else | 579 else |
491 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0) | 580 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0) |
492 | 581 |
493 end | 582 end |
494 buttonsWidth = max(buttonsWidth, col * 50) | 583 end |
495 end | 584 |
496 button.Count:SetText(button.numItems) | 585 button.Count:SetText(button.numItems) |
497 lastFrame = button | 586 lastFrame = button |
498 button:Show() | 587 button:Show() |
499 else | 588 else |
500 button:Hide() | 589 button:Hide() |
501 end | 590 end |
591 buttonsWidth = min(numButtons, 8) * (BUTTON_SIZE) | |
592 end | |
593 | |
594 | |
595 | |
596 if buttonsWidth ~= 0 then | |
597 buttonsWidth = buttonsWidth + 8+ ((min(numButtons, 8)-1)*2) | |
502 end | 598 end |
503 | 599 |
504 | 600 |
505 | 601 |
506 return buttonsWidth, buttonsHeight | 602 return buttonsWidth, buttonsHeight |
515 button:SetAttribute('*type*','item') | 611 button:SetAttribute('*type*','item') |
516 button:SetAttribute('*item*', name) | 612 button:SetAttribute('*item*', name) |
517 end | 613 end |
518 end | 614 end |
519 | 615 |
520 function ap:GetItemButton(itemID, texture, itemAP) | 616 function ap:GetItemButton(itemID, texture, itemAP, fishing) |
521 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP) | 617 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP) |
522 local button = self.ItemButtons[itemID] | 618 local button = self.ItemButtons[itemID] |
523 | 619 |
524 if not button then | 620 if not button then |
525 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton') | 621 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton') |
529 button:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]],"ADD") | 625 button:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]],"ADD") |
530 button:SetID(itemID) | 626 button:SetID(itemID) |
531 button.numItems = 0 | 627 button.numItems = 0 |
532 button.Icon:SetTexture(texture) | 628 button.Icon:SetTexture(texture) |
533 button:RegisterForClicks("AnyUp") | 629 button:RegisterForClicks("AnyUp") |
630 button.isFishingAP = fishing | |
534 self:SetItemAction(button, GetItemInfo(itemID)) | 631 self:SetItemAction(button, GetItemInfo(itemID)) |
535 | 632 |
536 print(' created') | 633 print(' created') |
537 self.ItemButtons[itemID] = button | 634 self.ItemButtons[itemID] = button |
538 self.numItems = self.numItems + 1 | 635 self.numItems = self.numItems + 1 |
551 end | 648 end |
552 | 649 |
553 function ap:GetItemAP(itemID, itemLink, bagData) | 650 function ap:GetItemAP(itemID, itemLink, bagData) |
554 if not self.cache.items[itemID] then | 651 if not self.cache.items[itemID] then |
555 | 652 |
556 print('doing tooltip scan') | 653 print('doing tooltip scan', itemLink, itemID) |
557 self.tooltip:SetOwner(self, 'ANCHOR_NONE') | 654 self.tooltip:SetOwner(self, 'ANCHOR_NONE') |
558 self.tooltip:SetHyperlink(itemLink) | 655 self.tooltip:SetHyperlink(itemLink) |
559 self.tooltip:Show() | 656 self.tooltip:Show() |
560 local numLines = self.tooltip:NumLines() | 657 local numLines = self.tooltip:NumLines() |
561 if numLines >= 3 then | 658 if numLines >= 3 then |
562 local subText = _G[TOOLTIP_NAME .. 'TextLeft2']:GetText() | |
563 if subText and subText:match(ARTIFACT_POWER) then | |
564 for i = 3, numLines do | 659 for i = 3, numLines do |
565 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText() | 660 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText() |
566 if text and text:match(ARTIFACT_POWER) then | 661 if text then |
567 text = text:gsub('[,%D]', '') | 662 |
568 print(itemLink, '-', tonumber(text)) | 663 text = text:lower():gsub(',', '') |
569 local itemAP = tonumber(text) | 664 if text:match('equipped artifact') then |
570 if itemAP then | 665 print(itemLink, '-', tonumber(text)) |
571 itemAP = itemAP | 666 local itemAP = text:match('%d+') |
572 self.cache.items[itemID] = itemAP | 667 if itemAP then |
668 itemAP = itemAP | |
669 self.cache.items[itemID] = tonumber(itemAP) | |
670 end | |
671 end | |
672 if text:match('fishing artifact') then | |
673 local fishingAP = text:match("%d+") | |
674 fishingAP = fishingAP | |
675 print(itemLink, 'fishing', tonumber(text)) | |
676 if fishingAP then | |
677 self.cache.items[itemID] = tonumber(fishingAP) | |
678 self.cache.fishing[itemID] = true | |
679 end | |
573 end | 680 end |
574 end | 681 end |
575 end | 682 end |
576 end | |
577 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() | |
578 if fishingText and fishingText:match('fishing artifact') then | |
579 local fishingAP = fishingText:match("%d+") | |
580 fishingAP = tonumber(fishingAP) | |
581 if fishingAP then | |
582 self.cache.items[itemID] = fishingAP | |
583 self.cache.fishing[itemID] = true | |
584 end | |
585 end | |
586 else | 683 else |
587 | 684 |
588 self.cache.items[itemID] = 0 | 685 self.cache.items[itemID] = 0 |
589 end | 686 end |
590 end | 687 end |
653 local bagData = self.profile.bagslots[id] | 750 local bagData = self.profile.bagslots[id] |
654 bagData.totalAP = 0 | 751 bagData.totalAP = 0 |
655 bagData.fishingAP = 0 | 752 bagData.fishingAP = 0 |
656 bagData.items = bagData.items or {} | 753 bagData.items = bagData.items or {} |
657 table.wipe(bagData.items) | 754 table.wipe(bagData.items) |
658 | 755 local c = self.cache |
659 self.cache.bagItems[id] = self.cache.bagItems[id] or {} | 756 |
660 self.cache.bags[id] = self.cache.bags[id] or {} | 757 c.bagItems[id] = c.bagItems[id] or {} |
661 self.cache.fishing[id] = self.cache.fishing[id] or {} | 758 c.bags[id] = c.bags[id] or {} |
759 c.fishing[id] = c.fishing[id] or {} | |
662 | 760 |
663 for slotID = 1, numSlots do | 761 for slotID = 1, numSlots do |
664 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) | 762 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) |
665 if link then | 763 if link then |
666 local itemID = GetContainerItemID(id, slotID) | 764 local itemID = GetContainerItemID(id, slotID) |
667 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) | 765 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) |
668 | 766 |
669 if class == 'Consumable' and subclass == 'Other' then | 767 if class == 'Consumable' or subclass == 'Cooking' then |
670 --print(GetItemInfo(link)) | 768 --print(GetItemInfo(link)) |
671 local itemAP, isFishingAP | 769 local itemAP, isFishingAP |
672 if self.cache.bags[id][slotID] and (self.cache.bagItems[id][slotID] == itemID) then | 770 if c.bags[id][slotID] and (c.bagItems[id][slotID] == itemID) then |
673 print('slot cache data', id, slotID) | 771 --print('cached slot', id, slotID, name) |
674 itemAP = self.cache.bags[id][slotID] | 772 itemAP = c.bags[id][slotID] |
773 isFishingAP = c.fishing[id] and c.fishing[id][slotID] | |
675 else | 774 else |
676 itemAP, isFishingAP = self:GetItemAP(itemID, link) | 775 itemAP, isFishingAP = self:GetItemAP(itemID, link) |
677 self.cache.bagItems[id][slotID] = itemID | 776 c.bagItems[id][slotID] = itemID |
678 self.cache.bags[id][slotID] = itemAP | 777 c.bags[id][slotID] = itemAP |
679 self.cache.fishing[id][slotID] = isFishingAP | 778 c.fishing[id][slotID] = isFishingAP |
680 end | 779 end |
681 | 780 |
682 | 781 |
683 --print(itemAP, isFishingAP) | 782 --print(itemAP, isFishingAP) |
684 if itemAP and (itemAP > 0) then | 783 if itemAP and (itemAP > 0) then |
685 local itemButton = self:GetItemButton(itemID, texture, itemAP) | 784 local itemButton = self:GetItemButton(itemID, texture, itemAP, isFishingAP) |
686 | 785 |
687 if isFishingAP then | 786 if isFishingAP then |
688 bagData.fishingItems = (bagData.fishingItems or 0) + 1 | 787 bagData.fishingItems = (bagData.fishingItems or 0) + 1 |
689 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP | 788 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP |
690 else | 789 else |
693 bagData.totalAP = (bagData.totalAP or 0) + itemAP | 792 bagData.totalAP = (bagData.totalAP or 0) + itemAP |
694 end | 793 end |
695 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 | 794 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 |
696 end | 795 end |
697 elseif self.profile.artifacts[itemID] then | 796 elseif self.profile.artifacts[itemID] then |
698 print('artfiact weapon', itemID, link, id, slotID) | 797 --print('artifact weapon', itemID, link, id, slotID) |
699 self.profile.artifacts[itemID].containerID = id | 798 self.profile.artifacts[itemID].containerID = id |
700 self.profile.artifacts[itemID].slotID = slotID | 799 self.profile.artifacts[itemID].slotID = slotID |
800 else | |
801 --print('skipping', class, subclass, link) | |
701 end | 802 end |
702 | 803 |
703 end | 804 end |
704 | 805 |
705 end | 806 end |
742 self.bagAP = 0 | 843 self.bagAP = 0 |
743 self.fishingAP = 0 | 844 self.fishingAP = 0 |
744 | 845 |
745 table.wipe(ItemCounts) | 846 table.wipe(ItemCounts) |
746 for id, bagData in pairs(self.profile.bagslots) do | 847 for id, bagData in pairs(self.profile.bagslots) do |
747 print(id, GetBagName(id), bagData.totalAP) | 848 print(id, GetBagName(id), bagData.totalAP, bagData.fishingAP) |
748 id = tonumber(id) | 849 id = tonumber(id) |
749 if bagData.totalAP then | 850 if bagData.totalAP then |
750 if (id == BANK_CONTAINER) or (id >= 5) then | 851 if (id == BANK_CONTAINER) or (id >= 5) then |
751 self.bankAP = self.bankAP + bagData.totalAP | 852 self.bankAP = self.bankAP + bagData.totalAP |
752 else | 853 else |
763 self:TryToShow() | 864 self:TryToShow() |
764 end | 865 end |
765 | 866 |
766 VeneerArtifactButtonMixin = {} | 867 VeneerArtifactButtonMixin = {} |
767 | 868 |
768 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped) | 869 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped, fishing) |
769 print(itemID, index) | 870 print(itemID, index) |
770 print(artifact.name, artifact.texture, artifact.currentXP) | 871 print(artifact.name, artifact.texture, artifact.currentXP) |
771 self:SetID(itemID) | 872 self:SetID(itemID) |
772 if not artifact.currentCost then | 873 if not artifact.currentCost then |
773 artifact.currentCost = artifact.cost | 874 artifact.currentCost = artifact.cost |
776 for k,v in pairs(artifact) do | 877 for k,v in pairs(artifact) do |
777 --print('::',k,v) | 878 --print('::',k,v) |
778 self[k] = v | 879 self[k] = v |
779 end | 880 end |
780 | 881 |
882 self.isFishing = fishing | |
781 -- this can change between artifact parses | 883 -- this can change between artifact parses |
782 local potentialPoints = self.actualLevel | 884 local potentialPoints = self.actualLevel |
783 local totalAP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0) | 885 local totalAP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0) |
784 print(totalAP) | 886 print(totalAP) |
785 local potentialXP = self.actualXP + totalAP | 887 local potentialXP = self.actualXP + totalAP |
817 | 919 |
818 function VeneerArtifactButtonMixin:Update() | 920 function VeneerArtifactButtonMixin:Update() |
819 local r, g, b = 1, 1, 1 | 921 local r, g, b = 1, 1, 1 |
820 local lR, lG, lB = 1, 1, 0 | 922 local lR, lG, lB = 1, 1, 0 |
821 local levelText = self.level | 923 local levelText = self.level |
822 local xpValue = self.currentXP | 924 local xpValue = ShortNumberString(self.currentXP) |
823 local costValue = self.currentCost | 925 local costValue = self.currentCost |
824 if self.actualLevel ~= self.level then | 926 if self.actualLevel ~= self.level then |
825 levelText, r,g,b = self.actualLevel, 0,1,0 | 927 levelText, r,g,b = self.actualLevel, 0,1,0 |
826 xpValue, costValue, lR, lG, lB = self.actualXP, self.actualCost, 0, 1, 0 | 928 xpValue, costValue, lR, lG, lB = ShortNumberString(self.potentialXP) .. '\n' .. ShortNumberString(self.potentialCost-self.potentialXP), self.actualCost, 0, 1, 0 |
827 elseif self.potentialLevel ~= self.level then | 929 elseif self.potentialLevel ~= self.level then |
828 levelText, r, g, b = self.potentialLevel, 0,1,1 | 930 levelText, r, g, b = self.potentialLevel, 0,1,1 |
829 xpValue, costValue, lR, lG, lB = self.potentialAdjustedXP, self.potentialCost, 0,1,0 | 931 xpValue, costValue, lR, lG, lB = ShortNumberString(self.potentialXP) .. '\n' .. ShortNumberString(self.potentialCost-self.potentialXP), self.potentialCost, 0,1,1 |
830 | 932 else |
933 xpValue, lR, lG, lB = ShortNumberString(self.actualXP) .. '\n|cFFFFFF00' .. ShortNumberString(self.actualCost-self.actualXP)..'|r', 1, 1, 1 | |
831 end | 934 end |
832 | 935 |
833 self.Level:SetText(levelText) | 936 self.Level:SetText(levelText) |
834 self.Level:SetTextColor(r, g, b) | 937 self.Level:SetTextColor(r, g, b) |
835 self.CurrentXP:SetText(ShortNumberString( xpValue)) | 938 self.CurrentXP:SetText( xpValue) |
836 self.CurrentXP:SetTextColor(lR, lG, lB) | 939 self.CurrentXP:SetTextColor(lR, lG, lB) |
837 | 940 |
838 if self.isEquipped then | 941 if self.isEquipped then |
839 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) | 942 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) |
840 self:GetNormalTexture():SetBlendMode('ADD') | 943 self:GetNormalTexture():SetBlendMode('ADD') |