Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 108:a41f6b74709a
- Handler number and boolean cluster arguments as positioning priority layer and "always top" respectively
- Use SetShown and IsShown instead of IsVisible in doing full re-anchor checks
author | Nick@Zahhak |
---|---|
date | Sat, 25 Feb 2017 11:42:07 -0500 |
parents | 8df154a2bfd6 |
children | 1196c2bad31c |
comparison
equal
deleted
inserted
replaced
107:ff00679a7817 | 108:a41f6b74709a |
---|---|
48 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed | 48 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed |
49 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data) | 49 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data) |
50 self:RegisterEvent('PLAYER_REGEN_ENABLED') | 50 self:RegisterEvent('PLAYER_REGEN_ENABLED') |
51 self:RegisterEvent('PLAYER_REGEN_DISABLED') | 51 self:RegisterEvent('PLAYER_REGEN_DISABLED') |
52 self:RegisterEvent('PLAYER_ENTERING_WORLD') | 52 self:RegisterEvent('PLAYER_ENTERING_WORLD') |
53 Veneer:AddHandler(self, self.anchorPoint, true) | 53 self:RegisterEvent('ITEM_LOCK_CHANGED') -- use to clear bag slot cache data |
54 Veneer:AddHandler(self, self.anchorPoint, 2) | |
54 SLASH_VENEER_AP1 = "/vap" | 55 SLASH_VENEER_AP1 = "/vap" |
55 SLASH_VENEER_AP2 = "/veneerap" | 56 SLASH_VENEER_AP2 = "/veneerap" |
56 SlashCmdList.VENEER_AP = function(arg) | 57 SlashCmdList.VENEER_AP = function(arg) |
57 if arg == 'fishing' then | 58 if arg == 'fishing' then |
58 if VeneerData.ArtifactPower.EnableFishing then | 59 if VeneerData.ArtifactPower.EnableFishing then |
60 else | 61 else |
61 VeneerData.ArtifactPower.EnableFishing = true | 62 VeneerData.ArtifactPower.EnableFishing = true |
62 end | 63 end |
63 self:Print('Show Underlight Angler:', (VeneerData.ArtifactPower.EnableFishing and 'ON' or 'OFF')) | 64 self:Print('Show Underlight Angler:', (VeneerData.ArtifactPower.EnableFishing and 'ON' or 'OFF')) |
64 self:Update() | 65 self:Update() |
65 | 66 elseif arg == 'reset' then |
67 if self.db then | |
68 table.wipe(self.db.cache) | |
69 table.wipe(self.db.fishingCache) | |
70 end | |
71 self:Print('Cache data reset.') | |
72 self:Update() | |
66 else | 73 else |
67 self:Show() | 74 self:Show() |
68 end | 75 end |
69 end | 76 end |
70 | 77 |
71 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') | 78 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') |
72 tinsert(UISpecialFrames, self:GetName()) | 79 tinsert(UISpecialFrames, self:GetName()) |
73 | 80 |
74 | 81 |
82 end | |
83 local ShortNumberString = function (value) | |
84 if value >= 100000 then | |
85 return tostring(floor(value/1000)) .. 'k' | |
86 elseif value >= 1000 then | |
87 return tostring(floor(value/100)/10) .. 'k' | |
88 else | |
89 return value | |
90 end | |
75 end | 91 end |
76 | 92 |
77 | 93 |
78 local IsBagnonOpen = function() | 94 local IsBagnonOpen = function() |
79 return ((BagnonFramebank and BagnonFramebank:IsShown()) or (BagnonFrameinventory and BagnonFrameinventory:IsShown())) | 95 return ((BagnonFramebank and BagnonFramebank:IsShown()) or (BagnonFrameinventory and BagnonFrameinventory:IsShown())) |
148 for i, data in pairs(self.fishingCache) do | 164 for i, data in pairs(self.fishingCache) do |
149 self.db.fishingCache[i] = data | 165 self.db.fishingCache[i] = data |
150 end | 166 end |
151 | 167 |
152 | 168 |
153 self.cache = self.db.cache | |
154 self.profile = self.db[guid] | 169 self.profile = self.db[guid] |
170 self.profile.cache = self.profile.cache or {} | |
171 self.profile.cache.bagItems = self.profile.cache.bagItems or {} | |
172 self.profile.cache.bags = self.profile.cache.bags or {} | |
173 self.profile.cache.fishing = self.profile.cache.fishing or {} | |
174 self.profile.cache.items = self.profile.cache.items or {} | |
155 self.profile.bagslots = self.profile.bagslots or {} | 175 self.profile.bagslots = self.profile.bagslots or {} |
156 self.profile.artifacts = self.profile.artifacts or {} | 176 self.profile.artifacts = self.profile.artifacts or {} |
157 self.updateSummary = true | 177 self.updateSummary = true |
178 self.cache = self.profile.cache | |
158 | 179 |
159 VeneerArtifactPowerTimer:SetScript('OnUpdate', function() | 180 VeneerArtifactPowerTimer:SetScript('OnUpdate', function() |
160 self:OnUpdate() | 181 self:OnUpdate() |
161 end) | 182 end) |
162 | 183 |
280 print('|cFF00FF88OnEvent()', event, ...) | 301 print('|cFF00FF88OnEvent()', event, ...) |
281 if event == 'PLAYER_ENTERING_WORLD' then | 302 if event == 'PLAYER_ENTERING_WORLD' then |
282 self:TryToShow() | 303 self:TryToShow() |
283 elseif event == 'BAG_UPDATE' then | 304 elseif event == 'BAG_UPDATE' then |
284 local containerID = ... | 305 local containerID = ... |
306 | |
307 | |
285 self:QueueBag(containerID) | 308 self:QueueBag(containerID) |
309 elseif event == 'ITEM_LOCK_CHANGED' then | |
310 | |
311 local containerID, slotID = ... | |
312 | |
313 if self.cache.bags[containerID] and self.cache.bags[containerID][slotID] then | |
314 self.cache.bags[containerID][slotID] = nil | |
315 self.cache.fishing[containerID][slotID] = nil | |
316 end | |
317 | |
318 | |
286 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then | 319 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then |
287 self:ScanAllBags() | 320 self:ScanAllBags() |
288 elseif event == 'BAG_UPDATE_DELAYED' then | 321 elseif event == 'BAG_UPDATE_DELAYED' then |
289 if not self.firstHit then | 322 if not self.firstHit then |
290 self.firstHit = true | 323 self.firstHit = true |
357 if self.bankAP and (self.bankAP > 0) then | 390 if self.bankAP and (self.bankAP > 0) then |
358 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r' | 391 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r' |
359 end | 392 end |
360 end | 393 end |
361 end | 394 end |
362 if self.fishingAP and self.fishingAP >= 1 then | 395 if self.fishingAP and self.fishingAP > 0 then |
363 bankText = (bankText and (bankText .. ' ') or '') .. '|cFF0088FF' .. tostring(self.fishingAP) .. ' fishing AP|r' | 396 bankText = (bankText and (bankText .. ' ') or '') .. '|cFF0088FF' .. tostring(self.fishingAP) .. ' fishing AP|r' |
364 end | 397 end |
365 | 398 |
366 self.SummaryHeader:SetText(bankText) | 399 self.SummaryHeader:SetText(bankText) |
367 | 400 |
368 local numButtons = 0 | 401 local numButtons = 0 |
369 local contentsHeight = 64 | 402 local contentsHeight = 16 + self.SummaryHeader:GetHeight() + 64 |
403 local contentsWidth = 64 | |
370 if self.profile.knowledgeMultiplier then | 404 if self.profile.knowledgeMultiplier then |
371 numButtons = self:UpdateArtifactButtons() | 405 numButtons = self:UpdateArtifactButtons() |
372 contentsHeight = contentsHeight + self:UpdateItemButtons() | 406 |
373 end | 407 contentsWidth = 64*numButtons + 4 * (numButtons+1) |
374 | 408 |
375 | 409 local itemsWidth, itemsHeight = self:UpdateItemButtons() |
376 | 410 contentsHeight = contentsHeight + itemsHeight |
377 self:SetWidth(64*numButtons + 4 * (numButtons+1)) | 411 contentsWidth = max(contentsWidth, itemsWidth) |
378 self:SetHeight(16 + self.SummaryHeader:GetHeight() + contentsHeight) | 412 end |
413 | |
414 | |
415 | |
416 self:SetWidth(contentsWidth) | |
417 self:SetHeight(contentsHeight) | |
379 self:Reanchor() | 418 self:Reanchor() |
380 end | 419 end |
381 | 420 |
382 function ap:UpdateArtifactButtons() | 421 function ap:UpdateArtifactButtons() |
383 | 422 |
393 fishingID = itemID | 432 fishingID = itemID |
394 fishingData = artifact | 433 fishingData = artifact |
395 end | 434 end |
396 | 435 |
397 else | 436 else |
398 numButtons = numButtons + 1 | 437 if artifact.level ~= 54 then |
399 button = self.Artifact[numButtons] | 438 numButtons = numButtons + 1 |
400 button.relativeFrame = lastFrame | 439 button = self.Artifact[numButtons] |
401 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID)) | 440 button.relativeFrame = lastFrame |
402 end | 441 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID)) |
403 | 442 end |
404 end | 443 end |
405 | 444 |
406 if fishingData then | 445 end |
446 | |
447 if fishingData and (self.fishingAP and self.fishingAP > 0) then | |
407 numButtons = numButtons + 1 | 448 numButtons = numButtons + 1 |
408 local button = self.Artifact[numButtons] | 449 local button = self.Artifact[numButtons] |
409 button.relativeFrame = lastFrame | 450 button.relativeFrame = lastFrame |
410 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) | 451 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) |
411 end | 452 end |
422 function ap:UpdateItemButtons() | 463 function ap:UpdateItemButtons() |
423 print('|cFF00FFFFUpdateItemButtons()|r') | 464 print('|cFF00FFFFUpdateItemButtons()|r') |
424 local lastFrame, upFrame | 465 local lastFrame, upFrame |
425 local numButtons = 0 | 466 local numButtons = 0 |
426 local buttonsHeight = 0 | 467 local buttonsHeight = 0 |
427 local buttonWidth = 0 | 468 local buttonsWidth = 0 |
428 for index, button in ipairs(self.Tokens) do | 469 for index, button in ipairs(self.Tokens) do |
429 if button.numItems >= 1 then | 470 if button.numItems >= 1 then |
430 if button.itemName then | 471 if button.itemName then |
431 self:SetItemAction(button) | 472 self:SetItemAction(button) |
432 end | 473 end |
436 print(index, button:GetID(), button.Icon:GetTexture()) | 477 print(index, button:GetID(), button.Icon:GetTexture()) |
437 if numButtons == 1 then | 478 if numButtons == 1 then |
438 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76) | 479 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76) |
439 upFrame = button | 480 upFrame = button |
440 buttonsHeight = 52 | 481 buttonsHeight = 52 |
441 elseif mod(numButtons,8) == 1 then | 482 buttonsWidth = 50 |
442 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2) | |
443 upFrame = button | |
444 buttonsHeight = buttonsHeight + 52 | |
445 else | 483 else |
446 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0) | 484 local col = mod(numButtons,8) |
485 if col == 1 then | |
486 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2) | |
487 upFrame = button | |
488 buttonsHeight = buttonsHeight + 52 | |
489 | |
490 else | |
491 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0) | |
492 | |
493 end | |
494 buttonsWidth = max(buttonsWidth, col * 50) | |
447 end | 495 end |
448 button.Count:SetText(button.numItems) | 496 button.Count:SetText(button.numItems) |
449 lastFrame = button | 497 lastFrame = button |
450 button:Show() | 498 button:Show() |
451 else | 499 else |
453 end | 501 end |
454 end | 502 end |
455 | 503 |
456 | 504 |
457 | 505 |
458 return buttonsHeight | 506 return buttonsWidth, buttonsHeight |
459 end | 507 end |
460 | 508 |
461 function ap:SetItemAction(button, name) | 509 function ap:SetItemAction(button, name) |
462 name = name or self.itemName | 510 name = name or self.itemName |
463 if InCombatLockdown() then | 511 if InCombatLockdown() then |
488 print(' created') | 536 print(' created') |
489 self.ItemButtons[itemID] = button | 537 self.ItemButtons[itemID] = button |
490 self.numItems = self.numItems + 1 | 538 self.numItems = self.numItems + 1 |
491 end | 539 end |
492 | 540 |
493 local itemAPtext = itemAP * self.profile.knowledgeMultiplier | 541 local itemAPtext = itemAP |
494 if itemAPtext >= 100000 then | 542 if itemAPtext >= 100000 then |
495 itemAPtext = floor(itemAPtext/1000) .. 'k' | 543 itemAPtext = floor(itemAPtext/1000) .. 'k' |
496 elseif itemAPtext >= 1000 then | 544 elseif itemAPtext >= 1000 then |
497 itemAPtext = (floor(itemAPtext/100)/10 ) .. 'k' | 545 itemAPtext = (floor(itemAPtext/100)/10 ) .. 'k' |
498 end | 546 end |
501 button.numItems = button.numItems + 1 | 549 button.numItems = button.numItems + 1 |
502 return button | 550 return button |
503 end | 551 end |
504 | 552 |
505 function ap:GetItemAP(itemID, itemLink, bagData) | 553 function ap:GetItemAP(itemID, itemLink, bagData) |
506 if not self.cache[itemID] then | 554 if not self.cache.items[itemID] then |
507 | 555 |
508 print('doing tooltip scan') | 556 print('doing tooltip scan') |
509 self.tooltip:SetOwner(self, 'ANCHOR_NONE') | 557 self.tooltip:SetOwner(self, 'ANCHOR_NONE') |
510 self.tooltip:SetHyperlink(itemLink) | 558 self.tooltip:SetHyperlink(itemLink) |
511 self.tooltip:Show() | 559 self.tooltip:Show() |
518 if text and text:match(ARTIFACT_POWER) then | 566 if text and text:match(ARTIFACT_POWER) then |
519 text = text:gsub('[,%D]', '') | 567 text = text:gsub('[,%D]', '') |
520 print(itemLink, '-', tonumber(text)) | 568 print(itemLink, '-', tonumber(text)) |
521 local itemAP = tonumber(text) | 569 local itemAP = tonumber(text) |
522 if itemAP then | 570 if itemAP then |
523 itemAP = itemAP / self.profile.knowledgeMultiplier | 571 itemAP = itemAP |
524 self.cache[itemID] = itemAP | 572 self.cache.items[itemID] = itemAP |
525 end | 573 end |
526 end | 574 end |
527 end | 575 end |
528 end | 576 end |
529 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() | 577 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() |
530 if fishingText and fishingText:match('fishing artifact') then | 578 if fishingText and fishingText:match('fishing artifact') then |
531 local fishingAP = fishingText:match("%d+") | 579 local fishingAP = fishingText:match("%d+") |
532 fishingAP = tonumber(fishingAP) | 580 fishingAP = tonumber(fishingAP) |
533 if fishingAP then | 581 if fishingAP then |
534 self.cache[itemID] = fishingAP | 582 self.cache.items[itemID] = fishingAP |
535 self.fishingCache[itemID] = true | 583 self.cache.fishing[itemID] = true |
536 end | 584 end |
537 end | 585 end |
538 else | 586 else |
539 | 587 |
540 self.cache[itemID] = 0 | 588 self.cache.items[itemID] = 0 |
541 end | 589 end |
542 end | 590 end |
543 return self.cache[itemID], self.fishingCache[itemID] | 591 return self.cache.items[itemID], self.cache.fishing[itemID] |
544 end | 592 end |
545 | 593 |
546 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) | 594 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) |
547 print('|cFF00FF00SetArtifact()|r') | 595 print('|cFF00FF00SetArtifact()|r') |
548 if not self.profile then | 596 if not self.profile then |
549 return | 597 return |
550 end | 598 end |
551 local artifacts = self.profile.artifacts | 599 local artifacts = self.profile.artifacts |
552 | 600 |
553 local multi = C_ArtifactUI.GetArtifactKnowledgeMultiplier() | 601 local multi = C_ArtifactUI.GetArtifactKnowledgeMultiplier() |
602 if multi and (self.profile.knowledgeMultiplier ~= multi) then | |
603 table.wipe(self.cache.items) | |
604 table.wipe(self.cache.fishing) | |
605 end | |
606 | |
554 self.profile.knowledgeMultiplier = multi or self.profile.knowledgeMultiplier | 607 self.profile.knowledgeMultiplier = multi or self.profile.knowledgeMultiplier |
555 print('multiplier:', multi) | 608 print('multiplier:', multi) |
556 | 609 |
557 if itemID then | 610 if itemID then |
558 | 611 |
565 artifact.name = name | 618 artifact.name = name |
566 artifact.texture = texture | 619 artifact.texture = texture |
567 artifact.currentXP = currentXP | 620 artifact.currentXP = currentXP |
568 artifact.level = pointsSpent | 621 artifact.level = pointsSpent |
569 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent) | 622 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent) |
570 artifact.cost = cost | 623 artifact.currentCost = cost |
571 | 624 |
572 local pointsAvailable = pointsSpent | 625 local pointsAvailable = pointsSpent |
573 local actualCost = cost | 626 local actualCost = cost |
574 local actualXP = currentXP | 627 local actualXP = currentXP |
575 while actualXP >= actualCost do | 628 while actualXP >= actualCost do |
601 bagData.totalAP = 0 | 654 bagData.totalAP = 0 |
602 bagData.fishingAP = 0 | 655 bagData.fishingAP = 0 |
603 bagData.items = bagData.items or {} | 656 bagData.items = bagData.items or {} |
604 table.wipe(bagData.items) | 657 table.wipe(bagData.items) |
605 | 658 |
659 self.cache.bagItems[id] = self.cache.bagItems[id] or {} | |
660 self.cache.bags[id] = self.cache.bags[id] or {} | |
661 self.cache.fishing[id] = self.cache.fishing[id] or {} | |
662 | |
606 for slotID = 1, numSlots do | 663 for slotID = 1, numSlots do |
607 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) | 664 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) |
608 if link then | 665 if link then |
609 local itemID = GetContainerItemID(id, slotID) | 666 local itemID = GetContainerItemID(id, slotID) |
610 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) | 667 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link) |
611 | 668 |
612 if class == 'Consumable' and subclass == 'Other' then | 669 if class == 'Consumable' and subclass == 'Other' then |
613 --print(GetItemInfo(link)) | 670 --print(GetItemInfo(link)) |
614 local itemAP, isFishingAP = self:GetItemAP(itemID, link) | 671 local itemAP, isFishingAP |
672 if self.cache.bags[id][slotID] and (self.cache.bagItems[id][slotID] == itemID) then | |
673 print('slot cache data', id, slotID) | |
674 itemAP = self.cache.bags[id][slotID] | |
675 else | |
676 itemAP, isFishingAP = self:GetItemAP(itemID, link) | |
677 self.cache.bagItems[id][slotID] = itemID | |
678 self.cache.bags[id][slotID] = itemAP | |
679 self.cache.fishing[id][slotID] = isFishingAP | |
680 end | |
681 | |
682 | |
615 --print(itemAP, isFishingAP) | 683 --print(itemAP, isFishingAP) |
616 if itemAP and (itemAP > 0) then | 684 if itemAP and (itemAP > 0) then |
617 local itemButton = self:GetItemButton(itemID, texture, itemAP) | 685 local itemButton = self:GetItemButton(itemID, texture, itemAP) |
618 | 686 |
619 if isFishingAP then | 687 if isFishingAP then |
620 bagData.fishingItems = (bagData.fishingItems or 0) + 1 | 688 bagData.fishingItems = (bagData.fishingItems or 0) + 1 |
621 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP | 689 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP |
622 else | 690 else |
623 itemAP = itemAP * self.profile.knowledgeMultiplier | 691 itemAP = itemAP |
624 bagData.numItems = (bagData.numItems or 0) + 1 | 692 bagData.numItems = (bagData.numItems or 0) + 1 |
625 bagData.totalAP = (bagData.totalAP or 0) + itemAP | 693 bagData.totalAP = (bagData.totalAP or 0) + itemAP |
626 end | 694 end |
627 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 | 695 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 |
628 end | 696 end |
699 | 767 |
700 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped) | 768 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped) |
701 print(itemID, index) | 769 print(itemID, index) |
702 print(artifact.name, artifact.texture, artifact.currentXP) | 770 print(artifact.name, artifact.texture, artifact.currentXP) |
703 self:SetID(itemID) | 771 self:SetID(itemID) |
772 if not artifact.currentCost then | |
773 artifact.currentCost = artifact.cost | |
774 end | |
775 | |
704 for k,v in pairs(artifact) do | 776 for k,v in pairs(artifact) do |
705 --print('::',k,v) | 777 --print('::',k,v) |
706 self[k] = v | 778 self[k] = v |
707 end | 779 end |
708 | 780 |
722 end | 794 end |
723 self.potentialCost = potentialCost | 795 self.potentialCost = potentialCost |
724 self.potentialLevel = potentialPoints | 796 self.potentialLevel = potentialPoints |
725 self.potentialAdjustedXP = potentialXP | 797 self.potentialAdjustedXP = potentialXP |
726 | 798 |
727 | 799 self.maxCost = self.currentCost |
800 for i = self.level + 1, #POINT_COSTS do | |
801 self.maxCost = self.maxCost + POINT_COSTS[i] | |
802 end | |
728 | 803 |
729 if index ~= 1 then | 804 if index ~= 1 then |
730 self:ClearAllPoints() | 805 self:ClearAllPoints() |
731 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) | 806 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) |
732 else | 807 else |
739 self:Show() | 814 self:Show() |
740 return self | 815 return self |
741 end | 816 end |
742 | 817 |
743 function VeneerArtifactButtonMixin:Update() | 818 function VeneerArtifactButtonMixin:Update() |
744 | |
745 local r, g, b = 1, 1, 1 | 819 local r, g, b = 1, 1, 1 |
746 local lR, lG, lB = 1, 1, 0 | 820 local lR, lG, lB = 1, 1, 0 |
747 local levelText = self.level | 821 local levelText = self.level |
748 local xpValue = self.currentXP | 822 local xpValue = self.currentXP |
749 local costValue = self.cost | 823 local costValue = self.currentCost |
750 if self.actualLevel ~= self.level then | 824 if self.actualLevel ~= self.level then |
751 levelText, r,g,b = self.actualLevel, 0,1,0 | 825 levelText, r,g,b = self.actualLevel, 0,1,0 |
752 xpValue, costValue, lR, lG, lB = self.actualXP, self.actualCost, 0, 1, 0 | 826 xpValue, costValue, lR, lG, lB = self.actualXP, self.actualCost, 0, 1, 0 |
753 elseif self.potentialLevel ~= self.level then | 827 elseif self.potentialLevel ~= self.level then |
754 levelText, r, g, b = self.potentialLevel, 0,1,1 | 828 levelText, r, g, b = self.potentialLevel, 0,1,1 |
755 xpValue, costValue, lR, lG, lB = self.potentialAdjustedXP, self.potentialCost, 0,1,0 | 829 xpValue, costValue, lR, lG, lB = self.potentialAdjustedXP, self.potentialCost, 0,1,0 |
756 | 830 |
757 end | 831 end |
758 | 832 |
759 if xpValue >= 100000 then | |
760 xpValue = tostring(floor(xpValue/1000))..'k' | |
761 elseif xpValue > 1000 then | |
762 xpValue = tostring(floor(xpValue/100)/10)..'k' | |
763 end | |
764 if costValue >= 100000 then | |
765 costValue = tostring(floor(costValue/1000))..'k' | |
766 elseif costValue >= 1000 then | |
767 costValue = tostring(floor(costValue/100)/10)..'k' | |
768 end | |
769 | |
770 | |
771 self.Level:SetText(levelText) | 833 self.Level:SetText(levelText) |
772 self.Level:SetTextColor(r, g, b) | 834 self.Level:SetTextColor(r, g, b) |
773 self.CurrentXP:SetText(xpValue) | 835 self.CurrentXP:SetText(ShortNumberString( xpValue)) |
774 self.CurrentXP:SetTextColor(lR, lG, lB) | 836 self.CurrentXP:SetTextColor(lR, lG, lB) |
775 | 837 |
776 if self.isEquipped then | 838 if self.isEquipped then |
777 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) | 839 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) |
778 self:GetNormalTexture():SetBlendMode('ADD') | 840 self:GetNormalTexture():SetBlendMode('ADD') |
779 self:GetNormalTexture():SetVertexColor(0,1,0) | 841 self:GetNormalTexture():SetVertexColor(0,1,0) |
780 else | 842 else |
781 self:SetNormalTexture(nil, 'ADD') | 843 self:SetNormalTexture(nil, 'ADD') |
782 end | 844 end |
783 | 845 |
784 local currentProgress = (self.currentXP < self.cost) and (self.currentXP / self.cost) or 1 | 846 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1 |
785 if self.level <= 53 then | 847 if self.level <= 53 then |
786 | |
787 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1 | 848 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1 |
788 self.CurrentProgress.animateTo = currentProgress * self:GetHeight() | 849 self.CurrentProgress.animateTo = currentProgress * self:GetHeight() |
789 self.CurrentProgress:Show() | 850 self.CurrentProgress:Show() |
790 self.ProgressLine:Show() | 851 self.ProgressLine:Show() |
791 else | 852 else |
793 self.ProgressLine:Hide() | 854 self.ProgressLine:Hide() |
794 end | 855 end |
795 | 856 |
796 if self.potentialXP > self.currentXP then | 857 if self.potentialXP > self.currentXP then |
797 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialXP / self.potentialCost) or 1 | 858 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialXP / self.potentialCost) or 1 |
798 | |
799 if (projectedProgress > currentProgress) then | 859 if (projectedProgress > currentProgress) then |
800 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') | 860 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') |
801 projectedProgress = projectedProgress - currentProgress | 861 projectedProgress = projectedProgress - currentProgress |
802 | |
803 else | 862 else |
804 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') | 863 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') |
805 end | 864 end |
806 print('show potential', currentProgress, projectedProgress) | 865 print('show potential', currentProgress, projectedProgress) |
807 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 | 866 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 |
808 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() | 867 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() |
809 | |
810 self.AdjustedLine:Show() | 868 self.AdjustedLine:Show() |
811 self.AdjustedProgress:Show() | 869 self.AdjustedProgress:Show() |
812 else | 870 else |
813 self.AdjustedProgress:Hide() | 871 self.AdjustedProgress:Hide() |
814 self.AdjustedLine:Hide() | 872 self.AdjustedLine:Hide() |
815 end | 873 end |
816 | |
817 | |
818 self.Icon:SetTexture(self.texture) | 874 self.Icon:SetTexture(self.texture) |
819 self:SetSize(64,64) | 875 self:SetSize(64,64) |
820 end | 876 end |
821 | 877 |
822 | 878 |
846 end | 902 end |
847 | 903 |
848 if self.AdjustedProgress.animateTo then | 904 if self.AdjustedProgress.animateTo then |
849 self:AnimateProgress(self.AdjustedProgress) | 905 self:AnimateProgress(self.AdjustedProgress) |
850 end | 906 end |
851 | |
852 end | 907 end |
853 | 908 |
854 function VeneerArtifactButtonMixin:OnEnter() | 909 function VeneerArtifactButtonMixin:OnEnter() |
855 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 910 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
856 GameTooltip:SetText(self.name) | 911 GameTooltip:SetText(self.name) |
857 GameTooltip:AddLine(tostring(self.currentXP) .. ' / '..tostring(self.cost), 1, 1, 0) | 912 GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 0) |
858 if self.potentialXP > self.currentXP then | 913 if self.potentialXP > self.currentXP then |
859 GameTooltip:AddLine(tostring(self.potentialXP) .. ' potential XP', 0, 1, 1) | 914 GameTooltip:AddLine(ShortNumberString(self.potentialXP) .. ' potential XP', 0, 1, 1) |
860 if self.potentialAdjustedXP ~= self.potentialXP then | 915 if self.potentialAdjustedXP ~= self.potentialXP then |
861 GameTooltip:AddLine(tostring(self.potentialAdjustedXP) .. ' / ' .. tostring(self.potentialCost).. ' after', 0, 1, 0) | 916 GameTooltip:AddLine(ShortNumberString(self.potentialAdjustedXP) .. ' / ' .. ShortNumberString(self.potentialCost).. ' after', 0, 1, 0) |
862 end | 917 end |
863 end | 918 end |
864 if self.actualLevel ~= self.level then | 919 if self.actualLevel ~= self.level then |
865 GameTooltip:AddLine(tostring(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 1) | 920 GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 1) |
921 end | |
922 if self.currentXP < self.currentCost then | |
923 GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' needed') | |
866 end | 924 end |
867 | 925 |
868 GameTooltip:Show() | 926 GameTooltip:Show() |
869 end | 927 end |
870 function VeneerArtifactButtonMixin:OnLeave() | 928 function VeneerArtifactButtonMixin:OnLeave() |
929 if GameTooltip:IsOwned(self) then | |
930 GameTooltip:Hide() | |
931 end | |
932 end | |
933 function VeneerArtifactButtonMixin:OnHide() | |
934 | |
871 if GameTooltip:IsOwned(self) then | 935 if GameTooltip:IsOwned(self) then |
872 GameTooltip:Hide() | 936 GameTooltip:Hide() |
873 end | 937 end |
874 end | 938 end |
875 | 939 |
876 function VeneerArtifactButtonMixin:OnClick(button, down) | 940 function VeneerArtifactButtonMixin:OnClick(button, down) |
877 if self.isEquipped then | 941 if self.isEquipped then |
878 SocketInventoryItem(16) | 942 SocketInventoryItem(16) |
879 else | 943 else |
944 if IsShiftKeyDown() then | |
880 SocketContainerItem(self.containerID, self.slotID) | 945 SocketContainerItem(self.containerID, self.slotID) |
881 end | 946 else |
882 end | 947 |
948 end | |
949 end | |
950 end |