Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 125:3f4794dca91b
template load order and Script handlers linkage
| author | Nenue |
|---|---|
| date | Sun, 15 Oct 2017 16:47:22 -0400 |
| parents | b3c0258b419d |
| children | 9f2cf5609420 |
comparison
equal
deleted
inserted
replaced
| 124:07fe8fae8ca8 | 125:3f4794dca91b |
|---|---|
| 313 | 313 |
| 314 end | 314 end |
| 315 | 315 |
| 316 function Module:TryToShow() | 316 function Module:TryToShow() |
| 317 | 317 |
| 318 print('|cFFFFFF00TryToShow()') | 318 --print('|cFFFFFF00TryToShow()') |
| 319 | 319 |
| 320 if not InCombatLockdown() then | 320 if not InCombatLockdown() then |
| 321 for _, name in ipairs(FRAME_LIST) do | 321 for _, name in ipairs(FRAME_LIST) do |
| 322 print('test:', name, (_G[name] and _G[name]:IsShown())) | 322 --print('test:', name, (_G[name] and _G[name]:IsShown())) |
| 323 if _G[name] and _G[name]:IsVisible() then | 323 if _G[name] and _G[name]:IsVisible() then |
| 324 if self:IsShown() then | 324 if self:IsShown() then |
| 325 self:Update() | 325 self:Update() |
| 326 else | 326 else |
| 327 self:Show() | 327 self:Show() |
| 329 return | 329 return |
| 330 end | 330 end |
| 331 end | 331 end |
| 332 end | 332 end |
| 333 | 333 |
| 334 print('failed tests') | 334 --print('failed tests') |
| 335 self:Hide() | 335 self:Hide() |
| 336 end | 336 end |
| 337 | 337 |
| 338 | 338 |
| 339 function Module:OnEvent(event, ...) | 339 function Module:OnEvent(event, ...) |
| 340 print('|cFF00FF88OnEvent()', event, ...) | 340 --print('|cFF00FF88OnEvent()', event, ...) |
| 341 if event == 'PLAYER_ENTERING_WORLD' then | 341 if event == 'PLAYER_ENTERING_WORLD' then |
| 342 self:TryToShow() | 342 self:TryToShow() |
| 343 elseif event == 'BAG_UPDATE' then | 343 elseif event == 'BAG_UPDATE' then |
| 344 local containerID = ... | 344 local containerID = ... |
| 345 | 345 |
| 374 if newItem then | 374 if newItem then |
| 375 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo() | 375 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo() |
| 376 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent) | 376 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 377 --self:ScanAllBags(self.bankAccess) | 377 --self:ScanAllBags(self.bankAccess) |
| 378 end | 378 end |
| 379 self:UpdateArtifactButtons() | |
| 379 elseif event == 'ARTIFACT_XP_UPDATE' then | 380 elseif event == 'ARTIFACT_XP_UPDATE' then |
| 380 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo() | 381 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo() |
| 381 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent) | 382 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 382 --self:ScanAllBags(self.bankAccess) | 383 --self:ScanAllBags(self.bankAccess) |
| 384 self:UpdateArtifactButtons() | |
| 383 elseif event == 'PLAYER_REGEN_ENABLED' then | 385 elseif event == 'PLAYER_REGEN_ENABLED' then |
| 384 | 386 |
| 385 if self.queuedScan then | 387 if self.queuedScan then |
| 386 self:ScanAllBags(self.backAccess) | 388 self:ScanAllBags(self.backAccess) |
| 387 else | 389 else |
| 557 local buttonsWidth = 0 | 559 local buttonsWidth = 0 |
| 558 if equipped then | 560 if equipped then |
| 559 numButtons = numButtons + 1 | 561 numButtons = numButtons + 1 |
| 560 button = self.Artifact[numButtons] | 562 button = self.Artifact[numButtons] |
| 561 button.relativeFrame = self | 563 button.relativeFrame = self |
| 564 button:SetItem(self.equippedID, equipped, numButtons, true, nil) | |
| 565 | |
| 562 if self.equippedID ~= button.itemID then | 566 if self.equippedID ~= button.itemID then |
| 563 button:SetItem(self.equippedID, equipped, numButtons, true, nil) | 567 |
| 564 hasArtifacts = true | 568 hasArtifacts = true |
| 565 end | 569 end |
| 566 lastFrame = button | 570 lastFrame = button |
| 567 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2) | 571 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2) |
| 568 end | 572 end |
| 587 | 591 |
| 588 hasArtifacts = true | 592 hasArtifacts = true |
| 589 numButtons = numButtons + 1 | 593 numButtons = numButtons + 1 |
| 590 button = self.Artifact[numButtons] | 594 button = self.Artifact[numButtons] |
| 591 button.relativeFrame = lastFrame | 595 button.relativeFrame = lastFrame |
| 592 if button.itemID ~= itemID then | 596 button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil) |
| 593 button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil) | |
| 594 end | |
| 595 lastFrame = button | 597 lastFrame = button |
| 596 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING | 598 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING |
| 597 end | 599 end |
| 598 end | 600 end |
| 599 end | 601 end |
| 789 return | 791 return |
| 790 end | 792 end |
| 791 local artifacts = self.profile.artifacts | 793 local artifacts = self.profile.artifacts |
| 792 | 794 |
| 793 if itemID then | 795 if itemID then |
| 794 self.currentEquipped = itemID | |
| 795 | 796 |
| 796 artifacts[itemID] = artifacts[itemID] or {} | 797 artifacts[itemID] = artifacts[itemID] or {} |
| 797 table.wipe(artifacts[itemID]) | 798 table.wipe(artifacts[itemID]) |
| 798 local artifact = artifacts[itemID] | 799 local artifact = artifacts[itemID] |
| 799 | 800 |
| 805 artifact.itemID = itemID | 806 artifact.itemID = itemID |
| 806 | 807 |
| 807 print('tier', artifact.tier) | 808 print('tier', artifact.tier) |
| 808 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier) | 809 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier) |
| 809 artifact.currentCost = cost | 810 artifact.currentCost = cost |
| 810 | 811 end |
| 811 for index, frame in pairs(self.Artifact) do | 812 |
| 812 if frame.itemID == itemID then | 813 local equippedID = C_ArtifactUI:GetEquippedArtifactInfo() |
| 813 frame:SetItem(itemID, artifact, index, (itemID == self.equippedID), (itemID == UNDERLIGHT_ANGLER_ID)) | 814 self.currentEquipped = equippedID |
| 814 end | |
| 815 end | |
| 816 | |
| 817 end | |
| 818 end | 815 end |
| 819 | 816 |
| 820 function Module:ScanBag(id) | 817 function Module:ScanBag(id) |
| 821 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) | 818 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) |
| 822 local numSlots = GetContainerNumSlots(id) | 819 local numSlots = GetContainerNumSlots(id) |
| 918 for _, bagID in ipairs(BANK_SLOTS) do | 915 for _, bagID in ipairs(BANK_SLOTS) do |
| 919 self:ScanBag(bagID) | 916 self:ScanBag(bagID) |
| 920 end | 917 end |
| 921 end | 918 end |
| 922 | 919 |
| 920 | |
| 921 | |
| 923 self.bankAP = 0 | 922 self.bankAP = 0 |
| 924 self.bagAP = 0 | 923 self.bagAP = 0 |
| 925 self.fishingAP = 0 | 924 self.fishingAP = 0 |
| 926 | 925 |
| 927 table.wipe(ItemCounts) | 926 table.wipe(ItemCounts) |
| 1025 end | 1024 end |
| 1026 | 1025 |
| 1027 self.itemID = itemID | 1026 self.itemID = itemID |
| 1028 self.isEquipped = equipped | 1027 self.isEquipped = equipped |
| 1029 self:Update() | 1028 self:Update() |
| 1030 self:Show() | 1029 self:SetShown(true) |
| 1031 | 1030 |
| 1032 return self | 1031 return self |
| 1033 end | 1032 end |
| 1034 | 1033 |
| 1035 function Artifact:UpdateXPBar() | 1034 function Artifact:UpdateXPBar() |
| 1093 | 1092 |
| 1094 end | 1093 end |
| 1095 | 1094 |
| 1096 function Artifact:OnLoad() | 1095 function Artifact:OnLoad() |
| 1097 print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID()) | 1096 print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID()) |
| 1098 self:RegisterEvent('ARTIFACT_UPDATE') | |
| 1099 self:RegisterEvent('PLAYER_LOGIN') | |
| 1100 end | |
| 1101 | |
| 1102 function Artifact:OnEvent(event) | |
| 1103 local itemID, _, _, nextCost = C_ArtifactUI.GetEquippedArtifactInfo() | |
| 1104 print(self:GetID(), '|cFFFF4400OnEvent()|r', event, itemID, '=', self.itemID, (itemID == self.itemID)) | |
| 1105 if itemID == self.itemID then | |
| 1106 self:Update() | |
| 1107 end | |
| 1108 end | 1097 end |
| 1109 | 1098 |
| 1110 function Artifact:Update() | 1099 function Artifact:Update() |
| 1111 if not self.itemID then | 1100 if not self.itemID then |
| 1112 return | 1101 return |
| 1113 end | 1102 end |
| 1114 | 1103 |
| 1115 print(self:GetName(), '|ff00FFFFUpdate()|r') | 1104 print(self:GetName(), '|cff00FFFFUpdate()|r') |
| 1116 local r1, g1, b1 = 1, 1, 1 -- top text | 1105 local r1, g1, b1 = 1, 1, 1 -- top text |
| 1117 local r2, g2, b2 = 1, 1, 0 -- bottom text | 1106 local r2, g2, b2 = 1, 1, 0 -- bottom text |
| 1118 local levelText = self.level | 1107 local levelText = self.level |
| 1119 local xpText = ShortNumberString(self.currentXP) | 1108 local xpText = ShortNumberString(self.currentXP) |
| 1120 local costText = ShortNumberString(self.currentCost) | 1109 local costText = ShortNumberString(self.currentCost) |
