annotate Modules/ArtifactPower.lua @ 129:9f2cf5609420 v7.3.0-20171022

- fix Argus world quests not being counted - add "Argus WQ" header in the summary box
author Nenue
date Sun, 22 Oct 2017 18:28:43 -0400
parents 3f4794dca91b
children 15a7f27b11e6
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@116 405 function Module:OnUpdate()
Nenue@101 406 if #self.scanQueue >= 1 then
Nenue@101 407 local scanInfo = tremove(self.scanQueue, 1)
Nick@111 408 end
Nick@111 409 if IsShiftKeyDown() then
Nick@111 410 self.Refresh:Show()
Nick@111 411 else
Nick@111 412 self.Refresh:Hide()
Nick@111 413 end
Nenue@101 414
Nenue@101 415 end
Nenue@101 416
Nenue@119 417 function Module:OnMouseDown(button)
Nenue@97 418 self.enabled = nil
Nenue@119 419 if button == 'RightButton' then
Nenue@119 420 self:Hide()
Nenue@119 421 end
Nenue@119 422
Nenue@97 423 end
Nenue@97 424
Nenue@116 425 function Module:Update()
Nenue@97 426 if not self:IsShown() then
Nenue@99 427 print('|cFFFF4400Update()|r')
Nenue@97 428 return
Nenue@97 429 end
Nenue@122 430 print('|cFFFFFF00pdate()|r')
Nenue@122 431
Nenue@122 432 local numButtons = 0
Nenue@122 433 local contentsHeight = 16
Nenue@122 434 local contentsWidth = 400
Nenue@122 435 if self.profile.knowledgeMultiplier then
Nenue@122 436 local artifactsWidth = self:UpdateArtifactButtons()
Nenue@122 437
Nenue@122 438 if artifactsWidth ~= 0 then
Nenue@122 439 contentsHeight = contentsHeight + 64
Nenue@122 440 end
Nenue@122 441
Nenue@122 442 contentsWidth = max(contentsWidth, min(artifactsWidth, 400))
Nenue@122 443
Nenue@122 444 local itemsWidth, itemsHeight = self:UpdateItemButtons()
Nenue@122 445 contentsHeight = contentsHeight + itemsHeight
Nenue@122 446 contentsWidth = max(contentsWidth, itemsWidth)
Nenue@122 447 end
Nenue@122 448
Nenue@122 449
Nenue@97 450
Nenue@97 451 local bankText, bagText
Nenue@101 452 if not self.profile.knowledgeMultiplier then
Nenue@101 453 bankText = '|cFF00FF00Shift-Right-Click an artifact weapon to start building data.'
Nenue@101 454 elseif not (self.bankAP and self.bagAP) then
Nenue@97 455 bankText = '|cFFFF0000Open bank frame to count all AP|r '
Nenue@97 456 else
Nick@111 457
Nick@111 458 if self.bagAP and (self.bagAP > 0) then
Nick@111 459 bankText = 'Inventory: |cFFFFFFFF' .. ShortNumberString(self.bagAP) .. '|r'
Nick@111 460 end
Nick@111 461 if self.bankAP and (self.bankAP > 0) then
Nick@111 462 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..ShortNumberString(self.bankAP)..' banked|r'
Nick@111 463 end
Nick@111 464 if self.fishingAP and self.fishingAP > 0 then
Nick@111 465 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFF0088FF' .. ShortNumberString(self.fishingAP) .. ' fishing|r'
Nick@111 466 end
Nick@111 467 end
Nick@111 468
Nenue@119 469 if self.worldQuestAP then
Nenue@119 470 bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. ''
Nenue@119 471 end
Nick@111 472
Nenue@129 473 if self.argusAP then
Nenue@129 474 bankText = (bankText and (bankText .. '\n') or '') .. '|cFF88FF00Argus WQ:|r |cFFFFFFFF' .. ShortNumberString(self.argusAP) .. ''
Nenue@129 475 end
Nenue@129 476
Nenue@129 477
Nenue@99 478
Nenue@97 479 self.SummaryHeader:SetText(bankText)
Nenue@122 480 if not self.lastButton then
Nenue@122 481 contentsHeight = contentsHeight + self.SummaryHeader:GetHeight()
Nenue@101 482 end
Nenue@101 483
Nenue@101 484
Nick@111 485 if not self.hasArtifacts then
Nick@111 486 self:SetShown(false)
Nick@111 487 end
Nick@111 488
Nenue@101 489
Nick@108 490 self:SetWidth(contentsWidth)
Nick@108 491 self:SetHeight(contentsHeight)
Nenue@101 492 self:Reanchor()
Nenue@101 493 end
Nenue@101 494
Nenue@129 495 function Module:GetContinentAP(mapAreaID)
Nenue@119 496
Nenue@129 497 for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do
Nenue@129 498 local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex);
Nenue@119 499 --print(zoneMapID, zoneName)
Nenue@119 500 if zoneDepth <= 1 then -- Exclude subzones
Nenue@129 501 local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID, (mapAreaID == 1184) and 1 or nil);
Nenue@119 502
Nenue@119 503 if taskInfo then
Nenue@119 504 for i, info in ipairs(taskInfo) do
Nenue@119 505 local questID = info.questId
Nenue@119 506
Nenue@119 507 local questTitle, factionID, capped = C_TaskQuest.GetQuestInfoByQuestID(questID)
Nenue@119 508 --print(questTitle, HaveQuestRewardData(questID))
Nenue@119 509 if HaveQuestRewardData(questID) then
Nenue@119 510
Nenue@119 511
Nenue@119 512 local numQuestRewards = GetNumQuestLogRewards(questID);
Nenue@119 513
Nenue@119 514 if numQuestRewards > 0 then
Nenue@119 515 for i = 1, numQuestRewards do
Nenue@119 516 local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID)
Nenue@119 517 if IsArtifactPowerItem(itemID) then
Nenue@119 518 local _, link = GetItemInfo(itemID)
Nenue@119 519 if link then
Nenue@119 520 local ap = self:GetItemAP(itemID, link)
Nenue@119 521 --print('ap =', ap)
Nenue@119 522 if ap then
Nenue@119 523 self.worldQuestAP = self.worldQuestAP + ap
Nenue@129 524 if mapAreaID == ZONE_ID_ARGUS then
Nenue@129 525 self.argusAP = self.argusAP + ap
Nenue@129 526 end
Nenue@119 527
Nenue@119 528 end
Nenue@119 529
Nenue@119 530 self.worldQuestItems[itemID] = (self.worldQuestItems[itemID] or 0) + 1
Nenue@119 531 end
Nenue@119 532
Nenue@119 533 --print(self.worldQuestAP)
Nenue@119 534 end
Nenue@119 535
Nenue@119 536 end
Nenue@119 537
Nenue@119 538 end
Nenue@119 539
Nenue@119 540
Nenue@119 541 else
Nenue@119 542 C_TaskQuest.RequestPreloadRewardData(questID);
Nenue@119 543 self.waitingForQuestRewardData = true
Nenue@119 544 end
Nenue@119 545 end
Nenue@119 546 end
Nenue@119 547 end
Nenue@119 548 end
Nenue@129 549
Nenue@129 550 end
Nenue@129 551
Nenue@129 552 function Module:UpdateWorldQuestsAP()
Nenue@129 553 self.waitingForQuestRewardData = false
Nenue@129 554 self.worldQuestAP = 0
Nenue@129 555 self.argusAP = 0
Nenue@129 556 wipe(self.worldQuestItems)
Nenue@129 557
Nenue@129 558 self:GetContinentAP(ZONE_ID_BROKEN_ISLE)
Nenue@129 559 self:GetContinentAP(ZONE_ID_ARGUS)
Nenue@129 560
Nenue@119 561 end
Nenue@119 562
Nenue@116 563 function Module:UpdateArtifactButtons()
Nenue@101 564
Nenue@97 565 -- Artifact icons, in no particular order
Nenue@99 566 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo()
Nenue@122 567 self.lastButton = nil
Nick@111 568 self.canAddAP = nil
Nick@111 569 self.canAddFishingAP = nil
Nick@111 570 local hasArtifacts
Nenue@97 571 local numButtons = 0
Nenue@99 572 local lastFrame = self
Nenue@99 573 local fishingID, fishingData
Nenue@98 574 local index, button
Nenue@116 575 local equipped =self.profile.artifacts[self.equippedID]
Nenue@116 576 local buttonsWidth = 0
Nenue@116 577 if equipped then
Nenue@116 578 numButtons = numButtons + 1
Nenue@116 579 button = self.Artifact[numButtons]
Nenue@116 580 button.relativeFrame = self
Nenue@125 581 button:SetItem(self.equippedID, equipped, numButtons, true, nil)
Nenue@125 582
Nenue@122 583 if self.equippedID ~= button.itemID then
Nenue@125 584
Nenue@122 585 hasArtifacts = true
Nenue@122 586 end
Nenue@122 587 lastFrame = button
Nenue@116 588 buttonsWidth = EQUIPPED_SIZE + (FRAME_PADDING * 2)
Nenue@116 589 end
Nenue@97 590 for itemID, artifact in pairs(self.profile.artifacts) do
Nenue@116 591 if (itemID == UNDERLIGHT_ANGLER_ID) then
Nenue@116 592 -- only add if we have fishing AP items and it's not being shown in the equipped slot
Nenue@116 593 if VeneerData.ArtifactPower.EnableFishing and (itemID ~= self.equippedID) then
Nenue@98 594 fishingID = itemID
Nenue@98 595 fishingData = artifact
Nenue@98 596 end
Nenue@97 597
Nick@111 598 if artifact.level < FISHING_MAX_TRAITS then
Nick@111 599 if itemID == self.equippedID then
Nick@111 600 self.canAddFishingAP = true
Nick@111 601 end
Nick@111 602 end
Nenue@98 603 else
Nick@111 604 if artifact.level < WEAPON_MAX_TRAITS then
Nick@111 605 if itemID == self.equippedID then
Nick@111 606 self.canAddAP = true
Nenue@116 607 else
Nenue@116 608
Nenue@116 609 hasArtifacts = true
Nenue@116 610 numButtons = numButtons + 1
Nenue@116 611 button = self.Artifact[numButtons]
Nenue@116 612 button.relativeFrame = lastFrame
Nenue@125 613 button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
Nenue@122 614 lastFrame = button
Nenue@116 615 buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING
Nick@111 616 end
Nick@108 617 end
Nenue@97 618 end
Nick@111 619 end
Nenue@97 620
Nenue@122 621 self.lastButton = lastFrame
Nenue@122 622
Nenue@97 623
Nick@108 624 if fishingData and (self.fishingAP and self.fishingAP > 0) then
Nenue@98 625 numButtons = numButtons + 1
Nick@111 626 hasArtifacts = true
Nenue@99 627 local button = self.Artifact[numButtons]
Nenue@99 628 button.relativeFrame = lastFrame
Nick@111 629 button.isFishing = true
Nenue@122 630 button:SetItem(fishingID, fishingData, numButtons, self.equippedID == fishingID)
Nenue@122 631 self.lastButton = button
Nenue@98 632 end
Nenue@97 633
Nick@111 634 self.hasArtifacts = hasArtifacts
Nenue@99 635 for i = numButtons+ 1, #self.Artifact do
Nenue@97 636 print('hide', i)
Nenue@97 637 self.Artifact[i]:Hide()
Nenue@97 638 end
Nenue@97 639
Nenue@122 640 self.SummaryHeader:ClearAllPoints()
Nenue@122 641 if self.lastButton then
Nenue@122 642 self.SummaryHeader:SetPoint('TOPLEFT', self.lastButton, 'TOPRIGHT', 4, -2)
Nenue@122 643 else
Nenue@122 644 self.SummaryHeader:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 4, 4)
Nenue@122 645 end
Nenue@122 646
Nenue@122 647
Nick@111 648
Nenue@116 649 return buttonsWidth
Nenue@97 650 end
Nenue@97 651
Nenue@99 652
Nenue@116 653 function Module:UpdateItemButtons()
Nenue@99 654 print('|cFF00FFFFUpdateItemButtons()|r')
Nick@111 655
Nick@111 656 local apType
Nick@111 657 if self.canAddFishingAP then
Nick@111 658 apType = true
Nick@111 659 elseif not self.canAddAP then
Nick@111 660 for index, button in ipairs(self.Tokens) do
Nick@111 661 button:Hide()
Nick@111 662 end
Nick@111 663 return 0, 0
Nick@111 664 end
Nick@111 665
Nick@111 666
Nenue@99 667 local lastFrame, upFrame
Nenue@99 668 local numButtons = 0
Nenue@101 669 local buttonsHeight = 0
Nick@108 670 local buttonsWidth = 0
Nick@111 671
Nenue@99 672 for index, button in ipairs(self.Tokens) do
Nick@111 673 if (button.numItems >= 1) and (button.isFishingAP == apType) then
Nenue@99 674 if button.itemName then
Nenue@99 675 self:SetItemAction(button)
Nenue@99 676 end
Nenue@99 677
Nenue@99 678 button:ClearAllPoints()
Nenue@99 679 numButtons = numButtons + 1
Nick@111 680 local col = mod(numButtons,8)
Nenue@99 681 print(index, button:GetID(), button.Icon:GetTexture())
Nenue@99 682 if numButtons == 1 then
Nenue@101 683 button:SetPoint('TOPLEFT', self, 'TOPLEFT', 4, -76)
Nenue@99 684 upFrame = button
Nenue@101 685 buttonsHeight = 52
Nenue@99 686 else
Nick@108 687 if col == 1 then
Nick@108 688 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2)
Nick@108 689 upFrame = button
Nick@108 690 buttonsHeight = buttonsHeight + 52
Nick@108 691
Nick@108 692 else
Nick@108 693 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0)
Nick@108 694
Nick@108 695 end
Nenue@99 696 end
Nick@111 697
Nenue@99 698 button.Count:SetText(button.numItems)
Nenue@99 699 lastFrame = button
Nenue@99 700 button:Show()
Nenue@99 701 else
Nenue@99 702 button:Hide()
Nenue@99 703 end
Nick@111 704 buttonsWidth = min(numButtons, 8) * (BUTTON_SIZE)
Nick@111 705 end
Nick@111 706
Nick@111 707
Nick@111 708
Nick@111 709 if buttonsWidth ~= 0 then
Nick@111 710 buttonsWidth = buttonsWidth + 8+ ((min(numButtons, 8)-1)*2)
Nenue@99 711 end
Nenue@99 712
Nenue@101 713
Nenue@101 714
Nick@108 715 return buttonsWidth, buttonsHeight
Nenue@99 716 end
Nenue@99 717
Nenue@116 718 function Module:SetItemAction(button, name)
Nenue@99 719 name = name or self.itemName
Nenue@99 720 if InCombatLockdown() then
Nenue@99 721 self.itemName = name
Nenue@99 722 return
Nenue@99 723 else
Nenue@99 724 button:SetAttribute('*type*','item')
Nenue@99 725 button:SetAttribute('*item*', name)
Nenue@99 726 end
Nenue@99 727 end
Nenue@99 728
Nenue@116 729 function Module:GetItemButton(itemID, texture, itemAP, fishing)
Nenue@99 730 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP)
Nenue@99 731 local button = self.ItemButtons[itemID]
Nenue@101 732
Nenue@99 733 if not button then
Nenue@99 734 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton')
Nenue@101 735 button.baseAP = itemAP
Nenue@101 736
Nenue@99 737 button:SetPushedTexture([[Interface\Buttons\UI-Quickslot-Depress]])
Nenue@99 738 button:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]],"ADD")
Nenue@99 739 button:SetID(itemID)
Nenue@99 740 button.numItems = 0
Nenue@99 741 button.Icon:SetTexture(texture)
Nenue@99 742 button:RegisterForClicks("AnyUp")
Nick@111 743 button.isFishingAP = fishing
Nenue@99 744 self:SetItemAction(button, GetItemInfo(itemID))
Nenue@99 745
Nenue@99 746 print(' created')
Nenue@99 747 self.ItemButtons[itemID] = button
Nenue@99 748 self.numItems = self.numItems + 1
Nenue@99 749 end
Nenue@99 750
Nenue@116 751 button.Label:SetText(ShortNumberString(itemAP))
Nenue@101 752
Nenue@99 753 button.numItems = button.numItems + 1
Nenue@99 754 return button
Nenue@99 755 end
Nenue@99 756
Nenue@116 757 function Module:GetItemAP(itemID, itemLink, bagData)
Nick@108 758 if not self.cache.items[itemID] then
Nenue@101 759
Nick@111 760 print('doing tooltip scan', itemLink, itemID)
Nenue@101 761 self.tooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@101 762 self.tooltip:SetHyperlink(itemLink)
Nenue@101 763 self.tooltip:Show()
Nenue@101 764 local numLines = self.tooltip:NumLines()
Nenue@101 765 if numLines >= 3 then
Nenue@101 766 for i = 3, numLines do
Nenue@101 767 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText()
Nick@111 768 if text then
Nick@111 769
Nick@111 770 text = text:lower():gsub(',', '')
Nenue@116 771
Nick@111 772 if text:match('equipped artifact') then
Nick@111 773 print(itemLink, '-', tonumber(text))
Nenue@116 774
Nenue@116 775 local itemAP = text:match('[%d%.]+')
Nick@111 776 if itemAP then
Nenue@116 777 -- tokens > 1M are described as '%f million'
Nenue@116 778 if text:match("million") then
Nenue@116 779 itemAP = tonumber(itemAP) * 1000000
Nenue@129 780 elseif text:match("billion") then
Nenue@129 781 itemAP = tonumber(itemAP) * 1000000000
Nenue@116 782 end
Nenue@116 783
Nick@111 784 itemAP = itemAP
Nick@111 785 self.cache.items[itemID] = tonumber(itemAP)
Nick@111 786 end
Nick@111 787 end
Nick@111 788 if text:match('fishing artifact') then
Nick@111 789 local fishingAP = text:match("%d+")
Nick@111 790 fishingAP = fishingAP
Nick@111 791 print(itemLink, 'fishing', tonumber(text))
Nick@111 792 if fishingAP then
Nick@111 793 self.cache.items[itemID] = tonumber(fishingAP)
Nick@111 794 self.cache.fishing[itemID] = true
Nick@111 795 end
Nenue@101 796 end
Nenue@101 797 end
Nenue@101 798 end
Nenue@101 799 else
Nenue@101 800
Nick@108 801 self.cache.items[itemID] = 0
Nenue@101 802 end
Nenue@101 803 end
Nick@108 804 return self.cache.items[itemID], self.cache.fishing[itemID]
Nenue@101 805 end
Nenue@101 806
Nenue@122 807 function Module:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@122 808 print('|cFF00FF00UpdateArtifact()|r')
Nenue@103 809 if not self.profile then
Nenue@103 810 return
Nenue@103 811 end
Nenue@103 812 local artifacts = self.profile.artifacts
Nenue@103 813
Nenue@103 814 if itemID then
Nenue@103 815
Nenue@103 816 artifacts[itemID] = artifacts[itemID] or {}
Nenue@103 817 table.wipe(artifacts[itemID])
Nenue@103 818 local artifact = artifacts[itemID]
Nenue@103 819
Nenue@103 820 artifact.name = name
Nenue@103 821 artifact.texture = texture
Nenue@103 822 artifact.currentXP = currentXP
Nenue@103 823 artifact.level = pointsSpent
Nenue@116 824 artifact.tier = C_ArtifactUI.GetArtifactTier() or ((pointsSpent >= 36) and 2 or 1)
Nenue@122 825 artifact.itemID = itemID
Nenue@116 826
Nenue@116 827 print('tier', artifact.tier)
Nenue@116 828 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier)
Nick@108 829 artifact.currentCost = cost
Nenue@125 830 end
Nenue@103 831
Nenue@125 832 local equippedID = C_ArtifactUI:GetEquippedArtifactInfo()
Nenue@125 833 self.currentEquipped = equippedID
Nenue@103 834 end
Nenue@103 835
Nenue@116 836 function Module:ScanBag(id)
Nenue@97 837 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id))
Nenue@97 838 local numSlots = GetContainerNumSlots(id)
Nenue@97 839 local requiresUpdate
Nenue@97 840 if numSlots == 0 then
Nenue@97 841 return nil
Nenue@97 842 end
Nenue@97 843
Nenue@97 844
Nenue@97 845 self.profile.bagslots[id] = self.profile.bagslots[id] or {}
Nenue@97 846 table.wipe(self.profile.bagslots[id])
Nenue@97 847 local bagData = self.profile.bagslots[id]
Nenue@97 848 bagData.totalAP = 0
Nenue@99 849 bagData.fishingAP = 0
Nenue@99 850 bagData.items = bagData.items or {}
Nenue@99 851 table.wipe(bagData.items)
Nick@111 852 local c = self.cache
Nenue@99 853
Nick@111 854 c.bagItems[id] = c.bagItems[id] or {}
Nick@111 855 c.bags[id] = c.bags[id] or {}
Nick@111 856 c.fishing[id] = c.fishing[id] or {}
Nick@108 857
Nenue@97 858 for slotID = 1, numSlots do
Nenue@97 859 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID)
Nenue@101 860 if link then
Nenue@101 861 local itemID = GetContainerItemID(id, slotID)
Nenue@101 862 local name, _, quality, iLevel, reqLevel, class, subclass = GetItemInfo(link)
Nenue@97 863
Nick@111 864 if class == 'Consumable' or subclass == 'Cooking' then
Nenue@102 865 --print(GetItemInfo(link))
Nick@108 866 local itemAP, isFishingAP
Nick@111 867 if c.bags[id][slotID] and (c.bagItems[id][slotID] == itemID) then
Nick@111 868 --print('cached slot', id, slotID, name)
Nick@111 869 itemAP = c.bags[id][slotID]
Nick@111 870 isFishingAP = c.fishing[id] and c.fishing[id][slotID]
Nick@108 871 else
Nick@108 872 itemAP, isFishingAP = self:GetItemAP(itemID, link)
Nick@111 873 c.bagItems[id][slotID] = itemID
Nick@111 874 c.bags[id][slotID] = itemAP
Nick@111 875 c.fishing[id][slotID] = isFishingAP
Nick@108 876 end
Nick@108 877
Nick@108 878
Nenue@102 879 --print(itemAP, isFishingAP)
Nenue@102 880 if itemAP and (itemAP > 0) then
Nick@111 881 local itemButton = self:GetItemButton(itemID, texture, itemAP, isFishingAP)
Nenue@102 882
Nenue@101 883 if isFishingAP then
Nenue@101 884 bagData.fishingItems = (bagData.fishingItems or 0) + 1
Nenue@101 885 bagData.fishingAP = (bagData.fishingAP or 0) + itemAP
Nenue@101 886 else
Nick@108 887 itemAP = itemAP
Nenue@101 888 bagData.numItems = (bagData.numItems or 0) + 1
Nenue@101 889 bagData.totalAP = (bagData.totalAP or 0) + itemAP
Nenue@101 890 end
Nenue@101 891 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1
Nenue@101 892 end
Nenue@101 893 elseif self.profile.artifacts[itemID] then
Nick@111 894 --print('artifact weapon', itemID, link, id, slotID)
Nenue@101 895 self.profile.artifacts[itemID].containerID = id
Nenue@101 896 self.profile.artifacts[itemID].slotID = slotID
Nick@111 897 else
Nick@111 898 --print('skipping', class, subclass, link)
Nenue@101 899 end
Nenue@99 900
Nenue@97 901 end
Nenue@97 902
Nenue@97 903 end
Nenue@97 904
Nenue@97 905 end
Nenue@97 906
Nenue@98 907 local BAG_SLOTS = {0, 1, 2, 3, 4 }
Nenue@98 908 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12}
Nenue@99 909 local ItemCounts = {}
Nenue@116 910 function Module:ScanAllBags()
Nenue@99 911 if InCombatLockdown() then
Nenue@99 912 self.queuedScan = true
Nenue@99 913 return
Nenue@99 914 end
Nenue@101 915 if not self.profile.knowledgeMultiplier then
Nenue@101 916 print('need to get knowledge level')
Nenue@101 917 return
Nenue@101 918 end
Nenue@101 919
Nenue@99 920 self.queuedScan = nil
Nenue@98 921
Nenue@101 922 print('|cFFFF0088ScanAllBags()|r', self.profile.knowledgeMultiplier)
Nenue@97 923
Nenue@99 924 for _, button in ipairs(self.Tokens) do
Nenue@99 925 button.numItems = 0
Nenue@99 926 end
Nenue@99 927
Nenue@99 928
Nenue@98 929 for _, bagID in ipairs(BAG_SLOTS) do
Nenue@98 930 self:ScanBag(bagID)
Nenue@97 931 end
Nenue@97 932
Nenue@99 933 if self.bankAccess then
Nenue@98 934 for _, bagID in ipairs(BANK_SLOTS) do
Nenue@98 935 self:ScanBag(bagID)
Nenue@98 936 end
Nenue@98 937 end
Nenue@98 938
Nenue@125 939
Nenue@125 940
Nenue@98 941 self.bankAP = 0
Nenue@98 942 self.bagAP = 0
Nenue@99 943 self.fishingAP = 0
Nenue@99 944
Nenue@99 945 table.wipe(ItemCounts)
Nenue@98 946 for id, bagData in pairs(self.profile.bagslots) do
Nick@111 947 print(id, GetBagName(id), bagData.totalAP, bagData.fishingAP)
Nenue@98 948 id = tonumber(id)
Nenue@98 949 if bagData.totalAP then
Nenue@98 950 if (id == BANK_CONTAINER) or (id >= 5) then
Nenue@98 951 self.bankAP = self.bankAP + bagData.totalAP
Nenue@98 952 else
Nenue@98 953 self.bagAP = self.bagAP + bagData.totalAP
Nenue@97 954 end
Nenue@98 955 end
Nenue@99 956 if bagData.fishingAP then
Nenue@99 957 self.fishingAP = self.fishingAP + bagData.fishingAP
Nenue@99 958 end
Nenue@97 959
Nenue@97 960 end
Nenue@98 961 self.lastUpdate = GetTime()
Nenue@103 962 self.queuedScan = nil
Nenue@99 963 self:TryToShow()
Nenue@97 964 end
Nenue@97 965
Nenue@98 966
Nenue@122 967 function Artifact:SetItem(itemID, artifact, index, equipped, fishing)
Nenue@122 968 print('|cFF00FFFFSetItem()|r', itemID, index)
Nenue@98 969 print(artifact.name, artifact.texture, artifact.currentXP)
Nenue@122 970
Nick@108 971 if not artifact.currentCost then
Nick@108 972 artifact.currentCost = artifact.cost
Nick@108 973 end
Nick@108 974
Nenue@98 975 for k,v in pairs(artifact) do
Nenue@98 976 --print('::',k,v)
Nenue@98 977 self[k] = v
Nenue@98 978 end
Nenue@98 979
Nick@111 980 self.isFishing = fishing
Nenue@98 981 -- this can change between artifact parses
Nenue@117 982 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 983 print('unspent:', unusedXP)
Nenue@99 984
Nenue@117 985 -- current standing artifact XP (what appears in the artifact ui)
Nenue@117 986 -- actual artifact XP after any unlocked points are spent
Nenue@117 987 -- total total of invested and inventory XP
Nenue@117 988 -- totalCost total of costs between current and actual level
Nenue@117 989 local actualXP = artifact.currentXP
Nenue@116 990 local actualLevel = artifact.level
Nenue@116 991 local actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
Nenue@116 992
Nenue@117 993 print('tier:', artifact.tier)
Nenue@117 994 print('current:', self.level, self.currentXP, '/', self.currentCost)
Nenue@116 995 while actualXP >= actualCost do
Nenue@116 996 actualXP = actualXP - actualCost
Nenue@116 997 actualLevel = actualLevel + 1
Nenue@116 998 actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier)
Nenue@117 999
Nenue@117 1000 print('* ', actualLevel, actualXP, actualCost, totalCost)
Nenue@98 1001 end
Nenue@117 1002 print('actual:', actualLevel, actualXP, '/', actualCost)
Nenue@117 1003
Nenue@117 1004
Nenue@123 1005 local totalXP = actualXP + unusedXP
Nenue@123 1006 local totalCost = actualCost
Nenue@123 1007 local totalLevel = actualLevel
Nenue@123 1008
Nenue@123 1009 local remaining = totalXP
Nenue@120 1010 local nextCost = artifact.currentCost
Nenue@123 1011 print(totalXP, totalCost)
Nenue@120 1012 if remaining > nextCost then
Nenue@120 1013 while remaining >= nextCost do
Nenue@117 1014 totalLevel = totalLevel + 1
Nenue@119 1015 remaining = remaining - nextCost
Nenue@117 1016 nextCost = C_ArtifactUI.GetCostForPointAtRank(totalLevel, artifact.tier)
Nenue@119 1017 print('|cFFFFFF00+ ', totalLevel, remaining, '/', totalCost)
Nenue@117 1018 end
Nenue@119 1019 totalXP = remaining
Nenue@119 1020 totalCost = nextCost
Nenue@117 1021 end
Nenue@117 1022 print('total:', totalLevel, totalXP, '/', totalCost)
Nenue@117 1023
Nenue@117 1024 self.currentLevel = self.level
Nenue@117 1025
Nenue@117 1026
Nenue@116 1027 self.actualCost = actualCost
Nenue@116 1028 self.actualLevel = actualLevel
Nenue@116 1029 self.actualXP = actualXP
Nenue@117 1030
Nenue@117 1031 self.totalXP = totalXP
Nenue@117 1032 self.totalCost = totalCost
Nenue@117 1033 self.totalLevel = totalLevel
Nenue@117 1034
Nenue@98 1035
Nenue@98 1036
Nenue@99 1037 if index ~= 1 then
Nenue@99 1038 self:ClearAllPoints()
Nenue@99 1039 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0)
Nenue@99 1040 else
Nenue@99 1041 self:ClearAllPoints()
Nenue@99 1042 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', 4, -4)
Nenue@99 1043 end
Nenue@98 1044
Nenue@122 1045 self.itemID = itemID
Nenue@99 1046 self.isEquipped = equipped
Nenue@98 1047 self:Update()
Nenue@125 1048 self:SetShown(true)
Nenue@122 1049
Nenue@98 1050 return self
Nenue@98 1051 end
Nenue@98 1052
Nenue@122 1053 function Artifact:UpdateXPBar()
Nenue@122 1054 local r3, g3, b3 = 1, .5, 0 -- main xp bar
Nenue@122 1055 -- current: amount shown in blizz ui
Nenue@122 1056 -- actual: amount contributing the next level, will be same until current point cap is reached
Nenue@122 1057 -- potential: total of ap on hand
Nenue@122 1058 print(self.currentXP, self.actualXP, self.potentialXP)
Nenue@122 1059
Nenue@123 1060 local maxHeight = self:GetHeight() - (XP_INSET*2)
Nenue@122 1061 local currentHeight = self.CurrentProgress:GetHeight() or 1
Nenue@122 1062 local offHeight = self.AdjustedProgress:GetHeight() or 1
Nenue@122 1063
Nenue@122 1064
Nenue@129 1065 self.CurrentProgress:SetPoint('BOTTOM', self.XPBackground, 'BOTTOM', 0, 0)
Nenue@122 1066 local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1
Nenue@122 1067 local projectedProgress = (self.totalXP < self.totalCost) and (self.totalXP / self.totalCost) or 1
Nenue@122 1068 if self.actualLevel ~= self.level then
Nenue@122 1069 r3, g3, b3 = 0, 1, 1
Nenue@122 1070 end
Nenue@122 1071
Nenue@123 1072 print('|cFFFF4400', currentProgress, projectedProgress, self.currentLevel, self.totalLevel)
Nenue@122 1073 if self.level <= WEAPON_MAX_TRAITS then
Nenue@122 1074 self.CurrentProgress.animateFrom = currentHeight or 1
Nenue@122 1075 self.CurrentProgress.animateTo = currentProgress * maxHeight
Nenue@122 1076 self.CurrentProgress:Show()
Nenue@122 1077 else
Nenue@122 1078 self.CurrentProgress:Hide()
Nenue@122 1079 end
Nenue@122 1080
Nenue@123 1081 local nextLevel = (self.totalLevel ~= self.currentLevel)
Nenue@123 1082
Nenue@123 1083 if self.totalXP ~= self.currentXP or nextLevel then
Nenue@123 1084 print('project', 'xp test=', (self.totalXP ~= self.currentXP), 'lvl test=', (self.totalLevel ~= self.currentLevel))
Nenue@123 1085
Nenue@123 1086 local projectedPos = projectedProgress
Nenue@123 1087
Nenue@123 1088 if projectedProgress > currentProgress and (not nextLevel) then
Nenue@123 1089 projectedPos = (projectedProgress - currentProgress)
Nenue@123 1090 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP', 0, 0)
Nenue@123 1091 print(' set above', projectedPos, self.CurrentProgress:GetPoint(3))
Nenue@122 1092 else
Nenue@123 1093 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM', 0 , XP_INSET)
Nenue@123 1094 print(' set under', projectedPos)
Nenue@122 1095 end
Nenue@122 1096 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1
Nenue@123 1097 self.AdjustedProgress.animateTo = projectedPos * maxHeight
Nenue@122 1098 self.AdjustedProgress:Show()
Nenue@122 1099 else
Nenue@123 1100 print('nothing to project')
Nenue@122 1101 self.AdjustedProgress:Hide()
Nenue@122 1102 end
Nenue@123 1103
Nenue@123 1104
Nenue@122 1105 --print(self.CurrentProgress:GetPoint(3))
Nenue@122 1106 --print(self.CurrentProgress:GetSize())
Nenue@122 1107
Nenue@123 1108 self.XPBackground:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', XP_INSET, XP_INSET)
Nenue@123 1109 self.XPBackground:SetPoint('TOPRIGHT', self, 'TOPLEFT', XP_INSET + XP_WIDTH, -XP_INSET)
Nenue@122 1110 self.CurrentProgress:SetColorTexture(r3,g3,b3,1)
Nenue@122 1111
Nenue@122 1112 end
Nenue@122 1113
Nenue@122 1114 function Artifact:OnLoad()
Nenue@122 1115 print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID())
Nenue@122 1116 end
Nenue@122 1117
Nenue@116 1118 function Artifact:Update()
Nenue@122 1119 if not self.itemID then
Nenue@122 1120 return
Nenue@122 1121 end
Nenue@122 1122
Nenue@125 1123 print(self:GetName(), '|cff00FFFFUpdate()|r')
Nenue@122 1124 local r1, g1, b1 = 1, 1, 1 -- top text
Nenue@122 1125 local r2, g2, b2 = 1, 1, 0 -- bottom text
Nenue@99 1126 local levelText = self.level
Nenue@116 1127 local xpText = ShortNumberString(self.currentXP)
Nenue@116 1128 local costText = ShortNumberString(self.currentCost)
Nenue@116 1129 local remainingText = ShortNumberString(self.currentCost - self.currentXP)
Nenue@122 1130
Nenue@122 1131 local maxHeight = self:GetHeight() - 4
Nenue@122 1132 local currentHeight = self.CurrentProgress:GetHeight() or 1
Nenue@122 1133 local offHeight = self.AdjustedProgress:GetHeight() or 1
Nenue@122 1134
Nenue@97 1135 if self.actualLevel ~= self.level then
Nenue@116 1136 levelText = self.actualLevel
Nenue@116 1137 r1, g1, b1 = 0, 1, 0
Nenue@116 1138 xpText = ShortNumberString(self.actualXP)
Nenue@116 1139 costText = ShortNumberString(self.actualCost)
Nenue@116 1140 remainingText = ShortNumberString(self.actualCost-self.actualXP)
Nenue@116 1141 --[[elseif self.potentialLevel ~= self.level then
Nenue@116 1142 r1, g1, b1 = 0, 1, 1
Nenue@116 1143 r2, g2, b2 = 0, 1, 1
Nenue@116 1144 costText = ShortNumberString(self.potentialCost)
Nenue@116 1145 remainingText = ShortNumberString(self.potentialCost-self.potentialXP)
Nenue@116 1146 --]]
Nenue@97 1147 end
Nenue@97 1148
Nenue@99 1149 self.Level:SetText(levelText)
Nenue@116 1150 self.CurrentXP:SetText( xpText )
Nenue@116 1151 self.RemainingCost:SetText(remainingText)
Nenue@116 1152 self.Level:SetTextColor(r1, g1, b1)
Nenue@116 1153 self.CurrentXP:SetTextColor(r1, g1, b1)
Nenue@99 1154
Nenue@97 1155 if self.isEquipped then
Nenue@116 1156 self:SetSize(64,64)
Nenue@97 1157 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]])
Nenue@97 1158 self:GetNormalTexture():SetBlendMode('ADD')
Nenue@97 1159 self:GetNormalTexture():SetVertexColor(0,1,0)
Nenue@97 1160 else
Nenue@116 1161 self:SetSize(48,48)
Nenue@97 1162 self:SetNormalTexture(nil, 'ADD')
Nenue@97 1163 end
Nenue@97 1164
Nenue@122 1165 self:UpdateXPBar()
Nenue@116 1166
Nenue@117 1167 if self.actualLevel ~= self.currentLevel then
Nenue@117 1168 self:SetNormalTexture([[Interface\Buttons\UI-Quickslot-Depress]], 'ADD')
Nenue@117 1169 self:GetNormalTexture():SetBlendMode('BLEND')
Nenue@117 1170 self:GetNormalTexture():SetVertexColor(1,1,1)
Nenue@117 1171 else
Nenue@117 1172 self:SetNormalTexture(nil, 'ADD')
Nenue@117 1173 end
Nenue@97 1174 self.Icon:SetTexture(self.texture)
Nenue@97 1175 end
Nenue@97 1176
Nenue@119 1177 local XP_SCALING_DURATION = .5
Nenue@116 1178 function Artifact:AnimateProgress(region)
Nenue@98 1179 local cTime = GetTime()
Nenue@98 1180 if not region.animateStart then
Nenue@98 1181 region.animateStart = cTime
Nenue@98 1182 end
Nenue@98 1183 local progressTo, progressFrom = region.animateTo, region.animateFrom
Nenue@98 1184 local elapsed = cTime - region.animateStart
Nenue@119 1185 if elapsed >= XP_SCALING_DURATION then
Nenue@98 1186 region:SetHeight(progressTo)
Nenue@98 1187 region.animateTo = nil
Nenue@98 1188 region.animateStart = nil
Nenue@98 1189 region.animateFrom = nil
Nenue@98 1190 else
Nenue@119 1191 local progress = elapsed / XP_SCALING_DURATION
Nenue@98 1192 local height = (progressFrom + (progressTo - progressFrom) * progress)
Nenue@98 1193 --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height))
Nenue@98 1194 region:SetHeight(height)
Nenue@98 1195 end
Nenue@98 1196 end
Nenue@98 1197
Nenue@116 1198 function Artifact:OnUpdate(sinceLast)
Nenue@98 1199 if self.CurrentProgress.animateTo then
Nenue@98 1200 self:AnimateProgress(self.CurrentProgress)
Nenue@98 1201 end
Nenue@98 1202
Nenue@98 1203 if self.AdjustedProgress.animateTo then
Nenue@98 1204 self:AnimateProgress(self.AdjustedProgress)
Nenue@98 1205 end
Nenue@98 1206 end
Nenue@98 1207
Nenue@116 1208 function Artifact:OnEnter()
Nenue@97 1209 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
Nenue@97 1210 GameTooltip:SetText(self.name)
Nenue@119 1211 GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 1)
Nenue@99 1212 if self.actualLevel ~= self.level then
Nenue@119 1213 GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 1, 1, 0)
Nick@108 1214 end
Nick@108 1215 if self.currentXP < self.currentCost then
Nenue@117 1216 GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' for level ' .. (self.currentLevel+1), 1, 1, 0)
Nenue@117 1217 else
Nenue@117 1218 GameTooltip:AddLine(ShortNumberString(self.actualCost - self.actualXP) .. ' for level ' .. (self.actualLevel+1), 0, 1, 0)
Nenue@117 1219 end
Nenue@117 1220 if self.totalLevel ~= self.actualLevel then
Nenue@117 1221 GameTooltip:AddLine('Level ' .. self.totalLevel .. ' with unspent tokens', 0, 1, 1)
Nenue@99 1222 end
Nenue@99 1223
Nenue@97 1224 GameTooltip:Show()
Nenue@97 1225 end
Nenue@116 1226 function Artifact:OnLeave()
Nenue@97 1227 if GameTooltip:IsOwned(self) then
Nenue@97 1228 GameTooltip:Hide()
Nenue@97 1229 end
Nenue@97 1230 end
Nenue@116 1231 function Artifact:OnHide()
Nick@108 1232
Nick@108 1233 if GameTooltip:IsOwned(self) then
Nick@108 1234 GameTooltip:Hide()
Nick@108 1235 end
Nick@108 1236 end
Nenue@97 1237
Nenue@116 1238 function Artifact:OnClick(button, down)
Nenue@97 1239 if self.isEquipped then
Nenue@97 1240 SocketInventoryItem(16)
Nenue@97 1241 else
Nick@108 1242 if IsShiftKeyDown() then
Nenue@119 1243 SocketContainerItem(self.containerID, self.slotID)
Nick@108 1244 else
Nick@108 1245
Nick@108 1246 end
Nenue@97 1247 end
Nenue@122 1248 end