annotate Modules/ArtifactPower.lua @ 133:86621c60512b v7.3.2-20171222

- Fixed AP calc tooltip appearing while hidden - Fixed PaperDoll relic tooltips missing nether crucible info
author Nenue
date Fri, 22 Dec 2017 20:36:40 -0500
parents 15a7f27b11e6
children 4979b5cca6de
rev   line source
Nenue@97 1 -- Veneer
Nenue@97 2 -- ArtifactPower.lua
Nenue@97 3 -- Created: 1/15/2017 11:44 PM
Nenue@97 4 -- %file-revision%
Nenue@97 5 --
Nenue@97 6
Nenue@97 7 local print = DEVIAN_WORKSPACE and function(...) print('VnAP', ...) end or nop
Nenue@97 8 VeneerArtifactPowerMixin = {
Nenue@99 9 numItems = 0,
Nenue@99 10 Tokens = {},
Nenue@101 11 cache = {},
Nenue@101 12 fishingCache = {},
Nenue@101 13 scanQueue = {},
Nenue@119 14 worldQuestAP = 0,
Nenue@119 15 worldQuestItems = {},
Nenue@99 16 ItemButtons = {},
Nenue@121 17 anchorGroup = 'TOP',
Nenue@122 18 anchorPoint = 'TOPLEFT',
Nenue@116 19 anchorPriority = 3,
Nenue@121 20 anchorFrom = 'BOTTOMLEFT',
Nenue@115 21 moduleName = 'Artifactor',
Nenue@115 22 HideCombat = true
Nenue@97 23 }
Nenue@122 24
Nenue@122 25 VeneerArtifactButtonMixin = {}
Nenue@122 26 local Artifact = VeneerArtifactButtonMixin
Nenue@122 27
Nenue@101 28 local defaultSettings = {
Nenue@101 29 firstUse = true,
Nenue@101 30 autoHide = true,
Nenue@101 31 }
Nenue@116 32 local Module = VeneerArtifactPowerMixin
Nenue@122 33 local BAGS_TO_SCAN = {BACKPACK_CONTAINER}
Nenue@97 34 local TOOLTIP_NAME = 'VeneerAPScanner'
Nenue@123 35 local XP_INSET = 1
Nenue@123 36 local XP_WIDTH = 4
Nick@111 37 local FISHING_MAX_TRAITS = 24
Nenue@116 38 local WEAPON_MAX_TRAITS = 92
Nenue@116 39 local FRAME_PADDING = 4
Nenue@116 40 local EQUIPPED_SIZE = 64
Nick@111 41 local BUTTON_SIZE = 48
Nenue@99 42 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'}
Nenue@99 43 local BAG_FRAMES = {'ContainerFrame1'}
Nenue@129 44 local BANK_FRAMES = {'BankFrame' }
Nenue@129 45 local ZONE_ID_ARGUS = 1184
Nenue@129 46 local ZONE_ID_BROKEN_ISLE = 1007
Nenue@99 47
Nenue@116 48 function Module:OnLoad()
Nenue@97 49 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan
Nenue@97 50 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity
Nenue@122 51 self:RegisterEvent('BANKFRAME_OPENED') -- bank info available
Nenue@122 52 self:RegisterEvent('BANKFRAME_CLOSED') --
Nenue@122 53 self:RegisterEvent('ARTIFACT_UPDATE') -- visible data change
Nenue@122 54 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- xp for equipped artifact
Nenue@122 55 self:RegisterEvent('PLAYER_REGEN_ENABLED') -- combat
Nenue@122 56 self:RegisterEvent('PLAYER_REGEN_DISABLED') --
Nenue@122 57 self:RegisterEvent('PLAYER_ENTERING_WORLD') -- zone/instance transfer
Nick@108 58 self:RegisterEvent('ITEM_LOCK_CHANGED') -- use to clear bag slot cache data
Nenue@115 59 Veneer:AddHandler(self)
Nenue@97 60 SLASH_VENEER_AP1 = "/vap"
Nenue@97 61 SLASH_VENEER_AP2 = "/veneerap"
Nenue@98 62 SlashCmdList.VENEER_AP = function(arg)
Nenue@98 63 if arg == 'fishing' then
Nenue@98 64 if VeneerData.ArtifactPower.EnableFishing then
Nenue@98 65 VeneerData.ArtifactPower.EnableFishing = nil
Nenue@98 66 else
Nenue@98 67 VeneerData.ArtifactPower.EnableFishing = true
Nenue@98 68 end
Nenue@98 69 self:Print('Show Underlight Angler:', (VeneerData.ArtifactPower.EnableFishing and 'ON' or 'OFF'))
Nenue@98 70 self:Update()
Nick@108 71 elseif arg == 'reset' then
Nick@108 72 if self.db then
Nick@108 73 table.wipe(self.db.cache)
Nick@108 74 table.wipe(self.db.fishingCache)
Nick@108 75 end
Nick@108 76 self:Print('Cache data reset.')
Nick@108 77 self:Update()
Nenue@122 78 elseif arg:match('item') then
Nenue@122 79 print('name', arg:match("^item (%S.+)"))
Nenue@122 80 print('num', arg:match("Hitem:(%d+)"))
Nenue@122 81 local linkOrID = arg:match("item:(%d+)") or arg:match("^item (%S+)")
Nenue@122 82 if linkOrID then
Nenue@122 83 local name, etc = GetItemInfo(linkOrID)
Nenue@122 84 end
Nenue@122 85
Nenue@98 86 else
Nenue@122 87
Nenue@98 88 self:Show()
Nenue@98 89 end
Nenue@97 90 end
Nenue@97 91
Nenue@97 92 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate')
Nenue@99 93
Nenue@97 94
Nenue@97 95 end
Nick@108 96 local ShortNumberString = function (value)
Nenue@122 97 if value >= 1000000000 then
Nenue@122 98
Nenue@122 99 return tostring(floor(value/10000000)/100) .. 'B'
Nenue@122 100 elseif value >= 1000000 then
Nenue@116 101 return tostring(floor(value/100000)/10) .. 'M'
Nenue@116 102 elseif value >= 100000 then
Nick@108 103 return tostring(floor(value/1000)) .. 'k'
Nick@108 104 elseif value >= 1000 then
Nick@108 105 return tostring(floor(value/100)/10) .. 'k'
Nick@108 106 else
Nick@108 107 return value
Nick@108 108 end
Nick@108 109 end
Nenue@97 110
Nenue@102 111
Nenue@102 112 local IsBagnonOpen = function()
Nenue@102 113 return ((BagnonFramebank and BagnonFramebank:IsShown()) or (BagnonFrameinventory and BagnonFrameinventory:IsShown()))
Nenue@102 114 end
Nenue@99 115 local addonCompatibility = {
Nenue@99 116 ['Bagnon'] = {
Nenue@99 117 BagFrames = {'BagnonFrameinventory'},
Nenue@99 118 BankFrames = {'BagnonFramebank'},
Nenue@102 119 FrameMethods = {
Nenue@103 120 ['Hide'] = IsBagnonOpen,
Nenue@103 121 ['Show'] = IsBagnonOpen
Nenue@102 122 },
Nenue@103 123 PostHooks = {},
Nenue@99 124 MethodClass = 'Bagnon',
Nenue@102 125 MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'},
Nenue@102 126
Nenue@99 127 }
Nenue@97 128 }
Nenue@97 129
Nenue@103 130
Nenue@103 131
Nenue@103 132 local queued_hooks = {}
Nenue@103 133 local function CreateHook(...)
Nenue@103 134 if select('#', ...) >= 2 then
Nenue@103 135 tinsert(queued_hooks, {...})
Nenue@103 136 end
Nenue@103 137 if not InCombatLockdown() then
Nenue@103 138 local info = tremove(queued_hooks)
Nenue@103 139 while info do
Nick@111 140 --[[local oFunc = tremove(info, #info)
Nick@111 141 local args = info
Nick@111 142
Nick@111 143 local func = function(...)
Nick@111 144 print('|cFFFF0088Callback:|r', unpack(args))
Nick@111 145
Nick@111 146 oFunc(...)
Nick@111 147 end
Nick@111 148 print('hooking', unpack(info), oFunc, func)
Nick@111 149 hooksecurefunc(unpack(info), func)
Nick@111 150 --]]
Nenue@103 151 hooksecurefunc(unpack(info))
Nenue@103 152 info = tremove(queued_hooks)
Nenue@103 153 end
Nenue@103 154
Nenue@103 155 end
Nenue@103 156 end
Nenue@103 157
Nenue@102 158 local function AddFrameHooks(frame, args)
Nenue@102 159 for funcName, func in pairs(args.FrameMethods) do
Nenue@102 160 print('binding', frame:GetName(), funcName, 'to', tostring(func))
Nenue@103 161 CreateHook(frame, funcName, function()
Nick@111 162 print(frame:GetName(), funcName, 'hook')
Nenue@103 163 VeneerArtifactPower:TryToShow()
Nenue@103 164 end)
Nenue@102 165 end
Nenue@102 166 end
Nenue@102 167 local PENDING_HOOKS = {}
Nenue@119 168 local guid = UnitGUID('player')
Nenue@102 169
Nenue@102 170 local function RegisterInventoryFrame(name, listType, args)
Nenue@102 171 print('register', name, 'as inventory frame type =', (listType == BAG_FRAMES) and 'bags' or 'bank')
Nenue@102 172 tinsert(FRAME_LIST, name)
Nenue@102 173 tinsert(listType, name)
Nenue@102 174 if _G[name] then
Nenue@102 175 AddFrameHooks(_G[name], args)
Nenue@102 176 else
Nenue@102 177 PENDING_HOOKS[name] = args
Nenue@102 178 end
Nenue@102 179 end
Nenue@102 180
Nenue@116 181 function Module:Setup()
Nenue@97 182 print(self:GetName()..':Setup()')
Nenue@119 183 guid = UnitGUID('player')
Nenue@97 184 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings
Nenue@101 185 self.db = VeneerData.ArtifactPower
Nenue@101 186 self.db[guid] = self.db[guid] or {}
Nenue@101 187 self.db.cache = self.db.cache or {}
Nenue@101 188 self.db.fishingCache = self.db.fishingCache or {}
Nenue@101 189
Nenue@101 190 for i, data in pairs(self.cache) do
Nenue@101 191 -- bring in anything found before player data is active
Nenue@101 192 self.db.cache[i] = data
Nenue@101 193 end
Nenue@101 194 for i, data in pairs(self.fishingCache) do
Nenue@101 195 self.db.fishingCache[i] = data
Nenue@101 196 end
Nenue@101 197
Nenue@101 198 self.profile = self.db[guid]
Nick@108 199 self.profile.cache = self.profile.cache or {}
Nick@108 200 self.profile.cache.bagItems = self.profile.cache.bagItems or {}
Nick@108 201 self.profile.cache.bags = self.profile.cache.bags or {}
Nick@108 202 self.profile.cache.fishing = self.profile.cache.fishing or {}
Nick@108 203 self.profile.cache.items = self.profile.cache.items or {}
Nenue@97 204 self.profile.bagslots = self.profile.bagslots or {}
Nenue@97 205 self.profile.artifacts = self.profile.artifacts or {}
Nenue@97 206 self.updateSummary = true
Nick@108 207 self.cache = self.profile.cache
Nenue@97 208
Nenue@101 209 VeneerArtifactPowerTimer:SetScript('OnUpdate', function()
Nenue@101 210 self:OnUpdate()
Nenue@101 211 end)
Nenue@101 212
Nenue@99 213 local DoTryToShow = function()
Nick@111 214
Nenue@99 215 self:TryToShow()
Nenue@99 216 end
Nenue@103 217 CreateHook("OpenBackpack", DoTryToShow)
Nenue@103 218 CreateHook("CloseBackpack", DoTryToShow)
Nenue@99 219
Nenue@97 220 -- Bagnon compatibility
Nenue@97 221 -- todo: ArkInventory, Elv, etc
Nenue@99 222 for addon, args in pairs(addonCompatibility) do
Nenue@99 223 if IsAddOnLoaded(addon) then
Nenue@102 224
Nenue@99 225 for _, name in ipairs(args.BagFrames) do
Nenue@102 226 RegisterInventoryFrame(name, BAG_FRAMES, args)
Nenue@99 227 end
Nenue@99 228 for _, name in ipairs(args.BankFrames) do
Nenue@102 229 RegisterInventoryFrame(name, BANK_FRAMES, args)
Nenue@99 230 end
Nenue@102 231
Nenue@102 232 -- should only specify non-secure functions in this table
Nenue@99 233 for _, name in ipairs(args.PostHooks) do
Nenue@99 234 local oFunc = _G[name]
Nenue@103 235 print('hook entry', name, tostring(oFunc))
Nenue@103 236 CreateHook(name, function(...)
Nenue@103 237 print('|cFFFF0088' .. name .. '|r', ..., 'original', tostring(oFunc))
Nenue@99 238 oFunc(...)
Nenue@99 239 self:TryToShow()
Nenue@103 240 end)
Nenue@99 241 end
Nenue@99 242 local frame = _G[args.MethodClass]
Nenue@99 243 if frame then
Nenue@103 244 print()
Nenue@99 245 for _, name in ipairs(args.MethodHooks) do
Nenue@103 246 CreateHook(frame, name, DoTryToShow)
Nenue@99 247 end
Nenue@97 248 end
Nenue@97 249 end
Nenue@97 250 end
Nenue@101 251
Nenue@101 252 if self.db.firstUse then
Nenue@101 253 self.db.firstUse = nil
Nenue@101 254
Nenue@101 255 end
Nenue@99 256 end
Nenue@97 257
Nenue@97 258 local UNDERLIGHT_ANGLER_ID = 133755
Nenue@97 259
Nenue@116 260 function Module:ResetCache()
Nick@111 261 table.wipe(self.cache.items)
Nick@111 262 table.wipe(self.cache.fishing)
Nick@111 263 table.wipe(self.cache.bags)
Nick@111 264 table.wipe(self.cache.bagItems)
Nick@111 265 self:ScanAllBags()
Nick@111 266 end
Nick@111 267
Nenue@116 268 function Module:QueueBag(containerID)
Nenue@97 269 containerID = tonumber(containerID)
Nenue@97 270 if not containerID then
Nenue@97 271 return
Nenue@97 272 end
Nenue@97 273
Nenue@97 274 if not tContains(BAGS_TO_SCAN, containerID) then
Nenue@97 275 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line')
Nenue@97 276 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID
Nenue@97 277 end
Nenue@97 278 end
Nenue@97 279
Nenue@116 280 function Module:Reanchor()
Nenue@99 281 if Veneer then
Nenue@99 282 Veneer:DynamicReanchor()
Nenue@99 283 end
Nenue@99 284 end
Nenue@99 285
Nenue@116 286 function Module:OnShow()
Nenue@99 287 print('|cFFFFFF00OnShow()|r')
Nenue@102 288
Nenue@102 289 for name, args in pairs(PENDING_HOOKS) do
Nenue@102 290 if _G[name] then
Nenue@102 291 AddFrameHooks(_G[name], args)
Nenue@102 292 PENDING_HOOKS[name] = nil
Nenue@102 293 end
Nenue@102 294 end
Nenue@102 295
Nenue@119 296 self:UpdateWorldQuestsAP()
Nenue@119 297 self:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@119 298 self.enabled = true
Nenue@102 299
Nenue@99 300 self:ScanAllBags()
Nenue@99 301 self:Reanchor()
Nenue@97 302 end
Nenue@116 303 function Module:OnHide()
Nick@111 304 print('|cFF88FF00OnHide()|r', debugstack())
Nenue@119 305 self:UnregisterEvent('QUEST_LOG_UPDATE')
Nenue@99 306 self:Reanchor()
Nenue@97 307 end
Nenue@116 308 function Module:OnEnter()
Nenue@97 309
Nenue@97 310 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
Nenue@97 311
Nenue@99 312
Nenue@97 313 GameTooltip:AddLine(self.bagAP)
Nenue@97 314 GameTooltip:AddLine(self.bankAP)
Nenue@97 315
Nenue@97 316 end
Nenue@97 317
Nenue@116 318 function Module:TryToShow()
Nenue@99 319
Nenue@125 320 --print('|cFFFFFF00TryToShow()')
Nenue@99 321
Nenue@99 322 if not InCombatLockdown() then
Nenue@99 323 for _, name in ipairs(FRAME_LIST) do
Nenue@125 324 --print('test:', name, (_G[name] and _G[name]:IsShown()))
Nick@111 325 if _G[name] and _G[name]:IsVisible() then
Nenue@99 326 if self:IsShown() then
Nenue@99 327 self:Update()
Nenue@99 328 else
Nenue@99 329 self:Show()
Nenue@99 330 end
Nenue@99 331 return
Nenue@99 332 end
Nenue@99 333 end
Nenue@99 334 end
Nenue@99 335
Nenue@125 336 --print('failed tests')
Nenue@99 337 self:Hide()
Nenue@99 338 end
Nenue@99 339
Nenue@99 340
Nenue@116 341 function Module:OnEvent(event, ...)
Nenue@125 342 --print('|cFF00FF88OnEvent()', event, ...)
Nenue@99 343 if event == 'PLAYER_ENTERING_WORLD' then
Nenue@99 344 self:TryToShow()
Nenue@99 345 elseif event == 'BAG_UPDATE' then
Nenue@97 346 local containerID = ...
Nick@108 347
Nick@108 348
Nenue@97 349 self:QueueBag(containerID)
Nick@108 350 elseif event == 'ITEM_LOCK_CHANGED' then
Nick@108 351
Nick@108 352 local containerID, slotID = ...
Nick@108 353
Nick@108 354 if self.cache.bags[containerID] and self.cache.bags[containerID][slotID] then
Nick@108 355 self.cache.bags[containerID][slotID] = nil
Nick@108 356 self.cache.fishing[containerID][slotID] = nil
Nick@108 357 end
Nick@108 358
Nick@108 359
Nenue@97 360 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then
Nenue@99 361 self:ScanAllBags()
Nenue@97 362 elseif event == 'BAG_UPDATE_DELAYED' then
Nenue@99 363 if not self.firstHit then
Nenue@122 364 -- prevent double call from login
Nenue@99 365 self.firstHit = true
Nenue@99 366 else
Nenue@99 367 self:ScanAllBags()
Nenue@99 368 end
Nenue@97 369 elseif event == 'BANKFRAME_OPENED' then
Nenue@97 370 self.bankAccess = true
Nenue@99 371 self:ScanAllBags()
Nenue@97 372 elseif event == 'BANKFRAME_CLOSED' then
Nenue@99 373 self.bankAccess = nil
Nenue@97 374 elseif event == 'ARTIFACT_UPDATE' then
Nenue@98 375 local newItem = ...
Nenue@98 376 if newItem then
Nenue@98 377 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo()
Nenue@122 378 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@122 379 --self:ScanAllBags(self.bankAccess)
Nenue@98 380 end
Nenue@125 381 self:UpdateArtifactButtons()
Nenue@98 382 elseif event == 'ARTIFACT_XP_UPDATE' then
Nenue@98 383 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo()
Nenue@122 384 self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@122 385 --self:ScanAllBags(self.bankAccess)
Nenue@125 386 self:UpdateArtifactButtons()
Nenue@97 387 elseif event == 'PLAYER_REGEN_ENABLED' then
Nenue@103 388
Nenue@103 389 if self.queuedScan then
Nenue@103 390 self:ScanAllBags(self.backAccess)
Nenue@103 391 else
Nenue@103 392 self:TryToShow()
Nenue@97 393 end
Nenue@97 394
Nenue@103 395 if #queued_hooks >= 1 then
Nenue@103 396 CreateHook()
Nenue@103 397 end
Nenue@119 398 elseif event == 'QUEST_LOG_UPDATE' then
Nenue@119 399 self:UpdateWorldQuestsAP()
Nenue@97 400 elseif event == 'PLAYER_REGEN_DISABLED' then
Nenue@97 401 self:Hide()
Nenue@97 402 end
Nenue@97 403 end
Nenue@97 404
Nenue@133 405 local hasShownHeaderTip
Nenue@116 406 function Module:OnUpdate()
Nenue@101 407 if #self.scanQueue >= 1 then
Nenue@101 408 local scanInfo = tremove(self.scanQueue, 1)
Nick@111 409 end
Nick@111 410 if IsShiftKeyDown() then
Nick@111 411 self.Refresh:Show()
Nick@111 412 else
Nick@111 413 self.Refresh:Hide()
Nick@111 414 end
Nenue@101 415
Nenue@133 416 if self.SummaryHeader:IsMouseOver() and self:IsShown() then
Nenue@133 417 if not hasShownHeaderTip then
Nenue@133 418 hasShownHeaderTip = true
Nenue@133 419 GameTooltip:SetOwner(self, 'ANCHOR_BOTTOM')
Nenue@133 420 GameTooltip:AddLine("World Quests")
Nenue@133 421
Nenue@133 422 for zone, data in pairs(self.apQuests) do
Nenue@133 423
Nenue@133 424 if #data >= 1 then
Nenue@133 425 GameTooltip:AddLine(zone)
Nenue@133 426 for i, quest in ipairs(data) do
Nenue@133 427
Nenue@133 428 if IsQuestComplete(quest[1]) then
Nenue@133 429 GameTooltip:AddDoubleLine(quest[2], ShortNumberString(quest[3]), 0.5,0.5,0.5, 0.5,0.5,0.5)
Nenue@133 430 else
Nenue@133 431 GameTooltip:AddDoubleLine(quest[2], ShortNumberString(quest[3]), 1,1,1, 0,1,0)
Nenue@133 432
Nenue@133 433 end
Nenue@133 434
Nenue@133 435 end
Nenue@133 436 end
Nenue@133 437
Nenue@133 438
Nenue@133 439 end
Nenue@133 440
Nenue@133 441 GameTooltip:Show()
Nenue@133 442 end
Nenue@133 443 else
Nenue@133 444 if GameTooltip:IsOwned(self) then
Nenue@133 445 hasShownHeaderTip = nil
Nenue@133 446 GameTooltip:Hide()
Nenue@133 447 end
Nenue@133 448
Nenue@133 449 end
Nenue@133 450
Nenue@133 451
Nenue@101 452 end
Nenue@101 453
Nenue@119 454 function Module:OnMouseDown(button)
Nenue@97 455 self.enabled = nil
Nenue@119 456 if button == 'RightButton' then
Nenue@119 457 self:Hide()
Nenue@119 458 end
Nenue@119 459
Nenue@97 460 end
Nenue@97 461
Nenue@116 462 function Module:Update()
Nenue@97 463 if not self:IsShown() then
Nenue@99 464 print('|cFFFF4400Update()|r')
Nenue@97 465 return
Nenue@97 466 end
Nenue@122 467 print('|cFFFFFF00pdate()|r')
Nenue@122 468
Nenue@122 469 local numButtons = 0
Nenue@122 470 local contentsHeight = 16
Nenue@122 471 local contentsWidth = 400
Nenue@122 472 if self.profile.knowledgeMultiplier then
Nenue@122 473 local artifactsWidth = self:UpdateArtifactButtons()
Nenue@122 474
Nenue@122 475 if artifactsWidth ~= 0 then
Nenue@122 476 contentsHeight = contentsHeight + 64
Nenue@122 477 end
Nenue@122 478
Nenue@122 479 contentsWidth = max(contentsWidth, min(artifactsWidth, 400))
Nenue@122 480
Nenue@122 481 local itemsWidth, itemsHeight = self:UpdateItemButtons()
Nenue@122 482 contentsHeight = contentsHeight + itemsHeight
Nenue@122 483 contentsWidth = max(contentsWidth, itemsWidth)
Nenue@122 484 end
Nenue@122 485
Nenue@122 486
Nenue@97 487
Nenue@97 488 local bankText, bagText
Nenue@101 489 if not self.profile.knowledgeMultiplier then
Nenue@101 490 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.'
Nenue@101 491 elseif not (self.bankAP and self.bagAP) then
Nenue@97 492 bankText = '|cFFFF0000Open bank frame to count all AP|r '
Nenue@97 493 else
Nick@111 494
Nick@111 495 if self.bagAP and (self.bagAP > 0) then
Nick@111 496 bankText = 'Inventory: |cFFFFFFFF' .. ShortNumberString(self.bagAP) .. '|r'
Nick@111 497 end
Nick@111 498 if self.bankAP and (self.bankAP > 0) then
Nick@111 499 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..ShortNumberString(self.bankAP)..' banked|r'
Nick@111 500 end
Nick@111 501 if self.fishingAP and self.fishingAP > 0 then
Nick@111 502 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFF0088FF' .. ShortNumberString(self.fishingAP) .. ' fishing|r'
Nick@111 503 end
Nick@111 504 end
Nick@111 505
Nenue@119 506 if self.worldQuestAP then
Nenue@119 507 bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. ''
Nenue@119 508 end
Nick@111 509
Nenue@129 510 if self.argusAP then
Nenue@129 511 bankText = (bankText and (bankText .. '\n') or '') .. '|cFF88FF00Argus WQ:|r |cFFFFFFFF' .. ShortNumberString(self.argusAP) .. ''
Nenue@129 512 end
Nenue@129 513
Nenue@129 514
Nenue@99 515
Nenue@97 516 self.SummaryHeader:SetText(bankText)
Nenue@122 517 if not self.lastButton then
Nenue@122 518 contentsHeight = contentsHeight + self.SummaryHeader:GetHeight()
Nenue@101 519 end
Nenue@101 520
Nenue@101 521
Nick@111 522 if not self.hasArtifacts then
Nick@111 523 self:SetShown(false)
Nick@111 524 end
Nick@111 525
Nenue@101 526
Nick@108 527 self:SetWidth(contentsWidth)
Nick@108 528 self:SetHeight(contentsHeight)
Nenue@101 529 self:Reanchor()
Nenue@101 530 end
Nenue@101 531
Nenue@133 532 Module.apQuests = {}
Nenue@129 533 function Module:GetContinentAP(mapAreaID)
Nenue@119 534
Nenue@129 535 for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do
Nenue@129 536 local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex);
Nenue@119 537 --print(zoneMapID, zoneName)
Nenue@119 538 if zoneDepth <= 1 then -- Exclude subzones
Nenue@129 539 local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID, (mapAreaID == 1184) and 1 or nil);
Nenue@119 540
Nenue@133 541 self.apQuests[zoneName] = self.apQuests[zoneName] or {}
Nenue@133 542 wipe(self.apQuests[zoneName])
Nenue@133 543
Nenue@119 544 if taskInfo then
Nenue@119 545 for i, info in ipairs(taskInfo) do
Nenue@119 546 local questID = info.questId
Nenue@119 547
Nenue@119 548 local questTitle, factionID, capped = C_TaskQuest.GetQuestInfoByQuestID(questID)
Nenue@133 549 if HaveQuestRewardData(questID) then
Nenue@119 550
Nenue@119 551
Nenue@131 552 for i = 1, GetNumQuestLogRewards(questID) or 0 do
Nenue@119 553 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@119 554 if IsArtifactPowerItem(itemID) then
Nenue@133 555
Nenue@133 556 print(questTitle, HaveQuestRewardData(questID))
Nenue@119 557 local _, link = GetItemInfo(itemID)
Nenue@119 558 if link then
Nenue@119 559 local ap = self:GetItemAP(itemID, link)
Nenue@119 560 --print('ap =', ap)
Nenue@119 561 if ap then
Nenue@133 562
Nenue@133 563 if not IsQuestComplete(questID) then
Nenue@133 564 self.worldQuestAP = self.worldQuestAP + ap
Nenue@133 565 if mapAreaID == ZONE_ID_ARGUS then
Nenue@133 566 self.argusAP = self.argusAP + ap
Nenue@133 567 end
Nenue@129 568 end
Nenue@119 569
Nenue@133 570
Nenue@133 571 tinsert(self.apQuests[zoneName], {questID, questTitle, ap})
Nenue@133 572
Nenue@133 573
Nenue@119 574 end
Nenue@119 575
Nenue@119 576 self.worldQuestItems[itemID] = (self.worldQuestItems[itemID] or 0) + 1
Nenue@119 577 end
Nenue@119 578
Nenue@119 579 --print(self.worldQuestAP)
Nenue@119 580 end
Nenue@119 581
Nenue@119 582 end
Nenue@119 583
Nenue@119 584
Nenue@119 585 else
Nenue@119 586 C_TaskQuest.RequestPreloadRewardData(questID);
Nenue@119 587 self.waitingForQuestRewardData = true
Nenue@119 588 end
Nenue@119 589 end
Nenue@119 590 end
Nenue@119 591 end
Nenue@119 592 end
Nenue@129 593
Nenue@129 594 end
Nenue@129 595
Nenue@129 596 function Module:UpdateWorldQuestsAP()
Nenue@129 597 self.waitingForQuestRewardData = false
Nenue@129 598 self.worldQuestAP = 0
Nenue@129 599 self.argusAP = 0
Nenue@129 600 wipe(self.worldQuestItems)
Nenue@133 601 wipe(self.apQuests)
Nenue@129 602 self:GetContinentAP(ZONE_ID_BROKEN_ISLE)
Nenue@129 603 self:GetContinentAP(ZONE_ID_ARGUS)
Nenue@129 604
Nenue@119 605 end
Nenue@119 606
Nenue@116 607 function Module:UpdateArtifactButtons()
Nenue@101 608
Nenue@97 609 -- Artifact icons, in no particular order
Nenue@99 610 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo()
Nenue@122 611 self.lastButton = nil
Nick@111 612 self.canAddAP = nil
Nick@111 613 self.canAddFishingAP = nil
Nick@111 614 local hasArtifacts
Nenue@97 615 local numButtons = 0
Nenue@99 616 local lastFrame = self
Nenue@99 617 local fishingID, fishingData
Nenue@98 618 local index, button
Nenue@116 619 local equipped =self.profile.artifacts[self.equippedID]
Nenue@116 620 local buttonsWidth = 0
Nenue@116 621 if equipped then
Nenue@116 622 numButtons = numButtons + 1
Nenue@116 623 button = self.Artifact[numButtons]
Nenue@116 624 button.relativeFrame = self
Nenue@125 625 button:SetItem(self.equippedID, equipped, numButtons, true, nil)
Nenue@125 626
Nenue@122 627 if self.equippedID ~= button.itemID then
Nenue@125 628
Nenue@122 629 hasArtifacts = true
Nenue@122 630 end
Nenue@122 631 lastFrame = button
Nenue@116 632 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2)
Nenue@116 633 end
Nenue@97 634 for itemID, artifact in pairs(self.profile.artifacts) do
Nenue@116 635 if (itemID == UNDERLIGHT_ANGLER_ID) then
Nenue@116 636 -- only add if we have fishing AP items and it's not being shown in the equipped slot
Nenue@116 637 if VeneerData.ArtifactPower.EnableFishing and (itemID ~= self.equippedID) then
Nenue@98 638 fishingID = itemID
Nenue@98 639 fishingData = artifact
Nenue@98 640 end
Nenue@97 641
Nick@111 642 if artifact.level < FISHING_MAX_TRAITS then
Nick@111 643 if itemID == self.equippedID then
Nick@111 644 self.canAddFishingAP = true
Nick@111 645 end
Nick@111 646 end
Nenue@98 647 else
Nick@111 648 if artifact.level < WEAPON_MAX_TRAITS then
Nick@111 649 if itemID == self.equippedID then
Nick@111 650 self.canAddAP = true
Nenue@116 651 else
Nenue@116 652
Nenue@116 653 hasArtifacts = true
Nenue@116 654 numButtons = numButtons + 1
Nenue@116 655 button = self.Artifact[numButtons]
Nenue@116 656 button.relativeFrame = lastFrame
Nenue@125 657 button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
Nenue@122 658 lastFrame = button
Nenue@116 659 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING
Nick@111 660 end
Nick@108 661 end
Nenue@97 662 end
Nick@111 663 end
Nenue@97 664
Nenue@122 665 self.lastButton = lastFrame
Nenue@122 666
Nenue@97 667
Nick@108 668 if fishingData and (self.fishingAP and self.fishingAP > 0) then
Nenue@98 669 numButtons = numButtons + 1
Nick@111 670 hasArtifacts = true
Nenue@99 671 local button = self.Artifact[numButtons]
Nenue@99 672 button.relativeFrame = lastFrame
Nick@111 673 button.isFishing = true
Nenue@122 674 button:SetItem(fishingID, fishingData, numButtons, self.equippedID == fishingID)
Nenue@122 675 self.lastButton = button
Nenue@98 676 end
Nenue@97 677
Nick@111 678 self.hasArtifacts = hasArtifacts
Nenue@99 679 for i = numButtons+ 1, #self.Artifact do
Nenue@97 680 print('hide', i)
Nenue@97 681 self.Artifact[i]:Hide()
Nenue@97 682 end
Nenue@97 683
Nenue@122 684 self.SummaryHeader:ClearAllPoints()
Nenue@122 685 if self.lastButton then
Nenue@122 686 self.SummaryHeader:SetPoint('TOPLEFT', self.lastButton, 'TOPRIGHT', 4, -2)
Nenue@122 687 else
Nenue@122 688 self.SummaryHeader:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 4, 4)
Nenue@122 689 end
Nenue@122 690
Nenue@122 691
Nick@111 692
Nenue@116 693 return buttonsWidth
Nenue@97 694 end
Nenue@97 695
Nenue@99 696
Nenue@116 697 function Module:UpdateItemButtons()
Nenue@99 698 print('|cFF00FFFFUpdateItemButtons()|r')
Nick@111 699
Nick@111 700 local apType
Nick@111 701 if self.canAddFishingAP then
Nick@111 702 apType = true
Nick@111 703 elseif not self.canAddAP then
Nick@111 704 for index, button in ipairs(self.Tokens) do
Nick@111 705 button:Hide()
Nick@111 706 end
Nick@111 707 return 0, 0
Nick@111 708 end
Nick@111 709
Nick@111 710
Nenue@99 711 local lastFrame, upFrame
Nenue@99 712 local numButtons = 0
Nenue@101 713 local buttonsHeight = 0
Nick@108 714 local buttonsWidth = 0
Nick@111 715
Nenue@99 716 for index, button in ipairs(self.Tokens) do
Nick@111 717 if (button.numItems >= 1) and (button.isFishingAP == apType) then
Nenue@99 718 if button.itemName then
Nenue@99 719 self:SetItemAction(button)
Nenue@99 720 end
Nenue@99 721
Nenue@99 722 button:ClearAllPoints()
Nenue@99 723 numButtons = numButtons + 1
Nick@111 724 local col = mod(numButtons,8)
Nenue@99 725 print(index, button:GetID(), button.Icon:GetTexture())
Nenue@99 726 if numButtons == 1 then
Nenue@101 727 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76)
Nenue@99 728 upFrame = button
Nenue@101 729 buttonsHeight = 52
Nenue@99 730 else
Nick@108 731 if col == 1 then
Nick@108 732 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2)
Nick@108 733 upFrame = button
Nick@108 734 buttonsHeight = buttonsHeight + 52
Nick@108 735
Nick@108 736 else
Nick@108 737 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0)
Nick@108 738
Nick@108 739 end
Nenue@99 740 end
Nick@111 741
Nenue@99 742 button.Count:SetText(button.numItems)
Nenue@99 743 lastFrame = button
Nenue@99 744 button:Show()
Nenue@99 745 else
Nenue@99 746 button:Hide()
Nenue@99 747 end
Nick@111 748 buttonsWidth = min(numButtons, 8) * (BUTTON_SIZE)
Nick@111 749 end
Nick@111 750
Nick@111 751
Nick@111 752
Nick@111 753 if buttonsWidth ~= 0 then
Nick@111 754 buttonsWidth = buttonsWidth + 8+ ((min(numButtons, 8)-1)*2)
Nenue@99 755 end
Nenue@99 756
Nenue@101 757
Nenue@101 758
Nick@108 759 return buttonsWidth, buttonsHeight
Nenue@99 760 end
Nenue@99 761
Nenue@116 762 function Module:SetItemAction(button, name)
Nenue@99 763 name = name or self.itemName
Nenue@99 764 if InCombatLockdown() then
Nenue@99 765 self.itemName = name
Nenue@99 766 return
Nenue@99 767 else
Nenue@99 768 button:SetAttribute('*type*','item')
Nenue@99 769 button:SetAttribute('*item*', name)
Nenue@99 770 end
Nenue@99 771 end
Nenue@99 772
Nenue@116 773 function Module:GetItemButton(itemID, texture, itemAP, fishing)
Nenue@99 774 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP)
Nenue@99 775 local button = self.ItemButtons[itemID]
Nenue@101 776
Nenue@99 777 if not button then
Nenue@99 778 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton')
Nenue@101 779 button.baseAP = itemAP
Nenue@101 780
Nenue@99 781 button:SetPushedTexture([[Interface\Buttons\UI-Quickslot-Depress]])
Nenue@99 782 button:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]],"ADD")
Nenue@99 783 button:SetID(itemID)
Nenue@99 784 button.numItems = 0
Nenue@99 785 button.Icon:SetTexture(texture)
Nenue@99 786 button:RegisterForClicks("AnyUp")
Nick@111 787 button.isFishingAP = fishing
Nenue@99 788 self:SetItemAction(button, GetItemInfo(itemID))
Nenue@99 789
Nenue@99 790 print(' created')
Nenue@99 791 self.ItemButtons[itemID] = button
Nenue@99 792 self.numItems = self.numItems + 1
Nenue@99 793 end
Nenue@99 794
Nenue@116 795 button.Label:SetText(ShortNumberString(itemAP))
Nenue@101 796
Nenue@99 797 button.numItems = button.numItems + 1
Nenue@99 798 return button
Nenue@99 799 end
Nenue@99 800
Nenue@116 801 function Module:GetItemAP(itemID, itemLink, bagData)
Nick@108 802 if not self.cache.items[itemID] then
Nenue@101 803
Nick@111 804 print('doing tooltip scan', itemLink, itemID)
Nenue@101 805 self.tooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@101 806 self.tooltip:SetHyperlink(itemLink)
Nenue@101 807 self.tooltip:Show()
Nenue@101 808 local numLines = self.tooltip:NumLines()
Nenue@101 809 if numLines >= 3 then
Nenue@101 810 for i = 3, numLines do
Nenue@101 811 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText()
Nick@111 812 if text then
Nick@111 813
Nick@111 814 text = text:lower():gsub(',', '')
Nenue@116 815
Nick@111 816 if text:match('equipped artifact') then
Nick@111 817 print(itemLink, '-', tonumber(text))
Nenue@116 818
Nenue@116 819 local itemAP = text:match('[%d%.]+')
Nick@111 820 if itemAP then
Nenue@116 821 -- tokens > 1M are described as '%f million'
Nenue@116 822 if text:match("million") then
Nenue@116 823 itemAP = tonumber(itemAP) * 1000000
Nenue@129 824 elseif text:match("billion") then
Nenue@129 825 itemAP = tonumber(itemAP) * 1000000000
Nenue@116 826 end
Nenue@116 827
Nick@111 828 itemAP = itemAP
Nick@111 829 self.cache.items[itemID] = tonumber(itemAP)
Nick@111 830 end
Nick@111 831 end
Nick@111 832 if text:match('fishing artifact') then
Nick@111 833 local fishingAP = text:match("%d+")
Nick@111 834 fishingAP = fishingAP
Nick@111 835 print(itemLink, 'fishing', tonumber(text))
Nick@111 836 if fishingAP then
Nick@111 837 self.cache.items[itemID] = tonumber(fishingAP)
Nick@111 838 self.cache.fishing[itemID] = true
Nick@111 839 end
Nenue@101 840 end
Nenue@101 841 end
Nenue@101 842 end
Nenue@101 843 else
Nenue@101 844
Nick@108 845 self.cache.items[itemID] = 0
Nenue@101 846 end
Nenue@101 847 end
Nick@108 848 return self.cache.items[itemID], self.cache.fishing[itemID]
Nenue@101 849 end
Nenue@101 850
Nenue@122 851 function Module:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@122 852 print('|cFF00FF00UpdateArtifact()|r')
Nenue@103 853 if not self.profile then
Nenue@103 854 return
Nenue@103 855 end
Nenue@103 856 local artifacts = self.profile.artifacts
Nenue@103 857
Nenue@103 858 if itemID then
Nenue@103 859
Nenue@103 860 artifacts[itemID] = artifacts[itemID] or {}
Nenue@103 861 table.wipe(artifacts[itemID])
Nenue@103 862 local artifact = artifacts[itemID]
Nenue@103 863
Nenue@103 864 artifact.name = name
Nenue@103 865 artifact.texture = texture
Nenue@103 866 artifact.currentXP = currentXP
Nenue@103 867 artifact.level = pointsSpent
Nenue@116 868 artifact.tier = C_ArtifactUI.GetArtifactTier() or ((pointsSpent >= 36) and 2 or 1)
Nenue@122 869 artifact.itemID = itemID
Nenue@116 870
Nenue@116 871 print('tier', artifact.tier)
Nenue@116 872 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier)
Nick@108 873 artifact.currentCost = cost
Nenue@125 874 end
Nenue@103 875
Nenue@125 876 local equippedID = C_ArtifactUI:GetEquippedArtifactInfo()
Nenue@125 877 self.currentEquipped = equippedID
Nenue@103 878 end
Nenue@103 879
Nenue@116 880 function Module:ScanBag(id)
Nenue@97 881 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id))
Nenue@97 882 local numSlots = GetContainerNumSlots(id)
Nenue@97 883 local requiresUpdate
Nenue@97 884 if numSlots == 0 then
Nenue@97 885 return nil
Nenue@97 886 end
Nenue@97 887
Nenue@97 888
Nenue@97 889 self.profile.bagslots[id] = self.profile.bagslots[id] or {}
Nenue@97 890 table.wipe(self.profile.bagslots[id])
Nenue@97 891 local bagData = self.profile.bagslots[id]
Nenue@97 892 bagData.totalAP = 0
Nenue@99 893 bagData.fishingAP = 0
Nenue@99 894 bagData.items = bagData.items or {}
Nenue@99 895 table.wipe(bagData.items)
Nick@111 896 local c = self.cache
Nenue@99 897
Nick@111 898 c.bagItems[id] = c.bagItems[id] or {}
Nick@111 899 c.bags[id] = c.bags[id] or {}
Nick@111 900 c.fishing[id] = c.fishing[id] or {}
Nick@108 901
Nenue@97 902 for slotID = 1, numSlots do
Nenue@97 903 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID)
Nenue@101 904 if link then
Nenue@101 905 local itemID = GetContainerItemID(id, slotID)
Nenue@101 906 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link)
Nenue@97 907
Nick@111 908 if class == 'Consumable' or subclass == 'Cooking' then
Nenue@102 909 --print(GetItemInfo(link))
Nick@108 910 local itemAP, isFishingAP
Nick@111 911 if c.bags[id][slotID] and (c.bagItems[id][slotID] == itemID) then
Nick@111 912 --print('cached slot', id, slotID, name)
Nick@111 913 itemAP = c.bags[id][slotID]
Nick@111 914 isFishingAP = c.fishing[id] and c.fishing[id][slotID]
Nick@108 915 else
Nick@108 916 itemAP, isFishingAP = self:GetItemAP(itemID, link)
Nick@111 917 c.bagItems[id][slotID] = itemID
Nick@111 918 c.bags[id][slotID] = itemAP
Nick@111 919 c.fishing[id][slotID] = isFishingAP
Nick@108 920 end
Nick@108 921
Nick@108 922
Nenue@102 923 --print(itemAP, isFishingAP)
Nenue@102 924 if itemAP and (itemAP > 0) then
Nick@111 925 local itemButton = self:GetItemButton(itemID, texture, itemAP, isFishingAP)
Nenue@102 926
Nenue@101 927 if isFishingAP then
Nenue@101 928 bagData.fishingItems = (bagData.fishingItems or 0) + 1
Nenue@101 929 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP
Nenue@101 930 else
Nick@108 931 itemAP = itemAP
Nenue@101 932 bagData.numItems = (bagData.numItems or 0) + 1
Nenue@101 933 bagData.totalAP = (bagData.totalAP or 0) + itemAP
Nenue@101 934 end
Nenue@101 935 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1
Nenue@101 936 end
Nenue@101 937 elseif self.profile.artifacts[itemID] then
Nick@111 938 --print('artifact weapon', itemID, link, id, slotID)
Nenue@101 939 self.profile.artifacts[itemID].containerID = id
Nenue@101 940 self.profile.artifacts[itemID].slotID = slotID
Nick@111 941 else
Nick@111 942 --print('skipping', class, subclass, link)
Nenue@101 943 end
Nenue@99 944
Nenue@97 945 end
Nenue@97 946
Nenue@97 947 end
Nenue@97 948
Nenue@97 949 end
Nenue@97 950
Nenue@98 951 local BAG_SLOTS = {0, 1, 2, 3, 4 }
Nenue@98 952 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12}
Nenue@99 953 local ItemCounts = {}
Nenue@116 954 function Module:ScanAllBags()
Nenue@99 955 if InCombatLockdown() then
Nenue@99 956 self.queuedScan = true
Nenue@99 957 return
Nenue@99 958 end
Nenue@101 959 if not self.profile.knowledgeMultiplier then
Nenue@101 960 print('need to get knowledge level')
Nenue@101 961 return
Nenue@101 962 end
Nenue@101 963
Nenue@99 964 self.queuedScan = nil
Nenue@98 965
Nenue@101 966 print('|cFFFF0088ScanAllBags()|r', self.profile.knowledgeMultiplier)
Nenue@97 967
Nenue@99 968 for _, button in ipairs(self.Tokens) do
Nenue@99 969 button.numItems = 0
Nenue@99 970 end
Nenue@99 971
Nenue@99 972
Nenue@98 973 for _, bagID in ipairs(BAG_SLOTS) do
Nenue@98 974 self:ScanBag(bagID)
Nenue@97 975 end
Nenue@97 976
Nenue@99 977 if self.bankAccess then
Nenue@98 978 for _, bagID in ipairs(BANK_SLOTS) do
Nenue@98 979 self:ScanBag(bagID)
Nenue@98 980 end
Nenue@98 981 end
Nenue@98 982
Nenue@125 983
Nenue@125 984
Nenue@98 985 self.bankAP = 0
Nenue@98 986 self.bagAP = 0
Nenue@99 987 self.fishingAP = 0
Nenue@99 988
Nenue@99 989 table.wipe(ItemCounts)
Nenue@98 990 for id, bagData in pairs(self.profile.bagslots) do
Nick@111 991 print(id, GetBagName(id), bagData.totalAP, bagData.fishingAP)
Nenue@98 992 id = tonumber(id)
Nenue@98 993 if bagData.totalAP then
Nenue@98 994 if (id == BANK_CONTAINER) or (id >= 5) then
Nenue@98 995 self.bankAP = self.bankAP + bagData.totalAP
Nenue@98 996 else
Nenue@98 997 self.bagAP = self.bagAP + bagData.totalAP
Nenue@97 998 end
Nenue@98 999 end
Nenue@99 1000 if bagData.fishingAP then
Nenue@99 1001 self.fishingAP = self.fishingAP + bagData.fishingAP
Nenue@99 1002 end
Nenue@97 1003
Nenue@97 1004 end
Nenue@98 1005 self.lastUpdate = GetTime()
Nenue@103 1006 self.queuedScan = nil
Nenue@99 1007 self:TryToShow()
Nenue@97 1008 end
Nenue@97 1009
Nenue@98 1010
Nenue@122 1011 function Artifact:SetItem(itemID, artifact, index, equipped, fishing)
Nenue@122 1012 print('|cFF00FFFFSetItem()|r', itemID, index)
Nenue@98 1013 print(artifact.name, artifact.texture, artifact.currentXP)
Nenue@122 1014
Nick@108 1015 if not artifact.currentCost then
Nick@108 1016 artifact.currentCost = artifact.cost
Nick@108 1017 end
Nick@108 1018
Nenue@98 1019 for k,v in pairs(artifact) do
Nenue@98 1020 --print('::',k,v)
Nenue@98 1021 self[k] = v
Nenue@98 1022 end
Nenue@98 1023
Nick@111 1024 self.isFishing = fishing
Nenue@98 1025 -- this can change between artifact parses
Nenue@117 1026 local unusedXP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0)
Nenue@117 1027 print('unspent:', unusedXP)
Nenue@99 1028
Nenue@117 1029 -- current standing artifact XP (what appears in the artifact ui)
Nenue@117 1030 -- actual artifact XP after any unlocked points are spent
Nenue@117 1031 -- total total of invested and inventory XP
Nenue@117 1032 -- totalCost total of costs between current and actual level
Nenue@117 1033 local actualXP = artifact.currentXP
Nenue@116 1034 local actualLevel = artifact.level
Nenue@116 1035 local actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
Nenue@116 1036
Nenue@117 1037 print('tier:', artifact.tier)
Nenue@117 1038 print('current:', self.level, self.currentXP, '/', self.currentCost)
Nenue@131 1039 while (actualXP >= actualCost) and (actualCost > 0) do
Nenue@116 1040 actualXP = actualXP - actualCost
Nenue@116 1041 actualLevel = actualLevel + 1
Nenue@116 1042 actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
Nenue@117 1043
Nenue@117 1044 print('* ', actualLevel, actualXP, actualCost, totalCost)
Nenue@98 1045 end
Nenue@117 1046 print('actual:', actualLevel, actualXP, '/', actualCost)
Nenue@117 1047
Nenue@117 1048
Nenue@123 1049 local totalXP = actualXP + unusedXP
Nenue@123 1050 local totalCost = actualCost
Nenue@123 1051 local totalLevel = actualLevel
Nenue@123 1052
Nenue@123 1053 local remaining = totalXP
Nenue@120 1054 local nextCost = artifact.currentCost
Nenue@123 1055 print(totalXP, totalCost)
Nenue@120 1056 if remaining > nextCost then
Nenue@131 1057 while (remaining >= nextCost) and (nextCost > 0) do
Nenue@117 1058 totalLevel = totalLevel + 1
Nenue@119 1059 remaining = remaining - nextCost
Nenue@117 1060 nextCost = C_ArtifactUI.GetCostForPointAtRank(totalLevel, artifact.tier)
Nenue@119 1061 print('|cFFFFFF00+ ', totalLevel, remaining, '/', totalCost)
Nenue@117 1062 end
Nenue@119 1063 totalXP = remaining
Nenue@119 1064 totalCost = nextCost
Nenue@117 1065 end
Nenue@117 1066 print('total:', totalLevel, totalXP, '/', totalCost)
Nenue@117 1067
Nenue@117 1068 self.currentLevel = self.level
Nenue@117 1069
Nenue@117 1070
Nenue@116 1071 self.actualCost = actualCost
Nenue@116 1072 self.actualLevel = actualLevel
Nenue@116 1073 self.actualXP = actualXP
Nenue@117 1074
Nenue@117 1075 self.totalXP = totalXP
Nenue@117 1076 self.totalCost = totalCost
Nenue@117 1077 self.totalLevel = totalLevel
Nenue@117 1078
Nenue@98 1079
Nenue@98 1080
Nenue@99 1081 if index ~= 1 then
Nenue@99 1082 self:ClearAllPoints()
Nenue@99 1083 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0)
Nenue@99 1084 else
Nenue@99 1085 self:ClearAllPoints()
Nenue@99 1086 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', 4, -4)
Nenue@99 1087 end
Nenue@98 1088
Nenue@122 1089 self.itemID = itemID
Nenue@99 1090 self.isEquipped = equipped
Nenue@98 1091 self:Update()
Nenue@125 1092 self:SetShown(true)
Nenue@122 1093
Nenue@98 1094 return self
Nenue@98 1095 end
Nenue@98 1096
Nenue@122 1097 function Artifact:UpdateXPBar()
Nenue@122 1098 local r3, g3, b3 = 1, .5, 0 -- main xp bar
Nenue@122 1099 -- current: amount shown in blizz ui
Nenue@122 1100 -- actual: amount contributing the next level, will be same until current point cap is reached
Nenue@122 1101 -- potential: total of ap on hand
Nenue@122 1102 print(self.currentXP, self.actualXP, self.potentialXP)
Nenue@122 1103
Nenue@123 1104 local maxHeight = self:GetHeight() - (XP_INSET*2)
Nenue@122 1105 local currentHeight = self.CurrentProgress:GetHeight() or 1
Nenue@122 1106 local offHeight = self.AdjustedProgress:GetHeight() or 1
Nenue@122 1107
Nenue@122 1108
Nenue@129 1109 self.CurrentProgress:SetPoint('BOTTOM', self.XPBackground, 'BOTTOM', 0, 0)
Nenue@122 1110 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1
Nenue@122 1111 local projectedProgress = (self.totalXP < self.totalCost) and (self.totalXP / self.totalCost) or 1
Nenue@122 1112 if self.actualLevel ~= self.level then
Nenue@122 1113 r3, g3, b3 = 0, 1, 1
Nenue@122 1114 end
Nenue@122 1115
Nenue@123 1116 print('|cFFFF4400', currentProgress, projectedProgress, self.currentLevel, self.totalLevel)
Nenue@122 1117 if self.level <= WEAPON_MAX_TRAITS then
Nenue@122 1118 self.CurrentProgress.animateFrom = currentHeight or 1
Nenue@122 1119 self.CurrentProgress.animateTo = currentProgress * maxHeight
Nenue@122 1120 self.CurrentProgress:Show()
Nenue@122 1121 else
Nenue@122 1122 self.CurrentProgress:Hide()
Nenue@122 1123 end
Nenue@122 1124
Nenue@123 1125 local nextLevel = (self.totalLevel ~= self.currentLevel)
Nenue@123 1126
Nenue@123 1127 if self.totalXP ~= self.currentXP or nextLevel then
Nenue@123 1128 print('project', 'xp test=', (self.totalXP ~= self.currentXP), 'lvl test=', (self.totalLevel ~= self.currentLevel))
Nenue@123 1129
Nenue@123 1130 local projectedPos = projectedProgress
Nenue@123 1131
Nenue@123 1132 if projectedProgress > currentProgress and (not nextLevel) then
Nenue@123 1133 projectedPos = (projectedProgress - currentProgress)
Nenue@123 1134 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP', 0, 0)
Nenue@123 1135 print(' set above', projectedPos, self.CurrentProgress:GetPoint(3))
Nenue@122 1136 else
Nenue@123 1137 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM', 0 , XP_INSET)
Nenue@123 1138 print(' set under', projectedPos)
Nenue@122 1139 end
Nenue@122 1140 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1
Nenue@123 1141 self.AdjustedProgress.animateTo = projectedPos * maxHeight
Nenue@122 1142 self.AdjustedProgress:Show()
Nenue@122 1143 else
Nenue@123 1144 print('nothing to project')
Nenue@122 1145 self.AdjustedProgress:Hide()
Nenue@122 1146 end
Nenue@123 1147
Nenue@123 1148
Nenue@122 1149 --print(self.CurrentProgress:GetPoint(3))
Nenue@122 1150 --print(self.CurrentProgress:GetSize())
Nenue@122 1151
Nenue@123 1152 self.XPBackground:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', XP_INSET, XP_INSET)
Nenue@123 1153 self.XPBackground:SetPoint('TOPRIGHT', self, 'TOPLEFT', XP_INSET + XP_WIDTH, -XP_INSET)
Nenue@122 1154 self.CurrentProgress:SetColorTexture(r3,g3,b3,1)
Nenue@122 1155
Nenue@122 1156 end
Nenue@122 1157
Nenue@122 1158 function Artifact:OnLoad()
Nenue@122 1159 print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID())
Nenue@122 1160 end
Nenue@122 1161
Nenue@116 1162 function Artifact:Update()
Nenue@122 1163 if not self.itemID then
Nenue@122 1164 return
Nenue@122 1165 end
Nenue@122 1166
Nenue@125 1167 print(self:GetName(), '|cff00FFFFUpdate()|r')
Nenue@122 1168 local r1, g1, b1 = 1, 1, 1 -- top text
Nenue@122 1169 local r2, g2, b2 = 1, 1, 0 -- bottom text
Nenue@99 1170 local levelText = self.level
Nenue@116 1171 local xpText = ShortNumberString(self.currentXP)
Nenue@116 1172 local costText = ShortNumberString(self.currentCost)
Nenue@116 1173 local remainingText = ShortNumberString(self.currentCost - self.currentXP)
Nenue@122 1174
Nenue@122 1175 local maxHeight = self:GetHeight() - 4
Nenue@122 1176 local currentHeight = self.CurrentProgress:GetHeight() or 1
Nenue@122 1177 local offHeight = self.AdjustedProgress:GetHeight() or 1
Nenue@122 1178
Nenue@97 1179 if self.actualLevel ~= self.level then
Nenue@116 1180 levelText = self.actualLevel
Nenue@116 1181 r1, g1, b1 = 0, 1, 0
Nenue@116 1182 xpText = ShortNumberString(self.actualXP)
Nenue@116 1183 costText = ShortNumberString(self.actualCost)
Nenue@116 1184 remainingText = ShortNumberString(self.actualCost-self.actualXP)
Nenue@116 1185 --[[elseif self.potentialLevel ~= self.level then
Nenue@116 1186 r1, g1, b1 = 0, 1, 1
Nenue@116 1187 r2, g2, b2 = 0, 1, 1
Nenue@116 1188 costText = ShortNumberString(self.potentialCost)
Nenue@116 1189 remainingText = ShortNumberString(self.potentialCost-self.potentialXP)
Nenue@116 1190 --]]
Nenue@97 1191 end
Nenue@97 1192
Nenue@99 1193 self.Level:SetText(levelText)
Nenue@116 1194 self.CurrentXP:SetText( xpText )
Nenue@116 1195 self.RemainingCost:SetText(remainingText)
Nenue@116 1196 self.Level:SetTextColor(r1, g1, b1)
Nenue@116 1197 self.CurrentXP:SetTextColor(r1, g1, b1)
Nenue@99 1198
Nenue@97 1199 if self.isEquipped then
Nenue@116 1200 self:SetSize(64,64)
Nenue@97 1201 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]])
Nenue@97 1202 self:GetNormalTexture():SetBlendMode('ADD')
Nenue@97 1203 self:GetNormalTexture():SetVertexColor(0,1,0)
Nenue@97 1204 else
Nenue@116 1205 self:SetSize(48,48)
Nenue@97 1206 self:SetNormalTexture(nil, 'ADD')
Nenue@97 1207 end
Nenue@97 1208
Nenue@122 1209 self:UpdateXPBar()
Nenue@116 1210
Nenue@117 1211 if self.actualLevel ~= self.currentLevel then
Nenue@117 1212 self:SetNormalTexture([[Interface\Buttons\UI-Quickslot-Depress]], 'ADD')
Nenue@117 1213 self:GetNormalTexture():SetBlendMode('BLEND')
Nenue@117 1214 self:GetNormalTexture():SetVertexColor(1,1,1)
Nenue@117 1215 else
Nenue@117 1216 self:SetNormalTexture(nil, 'ADD')
Nenue@117 1217 end
Nenue@97 1218 self.Icon:SetTexture(self.texture)
Nenue@97 1219 end
Nenue@97 1220
Nenue@119 1221 local XP_SCALING_DURATION = .5
Nenue@116 1222 function Artifact:AnimateProgress(region)
Nenue@98 1223 local cTime = GetTime()
Nenue@98 1224 if not region.animateStart then
Nenue@98 1225 region.animateStart = cTime
Nenue@98 1226 end
Nenue@98 1227 local progressTo, progressFrom = region.animateTo, region.animateFrom
Nenue@98 1228 local elapsed = cTime - region.animateStart
Nenue@119 1229 if elapsed >= XP_SCALING_DURATION then
Nenue@98 1230 region:SetHeight(progressTo)
Nenue@98 1231 region.animateTo = nil
Nenue@98 1232 region.animateStart = nil
Nenue@98 1233 region.animateFrom = nil
Nenue@98 1234 else
Nenue@119 1235 local progress = elapsed / XP_SCALING_DURATION
Nenue@98 1236 local height = (progressFrom + (progressTo - progressFrom) * progress)
Nenue@98 1237 --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height))
Nenue@98 1238 region:SetHeight(height)
Nenue@98 1239 end
Nenue@98 1240 end
Nenue@98 1241
Nenue@116 1242 function Artifact:OnUpdate(sinceLast)
Nenue@98 1243 if self.CurrentProgress.animateTo then
Nenue@98 1244 self:AnimateProgress(self.CurrentProgress)
Nenue@98 1245 end
Nenue@98 1246
Nenue@98 1247 if self.AdjustedProgress.animateTo then
Nenue@98 1248 self:AnimateProgress(self.AdjustedProgress)
Nenue@98 1249 end
Nenue@98 1250 end
Nenue@98 1251
Nenue@116 1252 function Artifact:OnEnter()
Nenue@97 1253 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
Nenue@97 1254 GameTooltip:SetText(self.name)
Nenue@119 1255 GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 1)
Nenue@99 1256 if self.actualLevel ~= self.level then
Nenue@119 1257 GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 1, 1, 0)
Nick@108 1258 end
Nick@108 1259 if self.currentXP < self.currentCost then
Nenue@117 1260 GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' for level ' .. (self.currentLevel+1), 1, 1, 0)
Nenue@117 1261 else
Nenue@117 1262 GameTooltip:AddLine(ShortNumberString(self.actualCost - self.actualXP) .. ' for level ' .. (self.actualLevel+1), 0, 1, 0)
Nenue@117 1263 end
Nenue@117 1264 if self.totalLevel ~= self.actualLevel then
Nenue@117 1265 GameTooltip:AddLine('Level ' .. self.totalLevel .. ' with unspent tokens', 0, 1, 1)
Nenue@99 1266 end
Nenue@99 1267
Nenue@97 1268 GameTooltip:Show()
Nenue@97 1269 end
Nenue@116 1270 function Artifact:OnLeave()
Nenue@97 1271 if GameTooltip:IsOwned(self) then
Nenue@97 1272 GameTooltip:Hide()
Nenue@97 1273 end
Nenue@97 1274 end
Nenue@116 1275 function Artifact:OnHide()
Nick@108 1276
Nick@108 1277 if GameTooltip:IsOwned(self) then
Nick@108 1278 GameTooltip:Hide()
Nick@108 1279 end
Nick@108 1280 end
Nenue@97 1281
Nenue@116 1282 function Artifact:OnClick(button, down)
Nenue@97 1283 if self.isEquipped then
Nenue@97 1284 SocketInventoryItem(16)
Nenue@97 1285 else
Nick@108 1286 if IsShiftKeyDown() then
Nenue@119 1287 SocketContainerItem(self.containerID, self.slotID)
Nick@108 1288 else
Nick@108 1289
Nick@108 1290 end
Nenue@97 1291 end
Nenue@122 1292 end