annotate Modules/ArtifactPower.lua @ 131:15a7f27b11e6 v7.3.2-20111027

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