Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 116:ddfe19d70a34
ArtifactPower:
- Further 7.2 accommodations, relating to tokens that grant millions of AP.
Currency:
- Ancient Mana zones list expanded
- Legionfall War Supplies, Nethershards, and Blood of Sargeras are tracked globally
PaperDoll:
- Should update more effectively when delayed artifact data loads in.
WorldState:
- Fixed hanging panels after OrderHallCommandBar is hidden.
| author | Nenue |
|---|---|
| date | Wed, 26 Apr 2017 20:06:38 -0400 |
| parents | 8c94bee4fdfc |
| children | 589045559484 |
comparison
equal
deleted
inserted
replaced
| 115:8c94bee4fdfc | 116:ddfe19d70a34 |
|---|---|
| 11 cache = {}, | 11 cache = {}, |
| 12 fishingCache = {}, | 12 fishingCache = {}, |
| 13 scanQueue = {}, | 13 scanQueue = {}, |
| 14 ItemButtons = {}, | 14 ItemButtons = {}, |
| 15 anchorPoint = 'TOP', | 15 anchorPoint = 'TOP', |
| 16 anchorPriority = 2, | 16 anchorPriority = 3, |
| 17 anchorFrom = 'TOP', | 17 anchorFrom = 'TOP', |
| 18 moduleName = 'Artifactor', | 18 moduleName = 'Artifactor', |
| 19 HideCombat = true | 19 HideCombat = true |
| 20 } | 20 } |
| 21 local defaultSettings = { | 21 local defaultSettings = { |
| 22 firstUse = true, | 22 firstUse = true, |
| 23 autoHide = true, | 23 autoHide = true, |
| 24 } | 24 } |
| 25 local ap = VeneerArtifactPowerMixin | 25 local Module = VeneerArtifactPowerMixin |
| 26 local BAGS_TO_SCAN = {BACKPACK_CONTAINER } | 26 local BAGS_TO_SCAN = {BACKPACK_CONTAINER } |
| 27 local TOOLTIP_NAME = 'VeneerAPScanner' | 27 local TOOLTIP_NAME = 'VeneerAPScanner' |
| 28 local POINT_COSTS = { | 28 local POINT_COSTS = { |
| 29 100, 300, 325, 350, 375, | 29 100, 300, 325, 350, 375, |
| 30 400, 425, 450, 525, 625, | 30 400, 425, 450, 525, 625, |
| 37 2440000, 2560000, 2690000, 2825000, 2965000, | 37 2440000, 2560000, 2690000, 2825000, 2965000, |
| 38 3115000, 3270000, 3435000, 3605000, 3785000, | 38 3115000, 3270000, 3435000, 3605000, 3785000, |
| 39 3975000, 4175000, 4385000, 4605000 | 39 3975000, 4175000, 4385000, 4605000 |
| 40 } | 40 } |
| 41 local FISHING_MAX_TRAITS = 24 | 41 local FISHING_MAX_TRAITS = 24 |
| 42 local WEAPON_MAX_TRAITS = 54 | 42 local WEAPON_MAX_TRAITS = 92 |
| 43 local FRAME_PADDING = 4 | |
| 44 local EQUIPPED_SIZE = 64 | |
| 43 local BUTTON_SIZE = 48 | 45 local BUTTON_SIZE = 48 |
| 44 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'} | 46 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'} |
| 45 local BAG_FRAMES = {'ContainerFrame1'} | 47 local BAG_FRAMES = {'ContainerFrame1'} |
| 46 local BANK_FRAMES = {'BankFrame'} | 48 local BANK_FRAMES = {'BankFrame'} |
| 47 | 49 |
| 48 function ap:OnLoad() | 50 function Module:OnLoad() |
| 49 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan | 51 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan |
| 50 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity | 52 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity |
| 51 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available | 53 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available |
| 52 self:RegisterEvent('BANKFRAME_CLOSED') -- " " " | 54 self:RegisterEvent('BANKFRAME_CLOSED') -- " " " |
| 53 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed | 55 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed |
| 83 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') | 85 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') |
| 84 | 86 |
| 85 | 87 |
| 86 end | 88 end |
| 87 local ShortNumberString = function (value) | 89 local ShortNumberString = function (value) |
| 88 if value >= 100000 then | 90 if value >= 1000000 then |
| 91 return tostring(floor(value/100000)/10) .. 'M' | |
| 92 elseif value >= 100000 then | |
| 89 return tostring(floor(value/1000)) .. 'k' | 93 return tostring(floor(value/1000)) .. 'k' |
| 90 elseif value >= 1000 then | 94 elseif value >= 1000 then |
| 91 return tostring(floor(value/100)/10) .. 'k' | 95 return tostring(floor(value/100)/10) .. 'k' |
| 92 else | 96 else |
| 93 return value | 97 return value |
| 161 else | 165 else |
| 162 PENDING_HOOKS[name] = args | 166 PENDING_HOOKS[name] = args |
| 163 end | 167 end |
| 164 end | 168 end |
| 165 | 169 |
| 166 function ap:Setup() | 170 function Module:Setup() |
| 167 print(self:GetName()..':Setup()') | 171 print(self:GetName()..':Setup()') |
| 168 local guid = UnitGUID('player') | 172 local guid = UnitGUID('player') |
| 169 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings | 173 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings |
| 170 self.db = VeneerData.ArtifactPower | 174 self.db = VeneerData.ArtifactPower |
| 171 self.db[guid] = self.db[guid] or {} | 175 self.db[guid] = self.db[guid] or {} |
| 241 end | 245 end |
| 242 end | 246 end |
| 243 | 247 |
| 244 local UNDERLIGHT_ANGLER_ID = 133755 | 248 local UNDERLIGHT_ANGLER_ID = 133755 |
| 245 | 249 |
| 246 function ap:ResetCache() | 250 function Module:ResetCache() |
| 247 table.wipe(self.cache.items) | 251 table.wipe(self.cache.items) |
| 248 table.wipe(self.cache.fishing) | 252 table.wipe(self.cache.fishing) |
| 249 table.wipe(self.cache.bags) | 253 table.wipe(self.cache.bags) |
| 250 table.wipe(self.cache.bagItems) | 254 table.wipe(self.cache.bagItems) |
| 251 self:ScanAllBags() | 255 self:ScanAllBags() |
| 252 end | 256 end |
| 253 | 257 |
| 254 function ap:QueueBag(containerID) | 258 function Module:QueueBag(containerID) |
| 255 containerID = tonumber(containerID) | 259 containerID = tonumber(containerID) |
| 256 if not containerID then | 260 if not containerID then |
| 257 return | 261 return |
| 258 end | 262 end |
| 259 | 263 |
| 261 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line') | 265 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line') |
| 262 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID | 266 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID |
| 263 end | 267 end |
| 264 end | 268 end |
| 265 | 269 |
| 266 function ap:Reanchor() | 270 function Module:Reanchor() |
| 267 if Veneer then | 271 if Veneer then |
| 268 Veneer:DynamicReanchor() | 272 Veneer:DynamicReanchor() |
| 269 end | 273 end |
| 270 end | 274 end |
| 271 | 275 |
| 272 function ap:OnShow() | 276 function Module:OnShow() |
| 273 print('|cFFFFFF00OnShow()|r') | 277 print('|cFFFFFF00OnShow()|r') |
| 274 | 278 |
| 275 for name, args in pairs(PENDING_HOOKS) do | 279 for name, args in pairs(PENDING_HOOKS) do |
| 276 if _G[name] then | 280 if _G[name] then |
| 277 AddFrameHooks(_G[name], args) | 281 AddFrameHooks(_G[name], args) |
| 282 | 286 |
| 283 self.enabled = true | 287 self.enabled = true |
| 284 self:ScanAllBags() | 288 self:ScanAllBags() |
| 285 self:Reanchor() | 289 self:Reanchor() |
| 286 end | 290 end |
| 287 function ap:OnHide() | 291 function Module:OnHide() |
| 288 print('|cFF88FF00OnHide()|r', debugstack()) | 292 print('|cFF88FF00OnHide()|r', debugstack()) |
| 289 self:Reanchor() | 293 self:Reanchor() |
| 290 end | 294 end |
| 291 function ap:OnEnter() | 295 function Module:OnEnter() |
| 292 | 296 |
| 293 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 297 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
| 294 | 298 |
| 295 | 299 |
| 296 GameTooltip:AddLine(self.bagAP) | 300 GameTooltip:AddLine(self.bagAP) |
| 297 GameTooltip:AddLine(self.bankAP) | 301 GameTooltip:AddLine(self.bankAP) |
| 298 | 302 |
| 299 end | 303 end |
| 300 | 304 |
| 301 function ap:TryToShow() | 305 function Module:TryToShow() |
| 302 | 306 |
| 303 print('|cFFFFFF00TryToShow()') | 307 print('|cFFFFFF00TryToShow()') |
| 304 | 308 |
| 305 if not InCombatLockdown() then | 309 if not InCombatLockdown() then |
| 306 for _, name in ipairs(FRAME_LIST) do | 310 for _, name in ipairs(FRAME_LIST) do |
| 319 print('failed tests') | 323 print('failed tests') |
| 320 self:Hide() | 324 self:Hide() |
| 321 end | 325 end |
| 322 | 326 |
| 323 | 327 |
| 324 function ap:OnEvent(event, ...) | 328 function Module:OnEvent(event, ...) |
| 325 print('|cFF00FF88OnEvent()', event, ...) | 329 print('|cFF00FF88OnEvent()', event, ...) |
| 326 if event == 'PLAYER_ENTERING_WORLD' then | 330 if event == 'PLAYER_ENTERING_WORLD' then |
| 327 self:TryToShow() | 331 self:TryToShow() |
| 328 elseif event == 'BAG_UPDATE' then | 332 elseif event == 'BAG_UPDATE' then |
| 329 local containerID = ... | 333 local containerID = ... |
| 378 elseif event == 'PLAYER_REGEN_DISABLED' then | 382 elseif event == 'PLAYER_REGEN_DISABLED' then |
| 379 self:Hide() | 383 self:Hide() |
| 380 end | 384 end |
| 381 end | 385 end |
| 382 | 386 |
| 383 function ap:OnUpdate() | 387 function Module:OnUpdate() |
| 384 if #self.scanQueue >= 1 then | 388 if #self.scanQueue >= 1 then |
| 385 local scanInfo = tremove(self.scanQueue, 1) | 389 local scanInfo = tremove(self.scanQueue, 1) |
| 386 end | 390 end |
| 387 if IsShiftKeyDown() then | 391 if IsShiftKeyDown() then |
| 388 self.Refresh:Show() | 392 self.Refresh:Show() |
| 390 self.Refresh:Hide() | 394 self.Refresh:Hide() |
| 391 end | 395 end |
| 392 | 396 |
| 393 end | 397 end |
| 394 | 398 |
| 395 function ap:OnMouseDown() | 399 function Module:OnMouseDown() |
| 396 self.enabled = nil | 400 self.enabled = nil |
| 397 self:Hide() | 401 self:Hide() |
| 398 end | 402 end |
| 399 | 403 |
| 400 function ap:Update() | 404 function Module:Update() |
| 401 if not self:IsShown() then | 405 if not self:IsShown() then |
| 402 print('|cFFFF4400Update()|r') | 406 print('|cFFFF4400Update()|r') |
| 403 return | 407 return |
| 404 end | 408 end |
| 405 print('|cFF00FFFFUpdate()|r') | 409 print('|cFF00FFFFUpdate()|r') |
| 425 self.worldQuestAP = 0 | 429 self.worldQuestAP = 0 |
| 426 if WorldPlan then | 430 if WorldPlan then |
| 427 | 431 |
| 428 if not self.worldPlanHooked then | 432 if not self.worldPlanHooked then |
| 429 WorldPlan:RegisterDataCallback(function() | 433 WorldPlan:RegisterDataCallback(function() |
| 434 print('data udpate callback') | |
| 430 self:Update() | 435 self:Update() |
| 431 end) | 436 end) |
| 437 self.worldPlanHooked = true | |
| 432 end | 438 end |
| 433 | 439 |
| 434 | 440 |
| 435 local showWQ | 441 local showWQ |
| 436 print('world plan is loaded') | 442 print('world plan is loaded') |
| 437 local worldQuests = WorldPlan:GetQuestPins() | 443 local worldQuests = WorldPlan:GetQuestPins() |
| 438 for index, pin in ipairs(worldQuests) do | 444 for index, pin in ipairs(worldQuests) do |
| 439 if pin.dataLoaded and (pin.rewardType == WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER) and (pin.isActive) then | 445 if (pin.rewardType == WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER) and (pin.isActive) and (pin.dataLoaded) then |
| 440 showWQ = true | 446 showWQ = true |
| 441 print(pin.itemNumber) | 447 print(pin.itemNumber) |
| 442 self.worldQuestAP = self.worldQuestAP + pin.itemNumber | 448 self.worldQuestAP = self.worldQuestAP + pin.itemNumber |
| 443 end | 449 end |
| 444 end | 450 end |
| 453 | 459 |
| 454 local numButtons = 0 | 460 local numButtons = 0 |
| 455 local contentsHeight = 16 + self.SummaryHeader:GetHeight() | 461 local contentsHeight = 16 + self.SummaryHeader:GetHeight() |
| 456 local contentsWidth = self.SummaryHeader:GetWidth() + 16 | 462 local contentsWidth = self.SummaryHeader:GetWidth() + 16 |
| 457 if self.profile.knowledgeMultiplier then | 463 if self.profile.knowledgeMultiplier then |
| 458 numButtons = self:UpdateArtifactButtons() | 464 local artifactsWidth = self:UpdateArtifactButtons() |
| 459 | 465 |
| 460 if numButtons ~= 0 then | 466 if artifactsWidth ~= 0 then |
| 461 contentsHeight = contentsHeight + 64 | 467 contentsHeight = contentsHeight + 64 |
| 462 end | 468 end |
| 463 | 469 |
| 464 contentsWidth = max(contentsWidth, 64*numButtons + 4 * (numButtons+1)) | 470 contentsWidth = max(contentsWidth, artifactsWidth) |
| 465 | 471 |
| 466 local itemsWidth, itemsHeight = self:UpdateItemButtons() | 472 local itemsWidth, itemsHeight = self:UpdateItemButtons() |
| 467 contentsHeight = contentsHeight + itemsHeight | 473 contentsHeight = contentsHeight + itemsHeight |
| 468 contentsWidth = max(contentsWidth, itemsWidth) | 474 contentsWidth = max(contentsWidth, itemsWidth) |
| 469 end | 475 end |
| 477 self:SetWidth(contentsWidth) | 483 self:SetWidth(contentsWidth) |
| 478 self:SetHeight(contentsHeight) | 484 self:SetHeight(contentsHeight) |
| 479 self:Reanchor() | 485 self:Reanchor() |
| 480 end | 486 end |
| 481 | 487 |
| 482 function ap:UpdateArtifactButtons() | 488 function Module:UpdateArtifactButtons() |
| 483 | 489 |
| 484 -- Artifact icons, in no particular order | 490 -- Artifact icons, in no particular order |
| 485 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() | 491 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() |
| 486 self.canAddAP = nil | 492 self.canAddAP = nil |
| 487 self.canAddFishingAP = nil | 493 self.canAddFishingAP = nil |
| 488 local hasArtifacts | 494 local hasArtifacts |
| 489 local numButtons = 0 | 495 local numButtons = 0 |
| 490 local lastFrame = self | 496 local lastFrame = self |
| 491 local fishingID, fishingData | 497 local fishingID, fishingData |
| 492 local index, button | 498 local index, button |
| 499 local equipped =self.profile.artifacts[self.equippedID] | |
| 500 local buttonsWidth = 0 | |
| 501 if equipped then | |
| 502 numButtons = numButtons + 1 | |
| 503 button = self.Artifact[numButtons] | |
| 504 button.relativeFrame = self | |
| 505 lastFrame = button:SetButton(self.equippedID, equipped, numButtons, true, nil) | |
| 506 hasArtifacts = true | |
| 507 | |
| 508 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2) | |
| 509 end | |
| 510 | |
| 511 | |
| 493 for itemID, artifact in pairs(self.profile.artifacts) do | 512 for itemID, artifact in pairs(self.profile.artifacts) do |
| 494 if (itemID == UNDERLIGHT_ANGLER_ID) then | 513 if (itemID == UNDERLIGHT_ANGLER_ID) then |
| 495 if VeneerData.ArtifactPower.EnableFishing then | 514 -- only add if we have fishing AP items and it's not being shown in the equipped slot |
| 515 if VeneerData.ArtifactPower.EnableFishing and (itemID ~= self.equippedID) then | |
| 496 fishingID = itemID | 516 fishingID = itemID |
| 497 fishingData = artifact | 517 fishingData = artifact |
| 498 end | 518 end |
| 499 | 519 |
| 500 if artifact.level < FISHING_MAX_TRAITS then | 520 if artifact.level < FISHING_MAX_TRAITS then |
| 501 if itemID == self.equippedID then | 521 if itemID == self.equippedID then |
| 502 self.canAddFishingAP = true | 522 self.canAddFishingAP = true |
| 503 end | 523 end |
| 504 end | 524 end |
| 505 | |
| 506 | |
| 507 else | 525 else |
| 508 if artifact.level < WEAPON_MAX_TRAITS then | 526 if artifact.level < WEAPON_MAX_TRAITS then |
| 509 | |
| 510 if itemID == self.equippedID then | 527 if itemID == self.equippedID then |
| 511 self.canAddAP = true | 528 self.canAddAP = true |
| 529 else | |
| 530 | |
| 531 hasArtifacts = true | |
| 532 numButtons = numButtons + 1 | |
| 533 button = self.Artifact[numButtons] | |
| 534 button.relativeFrame = lastFrame | |
| 535 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID), nil) | |
| 536 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING | |
| 512 end | 537 end |
| 513 hasArtifacts = true | |
| 514 numButtons = numButtons + 1 | |
| 515 button = self.Artifact[numButtons] | |
| 516 button.relativeFrame = lastFrame | |
| 517 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID), nil) | |
| 518 end | 538 end |
| 519 end | 539 end |
| 520 end | 540 end |
| 521 | 541 |
| 522 | 542 |
| 534 print('hide', i) | 554 print('hide', i) |
| 535 self.Artifact[i]:Hide() | 555 self.Artifact[i]:Hide() |
| 536 end | 556 end |
| 537 | 557 |
| 538 | 558 |
| 539 return numButtons | 559 return buttonsWidth |
| 540 end | 560 end |
| 541 | 561 |
| 542 | 562 |
| 543 function ap:UpdateItemButtons() | 563 function Module:UpdateItemButtons() |
| 544 print('|cFF00FFFFUpdateItemButtons()|r') | 564 print('|cFF00FFFFUpdateItemButtons()|r') |
| 545 | 565 |
| 546 local apType | 566 local apType |
| 547 if self.canAddFishingAP then | 567 if self.canAddFishingAP then |
| 548 apType = true | 568 apType = true |
| 603 | 623 |
| 604 | 624 |
| 605 return buttonsWidth, buttonsHeight | 625 return buttonsWidth, buttonsHeight |
| 606 end | 626 end |
| 607 | 627 |
| 608 function ap:SetItemAction(button, name) | 628 function Module:SetItemAction(button, name) |
| 609 name = name or self.itemName | 629 name = name or self.itemName |
| 610 if InCombatLockdown() then | 630 if InCombatLockdown() then |
| 611 self.itemName = name | 631 self.itemName = name |
| 612 return | 632 return |
| 613 else | 633 else |
| 614 button:SetAttribute('*type*','item') | 634 button:SetAttribute('*type*','item') |
| 615 button:SetAttribute('*item*', name) | 635 button:SetAttribute('*item*', name) |
| 616 end | 636 end |
| 617 end | 637 end |
| 618 | 638 |
| 619 function ap:GetItemButton(itemID, texture, itemAP, fishing) | 639 function Module:GetItemButton(itemID, texture, itemAP, fishing) |
| 620 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP) | 640 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP) |
| 621 local button = self.ItemButtons[itemID] | 641 local button = self.ItemButtons[itemID] |
| 622 | 642 |
| 623 if not button then | 643 if not button then |
| 624 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton') | 644 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton') |
| 636 print(' created') | 656 print(' created') |
| 637 self.ItemButtons[itemID] = button | 657 self.ItemButtons[itemID] = button |
| 638 self.numItems = self.numItems + 1 | 658 self.numItems = self.numItems + 1 |
| 639 end | 659 end |
| 640 | 660 |
| 641 local itemAPtext = itemAP | 661 button.Label:SetText(ShortNumberString(itemAP)) |
| 642 if itemAPtext >= 100000 then | |
| 643 itemAPtext = floor(itemAPtext/1000) .. 'k' | |
| 644 elseif itemAPtext >= 1000 then | |
| 645 itemAPtext = (floor(itemAPtext/100)/10 ) .. 'k' | |
| 646 end | |
| 647 button.Label:SetText(itemAPtext) | |
| 648 | 662 |
| 649 button.numItems = button.numItems + 1 | 663 button.numItems = button.numItems + 1 |
| 650 return button | 664 return button |
| 651 end | 665 end |
| 652 | 666 |
| 653 function ap:GetItemAP(itemID, itemLink, bagData) | 667 function Module:GetItemAP(itemID, itemLink, bagData) |
| 654 if not self.cache.items[itemID] then | 668 if not self.cache.items[itemID] then |
| 655 | 669 |
| 656 print('doing tooltip scan', itemLink, itemID) | 670 print('doing tooltip scan', itemLink, itemID) |
| 657 self.tooltip:SetOwner(self, 'ANCHOR_NONE') | 671 self.tooltip:SetOwner(self, 'ANCHOR_NONE') |
| 658 self.tooltip:SetHyperlink(itemLink) | 672 self.tooltip:SetHyperlink(itemLink) |
| 662 for i = 3, numLines do | 676 for i = 3, numLines do |
| 663 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText() | 677 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText() |
| 664 if text then | 678 if text then |
| 665 | 679 |
| 666 text = text:lower():gsub(',', '') | 680 text = text:lower():gsub(',', '') |
| 681 | |
| 667 if text:match('equipped artifact') then | 682 if text:match('equipped artifact') then |
| 668 print(itemLink, '-', tonumber(text)) | 683 print(itemLink, '-', tonumber(text)) |
| 669 local itemAP = text:match('%d+') | 684 |
| 685 local itemAP = text:match('[%d%.]+') | |
| 670 if itemAP then | 686 if itemAP then |
| 687 -- tokens > 1M are described as '%f million' | |
| 688 if text:match("million") then | |
| 689 itemAP = tonumber(itemAP) * 1000000 | |
| 690 end | |
| 691 | |
| 671 itemAP = itemAP | 692 itemAP = itemAP |
| 672 self.cache.items[itemID] = tonumber(itemAP) | 693 self.cache.items[itemID] = tonumber(itemAP) |
| 673 end | 694 end |
| 674 end | 695 end |
| 675 if text:match('fishing artifact') then | 696 if text:match('fishing artifact') then |
| 689 end | 710 end |
| 690 end | 711 end |
| 691 return self.cache.items[itemID], self.cache.fishing[itemID] | 712 return self.cache.items[itemID], self.cache.fishing[itemID] |
| 692 end | 713 end |
| 693 | 714 |
| 694 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) | 715 function Module:SetArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 695 print('|cFF00FF00SetArtifact()|r') | 716 print('|cFF00FF00SetArtifact()|r') |
| 696 if not self.profile then | 717 if not self.profile then |
| 697 return | 718 return |
| 698 end | 719 end |
| 699 local artifacts = self.profile.artifacts | 720 local artifacts = self.profile.artifacts |
| 717 | 738 |
| 718 artifact.name = name | 739 artifact.name = name |
| 719 artifact.texture = texture | 740 artifact.texture = texture |
| 720 artifact.currentXP = currentXP | 741 artifact.currentXP = currentXP |
| 721 artifact.level = pointsSpent | 742 artifact.level = pointsSpent |
| 722 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent) | 743 artifact.tier = C_ArtifactUI.GetArtifactTier() or ((pointsSpent >= 36) and 2 or 1) |
| 744 | |
| 745 print('tier', artifact.tier) | |
| 746 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier) | |
| 723 artifact.currentCost = cost | 747 artifact.currentCost = cost |
| 724 | 748 |
| 725 local pointsAvailable = pointsSpent | 749 |
| 726 local actualCost = cost | 750 |
| 727 local actualXP = currentXP | 751 end |
| 728 while actualXP >= actualCost do | 752 end |
| 729 pointsAvailable = pointsAvailable + 1 | 753 |
| 730 actualXP = actualXP - actualCost | 754 function Module:ScanBag(id) |
| 731 print(pointsAvailable, '-', actualCost, '=', actualXP) | |
| 732 actualCost = C_ArtifactUI.GetCostForPointAtRank(pointsAvailable) | |
| 733 end | |
| 734 print('updating', itemID, name, currentXP, pointsSpent, pointsAvailable, actualXP) | |
| 735 artifact.actualXP = actualXP | |
| 736 artifact.actualLevel = pointsAvailable | |
| 737 artifact.actualCost = actualCost | |
| 738 | |
| 739 end | |
| 740 end | |
| 741 | |
| 742 function ap:ScanBag(id) | |
| 743 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) | 755 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) |
| 744 local numSlots = GetContainerNumSlots(id) | 756 local numSlots = GetContainerNumSlots(id) |
| 745 local requiresUpdate | 757 local requiresUpdate |
| 746 if numSlots == 0 then | 758 if numSlots == 0 then |
| 747 return nil | 759 return nil |
| 811 end | 823 end |
| 812 | 824 |
| 813 local BAG_SLOTS = {0, 1, 2, 3, 4 } | 825 local BAG_SLOTS = {0, 1, 2, 3, 4 } |
| 814 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12} | 826 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12} |
| 815 local ItemCounts = {} | 827 local ItemCounts = {} |
| 816 function ap:ScanAllBags() | 828 function Module:ScanAllBags() |
| 817 if InCombatLockdown() then | 829 if InCombatLockdown() then |
| 818 self.queuedScan = true | 830 self.queuedScan = true |
| 819 return | 831 return |
| 820 end | 832 end |
| 821 if not self.profile.knowledgeMultiplier then | 833 if not self.profile.knowledgeMultiplier then |
| 866 self.queuedScan = nil | 878 self.queuedScan = nil |
| 867 self:TryToShow() | 879 self:TryToShow() |
| 868 end | 880 end |
| 869 | 881 |
| 870 VeneerArtifactButtonMixin = {} | 882 VeneerArtifactButtonMixin = {} |
| 871 | 883 local Artifact = VeneerArtifactButtonMixin |
| 872 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped, fishing) | 884 |
| 885 function Artifact:SetButton(itemID, artifact, index, equipped, fishing) | |
| 873 print(itemID, index) | 886 print(itemID, index) |
| 874 print(artifact.name, artifact.texture, artifact.currentXP) | 887 print(artifact.name, artifact.texture, artifact.currentXP) |
| 875 self:SetID(itemID) | 888 self:SetID(itemID) |
| 876 if not artifact.currentCost then | 889 if not artifact.currentCost then |
| 877 artifact.currentCost = artifact.cost | 890 artifact.currentCost = artifact.cost |
| 882 self[k] = v | 895 self[k] = v |
| 883 end | 896 end |
| 884 | 897 |
| 885 self.isFishing = fishing | 898 self.isFishing = fishing |
| 886 -- this can change between artifact parses | 899 -- this can change between artifact parses |
| 887 local potentialPoints = self.actualLevel | |
| 888 local totalAP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0) | 900 local totalAP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0) |
| 889 print(totalAP) | 901 print(totalAP) |
| 890 local potentialXP = self.actualXP + totalAP | 902 |
| 891 | 903 -- currentXP what has been spent on the artifact |
| 892 self.potentialXP = potentialXP | 904 -- actualXP amount |
| 893 local potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints) | 905 -- totalXP |
| 894 while potentialXP >= potentialCost do | 906 local actualXP = artifact.currentXP + totalAP |
| 895 potentialXP = potentialXP - potentialCost | 907 local actualLevel = artifact.level |
| 896 potentialPoints = potentialPoints + 1 | 908 local actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier) |
| 897 print('inc estimate', potentialXP, potentialPoints) | 909 |
| 898 potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints) | 910 while actualXP >= actualCost do |
| 899 end | 911 actualXP = actualXP - actualCost |
| 900 self.potentialCost = potentialCost | 912 actualLevel = actualLevel + 1 |
| 901 self.potentialLevel = potentialPoints | 913 actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier) |
| 902 self.potentialAdjustedXP = potentialXP | 914 print('* ', actualLevel, actualXP, actualCost) |
| 903 | 915 end |
| 904 self.maxCost = self.currentCost | 916 self.actualCost = actualCost |
| 905 for i = self.level + 1, #POINT_COSTS do | 917 self.actualLevel = actualLevel |
| 906 self.maxCost = self.maxCost + POINT_COSTS[i] | 918 self.actualXP = actualXP |
| 907 end | 919 self.totalXP = artifact.currentXP + totalAP |
| 920 | |
| 908 | 921 |
| 909 if index ~= 1 then | 922 if index ~= 1 then |
| 910 self:ClearAllPoints() | 923 self:ClearAllPoints() |
| 911 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) | 924 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) |
| 912 else | 925 else |
| 918 self:Update() | 931 self:Update() |
| 919 self:Show() | 932 self:Show() |
| 920 return self | 933 return self |
| 921 end | 934 end |
| 922 | 935 |
| 923 function VeneerArtifactButtonMixin:Update() | 936 function Artifact:Update() |
| 924 local r, g, b = 1, 1, 1 | 937 local r1, g1, b1 = 1, 1, 1 |
| 925 local lR, lG, lB = 1, 1, 0 | 938 local r2, g2, b2 = 1, 1, 0 |
| 926 local levelText = self.level | 939 local levelText = self.level |
| 927 local xpValue = ShortNumberString(self.currentXP) | 940 local xpText = ShortNumberString(self.currentXP) |
| 928 local costValue = self.currentCost | 941 local costText = ShortNumberString(self.currentCost) |
| 942 local remainingText = ShortNumberString(self.currentCost - self.currentXP) | |
| 943 -- current: amount shown in blizz ui | |
| 944 -- actual: amount contributing the next level, will be same until current point cap is reached | |
| 945 -- potential: total of ap on hand | |
| 946 print(self.currentXP, self.actualXP, self.potentialXP) | |
| 929 if self.actualLevel ~= self.level then | 947 if self.actualLevel ~= self.level then |
| 930 levelText, r,g,b = self.actualLevel, 0,1,0 | 948 |
| 931 xpValue, costValue, lR, lG, lB = ShortNumberString(self.potentialXP) .. '\n' .. ShortNumberString(self.potentialCost-self.potentialXP), self.actualCost, 0, 1, 0 | 949 levelText = self.actualLevel |
| 932 elseif self.potentialLevel ~= self.level then | 950 r1, g1, b1 = 0, 1, 0 |
| 933 levelText, r, g, b = self.potentialLevel, 0,1,1 | 951 r2, g2, b2 = 0, 1, 0 |
| 934 xpValue, costValue, lR, lG, lB = ShortNumberString(self.potentialXP) .. '\n' .. ShortNumberString(self.potentialCost-self.potentialXP), self.potentialCost, 0,1,1 | 952 xpText = ShortNumberString(self.actualXP) |
| 935 else | 953 costText = ShortNumberString(self.actualCost) |
| 936 xpValue, lR, lG, lB = ShortNumberString(self.actualXP) .. '\n|cFFFFFF00' .. ShortNumberString(self.actualCost-self.actualXP)..'|r', 1, 1, 1 | 954 remainingText = ShortNumberString(self.actualCost-self.actualXP) |
| 955 --[[elseif self.potentialLevel ~= self.level then | |
| 956 r1, g1, b1 = 0, 1, 1 | |
| 957 r2, g2, b2 = 0, 1, 1 | |
| 958 costText = ShortNumberString(self.potentialCost) | |
| 959 remainingText = ShortNumberString(self.potentialCost-self.potentialXP) | |
| 960 --]] | |
| 937 end | 961 end |
| 938 | 962 |
| 939 self.Level:SetText(levelText) | 963 self.Level:SetText(levelText) |
| 940 self.Level:SetTextColor(r, g, b) | 964 self.CurrentXP:SetText( xpText ) |
| 941 self.CurrentXP:SetText( xpValue) | 965 self.RemainingCost:SetText(remainingText) |
| 942 self.CurrentXP:SetTextColor(lR, lG, lB) | 966 self.Level:SetTextColor(r1, g1, b1) |
| 967 self.CurrentXP:SetTextColor(r1, g1, b1) | |
| 943 | 968 |
| 944 if self.isEquipped then | 969 if self.isEquipped then |
| 970 self:SetSize(64,64) | |
| 945 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) | 971 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) |
| 946 self:GetNormalTexture():SetBlendMode('ADD') | 972 self:GetNormalTexture():SetBlendMode('ADD') |
| 947 self:GetNormalTexture():SetVertexColor(0,1,0) | 973 self:GetNormalTexture():SetVertexColor(0,1,0) |
| 948 else | 974 else |
| 975 self:SetSize(48,48) | |
| 949 self:SetNormalTexture(nil, 'ADD') | 976 self:SetNormalTexture(nil, 'ADD') |
| 950 end | 977 end |
| 951 | 978 |
| 952 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1 | 979 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1 |
| 953 if self.level <= 53 then | 980 if self.level <= 53 then |
| 958 else | 985 else |
| 959 self.CurrentProgress:Hide() | 986 self.CurrentProgress:Hide() |
| 960 self.ProgressLine:Hide() | 987 self.ProgressLine:Hide() |
| 961 end | 988 end |
| 962 | 989 |
| 963 if self.potentialXP > self.currentXP then | 990 if self.actualXP ~= self.currentXP then |
| 964 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialXP / self.potentialCost) or 1 | 991 local projectedProgress = (self.actualXP ~= self.actualCost) and (self.actualXP / self.actualCost) or 1 |
| 965 if (projectedProgress > currentProgress) then | 992 if (projectedProgress > currentProgress) then |
| 966 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') | 993 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') |
| 967 projectedProgress = projectedProgress - currentProgress | 994 projectedProgress = projectedProgress - currentProgress |
| 968 else | 995 else |
| 996 self.CurrentProgress:Hide() | |
| 997 self.ProgressLine:Hide() | |
| 969 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') | 998 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') |
| 970 end | 999 end |
| 971 print('show potential', currentProgress, projectedProgress) | 1000 print('show actual', currentProgress, projectedProgress) |
| 972 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 | 1001 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 |
| 973 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() | 1002 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() |
| 974 self.AdjustedLine:Show() | 1003 self.AdjustedLine:Show() |
| 975 self.AdjustedProgress:Show() | 1004 self.AdjustedProgress:Show() |
| 976 else | 1005 else |
| 977 self.AdjustedProgress:Hide() | 1006 self.AdjustedProgress:Hide() |
| 978 self.AdjustedLine:Hide() | 1007 self.AdjustedLine:Hide() |
| 979 end | 1008 end |
| 1009 | |
| 1010 | |
| 1011 | |
| 980 self.Icon:SetTexture(self.texture) | 1012 self.Icon:SetTexture(self.texture) |
| 981 self:SetSize(64,64) | 1013 end |
| 982 end | 1014 |
| 983 | 1015 |
| 984 | 1016 function Artifact:AnimateProgress(region) |
| 985 function VeneerArtifactButtonMixin:AnimateProgress(region) | |
| 986 local cTime = GetTime() | 1017 local cTime = GetTime() |
| 987 if not region.animateStart then | 1018 if not region.animateStart then |
| 988 region.animateStart = cTime | 1019 region.animateStart = cTime |
| 989 end | 1020 end |
| 990 local progressTo, progressFrom = region.animateTo, region.animateFrom | 1021 local progressTo, progressFrom = region.animateTo, region.animateFrom |
| 1000 --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height)) | 1031 --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height)) |
| 1001 region:SetHeight(height) | 1032 region:SetHeight(height) |
| 1002 end | 1033 end |
| 1003 end | 1034 end |
| 1004 | 1035 |
| 1005 function VeneerArtifactButtonMixin:OnUpdate(sinceLast) | 1036 function Artifact:OnUpdate(sinceLast) |
| 1006 if self.CurrentProgress.animateTo then | 1037 if self.CurrentProgress.animateTo then |
| 1007 self:AnimateProgress(self.CurrentProgress) | 1038 self:AnimateProgress(self.CurrentProgress) |
| 1008 end | 1039 end |
| 1009 | 1040 |
| 1010 if self.AdjustedProgress.animateTo then | 1041 if self.AdjustedProgress.animateTo then |
| 1011 self:AnimateProgress(self.AdjustedProgress) | 1042 self:AnimateProgress(self.AdjustedProgress) |
| 1012 end | 1043 end |
| 1013 end | 1044 end |
| 1014 | 1045 |
| 1015 function VeneerArtifactButtonMixin:OnEnter() | 1046 function Artifact:OnEnter() |
| 1016 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 1047 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
| 1017 GameTooltip:SetText(self.name) | 1048 GameTooltip:SetText(self.name) |
| 1018 GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 0) | 1049 GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 0) |
| 1019 if self.potentialXP > self.currentXP then | 1050 if self.totalXP ~= self.currentXP then |
| 1020 GameTooltip:AddLine(ShortNumberString(self.potentialXP) .. ' potential XP', 0, 1, 1) | 1051 GameTooltip:AddLine(ShortNumberString(self.totalXP) .. ' total XP', 0, 1, 1) |
| 1021 if self.potentialAdjustedXP ~= self.potentialXP then | 1052 if self.actualXP ~= self.potentialXP then |
| 1022 GameTooltip:AddLine(ShortNumberString(self.potentialAdjustedXP) .. ' / ' .. ShortNumberString(self.potentialCost).. ' after', 0, 1, 0) | 1053 GameTooltip:AddLine(ShortNumberString(self.actualXP) .. ' / ' .. ShortNumberString(self.actualCost).. ' after', 0, 1, 0) |
| 1023 end | 1054 end |
| 1024 end | 1055 end |
| 1025 if self.actualLevel ~= self.level then | 1056 if self.actualLevel ~= self.level then |
| 1026 GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 1) | 1057 GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 1) |
| 1027 end | 1058 end |
| 1029 GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' needed') | 1060 GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' needed') |
| 1030 end | 1061 end |
| 1031 | 1062 |
| 1032 GameTooltip:Show() | 1063 GameTooltip:Show() |
| 1033 end | 1064 end |
| 1034 function VeneerArtifactButtonMixin:OnLeave() | 1065 function Artifact:OnLeave() |
| 1035 if GameTooltip:IsOwned(self) then | 1066 if GameTooltip:IsOwned(self) then |
| 1036 GameTooltip:Hide() | 1067 GameTooltip:Hide() |
| 1037 end | 1068 end |
| 1038 end | 1069 end |
| 1039 function VeneerArtifactButtonMixin:OnHide() | 1070 function Artifact:OnHide() |
| 1040 | 1071 |
| 1041 if GameTooltip:IsOwned(self) then | 1072 if GameTooltip:IsOwned(self) then |
| 1042 GameTooltip:Hide() | 1073 GameTooltip:Hide() |
| 1043 end | 1074 end |
| 1044 end | 1075 end |
| 1045 | 1076 |
| 1046 function VeneerArtifactButtonMixin:OnClick(button, down) | 1077 function Artifact:OnClick(button, down) |
| 1047 if self.isEquipped then | 1078 if self.isEquipped then |
| 1048 SocketInventoryItem(16) | 1079 SocketInventoryItem(16) |
| 1049 else | 1080 else |
| 1050 if IsShiftKeyDown() then | 1081 if IsShiftKeyDown() then |
| 1051 SocketContainerItem(self.containerID, self.slotID) | 1082 SocketContainerItem(self.containerID, self.slotID) |
