comparison Modules/ArtifactPower.lua @ 122:ea2c616a3b4f

Standardize anchor variables - anchorGroup sets general position, defers to anchorPoint - anchorPoint and anchorFrom are used in SetPoint, deferring to anchorGroup and its inverse Artifact Power: - scan and update triggers trimmed down BuffFrame: - extra values can be right clicked to hide for particular auras LFG: - Desolate Host link placed above Sisters when searching for best cheevos TalkingHead - Re-enable TalkingHeadFrame click behaviour
author Nenue
date Mon, 21 Aug 2017 22:15:46 -0400
parents 1f68c46bc4de
children b3c0258b419d
comparison
equal deleted inserted replaced
121:1f68c46bc4de 122:ea2c616a3b4f
13 scanQueue = {}, 13 scanQueue = {},
14 worldQuestAP = 0, 14 worldQuestAP = 0,
15 worldQuestItems = {}, 15 worldQuestItems = {},
16 ItemButtons = {}, 16 ItemButtons = {},
17 anchorGroup = 'TOP', 17 anchorGroup = 'TOP',
18 anchorPoint = 'TOP', 18 anchorPoint = 'TOPLEFT',
19 anchorPriority = 3, 19 anchorPriority = 3,
20 anchorFrom = 'BOTTOMLEFT', 20 anchorFrom = 'BOTTOMLEFT',
21 moduleName = 'Artifactor', 21 moduleName = 'Artifactor',
22 HideCombat = true 22 HideCombat = true
23 } 23 }
24
25 VeneerArtifactButtonMixin = {}
26 local Artifact = VeneerArtifactButtonMixin
27
24 local defaultSettings = { 28 local defaultSettings = {
25 firstUse = true, 29 firstUse = true,
26 autoHide = true, 30 autoHide = true,
27 } 31 }
28 local Module = VeneerArtifactPowerMixin 32 local Module = VeneerArtifactPowerMixin
29 local BAGS_TO_SCAN = {BACKPACK_CONTAINER } 33 local BAGS_TO_SCAN = {BACKPACK_CONTAINER}
30 local TOOLTIP_NAME = 'VeneerAPScanner' 34 local TOOLTIP_NAME = 'VeneerAPScanner'
31 local POINT_COSTS = {
32 100, 300, 325, 350, 375,
33 400, 425, 450, 525, 625,
34 750, 875, 1000, 6840, 8830,
35 11280, 14400, 18620, 24000, 30600,
36 39520, 50880, 64800, 82500, 105280,
37 138650, 182780, 240870, 325520, 417560,
38 546000, 718200, 946660, 1245840, 1635200,
39 191500, 2010000, 2110000, 2215000, 2325000,
40 2440000, 2560000, 2690000, 2825000, 2965000,
41 3115000, 3270000, 3435000, 3605000, 3785000,
42 3975000, 4175000, 4385000, 4605000
43 }
44 local FISHING_MAX_TRAITS = 24 35 local FISHING_MAX_TRAITS = 24
45 local WEAPON_MAX_TRAITS = 92 36 local WEAPON_MAX_TRAITS = 92
46 local FRAME_PADDING = 4 37 local FRAME_PADDING = 4
47 local EQUIPPED_SIZE = 64 38 local EQUIPPED_SIZE = 64
48 local BUTTON_SIZE = 48 39 local BUTTON_SIZE = 48
51 local BANK_FRAMES = {'BankFrame'} 42 local BANK_FRAMES = {'BankFrame'}
52 43
53 function Module:OnLoad() 44 function Module:OnLoad()
54 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan 45 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan
55 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity 46 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity
56 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available 47 self:RegisterEvent('BANKFRAME_OPENED') -- bank info available
57 self:RegisterEvent('BANKFRAME_CLOSED') -- " " " 48 self:RegisterEvent('BANKFRAME_CLOSED') --
58 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed 49 self:RegisterEvent('ARTIFACT_UPDATE') -- visible data change
59 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data) 50 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- xp for equipped artifact
60 self:RegisterEvent('PLAYER_REGEN_ENABLED') 51 self:RegisterEvent('PLAYER_REGEN_ENABLED') -- combat
61 self:RegisterEvent('PLAYER_REGEN_DISABLED') 52 self:RegisterEvent('PLAYER_REGEN_DISABLED') --
62 self:RegisterEvent('PLAYER_ENTERING_WORLD') 53 self:RegisterEvent('PLAYER_ENTERING_WORLD') -- zone/instance transfer
63 self:RegisterEvent('ITEM_LOCK_CHANGED') -- use to clear bag slot cache data 54 self:RegisterEvent('ITEM_LOCK_CHANGED') -- use to clear bag slot cache data
64 Veneer:AddHandler(self) 55 Veneer:AddHandler(self)
65 SLASH_VENEER_AP1 = "/vap" 56 SLASH_VENEER_AP1 = "/vap"
66 SLASH_VENEER_AP2 = "/veneerap" 57 SLASH_VENEER_AP2 = "/veneerap"
67 SlashCmdList.VENEER_AP = function(arg) 58 SlashCmdList.VENEER_AP = function(arg)
78 table.wipe(self.db.cache) 69 table.wipe(self.db.cache)
79 table.wipe(self.db.fishingCache) 70 table.wipe(self.db.fishingCache)
80 end 71 end
81 self:Print('Cache data reset.') 72 self:Print('Cache data reset.')
82 self:Update() 73 self:Update()
74 elseif arg:match('item') then
75 print('name', arg:match("^item (%S.+)"))
76 print('num', arg:match("Hitem:(%d+)"))
77 local linkOrID = arg:match("item:(%d+)") or arg:match("^item (%S+)")
78 if linkOrID then
79 local name, etc = GetItemInfo(linkOrID)
80 end
81
83 else 82 else
83
84 self:Show() 84 self:Show()
85 end 85 end
86 end 86 end
87 87
88 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') 88 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate')
89 89
90 90
91 end 91 end
92 local ShortNumberString = function (value) 92 local ShortNumberString = function (value)
93 if value >= 1000000 then 93 if value >= 1000000000 then
94
95 return tostring(floor(value/10000000)/100) .. 'B'
96 elseif value >= 1000000 then
94 return tostring(floor(value/100000)/10) .. 'M' 97 return tostring(floor(value/100000)/10) .. 'M'
95 elseif value >= 100000 then 98 elseif value >= 100000 then
96 return tostring(floor(value/1000)) .. 'k' 99 return tostring(floor(value/1000)) .. 'k'
97 elseif value >= 1000 then 100 elseif value >= 1000 then
98 return tostring(floor(value/100)/10) .. 'k' 101 return tostring(floor(value/100)/10) .. 'k'
352 355
353 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then 356 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then
354 self:ScanAllBags() 357 self:ScanAllBags()
355 elseif event == 'BAG_UPDATE_DELAYED' then 358 elseif event == 'BAG_UPDATE_DELAYED' then
356 if not self.firstHit then 359 if not self.firstHit then
360 -- prevent double call from login
357 self.firstHit = true 361 self.firstHit = true
358 else 362 else
359 self:ScanAllBags() 363 self:ScanAllBags()
360 end 364 end
361 elseif event == 'BANKFRAME_OPENED' then 365 elseif event == 'BANKFRAME_OPENED' then
365 self.bankAccess = nil 369 self.bankAccess = nil
366 elseif event == 'ARTIFACT_UPDATE' then 370 elseif event == 'ARTIFACT_UPDATE' then
367 local newItem = ... 371 local newItem = ...
368 if newItem then 372 if newItem then
369 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo() 373 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo()
370 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) 374 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
371 self:ScanAllBags(self.bankAccess) 375 --self:ScanAllBags(self.bankAccess)
372 end 376 end
373 elseif event == 'ARTIFACT_XP_UPDATE' then 377 elseif event == 'ARTIFACT_XP_UPDATE' then
374 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo() 378 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo()
375 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) 379 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
376 self:ScanAllBags(self.bankAccess) 380 --self:ScanAllBags(self.bankAccess)
377 elseif event == 'PLAYER_REGEN_ENABLED' then 381 elseif event == 'PLAYER_REGEN_ENABLED' then
378 382
379 if self.queuedScan then 383 if self.queuedScan then
380 self:ScanAllBags(self.backAccess) 384 self:ScanAllBags(self.backAccess)
381 else 385 else
415 function Module:Update() 419 function Module:Update()
416 if not self:IsShown() then 420 if not self:IsShown() then
417 print('|cFFFF4400Update()|r') 421 print('|cFFFF4400Update()|r')
418 return 422 return
419 end 423 end
420 print('|cFF00FFFFUpdate()|r') 424 print('|cFFFFFF00pdate()|r')
425
426 local numButtons = 0
427 local contentsHeight = 16
428 local contentsWidth = 400
429 if self.profile.knowledgeMultiplier then
430 local artifactsWidth = self:UpdateArtifactButtons()
431
432 if artifactsWidth ~= 0 then
433 contentsHeight = contentsHeight + 64
434 end
435
436 contentsWidth = max(contentsWidth, min(artifactsWidth, 400))
437
438 local itemsWidth, itemsHeight = self:UpdateItemButtons()
439 contentsHeight = contentsHeight + itemsHeight
440 contentsWidth = max(contentsWidth, itemsWidth)
441 end
442
443
421 444
422 local bankText, bagText 445 local bankText, bagText
423 if not self.profile.knowledgeMultiplier then 446 if not self.profile.knowledgeMultiplier then
424 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.' 447 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.'
425 elseif not (self.bankAP and self.bagAP) then 448 elseif not (self.bankAP and self.bagAP) then
441 bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. '' 464 bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. ''
442 end 465 end
443 466
444 467
445 self.SummaryHeader:SetText(bankText) 468 self.SummaryHeader:SetText(bankText)
446 469 if not self.lastButton then
447 local numButtons = 0 470 contentsHeight = contentsHeight + self.SummaryHeader:GetHeight()
448 local contentsHeight = 16 + self.SummaryHeader:GetHeight()
449 local contentsWidth = 400
450 if self.profile.knowledgeMultiplier then
451 local artifactsWidth = self:UpdateArtifactButtons()
452
453 if artifactsWidth ~= 0 then
454 contentsHeight = contentsHeight + 64
455 end
456
457 contentsWidth = max(contentsWidth, min(artifactsWidth, 400))
458
459 local itemsWidth, itemsHeight = self:UpdateItemButtons()
460 contentsHeight = contentsHeight + itemsHeight
461 contentsWidth = max(contentsWidth, itemsWidth)
462 end 471 end
463 472
464 473
465 if not self.hasArtifacts then 474 if not self.hasArtifacts then
466 self:SetShown(false) 475 self:SetShown(false)
532 541
533 function Module:UpdateArtifactButtons() 542 function Module:UpdateArtifactButtons()
534 543
535 -- Artifact icons, in no particular order 544 -- Artifact icons, in no particular order
536 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() 545 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo()
546 self.lastButton = nil
537 self.canAddAP = nil 547 self.canAddAP = nil
538 self.canAddFishingAP = nil 548 self.canAddFishingAP = nil
539 local hasArtifacts 549 local hasArtifacts
540 local numButtons = 0 550 local numButtons = 0
541 local lastFrame = self 551 local lastFrame = self
545 local buttonsWidth = 0 555 local buttonsWidth = 0
546 if equipped then 556 if equipped then
547 numButtons = numButtons + 1 557 numButtons = numButtons + 1
548 button = self.Artifact[numButtons] 558 button = self.Artifact[numButtons]
549 button.relativeFrame = self 559 button.relativeFrame = self
550 lastFrame = button:SetButton(self.equippedID, equipped, numButtons, true, nil) 560 if self.equippedID ~= button.itemID then
551 hasArtifacts = true 561 button:SetItem(self.equippedID, equipped, numButtons, true, nil)
552 562 hasArtifacts = true
563 end
564 lastFrame = button
553 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2) 565 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2)
554 end 566 end
555
556
557 for itemID, artifact in pairs(self.profile.artifacts) do 567 for itemID, artifact in pairs(self.profile.artifacts) do
558 if (itemID == UNDERLIGHT_ANGLER_ID) then 568 if (itemID == UNDERLIGHT_ANGLER_ID) then
559 -- only add if we have fishing AP items and it's not being shown in the equipped slot 569 -- only add if we have fishing AP items and it's not being shown in the equipped slot
560 if VeneerData.ArtifactPower.EnableFishing and (itemID ~= self.equippedID) then 570 if VeneerData.ArtifactPower.EnableFishing and (itemID ~= self.equippedID) then
561 fishingID = itemID 571 fishingID = itemID
575 585
576 hasArtifacts = true 586 hasArtifacts = true
577 numButtons = numButtons + 1 587 numButtons = numButtons + 1
578 button = self.Artifact[numButtons] 588 button = self.Artifact[numButtons]
579 button.relativeFrame = lastFrame 589 button.relativeFrame = lastFrame
580 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID), nil) 590 if button.itemID ~= itemID then
591 button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
592 end
593 lastFrame = button
581 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING 594 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING
582 end 595 end
583 end 596 end
584 end 597 end
585 end 598 end
599
600 self.lastButton = lastFrame
586 601
587 602
588 if fishingData and (self.fishingAP and self.fishingAP > 0) then 603 if fishingData and (self.fishingAP and self.fishingAP > 0) then
589 numButtons = numButtons + 1 604 numButtons = numButtons + 1
590 hasArtifacts = true 605 hasArtifacts = true
591 local button = self.Artifact[numButtons] 606 local button = self.Artifact[numButtons]
592 button.relativeFrame = lastFrame 607 button.relativeFrame = lastFrame
593 button.isFishing = true 608 button.isFishing = true
594 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) 609 button:SetItem(fishingID, fishingData, numButtons, self.equippedID == fishingID)
610 self.lastButton = button
595 end 611 end
596 612
597 self.hasArtifacts = hasArtifacts 613 self.hasArtifacts = hasArtifacts
598 for i = numButtons+ 1, #self.Artifact do 614 for i = numButtons+ 1, #self.Artifact do
599 print('hide', i) 615 print('hide', i)
600 self.Artifact[i]:Hide() 616 self.Artifact[i]:Hide()
601 end 617 end
618
619 self.SummaryHeader:ClearAllPoints()
620 if self.lastButton then
621 self.SummaryHeader:SetPoint('TOPLEFT', self.lastButton, 'TOPRIGHT', 4, -2)
622 else
623 self.SummaryHeader:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 4, 4)
624 end
625
602 626
603 627
604 return buttonsWidth 628 return buttonsWidth
605 end 629 end
606 630
755 end 779 end
756 end 780 end
757 return self.cache.items[itemID], self.cache.fishing[itemID] 781 return self.cache.items[itemID], self.cache.fishing[itemID]
758 end 782 end
759 783
760 function Module:SetArtifact(itemID, name, texture, currentXP, pointsSpent) 784 function Module:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
761 print('|cFF00FF00SetArtifact()|r') 785 print('|cFF00FF00UpdateArtifact()|r')
762 if not self.profile then 786 if not self.profile then
763 return 787 return
764 end 788 end
765 local artifacts = self.profile.artifacts 789 local artifacts = self.profile.artifacts
766 790
767 local multi = C_ArtifactUI.GetArtifactKnowledgeMultiplier()
768 if multi and (self.profile.knowledgeMultiplier ~= multi) then
769 table.wipe(self.cache.items)
770 table.wipe(self.cache.fishing)
771 end
772
773 self.profile.knowledgeMultiplier = multi or self.profile.knowledgeMultiplier
774 print('multiplier:', multi)
775
776 if itemID then 791 if itemID then
777
778 self.currentEquipped = itemID 792 self.currentEquipped = itemID
779 793
780 artifacts[itemID] = artifacts[itemID] or {} 794 artifacts[itemID] = artifacts[itemID] or {}
781 table.wipe(artifacts[itemID]) 795 table.wipe(artifacts[itemID])
782 local artifact = artifacts[itemID] 796 local artifact = artifacts[itemID]
784 artifact.name = name 798 artifact.name = name
785 artifact.texture = texture 799 artifact.texture = texture
786 artifact.currentXP = currentXP 800 artifact.currentXP = currentXP
787 artifact.level = pointsSpent 801 artifact.level = pointsSpent
788 artifact.tier = C_ArtifactUI.GetArtifactTier() or ((pointsSpent >= 36) and 2 or 1) 802 artifact.tier = C_ArtifactUI.GetArtifactTier() or ((pointsSpent >= 36) and 2 or 1)
803 artifact.itemID = itemID
789 804
790 print('tier', artifact.tier) 805 print('tier', artifact.tier)
791 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier) 806 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier)
792 artifact.currentCost = cost 807 artifact.currentCost = cost
793 808
794 809 for index, frame in pairs(self.Artifact) do
810 if frame.itemID == itemID then
811 frame:SetItem(itemID, artifact, index, (itemID == self.equippedID), (itemID == UNDERLIGHT_ANGLER_ID))
812 end
813 end
795 814
796 end 815 end
797 end 816 end
798 817
799 function Module:ScanBag(id) 818 function Module:ScanBag(id)
922 self.lastUpdate = GetTime() 941 self.lastUpdate = GetTime()
923 self.queuedScan = nil 942 self.queuedScan = nil
924 self:TryToShow() 943 self:TryToShow()
925 end 944 end
926 945
927 VeneerArtifactButtonMixin = {} 946
928 local Artifact = VeneerArtifactButtonMixin 947 function Artifact:SetItem(itemID, artifact, index, equipped, fishing)
929 948 print('|cFF00FFFFSetItem()|r', itemID, index)
930 function Artifact:SetButton(itemID, artifact, index, equipped, fishing)
931 print(itemID, index)
932 print(artifact.name, artifact.texture, artifact.currentXP) 949 print(artifact.name, artifact.texture, artifact.currentXP)
933 self:SetID(itemID) 950
934 if not artifact.currentCost then 951 if not artifact.currentCost then
935 artifact.currentCost = artifact.cost 952 artifact.currentCost = artifact.cost
936 end 953 end
937 954
938 for k,v in pairs(artifact) do 955 for k,v in pairs(artifact) do
1002 else 1019 else
1003 self:ClearAllPoints() 1020 self:ClearAllPoints()
1004 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', 4, -4) 1021 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', 4, -4)
1005 end 1022 end
1006 1023
1024 self.itemID = itemID
1007 self.isEquipped = equipped 1025 self.isEquipped = equipped
1008 self:Update() 1026 self:Update()
1009 self:Show() 1027 self:Show()
1028
1010 return self 1029 return self
1011 end 1030 end
1012 1031
1032 function Artifact:UpdateXPBar()
1033 local r3, g3, b3 = 1, .5, 0 -- main xp bar
1034 -- current: amount shown in blizz ui
1035 -- actual: amount contributing the next level, will be same until current point cap is reached
1036 -- potential: total of ap on hand
1037 print(self.currentXP, self.actualXP, self.potentialXP)
1038
1039 local maxHeight = self:GetHeight() - 8
1040 local currentHeight = self.CurrentProgress:GetHeight() or 1
1041 local offHeight = self.AdjustedProgress:GetHeight() or 1
1042
1043
1044 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1
1045 local projectedProgress = (self.totalXP < self.totalCost) and (self.totalXP / self.totalCost) or 1
1046 if self.actualLevel ~= self.level then
1047 r3, g3, b3 = 0, 1, 1
1048 end
1049
1050 print('|cFFFF4400', currentProgress)
1051 if self.level <= WEAPON_MAX_TRAITS then
1052 self.CurrentProgress.animateFrom = currentHeight or 1
1053 self.CurrentProgress.animateTo = currentProgress * maxHeight
1054 self.CurrentProgress:Show()
1055 self.ProgressLine:Show()
1056 else
1057 self.CurrentProgress:Hide()
1058 self.ProgressLine:Hide()
1059 end
1060
1061 if self.totalXP ~= self.currentXP then
1062 print('|cFF00FFFF', projectedProgress)
1063 if (projectedProgress > currentProgress) then
1064 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP')
1065 projectedProgress = projectedProgress - currentProgress
1066 print('show projected above', currentProgress, projectedProgress)
1067 else
1068 self.CurrentProgress:Hide()
1069 self.ProgressLine:Hide()
1070 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM', 0 , 4)
1071 print('show projected at bottom', currentProgress, projectedProgress)
1072 end
1073
1074 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1
1075 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight()
1076 self.AdjustedLine:Show()
1077 self.AdjustedProgress:Show()
1078 else
1079 self.CurrentProgress:SetPoint('BOTTOM', self, 'BOTTOM', 0, 4)
1080 self.AdjustedProgress:Hide()
1081 self.AdjustedLine:Hide()
1082 end
1083 --print(self.CurrentProgress:GetPoint(3))
1084 --print(self.CurrentProgress:GetSize())
1085
1086 self.CurrentProgress:SetColorTexture(r3,g3,b3,1)
1087
1088 end
1089
1090 function Artifact:OnLoad()
1091 print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID())
1092 self:RegisterEvent('ARTIFACT_UPDATE')
1093 self:RegisterEvent('PLAYER_LOGIN')
1094 end
1095
1096 function Artifact:OnEvent(event)
1097 local itemID, _, _, nextCost = C_ArtifactUI.GetEquippedArtifactInfo()
1098 print(self:GetID(), '|cFFFF4400OnEvent()|r', event, itemID, '=', self.itemID, (itemID == self.itemID))
1099 if itemID == self.itemID then
1100 self:Update()
1101 end
1102 end
1103
1013 function Artifact:Update() 1104 function Artifact:Update()
1014 local r1, g1, b1 = 1, 1, 1 1105 if not self.itemID then
1015 local r2, g2, b2 = 1, 1, 0 1106 return
1107 end
1108
1109 print(self:GetName(), '|ff00FFFFUpdate()|r')
1110 local r1, g1, b1 = 1, 1, 1 -- top text
1111 local r2, g2, b2 = 1, 1, 0 -- bottom text
1016 local levelText = self.level 1112 local levelText = self.level
1017 local xpText = ShortNumberString(self.currentXP) 1113 local xpText = ShortNumberString(self.currentXP)
1018 local costText = ShortNumberString(self.currentCost) 1114 local costText = ShortNumberString(self.currentCost)
1019 local remainingText = ShortNumberString(self.currentCost - self.currentXP) 1115 local remainingText = ShortNumberString(self.currentCost - self.currentXP)
1020 -- current: amount shown in blizz ui 1116
1021 -- actual: amount contributing the next level, will be same until current point cap is reached 1117 local maxHeight = self:GetHeight() - 4
1022 -- potential: total of ap on hand 1118 local currentHeight = self.CurrentProgress:GetHeight() or 1
1023 print(self.currentXP, self.actualXP, self.potentialXP) 1119 local offHeight = self.AdjustedProgress:GetHeight() or 1
1120
1024 if self.actualLevel ~= self.level then 1121 if self.actualLevel ~= self.level then
1025 levelText = self.actualLevel 1122 levelText = self.actualLevel
1026 r1, g1, b1 = 0, 1, 0 1123 r1, g1, b1 = 0, 1, 0
1027 --r2, g2, b2 = 0, 1, 0
1028 xpText = ShortNumberString(self.actualXP) 1124 xpText = ShortNumberString(self.actualXP)
1029 costText = ShortNumberString(self.actualCost) 1125 costText = ShortNumberString(self.actualCost)
1030 remainingText = ShortNumberString(self.actualCost-self.actualXP) 1126 remainingText = ShortNumberString(self.actualCost-self.actualXP)
1031 --[[elseif self.potentialLevel ~= self.level then 1127 --[[elseif self.potentialLevel ~= self.level then
1032 r1, g1, b1 = 0, 1, 1 1128 r1, g1, b1 = 0, 1, 1
1033 r2, g2, b2 = 0, 1, 1 1129 r2, g2, b2 = 0, 1, 1
1034 costText = ShortNumberString(self.potentialCost) 1130 costText = ShortNumberString(self.potentialCost)
1035 remainingText = ShortNumberString(self.potentialCost-self.potentialXP) 1131 remainingText = ShortNumberString(self.potentialCost-self.potentialXP)
1036 --]] 1132 --]]
1037 elseif self.totalLevel ~= self.actualLevel then
1038 r1, g1, b1 = 0, 1, 1
1039 end 1133 end
1040 1134
1041 self.Level:SetText(levelText) 1135 self.Level:SetText(levelText)
1042 self.CurrentXP:SetText( xpText ) 1136 self.CurrentXP:SetText( xpText )
1043 self.RemainingCost:SetText(remainingText) 1137 self.RemainingCost:SetText(remainingText)
1052 else 1146 else
1053 self:SetSize(48,48) 1147 self:SetSize(48,48)
1054 self:SetNormalTexture(nil, 'ADD') 1148 self:SetNormalTexture(nil, 'ADD')
1055 end 1149 end
1056 1150
1057 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1 1151 self:UpdateXPBar()
1058 print('|cFFFF4400', currentProgress)
1059 if self.level <= 92 then
1060 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1
1061 self.CurrentProgress.animateTo = currentProgress * self:GetHeight()
1062 self.CurrentProgress:Show()
1063 self.ProgressLine:Show()
1064 else
1065 self.CurrentProgress:Hide()
1066 self.ProgressLine:Hide()
1067 end
1068
1069 if self.totalXP ~= self.currentXP then
1070 local projectedProgress = (self.totalXP / self.totalCost)
1071 print('|cFF00FFFF', projectedProgress)
1072 if (projectedProgress > currentProgress) then
1073 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP')
1074 projectedProgress = projectedProgress - currentProgress
1075 else
1076 self.CurrentProgress:Hide()
1077 self.ProgressLine:Hide()
1078 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM')
1079 end
1080 print('show actual', currentProgress, projectedProgress)
1081 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1
1082 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight()
1083 self.AdjustedLine:Show()
1084 self.AdjustedProgress:Show()
1085 else
1086 self.CurrentProgress:SetPoint('BOTTOM', self, 'BOTTOM')
1087 self.AdjustedProgress:Hide()
1088 self.AdjustedLine:Hide()
1089 end
1090 print(self.CurrentProgress:GetPoint(3))
1091 print(self.CurrentProgress:GetSize())
1092 1152
1093 if self.actualLevel ~= self.currentLevel then 1153 if self.actualLevel ~= self.currentLevel then
1094 self:SetNormalTexture([[Interface\Buttons\UI-Quickslot-Depress]], 'ADD') 1154 self:SetNormalTexture([[Interface\Buttons\UI-Quickslot-Depress]], 'ADD')
1095 self:GetNormalTexture():SetBlendMode('BLEND') 1155 self:GetNormalTexture():SetBlendMode('BLEND')
1096 self:GetNormalTexture():SetVertexColor(1,1,1) 1156 self:GetNormalTexture():SetVertexColor(1,1,1)