Mercurial > wow > buffalo2
comparison Modules/ArtifactPower.lua @ 99:74d6d97a2d24 v7.1.5-r100
- artifact progress visualizations, green for current, blue for attainable
- force fishing artifact to list last
- support for fishing artifact power
| author | Nenue |
|---|---|
| date | Fri, 20 Jan 2017 19:40:55 -0500 |
| parents | dadddb8a551f |
| children | f32b63c93275 |
comparison
equal
deleted
inserted
replaced
| 98:dadddb8a551f | 99:74d6d97a2d24 |
|---|---|
| 4 -- %file-revision% | 4 -- %file-revision% |
| 5 -- | 5 -- |
| 6 | 6 |
| 7 local print = DEVIAN_WORKSPACE and function(...) print('VnAP', ...) end or nop | 7 local print = DEVIAN_WORKSPACE and function(...) print('VnAP', ...) end or nop |
| 8 VeneerArtifactPowerMixin = { | 8 VeneerArtifactPowerMixin = { |
| 9 | 9 numItems = 0, |
| 10 Tokens = {}, | |
| 11 ItemButtons = {}, | |
| 10 anchorPoint = 'TOP', | 12 anchorPoint = 'TOP', |
| 11 anchorFrom = 'TOP', | 13 anchorFrom = 'TOP', |
| 12 } | 14 } |
| 13 local ap = VeneerArtifactPowerMixin | 15 local ap = VeneerArtifactPowerMixin |
| 14 local BAGS_TO_SCAN = {BACKPACK_CONTAINER } | 16 local BAGS_TO_SCAN = {BACKPACK_CONTAINER } |
| 25 2440000, 2560000, 2690000, 2825000, 2965000, | 27 2440000, 2560000, 2690000, 2825000, 2965000, |
| 26 3115000, 3270000, 3435000, 3605000, 3785000, | 28 3115000, 3270000, 3435000, 3605000, 3785000, |
| 27 3975000, 4175000, 4385000, 4605000 | 29 3975000, 4175000, 4385000, 4605000 |
| 28 } | 30 } |
| 29 | 31 |
| 32 local FRAME_LIST = {'ContainerFrame1', 'BankFrame'} | |
| 33 local BAG_FRAMES = {'ContainerFrame1'} | |
| 34 local BANK_FRAMES = {'BankFrame'} | |
| 35 | |
| 30 function ap:OnLoad() | 36 function ap:OnLoad() |
| 31 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan | 37 self:RegisterEvent('BAG_UPDATE') -- use to obtain bag IDs to scan |
| 32 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity | 38 self:RegisterEvent('BAG_UPDATE_DELAYED') -- use to trigger actual scan activity |
| 33 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available | 39 self:RegisterEvent('BANKFRAME_OPENED') -- determine when bank info is available |
| 34 self:RegisterEvent('BANKFRAME_CLOSED') -- " " " | 40 self:RegisterEvent('BANKFRAME_CLOSED') -- " " " |
| 35 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed | 41 self:RegisterEvent('ARTIFACT_UPDATE') -- when artifact data has changed |
| 36 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data) | 42 self:RegisterEvent('ARTIFACT_XP_UPDATE') -- when artifact xp has changed (but not necessarily data) |
| 37 self:RegisterEvent('MODIFIER_STATE_CHANGED') | |
| 38 self:RegisterEvent('PLAYER_REGEN_ENABLED') | 43 self:RegisterEvent('PLAYER_REGEN_ENABLED') |
| 39 self:RegisterEvent('PLAYER_REGEN_DISABLED') | 44 self:RegisterEvent('PLAYER_REGEN_DISABLED') |
| 45 self:RegisterEvent('PLAYER_ENTERING_WORLD') | |
| 40 Veneer:AddHandler(self, self.anchorPoint, true) | 46 Veneer:AddHandler(self, self.anchorPoint, true) |
| 41 SLASH_VENEER_AP1 = "/vap" | 47 SLASH_VENEER_AP1 = "/vap" |
| 42 SLASH_VENEER_AP2 = "/veneerap" | 48 SLASH_VENEER_AP2 = "/veneerap" |
| 43 SlashCmdList.VENEER_AP = function(arg) | 49 SlashCmdList.VENEER_AP = function(arg) |
| 44 if arg == 'fishing' then | 50 if arg == 'fishing' then |
| 54 self:Show() | 60 self:Show() |
| 55 end | 61 end |
| 56 end | 62 end |
| 57 | 63 |
| 58 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') | 64 self.tooltip = CreateFrame('GameTooltip', TOOLTIP_NAME, self, 'GameTooltipTemplate') |
| 59 | 65 tinsert(UISpecialFrames, self:GetName()) |
| 60 end | 66 |
| 61 | 67 |
| 62 local defaultSettings = { | 68 end |
| 69 | |
| 70 local addonCompatibility = { | |
| 71 ['Bagnon'] = { | |
| 72 BagFrames = {'BagnonFrameinventory'}, | |
| 73 BankFrames = {'BagnonFramebank'}, | |
| 74 PostHooks = {'ToggleAllBags', 'ToggleBackpack' }, | |
| 75 MethodClass = 'Bagnon', | |
| 76 MethodHooks = {'BANK_OPENED', 'BANKFRAME_CLOSED'} | |
| 77 } | |
| 63 } | 78 } |
| 79 | |
| 64 | 80 |
| 65 function ap:Setup() | 81 function ap:Setup() |
| 66 print(self:GetName()..':Setup()') | 82 print(self:GetName()..':Setup()') |
| 67 local guid = UnitGUID('player') | 83 local guid = UnitGUID('player') |
| 68 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings | 84 VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings |
| 70 self.profile = VeneerData.ArtifactPower[guid] | 86 self.profile = VeneerData.ArtifactPower[guid] |
| 71 self.profile.bagslots = self.profile.bagslots or {} | 87 self.profile.bagslots = self.profile.bagslots or {} |
| 72 self.profile.artifacts = self.profile.artifacts or {} | 88 self.profile.artifacts = self.profile.artifacts or {} |
| 73 self.updateSummary = true | 89 self.updateSummary = true |
| 74 | 90 |
| 91 local DoTryToShow = function() | |
| 92 self:TryToShow() | |
| 93 end | |
| 94 hooksecurefunc("OpenBackpack", DoTryToShow) | |
| 95 hooksecurefunc("CloseBackpack", DoTryToShow) | |
| 96 | |
| 75 -- Bagnon compatibility | 97 -- Bagnon compatibility |
| 76 -- todo: ArkInventory, Elv, etc | 98 -- todo: ArkInventory, Elv, etc |
| 77 if IsAddOnLoaded('Bagnon') then | 99 for addon, args in pairs(addonCompatibility) do |
| 78 local oToggleAllBags = ToggleAllBags | 100 if IsAddOnLoaded(addon) then |
| 79 ToggleAllBags = function() | 101 for _, name in ipairs(args.BagFrames) do |
| 80 print('|cFFFF0088ToggleAllBags') | 102 tinsert(FRAME_LIST, name) |
| 81 oToggleAllBags() | 103 tinsert(BAG_FRAMES, name) |
| 82 if BagnonFrameinventory:IsShown() then | 104 end |
| 83 self:Show() | 105 for _, name in ipairs(args.BankFrames) do |
| 84 else | 106 tinsert(FRAME_LIST, name) |
| 85 self.enabled = nil | 107 tinsert(BAG_FRAMES, name) |
| 86 self:Hide() | 108 end |
| 87 end | 109 for _, name in ipairs(args.PostHooks) do |
| 88 end | 110 local oFunc = _G[name] |
| 89 else | 111 _G[name] = function(...) |
| 90 hooksecurefunc("OpenBackpack", function() | 112 print('|cFFFF0088' .. name .. '|r', ...) |
| 91 self:Show() | 113 oFunc(...) |
| 92 end) | 114 self:TryToShow() |
| 93 hooksecurefunc("CloseBackpack", function() | 115 end |
| 94 self.enabled = nil | 116 end |
| 95 self:Hide() | 117 local frame = _G[args.MethodClass] |
| 96 end) | 118 if frame then |
| 97 end | 119 for _, name in ipairs(args.MethodHooks) do |
| 98 | 120 hooksecurefunc(frame, name, DoTryToShow) |
| 99 | 121 end |
| 100 end | 122 end |
| 123 end | |
| 124 end | |
| 125 end | |
| 126 | |
| 101 local UNDERLIGHT_ANGLER_ID = 133755 | 127 local UNDERLIGHT_ANGLER_ID = 133755 |
| 102 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) | 128 function ap:SetArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 103 print('|cFF00FF00SetArtifact()|r') | 129 print('|cFF00FF00SetArtifact()|r') |
| 104 if not self.profile then | 130 if not self.profile then |
| 105 return | 131 return |
| 106 end | 132 end |
| 107 local artifacts = self.profile.artifacts | 133 local artifacts = self.profile.artifacts |
| 108 | 134 |
| 109 | 135 |
| 110 if itemID then | 136 if itemID then |
| 137 | |
| 138 self.currentEquipped = itemID | |
| 139 | |
| 111 artifacts[itemID] = artifacts[itemID] or {} | 140 artifacts[itemID] = artifacts[itemID] or {} |
| 112 table.wipe(artifacts[itemID]) | 141 table.wipe(artifacts[itemID]) |
| 113 local artifact = artifacts[itemID] | 142 local artifact = artifacts[itemID] |
| 114 | 143 |
| 115 artifact.name = name | 144 artifact.name = name |
| 145 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line') | 174 print(' queueing', containerID, type(containerID), #BAGS_TO_SCAN , 'in line') |
| 146 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID | 175 BAGS_TO_SCAN[#BAGS_TO_SCAN + 1] = containerID |
| 147 end | 176 end |
| 148 end | 177 end |
| 149 | 178 |
| 179 function ap:Reanchor() | |
| 180 if Veneer then | |
| 181 Veneer:DynamicReanchor() | |
| 182 end | |
| 183 end | |
| 184 | |
| 150 function ap:OnShow() | 185 function ap:OnShow() |
| 186 print('|cFFFFFF00OnShow()|r') | |
| 151 self.enabled = true | 187 self.enabled = true |
| 152 self:Update() | 188 self:ScanAllBags() |
| 153 Veneer:DynamicReanchor() | 189 self:Reanchor() |
| 190 if not self.postShowSetup then | |
| 191 self.postShowSetup = true | |
| 192 hooksecurefunc("HideUIPanel", function() self:TryToShow() end) | |
| 193 end | |
| 154 end | 194 end |
| 155 function ap:OnHide() | 195 function ap:OnHide() |
| 156 Veneer:DynamicReanchor() | 196 print('|cFF88FF00OnHide()|r') |
| 157 end | 197 self:Reanchor() |
| 158 | 198 end |
| 159 function ap:OnEnter() | 199 function ap:OnEnter() |
| 160 | 200 |
| 161 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 201 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
| 202 | |
| 162 | 203 |
| 163 GameTooltip:AddLine(self.bagAP) | 204 GameTooltip:AddLine(self.bagAP) |
| 164 GameTooltip:AddLine(self.bankAP) | 205 GameTooltip:AddLine(self.bankAP) |
| 165 | 206 |
| 166 end | 207 end |
| 167 | 208 |
| 209 function ap:TryToShow() | |
| 210 | |
| 211 print('|cFFFFFF00TryToShow()') | |
| 212 | |
| 213 if not InCombatLockdown() then | |
| 214 for _, name in ipairs(FRAME_LIST) do | |
| 215 --print(name, (_G[name] and _G[name]:IsShown())) | |
| 216 if _G[name] and _G[name]:IsShown() then | |
| 217 if self:IsShown() then | |
| 218 self:Update() | |
| 219 else | |
| 220 self:Show() | |
| 221 end | |
| 222 return | |
| 223 end | |
| 224 end | |
| 225 end | |
| 226 | |
| 227 | |
| 228 self:Hide() | |
| 229 end | |
| 230 | |
| 231 | |
| 168 function ap:OnEvent(event, ...) | 232 function ap:OnEvent(event, ...) |
| 169 print(self:GetName()..':OnEvent()', event, ...) | 233 print('|cFF00FF88OnEvent()', event, ...) |
| 170 if event == 'BAG_UPDATE' then | 234 if event == 'PLAYER_ENTERING_WORLD' then |
| 235 self:TryToShow() | |
| 236 elseif event == 'BAG_UPDATE' then | |
| 171 local containerID = ... | 237 local containerID = ... |
| 172 self:QueueBag(containerID) | 238 self:QueueBag(containerID) |
| 173 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then | 239 elseif event == 'PLAYER_BANKSLOTS_CHANGED' then |
| 174 self:ScanAllBags(true) | 240 self:ScanAllBags() |
| 175 self:Update() | |
| 176 elseif event == 'BAG_UPDATE_DELAYED' then | 241 elseif event == 'BAG_UPDATE_DELAYED' then |
| 177 self:ScanAllBags(self.bankAccess) | 242 if not self.firstHit then |
| 243 self.firstHit = true | |
| 244 else | |
| 245 self:ScanAllBags() | |
| 246 end | |
| 178 elseif event == 'BANKFRAME_OPENED' then | 247 elseif event == 'BANKFRAME_OPENED' then |
| 179 self.bankAccess = true | 248 self.bankAccess = true |
| 180 self:ScanAllBags(true) | 249 self:ScanAllBags() |
| 181 elseif event == 'BANKFRAME_CLOSED' then | 250 elseif event == 'BANKFRAME_CLOSED' then |
| 182 self.bankAccess = false | 251 self.bankAccess = nil |
| 183 elseif event == 'ARTIFACT_UPDATE' then | 252 elseif event == 'ARTIFACT_UPDATE' then |
| 184 local newItem = ... | 253 local newItem = ... |
| 185 if newItem then | 254 if newItem then |
| 186 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo() | 255 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetArtifactInfo() |
| 187 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) | 256 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 191 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo() | 260 local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo() |
| 192 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) | 261 self:SetArtifact(itemID, name, texture, currentXP, pointsSpent) |
| 193 self:ScanAllBags(self.bankAccess) | 262 self:ScanAllBags(self.bankAccess) |
| 194 elseif event == 'PLAYER_REGEN_ENABLED' then | 263 elseif event == 'PLAYER_REGEN_ENABLED' then |
| 195 if self.enabled then | 264 if self.enabled then |
| 196 self:Show() | 265 if self.queuedScan then |
| 266 self:ScanAllBags(self.backAccess) | |
| 267 else | |
| 268 self:TryToShow() | |
| 269 end | |
| 197 end | 270 end |
| 198 | 271 |
| 199 elseif event == 'PLAYER_REGEN_DISABLED' then | 272 elseif event == 'PLAYER_REGEN_DISABLED' then |
| 200 self:Hide() | 273 self:Hide() |
| 201 end | 274 end |
| 206 self:Hide() | 279 self:Hide() |
| 207 end | 280 end |
| 208 | 281 |
| 209 function ap:Update() | 282 function ap:Update() |
| 210 if not self:IsShown() then | 283 if not self:IsShown() then |
| 284 print('|cFFFF4400Update()|r') | |
| 211 return | 285 return |
| 212 end | 286 end |
| 213 print('|cFF00FFFFUpdate()|r') | 287 print('|cFF00FFFFUpdate()|r') |
| 214 | 288 |
| 215 local bankText, bagText | 289 local bankText, bagText |
| 216 if not (self.bankAP and self.bagAP) then | 290 if not (self.bankAP and self.bagAP) then |
| 217 bankText = '|cFFFF0000Open bank frame to count all AP|r ' | 291 bankText = '|cFFFF0000Open bank frame to count all AP|r ' |
| 218 else | 292 else |
| 219 if (self.bagAP + self.bankAP) == 0 then | 293 if (self.bagAP + self.bankAP) == 0 then |
| 220 bankText = '|cFF00FFFFNo Items|r' | 294 bankText = '|cFFFF4400No Artifact Power tokens on hand|r' |
| 221 else | 295 else |
| 222 if self.bagAP and (self.bagAP > 0) then | 296 if self.bagAP and (self.bagAP > 0) then |
| 223 bankText = '|cFFFFFFFF' .. tostring(self.bagAP) .. '|r' | 297 bankText = '|cFFFFFFFF' .. tostring(self.bagAP) .. '|r' |
| 224 end | 298 end |
| 225 if self.bankAP and (self.bankAP > 0) then | 299 if self.bankAP and (self.bankAP > 0) then |
| 226 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r' | 300 bankText = (bankText and (bankText .. ' | ') or '') .. '|cFFFFFF00'..tostring(self.bankAP)..'|r' |
| 227 end | 301 end |
| 228 end | 302 end |
| 229 end | 303 end |
| 304 if self.fishingAP and self.fishingAP >= 1 then | |
| 305 bankText = (bankText and (bankText .. ' ') or '') .. '|cFF0088FF' .. tostring(self.fishingAP) .. ' fishing AP|r' | |
| 306 end | |
| 307 | |
| 230 self.SummaryHeader:SetText(bankText) | 308 self.SummaryHeader:SetText(bankText) |
| 231 | 309 |
| 232 -- Artifact icons, in no particular order | 310 -- Artifact icons, in no particular order |
| 233 local equippedID = C_ArtifactUI.GetEquippedArtifactInfo() | 311 self.equippedID = C_ArtifactUI.GetEquippedArtifactInfo() |
| 234 local numButtons = 0 | 312 local numButtons = 0 |
| 235 local lastFrame | 313 local lastFrame = self |
| 236 local fishingRod, fishingID, fishingData | 314 local fishingID, fishingData |
| 237 local index, button | 315 local index, button |
| 238 for itemID, artifact in pairs(self.profile.artifacts) do | 316 for itemID, artifact in pairs(self.profile.artifacts) do |
| 239 local isFishingRod = (itemID == UNDERLIGHT_ANGLER_ID) | 317 if (itemID == UNDERLIGHT_ANGLER_ID) then |
| 240 if isFishingRod then | |
| 241 if VeneerData.ArtifactPower.EnableFishing then | 318 if VeneerData.ArtifactPower.EnableFishing then |
| 242 fishingID = itemID | 319 fishingID = itemID |
| 243 fishingData = artifact | 320 fishingData = artifact |
| 244 end | 321 end |
| 245 | 322 |
| 246 else | 323 else |
| 247 numButtons = numButtons + 1 | 324 numButtons = numButtons + 1 |
| 248 button = self.Artifact[numButtons] | 325 button = self.Artifact[numButtons] |
| 249 lastFrame = button:SetButton(itemID, artifact, lastFrame) | 326 button.relativeFrame = lastFrame |
| 327 lastFrame = button:SetButton(itemID, artifact, numButtons, (self.equippedID == itemID)) | |
| 250 end | 328 end |
| 251 | 329 |
| 252 end | 330 end |
| 253 | 331 |
| 254 if fishingData then | 332 if fishingData then |
| 255 numButtons = numButtons + 1 | 333 numButtons = numButtons + 1 |
| 256 local button = self.Artifact[GetNumSpecializations()+1] | 334 local button = self.Artifact[numButtons] |
| 257 button:SetButton(fishingID, fishingData, lastFrame) | 335 button.relativeFrame = lastFrame |
| 258 end | 336 button:SetButton(fishingID, fishingData, numButtons, self.equippedID == fishingID) |
| 259 | 337 end |
| 260 for i = numButtons+ (fishingRod and 2 or 1), #self.Artifact do | 338 |
| 339 for i = numButtons+ 1, #self.Artifact do | |
| 261 print('hide', i) | 340 print('hide', i) |
| 262 self.Artifact[i]:Hide() | 341 self.Artifact[i]:Hide() |
| 263 end | 342 end |
| 264 | 343 |
| 344 self:UpdateItemButtons() | |
| 265 | 345 |
| 266 | 346 |
| 267 self:SetWidth(64*numButtons + 4 * (numButtons+1)) | 347 self:SetWidth(64*numButtons + 4 * (numButtons+1)) |
| 268 self:SetHeight(12 + self.SummaryHeader:GetHeight() + 64) | 348 self:SetHeight(12 + self.SummaryHeader:GetHeight() + 64) |
| 269 self:Reanchor() | 349 self:Reanchor() |
| 270 | 350 |
| 351 end | |
| 352 | |
| 353 | |
| 354 function ap:UpdateItemButtons() | |
| 355 print('|cFF00FFFFUpdateItemButtons()|r') | |
| 356 local lastFrame, upFrame | |
| 357 local numButtons = 0 | |
| 358 for index, button in ipairs(self.Tokens) do | |
| 359 if button.numItems >= 1 then | |
| 360 if button.itemName then | |
| 361 self:SetItemAction(button) | |
| 362 end | |
| 363 | |
| 364 button:ClearAllPoints() | |
| 365 numButtons = numButtons + 1 | |
| 366 print(index, button:GetID(), button.Icon:GetTexture()) | |
| 367 if numButtons == 1 then | |
| 368 button:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -2) | |
| 369 upFrame = button | |
| 370 elseif mod(numButtons,8) == 1 then | |
| 371 button:SetPoint('TOPLEFT', upFrame, 'BOTTOMLEFT', 0, -2) | |
| 372 upFrame = button | |
| 373 else | |
| 374 button:SetPoint('TOPLEFT', lastFrame, 'TOPRIGHT', 2, 0) | |
| 375 end | |
| 376 button.Count:SetText(button.numItems) | |
| 377 lastFrame = button | |
| 378 button:Show() | |
| 379 else | |
| 380 | |
| 381 button:Hide() | |
| 382 end | |
| 383 | |
| 384 end | |
| 385 | |
| 386 end | |
| 387 | |
| 388 function ap:SetItemAction(button, name) | |
| 389 name = name or self.itemName | |
| 390 if InCombatLockdown() then | |
| 391 self.itemName = name | |
| 392 return | |
| 393 else | |
| 394 button:SetAttribute('*type*','item') | |
| 395 button:SetAttribute('*item*', name) | |
| 396 end | |
| 397 end | |
| 398 | |
| 399 function ap:GetItemButton(itemID, texture, itemAP) | |
| 400 print('|cFF00FFFFGetItemButton()|r', itemID, texture, itemAP) | |
| 401 local button = self.ItemButtons[itemID] | |
| 402 if not button then | |
| 403 button = CreateFrame('Button', 'VeneerAPToken'..itemID, self, 'VeneerItemButton') | |
| 404 button:SetPushedTexture([[Interface\Buttons\UI-Quickslot-Depress]]) | |
| 405 button:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]],"ADD") | |
| 406 button:SetID(itemID) | |
| 407 button.numItems = 0 | |
| 408 button.Icon:SetTexture(texture) | |
| 409 button.Label:SetText(itemAP) | |
| 410 button:RegisterForClicks("AnyUp") | |
| 411 self:SetItemAction(button, GetItemInfo(itemID)) | |
| 412 | |
| 413 print(' created') | |
| 414 self.ItemButtons[itemID] = button | |
| 415 self.numItems = self.numItems + 1 | |
| 416 end | |
| 417 | |
| 418 button.numItems = button.numItems + 1 | |
| 419 return button | |
| 271 end | 420 end |
| 272 | 421 |
| 273 function ap:ScanBag(id) | 422 function ap:ScanBag(id) |
| 274 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) | 423 print('|cFF00FFFFScanBag()|r', id, IsBagOpen(id), GetContainerNumSlots(id)) |
| 275 local numSlots = GetContainerNumSlots(id) | 424 local numSlots = GetContainerNumSlots(id) |
| 281 | 430 |
| 282 self.profile.bagslots[id] = self.profile.bagslots[id] or {} | 431 self.profile.bagslots[id] = self.profile.bagslots[id] or {} |
| 283 table.wipe(self.profile.bagslots[id]) | 432 table.wipe(self.profile.bagslots[id]) |
| 284 local bagData = self.profile.bagslots[id] | 433 local bagData = self.profile.bagslots[id] |
| 285 bagData.totalAP = 0 | 434 bagData.totalAP = 0 |
| 435 bagData.fishingAP = 0 | |
| 436 bagData.items = bagData.items or {} | |
| 437 table.wipe(bagData.items) | |
| 438 | |
| 286 for slotID = 1, numSlots do | 439 for slotID = 1, numSlots do |
| 287 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) | 440 local texture, count, locked, quality, readable, lootable, link = GetContainerItemInfo(id, slotID) |
| 288 local itemID = GetContainerItemID(id, slotID) | 441 local itemID = GetContainerItemID(id, slotID) |
| 289 | 442 |
| 290 if link then | 443 if link then |
| 303 local itemAP = tonumber(text) | 456 local itemAP = tonumber(text) |
| 304 if itemAP then | 457 if itemAP then |
| 305 requiresUpdate = true | 458 requiresUpdate = true |
| 306 bagData.numItems = (bagData.numItems or 0) + 1 | 459 bagData.numItems = (bagData.numItems or 0) + 1 |
| 307 bagData.totalAP = (bagData.totalAP or 0) + itemAP | 460 bagData.totalAP = (bagData.totalAP or 0) + itemAP |
| 308 bagData.items = bagData.items or {} | 461 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 |
| 309 if not bagData.items[itemID] then | 462 |
| 310 bagData.numUnique = (bagData.numUnique or 0) + 1 | 463 |
| 311 end | 464 local itemButton = self:GetItemButton(itemID, texture, itemAP) |
| 312 bagData.items[itemID] = (bagData.items[itemAP] or 0) + 1 | |
| 313 end | 465 end |
| 314 end | 466 end |
| 315 end | 467 end |
| 316 end | 468 end |
| 469 local fishingText = _G[TOOLTIP_NAME .. 'TextLeft3']:GetText() | |
| 470 if fishingText and fishingText:match('fishing artifact') then | |
| 471 local fishingAP = fishingText:match("%d+") | |
| 472 fishingAP = tonumber(fishingAP) | |
| 473 if fishingAP then | |
| 474 bagData.fishingItems = (bagData.fishingItems or 0) + 1 | |
| 475 bagData.fishingAP = (bagData.fishingAP or 0) + fishingAP | |
| 476 bagData.items[itemID] = (bagData.items[itemID] or 0) + 1 | |
| 477 local itemButton = self:GetItemButton(itemID, texture, fishingAP) | |
| 478 print(fishingAP, bagData.fishingAP) | |
| 479 end | |
| 480 | |
| 481 end | |
| 482 | |
| 317 end | 483 end |
| 318 end | 484 end |
| 319 | 485 |
| 320 if self.profile.artifacts[itemID] then | 486 if self.profile.artifacts[itemID] then |
| 321 print('artfiact weapon', itemID, link, id, slotID) | 487 print('artfiact weapon', itemID, link, id, slotID) |
| 327 | 493 |
| 328 end | 494 end |
| 329 | 495 |
| 330 local BAG_SLOTS = {0, 1, 2, 3, 4 } | 496 local BAG_SLOTS = {0, 1, 2, 3, 4 } |
| 331 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12} | 497 local BANK_SLOTS = {-1, 5, 6,7, 8, 9, 10, 11, 12} |
| 332 | 498 local ItemCounts = {} |
| 333 function ap:ScanAllBags(checkBank) | 499 function ap:ScanAllBags() |
| 500 if InCombatLockdown() then | |
| 501 self.queuedScan = true | |
| 502 return | |
| 503 end | |
| 504 self.queuedScan = nil | |
| 505 | |
| 334 print('|cFFFF0088ScanAllBags()|r') | 506 print('|cFFFF0088ScanAllBags()|r') |
| 507 | |
| 508 for _, button in ipairs(self.Tokens) do | |
| 509 button.numItems = 0 | |
| 510 end | |
| 511 | |
| 335 | 512 |
| 336 for _, bagID in ipairs(BAG_SLOTS) do | 513 for _, bagID in ipairs(BAG_SLOTS) do |
| 337 self:ScanBag(bagID) | 514 self:ScanBag(bagID) |
| 338 end | 515 end |
| 339 | 516 |
| 340 if checkBank then | 517 if self.bankAccess then |
| 341 for _, bagID in ipairs(BANK_SLOTS) do | 518 for _, bagID in ipairs(BANK_SLOTS) do |
| 342 self:ScanBag(bagID) | 519 self:ScanBag(bagID) |
| 343 end | 520 end |
| 344 end | 521 end |
| 345 | 522 |
| 346 self.bankAP = 0 | 523 self.bankAP = 0 |
| 347 self.bagAP = 0 | 524 self.bagAP = 0 |
| 525 self.fishingAP = 0 | |
| 526 | |
| 527 table.wipe(ItemCounts) | |
| 348 for id, bagData in pairs(self.profile.bagslots) do | 528 for id, bagData in pairs(self.profile.bagslots) do |
| 349 print(id, GetBagName(id), bagData.totalAP) | 529 print(id, GetBagName(id), bagData.totalAP) |
| 350 id = tonumber(id) | 530 id = tonumber(id) |
| 351 if bagData.totalAP then | 531 if bagData.totalAP then |
| 352 if (id == BANK_CONTAINER) or (id >= 5) then | 532 if (id == BANK_CONTAINER) or (id >= 5) then |
| 353 self.bankAP = self.bankAP + bagData.totalAP | 533 self.bankAP = self.bankAP + bagData.totalAP |
| 354 else | 534 else |
| 355 self.bagAP = self.bagAP + bagData.totalAP | 535 self.bagAP = self.bagAP + bagData.totalAP |
| 356 end | 536 end |
| 357 end | 537 end |
| 538 if bagData.fishingAP then | |
| 539 self.fishingAP = self.fishingAP + bagData.fishingAP | |
| 540 end | |
| 358 | 541 |
| 359 end | 542 end |
| 360 self.lastUpdate = GetTime() | 543 self.lastUpdate = GetTime() |
| 361 self:Update() | 544 self:TryToShow() |
| 362 self.updateSummary = nil | |
| 363 end | 545 end |
| 364 | 546 |
| 365 VeneerArtifactButtonMixin = {} | 547 VeneerArtifactButtonMixin = {} |
| 366 | 548 |
| 367 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, lastFrame) | 549 function VeneerArtifactButtonMixin:SetButton(itemID, artifact, index, equipped) |
| 550 print(itemID, index) | |
| 368 print(artifact.name, artifact.texture, artifact.currentXP) | 551 print(artifact.name, artifact.texture, artifact.currentXP) |
| 369 self:SetID(itemID) | 552 self:SetID(itemID) |
| 370 for k,v in pairs(artifact) do | 553 for k,v in pairs(artifact) do |
| 371 --print('::',k,v) | 554 --print('::',k,v) |
| 372 self[k] = v | 555 self[k] = v |
| 373 end | 556 end |
| 374 | 557 |
| 375 -- this can change between artifact parses | 558 -- this can change between artifact parses |
| 376 local potentialPoints = self.actualLevel | 559 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) | 560 local totalAP = (itemID ~= UNDERLIGHT_ANGLER_ID) and ((self:GetParent().bankAP or 0) + (self:GetParent().bagAP or 0)) or (self:GetParent().fishingAP or 0) |
| 561 print(totalAP) | |
| 378 local potentialXP = self.actualXP + totalAP | 562 local potentialXP = self.actualXP + totalAP |
| 563 | |
| 379 self.potentialXP = potentialXP | 564 self.potentialXP = potentialXP |
| 380 local potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints) | 565 local potentialCost = C_ArtifactUI.GetCostForPointAtRank(potentialPoints) |
| 381 while potentialXP >= potentialCost do | 566 while potentialXP >= potentialCost do |
| 382 potentialXP = potentialXP - potentialCost | 567 potentialXP = potentialXP - potentialCost |
| 383 potentialPoints = potentialPoints + 1 | 568 potentialPoints = potentialPoints + 1 |
| 387 self.potentialCost = potentialCost | 572 self.potentialCost = potentialCost |
| 388 self.potentialLevel = potentialPoints | 573 self.potentialLevel = potentialPoints |
| 389 self.potentialAdjustedXP = potentialXP | 574 self.potentialAdjustedXP = potentialXP |
| 390 | 575 |
| 391 | 576 |
| 392 | 577 if index ~= 1 then |
| 393 self.isEquipped = (equippedID == itemID) | 578 self:ClearAllPoints() |
| 394 self.relativeFrame = lastFrame | 579 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) |
| 580 else | |
| 581 self:ClearAllPoints() | |
| 582 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPLEFT', 4, -4) | |
| 583 end | |
| 584 | |
| 585 self.isEquipped = equipped | |
| 395 self:Update() | 586 self:Update() |
| 396 self:Show() | 587 self:Show() |
| 397 return self | 588 return self |
| 398 end | 589 end |
| 399 | 590 |
| 400 function VeneerArtifactButtonMixin:Update() | 591 function VeneerArtifactButtonMixin:Update() |
| 401 | 592 |
| 593 local r, g, b = 1, 1, 1 | |
| 594 local lR, lG, lB = 1, 1, 0 | |
| 595 local levelText = self.level | |
| 596 local xpValue = self.currentXP | |
| 597 local costValue = self.cost | |
| 402 if self.actualLevel ~= self.level then | 598 if self.actualLevel ~= self.level then |
| 403 self.Level:SetText(self.actualLevel) | 599 levelText, r,g,b = self.actualLevel, 0,1,0 |
| 404 self.Level:SetTextColor(0,1,0) | 600 xpValue, costValue, lR, lG, lB = self.actualXP, self.actualCost, 0, 1, 0 |
| 405 self.CurrentXP:SetText(self.adjustedXP) | 601 elseif self.potentialLevel ~= self.level then |
| 406 self.CurrentXP:SetTextColor(0,1,0) | 602 levelText, r, g, b = self.potentialLevel, 0,1,1 |
| 407 else | 603 xpValue, costValue, lR, lG, lB = self.potentialAdjustedXP, self.potentialCost, 0,1,0 |
| 408 self.Level:SetText(self.level, 1, 1, 1) | 604 |
| 409 self.Level:SetTextColor(1,1,1) | 605 end |
| 410 self.CurrentXP:SetText(self.currentXP) | 606 |
| 411 self.CurrentXP:SetTextColor(1,1,0) | 607 if xpValue >= 100000 then |
| 412 end | 608 xpValue = tostring(floor(xpValue/1000))..'k' |
| 609 elseif xpValue > 1000 then | |
| 610 xpValue = tostring(floor(xpValue/100)/10)..'k' | |
| 611 end | |
| 612 if costValue >= 100000 then | |
| 613 costValue = tostring(floor(costValue/1000))..'k' | |
| 614 elseif costValue >= 1000 then | |
| 615 costValue = tostring(floor(costValue/100)/10)..'k' | |
| 616 end | |
| 617 | |
| 618 | |
| 619 self.Level:SetText(levelText) | |
| 620 self.Level:SetTextColor(r, g, b) | |
| 621 self.CurrentXP:SetText(xpValue) | |
| 622 self.CurrentXP:SetTextColor(lR, lG, lB) | |
| 413 | 623 |
| 414 if self.isEquipped then | 624 if self.isEquipped then |
| 415 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) | 625 self:SetNormalTexture([[Interface\Buttons\ButtonHilight-Square]]) |
| 416 self:GetNormalTexture():SetBlendMode('ADD') | 626 self:GetNormalTexture():SetBlendMode('ADD') |
| 417 self:GetNormalTexture():SetVertexColor(0,1,0) | 627 self:GetNormalTexture():SetVertexColor(0,1,0) |
| 418 else | 628 else |
| 419 self:SetNormalTexture(nil, 'ADD') | 629 self:SetNormalTexture(nil, 'ADD') |
| 420 end | 630 end |
| 421 | 631 |
| 422 self:ClearAllPoints() | |
| 423 if self.relativeFrame then | |
| 424 self:SetPoint('TOPLEFT', self.relativeFrame, 'TOPRIGHT', 4, 0) | |
| 425 else | |
| 426 self:SetPoint('TOPLEFT', 4, -4) | |
| 427 end | |
| 428 local currentProgress = (self.currentXP < self.cost) and (self.currentXP / self.cost) or 1 | 632 local currentProgress = (self.currentXP < self.cost) and (self.currentXP / self.cost) or 1 |
| 429 if self.level <= 53 then | 633 if self.level <= 53 then |
| 634 | |
| 430 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1 | 635 self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1 |
| 431 self.CurrentProgress.animateTo = currentProgress * self:GetHeight() | 636 self.CurrentProgress.animateTo = currentProgress * self:GetHeight() |
| 432 self.CurrentProgress:Show() | 637 self.CurrentProgress:Show() |
| 433 else | 638 else |
| 434 self.CurrentProgress:Hide() | 639 self.CurrentProgress:Hide() |
| 435 end | 640 end |
| 436 print(currentProgress) | 641 |
| 437 if self.potentialXP > self.currentXP then | 642 if self.potentialXP > self.currentXP then |
| 438 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialAdjustedXP / self.potentialCost) or 1 | 643 local projectedProgress = (self.potentialAdjustedXP < self.potentialCost) and (self.potentialXP / self.potentialCost) or 1 |
| 439 print(projectedProgress) | 644 |
| 440 if (projectedProgress > currentProgress) then | 645 if (projectedProgress > currentProgress) then |
| 441 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') | 646 self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') |
| 442 projectedProgress = projectedProgress - currentProgress | 647 projectedProgress = projectedProgress - currentProgress |
| 443 print(projectedProgress) | 648 |
| 444 else | 649 else |
| 445 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') | 650 self.AdjustedProgress:SetPoint('BOTTOM', self, 'BOTTOM') |
| 446 end | 651 end |
| 652 print('show potential', currentProgress, projectedProgress) | |
| 447 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 | 653 self.AdjustedProgress.animateFrom = self.AdjustedProgress:GetHeight() or 1 |
| 448 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() | 654 self.AdjustedProgress.animateTo = projectedProgress * self:GetHeight() |
| 449 | 655 |
| 450 self.AdjustedProgress:Show() | 656 self.AdjustedProgress:Show() |
| 451 else | 657 else |
| 452 self.AdjustedProgress:Hide() | 658 self.AdjustedProgress:Hide() |
| 453 end | 659 end |
| 454 | 660 |
| 661 | |
| 455 self.Icon:SetTexture(self.texture) | 662 self.Icon:SetTexture(self.texture) |
| 456 self.Name:SetText(self.name) | |
| 457 self:SetSize(64,64) | 663 self:SetSize(64,64) |
| 458 end | 664 end |
| 459 | 665 |
| 460 | 666 |
| 461 function VeneerArtifactButtonMixin:AnimateProgress(region) | 667 function VeneerArtifactButtonMixin:AnimateProgress(region) |
| 493 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') | 699 GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') |
| 494 GameTooltip:SetText(self.name) | 700 GameTooltip:SetText(self.name) |
| 495 GameTooltip:AddLine(tostring(self.currentXP) .. ' / '..tostring(self.cost), 1, 1, 0) | 701 GameTooltip:AddLine(tostring(self.currentXP) .. ' / '..tostring(self.cost), 1, 1, 0) |
| 496 if self.potentialXP > self.currentXP then | 702 if self.potentialXP > self.currentXP then |
| 497 GameTooltip:AddLine(tostring(self.potentialXP) .. ' potential XP', 0, 1, 1) | 703 GameTooltip:AddLine(tostring(self.potentialXP) .. ' potential XP', 0, 1, 1) |
| 498 if self.adjustedXP ~= self.potentialXP then | 704 if self.potentialAdjustedXP ~= self.potentialXP then |
| 499 GameTooltip:AddLine(tostring(self.potentialAdjustedXP) .. ' / ' .. tostring(self.potentialAdjustedCost).. ' after spending', 0, 1, 0) | 705 GameTooltip:AddLine(tostring(self.potentialAdjustedXP) .. ' / ' .. tostring(self.potentialCost).. ' after', 0, 1, 0) |
| 500 end | 706 end |
| 501 end | 707 end |
| 708 if self.actualLevel ~= self.level then | |
| 709 GameTooltip:AddLine(tostring(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 1) | |
| 710 end | |
| 711 | |
| 502 GameTooltip:Show() | 712 GameTooltip:Show() |
| 503 end | 713 end |
| 504 function VeneerArtifactButtonMixin:OnLeave() | 714 function VeneerArtifactButtonMixin:OnLeave() |
| 505 if GameTooltip:IsOwned(self) then | 715 if GameTooltip:IsOwned(self) then |
| 506 GameTooltip:Hide() | 716 GameTooltip:Hide() |
