annotate Modules/ArtifactPower.lua @ 98:dadddb8a551f

- bag scan intervals - progress visualization - artifact xp updates
author Nenue
date Tue, 17 Jan 2017 09:49:15 -0500
parents 5476337198ec
children 74d6d97a2d24
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@97 9
Nenue@97 10 anchorPoint = 'TOP',
Nenue@97 11 anchorFrom = 'TOP',
Nenue@97 12 }
Nenue@97 13 local ap = VeneerArtifactPowerMixin
Nenue@97 14 local BAGS_TO_SCAN = {BACKPACK_CONTAINER }
Nenue@97 15 local TOOLTIP_NAME = 'VeneerAPScanner'
Nenue@98 16 local POINT_COSTS = {
Nenue@98 17 100, 300, 325, 350, 375,
Nenue@98 18 400, 425, 450, 525, 625,
Nenue@98 19 750, 875, 1000, 6840, 8830,
Nenue@98 20 11280, 14400, 18620, 24000, 30600,
Nenue@98 21 39520, 50880, 64800, 82500, 105280,
Nenue@98 22 138650, 182780, 240870, 325520, 417560,
Nenue@98 23 546000, 718200, 946660, 1245840, 1635200,
Nenue@98 24 191500, 2010000, 2110000, 2215000, 2325000,
Nenue@98 25 2440000, 2560000, 2690000, 2825000, 2965000,
Nenue@98 26 3115000, 3270000, 3435000, 3605000, 3785000,
Nenue@98 27 3975000, 4175000, 4385000, 4605000
Nenue@98 28 }
Nenue@97 29
Nenue@97 30 function ap:OnLoad()
Nenue@97 31 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan
Nenue@97 32 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity
Nenue@97 33 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available
Nenue@97 34 self:RegisterEvent('BANKFRAME_CLOSED') -- " " "
Nenue@97 35 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed
Nenue@98 36 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data)
Nenue@97 37 self:RegisterEvent('MODIFIER_STATE_CHANGED')
Nenue@97 38 self:RegisterEvent('PLAYER_REGEN_ENABLED')
Nenue@97 39 self:RegisterEvent('PLAYER_REGEN_DISABLED')
Nenue@97 40 Veneer:AddHandler(self, self.anchorPoint, true)
Nenue@97 41 SLASH_VENEER_AP1 = "/vap"
Nenue@97 42 SLASH_VENEER_AP2 = "/veneerap"
Nenue@98 43 SlashCmdList.VENEER_AP = function(arg)
Nenue@98 44 if arg == 'fishing' then
Nenue@98 45 if VeneerData.ArtifactPower.EnableFishing then
Nenue@98 46 VeneerData.ArtifactPower.EnableFishing = nil
Nenue@98 47 else
Nenue@98 48 VeneerData.ArtifactPower.EnableFishing = true
Nenue@98 49 end
Nenue@98 50 self:Print('Show Underlight Angler:', (VeneerData.ArtifactPower.EnableFishing and 'ON' or 'OFF'))
Nenue@98 51 self:Update()
Nenue@98 52
Nenue@98 53 else
Nenue@98 54 self:Show()
Nenue@98 55 end
Nenue@97 56 end
Nenue@97 57
Nenue@97 58 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate')
Nenue@97 59
Nenue@97 60 end
Nenue@97 61
Nenue@97 62 local defaultSettings = {
Nenue@97 63 }
Nenue@97 64
Nenue@97 65 function ap:Setup()
Nenue@97 66 print(self:GetName()..':Setup()')
Nenue@97 67 local guid = UnitGUID('player')
Nenue@97 68 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings
Nenue@97 69 VeneerData.ArtifactPower[guid] = VeneerData.ArtifactPower[guid] or {}
Nenue@97 70 self.profile = VeneerData.ArtifactPower[guid]
Nenue@97 71 self.profile.bagslots = self.profile.bagslots or {}
Nenue@97 72 self.profile.artifacts = self.profile.artifacts or {}
Nenue@97 73 self.updateSummary = true
Nenue@97 74
Nenue@97 75 -- Bagnon compatibility
Nenue@97 76 -- todo: ArkInventory, Elv, etc
Nenue@97 77 if IsAddOnLoaded('Bagnon') then
Nenue@97 78 local oToggleAllBags = ToggleAllBags
Nenue@97 79 ToggleAllBags = function()
Nenue@97 80 print('|cFFFF0088ToggleAllBags')
Nenue@97 81 oToggleAllBags()
Nenue@97 82 if BagnonFrameinventory:IsShown() then
Nenue@97 83 self:Show()
Nenue@97 84 else
Nenue@97 85 self.enabled = nil
Nenue@97 86 self:Hide()
Nenue@97 87 end
Nenue@97 88 end
Nenue@97 89 else
Nenue@97 90 hooksecurefunc("OpenBackpack", function()
Nenue@97 91 self:Show()
Nenue@97 92 end)
Nenue@97 93 hooksecurefunc("CloseBackpack", function()
Nenue@97 94 self.enabled = nil
Nenue@97 95 self:Hide()
Nenue@97 96 end)
Nenue@97 97 end
Nenue@97 98
Nenue@97 99
Nenue@97 100 end
Nenue@97 101 local UNDERLIGHT_ANGLER_ID = 133755
Nenue@98 102 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@98 103 print('|cFF00FF00SetArtifact()|r')
Nenue@97 104 if not self.profile then
Nenue@97 105 return
Nenue@97 106 end
Nenue@97 107 local artifacts = self.profile.artifacts
Nenue@97 108
Nenue@97 109
Nenue@97 110 if itemID then
Nenue@98 111 artifacts[itemID] = artifacts[itemID] or {}
Nenue@98 112 table.wipe(artifacts[itemID])
Nenue@98 113 local artifact = artifacts[itemID]
Nenue@97 114
Nenue@98 115 artifact.name = name
Nenue@98 116 artifact.texture = texture
Nenue@98 117 artifact.currentXP = currentXP
Nenue@98 118 artifact.level = pointsSpent
Nenue@98 119 local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent)
Nenue@98 120 artifact.cost = cost
Nenue@97 121
Nenue@98 122 local pointsAvailable = pointsSpent
Nenue@98 123 local actualCost = cost
Nenue@98 124 local actualXP = currentXP
Nenue@98 125 while actualXP >= actualCost do
Nenue@98 126 pointsAvailable = pointsAvailable + 1
Nenue@98 127 actualXP = actualXP - actualCost
Nenue@98 128 print(pointsAvailable, '-', actualCost, '=', actualXP)
Nenue@98 129 actualCost = C_ArtifactUI.GetCostForPointAtRank(pointsAvailable)
Nenue@98 130 end
Nenue@98 131 print('updating', itemID, name, currentXP, pointsSpent, pointsAvailable, actualXP)
Nenue@98 132 artifact.actualXP = actualXP
Nenue@98 133 artifact.actualLevel = pointsAvailable
Nenue@98 134 artifact.actualCost = actualCost
Nenue@97 135
Nenue@97 136 end
Nenue@97 137 end
Nenue@97 138 function ap:QueueBag(containerID)
Nenue@97 139 containerID = tonumber(containerID)
Nenue@97 140 if not containerID then
Nenue@97 141 return
Nenue@97 142 end
Nenue@97 143
Nenue@97 144 if not tContains(BAGS_TO_SCAN, containerID) then
Nenue@97 145 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line')
Nenue@97 146 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID
Nenue@97 147 end
Nenue@97 148 end
Nenue@97 149
Nenue@97 150 function ap:OnShow()
Nenue@97 151 self.enabled = true
Nenue@97 152 self:Update()
Nenue@97 153 Veneer:DynamicReanchor()
Nenue@97 154 end
Nenue@97 155 function ap:OnHide()
Nenue@97 156 Veneer:DynamicReanchor()
Nenue@97 157 end
Nenue@97 158
Nenue@97 159 function ap:OnEnter()
Nenue@97 160
Nenue@97 161 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
Nenue@97 162
Nenue@97 163 GameTooltip:AddLine(self.bagAP)
Nenue@97 164 GameTooltip:AddLine(self.bankAP)
Nenue@97 165
Nenue@97 166 end
Nenue@97 167
Nenue@97 168 function ap:OnEvent(event, ...)
Nenue@97 169 print(self:GetName()..':OnEvent()', event, ...)
Nenue@97 170 if event == 'BAG_UPDATE' then
Nenue@97 171 local containerID = ...
Nenue@97 172 self:QueueBag(containerID)
Nenue@97 173 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then
Nenue@98 174 self:ScanAllBags(true)
Nenue@98 175 self:Update()
Nenue@97 176 elseif event == 'BAG_UPDATE_DELAYED' then
Nenue@98 177 self:ScanAllBags(self.bankAccess)
Nenue@97 178 elseif event == 'BANKFRAME_OPENED' then
Nenue@97 179 self.bankAccess = true
Nenue@98 180 self:ScanAllBags(true)
Nenue@97 181 elseif event == 'BANKFRAME_CLOSED' then
Nenue@97 182 self.bankAccess = false
Nenue@97 183 elseif event == 'ARTIFACT_UPDATE' then
Nenue@98 184 local newItem = ...
Nenue@98 185 if newItem then
Nenue@98 186 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo()
Nenue@98 187 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@98 188 self:ScanAllBags(self.bankAccess)
Nenue@98 189 end
Nenue@98 190 elseif event == 'ARTIFACT_XP_UPDATE' then
Nenue@98 191 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo()
Nenue@98 192 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent)
Nenue@98 193 self:ScanAllBags(self.bankAccess)
Nenue@97 194 elseif event == 'PLAYER_REGEN_ENABLED' then
Nenue@97 195 if self.enabled then
Nenue@97 196 self:Show()
Nenue@97 197 end
Nenue@97 198
Nenue@97 199 elseif event == 'PLAYER_REGEN_DISABLED' then
Nenue@97 200 self:Hide()
Nenue@97 201 end
Nenue@97 202 end
Nenue@97 203
Nenue@97 204 function ap:OnMouseDown()
Nenue@97 205 self.enabled = nil
Nenue@97 206 self:Hide()
Nenue@97 207 end
Nenue@97 208
Nenue@97 209 function ap:Update()
Nenue@97 210 if not self:IsShown() then
Nenue@97 211 return
Nenue@97 212 end
Nenue@97 213 print('|cFF00FFFFUpdate()|r')
Nenue@97 214
Nenue@97 215 local bankText, bagText
Nenue@97 216 if not (self.bankAP and self.bagAP) then
Nenue@97 217 bankText = '|cFFFF0000Open bank frame to count all AP|r '
Nenue@97 218 else
Nenue@98 219 if (self.bagAP + self.bankAP) == 0 then
Nenue@98 220 bankText = '|cFF00FFFFNo Items|r'
Nenue@98 221 else
Nenue@98 222 if self.bagAP and (self.bagAP > 0) then
Nenue@98 223 bankText = '|cFFFFFFFF' .. tostring(self.bagAP) .. '|r'
Nenue@98 224 end
Nenue@98 225 if self.bankAP and (self.bankAP > 0) then
Nenue@98 226 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r'
Nenue@98 227 end
Nenue@98 228 end
Nenue@97 229 end
Nenue@97 230 self.SummaryHeader:SetText(bankText)
Nenue@97 231
Nenue@97 232 -- Artifact icons, in no particular order
Nenue@97 233 local equippedID = C_ArtifactUI.GetEquippedArtifactInfo()
Nenue@97 234 local numButtons = 0
Nenue@97 235 local lastFrame
Nenue@98 236 local fishingRod, fishingID, fishingData
Nenue@98 237 local index, button
Nenue@97 238 for itemID, artifact in pairs(self.profile.artifacts) do
Nenue@98 239 local isFishingRod = (itemID == UNDERLIGHT_ANGLER_ID)
Nenue@98 240 if isFishingRod then
Nenue@98 241 if VeneerData.ArtifactPower.EnableFishing then
Nenue@98 242 fishingID = itemID
Nenue@98 243 fishingData = artifact
Nenue@98 244 end
Nenue@97 245
Nenue@98 246 else
Nenue@98 247 numButtons = numButtons + 1
Nenue@98 248 button = self.Artifact[numButtons]
Nenue@98 249 lastFrame = button:SetButton(itemID, artifact, lastFrame)
Nenue@97 250 end
Nenue@97 251
Nenue@98 252 end
Nenue@97 253
Nenue@98 254 if fishingData then
Nenue@98 255 numButtons = numButtons + 1
Nenue@98 256 local button = self.Artifact[GetNumSpecializations()+1]
Nenue@98 257 button:SetButton(fishingID, fishingData, lastFrame)
Nenue@98 258 end
Nenue@97 259
Nenue@98 260 for i = numButtons+ (fishingRod and 2 or 1), #self.Artifact do
Nenue@97 261 print('hide', i)
Nenue@97 262 self.Artifact[i]:Hide()
Nenue@97 263 end
Nenue@97 264
Nenue@97 265
Nenue@97 266
Nenue@98 267 self:SetWidth(64*numButtons + 4 * (numButtons+1))
Nenue@98 268 self:SetHeight(12 + self.SummaryHeader:GetHeight() + 64)
Nenue@97 269 self:Reanchor()
Nenue@97 270
Nenue@97 271 end
Nenue@97 272
Nenue@97 273 function ap:ScanBag(id)
Nenue@97 274 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id))
Nenue@97 275 local numSlots = GetContainerNumSlots(id)
Nenue@97 276 local requiresUpdate
Nenue@97 277 if numSlots == 0 then
Nenue@97 278 return nil
Nenue@97 279 end
Nenue@97 280
Nenue@97 281
Nenue@97 282 self.profile.bagslots[id] = self.profile.bagslots[id] or {}
Nenue@97 283 table.wipe(self.profile.bagslots[id])
Nenue@97 284 local bagData = self.profile.bagslots[id]
Nenue@97 285 bagData.totalAP = 0
Nenue@97 286 for slotID = 1, numSlots do
Nenue@97 287 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID)
Nenue@97 288 local itemID = GetContainerItemID(id, slotID)
Nenue@97 289
Nenue@97 290 if link then
Nenue@97 291 self.tooltip:SetOwner(self, 'ANCHOR_NONE')
Nenue@97 292 self.tooltip:SetHyperlink(link)
Nenue@97 293 self.tooltip:Show()
Nenue@97 294 local numLines = self.tooltip:NumLines()
Nenue@97 295 if numLines >= 3 then
Nenue@97 296 local subText = _G[TOOLTIP_NAME .. 'TextLeft2']:GetText()
Nenue@97 297 if subText and subText:match(ARTIFACT_POWER) then
Nenue@97 298 for i = 3, numLines do
Nenue@97 299 local text = _G[TOOLTIP_NAME .. 'TextLeft'.. i]:GetText()
Nenue@97 300 if text and text:match(ARTIFACT_POWER) then
Nenue@97 301 text = text:gsub('[,%D]', '')
Nenue@97 302 print(link, '-', tonumber(text))
Nenue@97 303 local itemAP = tonumber(text)
Nenue@97 304 if itemAP then
Nenue@98 305 requiresUpdate = true
Nenue@97 306 bagData.numItems = (bagData.numItems or 0) + 1
Nenue@97 307 bagData.totalAP = (bagData.totalAP or 0) + itemAP
Nenue@97 308 bagData.items = bagData.items or {}
Nenue@97 309 if not bagData.items[itemID] then
Nenue@97 310 bagData.numUnique = (bagData.numUnique or 0) + 1
Nenue@97 311 end
Nenue@97 312 bagData.items[itemID] = (bagData.items[itemAP] or 0) + 1
Nenue@97 313 end
Nenue@97 314 end
Nenue@97 315 end
Nenue@97 316 end
Nenue@97 317 end
Nenue@97 318 end
Nenue@97 319
Nenue@97 320 if self.profile.artifacts[itemID] then
Nenue@97 321 print('artfiact weapon', itemID, link, id, slotID)
Nenue@97 322 self.profile.artifacts[itemID].containerID = id
Nenue@97 323 self.profile.artifacts[itemID].slotID = slotID
Nenue@97 324 end
Nenue@97 325
Nenue@97 326 end
Nenue@97 327
Nenue@97 328 end
Nenue@97 329
Nenue@98 330 local BAG_SLOTS = {0, 1, 2, 3, 4 }
Nenue@98 331 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12}
Nenue@98 332
Nenue@98 333 function ap:ScanAllBags(checkBank)
Nenue@97 334 print('|cFFFF0088ScanAllBags()|r')
Nenue@97 335
Nenue@98 336 for _, bagID in ipairs(BAG_SLOTS) do
Nenue@98 337 self:ScanBag(bagID)
Nenue@97 338 end
Nenue@97 339
Nenue@98 340 if checkBank then
Nenue@98 341 for _, bagID in ipairs(BANK_SLOTS) do
Nenue@98 342 self:ScanBag(bagID)
Nenue@98 343 end
Nenue@98 344 end
Nenue@98 345
Nenue@98 346 self.bankAP = 0
Nenue@98 347 self.bagAP = 0
Nenue@98 348 for id, bagData in pairs(self.profile.bagslots) do
Nenue@98 349 print(id, GetBagName(id), bagData.totalAP)
Nenue@98 350 id = tonumber(id)
Nenue@98 351 if bagData.totalAP then
Nenue@98 352 if (id == BANK_CONTAINER) or (id >= 5) then
Nenue@98 353 self.bankAP = self.bankAP + bagData.totalAP
Nenue@98 354 else
Nenue@98 355 self.bagAP = self.bagAP + bagData.totalAP
Nenue@97 356 end
Nenue@98 357 end
Nenue@97 358
Nenue@97 359 end
Nenue@98 360 self.lastUpdate = GetTime()
Nenue@98 361 self:Update()
Nenue@97 362 self.updateSummary = nil
Nenue@97 363 end
Nenue@97 364
Nenue@97 365 VeneerArtifactButtonMixin = {}
Nenue@98 366
Nenue@98 367 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, lastFrame)
Nenue@98 368 print(artifact.name, artifact.texture, artifact.currentXP)
Nenue@98 369 self:SetID(itemID)
Nenue@98 370 for k,v in pairs(artifact) do
Nenue@98 371 --print('::',k,v)
Nenue@98 372 self[k] = v
Nenue@98 373 end
Nenue@98 374
Nenue@98 375 -- this can change between artifact parses
Nenue@98 376 local potentialPoints = self.actualLevel
Nenue@98 377 local totalAP = (itemID == UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self.fishingAP or 0)
Nenue@98 378 local potentialXP = self.actualXP + totalAP
Nenue@98 379 self.potentialXP = potentialXP
Nenue@98 380 local potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints)
Nenue@98 381 while potentialXP >= potentialCost do
Nenue@98 382 potentialXP = potentialXP - potentialCost
Nenue@98 383 potentialPoints = potentialPoints + 1
Nenue@98 384 print('inc estimate', potentialXP, potentialPoints)
Nenue@98 385 potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints)
Nenue@98 386 end
Nenue@98 387 self.potentialCost = potentialCost
Nenue@98 388 self.potentialLevel = potentialPoints
Nenue@98 389 self.potentialAdjustedXP = potentialXP
Nenue@98 390
Nenue@98 391
Nenue@98 392
Nenue@98 393 self.isEquipped = (equippedID == itemID)
Nenue@98 394 self.relativeFrame = lastFrame
Nenue@98 395 self:Update()
Nenue@98 396 self:Show()
Nenue@98 397 return self
Nenue@98 398 end
Nenue@98 399
Nenue@97 400 function VeneerArtifactButtonMixin:Update()
Nenue@97 401
Nenue@97 402 if self.actualLevel ~= self.level then
Nenue@97 403 self.Level:SetText(self.actualLevel)
Nenue@97 404 self.Level:SetTextColor(0,1,0)
Nenue@97 405 self.CurrentXP:SetText(self.adjustedXP)
Nenue@97 406 self.CurrentXP:SetTextColor(0,1,0)
Nenue@97 407 else
Nenue@97 408 self.Level:SetText(self.level, 1, 1, 1)
Nenue@97 409 self.Level:SetTextColor(1,1,1)
Nenue@97 410 self.CurrentXP:SetText(self.currentXP)
Nenue@97 411 self.CurrentXP:SetTextColor(1,1,0)
Nenue@97 412 end
Nenue@97 413
Nenue@97 414 if self.isEquipped then
Nenue@97 415 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]])
Nenue@97 416 self:GetNormalTexture():SetBlendMode('ADD')
Nenue@97 417 self:GetNormalTexture():SetVertexColor(0,1,0)
Nenue@97 418 else
Nenue@97 419 self:SetNormalTexture(nil, 'ADD')
Nenue@97 420 end
Nenue@97 421
Nenue@97 422 self:ClearAllPoints()
Nenue@97 423 if self.relativeFrame then
Nenue@98 424 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0)
Nenue@97 425 else
Nenue@98 426 self:SetPoint('TOPLEFT', 4, -4)
Nenue@97 427 end
Nenue@98 428 local currentProgress = (self.currentXP < self.cost) and (self.currentXP / self.cost) or 1
Nenue@98 429 if self.level <= 53 then
Nenue@98 430 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1
Nenue@98 431 self.CurrentProgress.animateTo = currentProgress * self:GetHeight()
Nenue@98 432 self.CurrentProgress:Show()
Nenue@98 433 else
Nenue@98 434 self.CurrentProgress:Hide()
Nenue@98 435 end
Nenue@98 436 print(currentProgress)
Nenue@98 437 if self.potentialXP > self.currentXP then
Nenue@98 438 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialAdjustedXP / self.potentialCost) or 1
Nenue@98 439 print(projectedProgress)
Nenue@98 440 if (projectedProgress > currentProgress) then
Nenue@98 441 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP')
Nenue@98 442 projectedProgress = projectedProgress - currentProgress
Nenue@98 443 print(projectedProgress)
Nenue@98 444 else
Nenue@98 445 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM')
Nenue@98 446 end
Nenue@98 447 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1
Nenue@98 448 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight()
Nenue@97 449
Nenue@98 450 self.AdjustedProgress:Show()
Nenue@98 451 else
Nenue@98 452 self.AdjustedProgress:Hide()
Nenue@98 453 end
Nenue@97 454
Nenue@97 455 self.Icon:SetTexture(self.texture)
Nenue@97 456 self.Name:SetText(self.name)
Nenue@97 457 self:SetSize(64,64)
Nenue@97 458 end
Nenue@97 459
Nenue@98 460
Nenue@98 461 function VeneerArtifactButtonMixin:AnimateProgress(region)
Nenue@98 462 local cTime = GetTime()
Nenue@98 463 if not region.animateStart then
Nenue@98 464 region.animateStart = cTime
Nenue@98 465 end
Nenue@98 466 local progressTo, progressFrom = region.animateTo, region.animateFrom
Nenue@98 467 local elapsed = cTime - region.animateStart
Nenue@98 468 if elapsed >= .5 then
Nenue@98 469 region:SetHeight(progressTo)
Nenue@98 470 region.animateTo = nil
Nenue@98 471 region.animateStart = nil
Nenue@98 472 region.animateFrom = nil
Nenue@98 473 else
Nenue@98 474 local progress = elapsed / .5
Nenue@98 475 local height = (progressFrom + (progressTo - progressFrom) * progress)
Nenue@98 476 --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height))
Nenue@98 477 region:SetHeight(height)
Nenue@98 478 end
Nenue@98 479 end
Nenue@98 480
Nenue@98 481 function VeneerArtifactButtonMixin:OnUpdate(sinceLast)
Nenue@98 482 if self.CurrentProgress.animateTo then
Nenue@98 483 self:AnimateProgress(self.CurrentProgress)
Nenue@98 484 end
Nenue@98 485
Nenue@98 486 if self.AdjustedProgress.animateTo then
Nenue@98 487 self:AnimateProgress(self.AdjustedProgress)
Nenue@98 488 end
Nenue@98 489
Nenue@98 490 end
Nenue@98 491
Nenue@97 492 function VeneerArtifactButtonMixin:OnEnter()
Nenue@97 493 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR')
Nenue@97 494 GameTooltip:SetText(self.name)
Nenue@98 495 GameTooltip:AddLine(tostring(self.currentXP) .. ' / '..tostring(self.cost), 1, 1, 0)
Nenue@98 496 if self.potentialXP > self.currentXP then
Nenue@98 497 GameTooltip:AddLine(tostring(self.potentialXP) .. ' potential XP', 0, 1, 1)
Nenue@98 498 if self.adjustedXP ~= self.potentialXP then
Nenue@98 499 GameTooltip:AddLine(tostring(self.potentialAdjustedXP) .. ' / ' .. tostring(self.potentialAdjustedCost).. ' after spending', 0, 1, 0)
Nenue@98 500 end
Nenue@97 501 end
Nenue@97 502 GameTooltip:Show()
Nenue@97 503 end
Nenue@97 504 function VeneerArtifactButtonMixin:OnLeave()
Nenue@97 505 if GameTooltip:IsOwned(self) then
Nenue@97 506 GameTooltip:Hide()
Nenue@97 507 end
Nenue@97 508 end
Nenue@97 509
Nenue@97 510 function VeneerArtifactButtonMixin:OnClick(button, down)
Nenue@97 511 if self.isEquipped then
Nenue@97 512 SocketInventoryItem(16)
Nenue@97 513 else
Nenue@97 514 SocketContainerItem(self.containerID, self.slotID)
Nenue@97 515 end
Nenue@97 516 end