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