annotate Export.lua @ 200:6e8838b231d4 v97

Fixed issue with distinguishing different variants of the same item.
author Yellowfive
date Wed, 13 Jan 2021 13:11:54 -0600
parents 23b740b4c93a
children
rev   line source
yellowfive@57 1 local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot")
yellowfive@57 2 local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true)
yellowfive@57 3 local AceGUI = LibStub("AceGUI-3.0")
yellowfive@57 4
yellowfive@57 5 local _lastExport = nil
yellowfive@57 6 local _txt = nil
yellowfive@57 7
yellowfive@57 8 local function createLabel(container, text, width)
yellowfive@57 9 local lbl = AceGUI:Create("AmrUiLabel")
yellowfive@124 10 container:AddChild(lbl)
yellowfive@57 11 lbl:SetWidth(width or 800)
yellowfive@57 12 lbl:SetText(text)
yellowfive@57 13 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
yellowfive@57 14 return lbl
yellowfive@57 15 end
yellowfive@57 16
yellowfive@57 17 local function onSplashClose()
yellowfive@57 18 Amr:HideCover()
yellowfive@57 19 Amr.db.char.FirstUse = false
yellowfive@57 20 end
yellowfive@57 21
yellowfive@69 22 local function onTextChanged(widget)
yellowfive@69 23 local val = _txt:GetText()
yellowfive@69 24 if val == "overwolf-bib" then
yellowfive@69 25 -- go to the gear tab, open import window, and show a cover
yellowfive@69 26 Amr:ShowTab("Gear")
yellowfive@69 27 Amr:ShowImportWindow(true)
yellowfive@69 28 end
yellowfive@69 29 end
yellowfive@69 30
yellowfive@57 31 -- render a splash screen with first-time help
yellowfive@57 32 local function renderSplash(container)
yellowfive@57 33 local panel = Amr:RenderCoverChrome(container, 700, 450)
yellowfive@57 34
yellowfive@57 35 local lbl = createLabel(panel, L.ExportSplashTitle, 650)
yellowfive@57 36 lbl:SetJustifyH("CENTER")
yellowfive@57 37 lbl:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive))
yellowfive@57 38 lbl:SetPoint("TOP", panel.content, "TOP", 0, -10)
yellowfive@57 39
yellowfive@57 40 local lbl2 = createLabel(panel, L.ExportSplashSubtitle, 650)
yellowfive@57 41 lbl2:SetJustifyH("CENTER")
yellowfive@57 42 lbl2:SetFont(Amr.CreateFont("Bold", 18, Amr.Colors.TextTan))
yellowfive@57 43 lbl2:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -20)
yellowfive@57 44
yellowfive@57 45 lbl = createLabel(panel, L.ExportSplash1, 650)
yellowfive@57 46 lbl:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
yellowfive@57 47 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -70)
yellowfive@57 48
yellowfive@57 49 lbl2 = createLabel(panel, L.ExportSplash2, 650)
yellowfive@57 50 lbl2:SetFont(Amr.CreateFont("Regular", 14, Amr.Colors.Text))
yellowfive@57 51 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -15)
yellowfive@57 52
yellowfive@57 53 local btn = AceGUI:Create("AmrUiButton")
yellowfive@57 54 btn:SetText(L.ExportSplashClose)
yellowfive@57 55 btn:SetBackgroundColor(Amr.Colors.Green)
yellowfive@57 56 btn:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White))
yellowfive@57 57 btn:SetWidth(120)
yellowfive@57 58 btn:SetHeight(28)
yellowfive@57 59 btn:SetCallback("OnClick", onSplashClose)
yellowfive@57 60 panel:AddChild(btn)
yellowfive@124 61 btn:SetPoint("BOTTOM", panel.content, "BOTTOM", 0, 20)
yellowfive@57 62 end
yellowfive@57 63
yellowfive@57 64 -- renders the main UI for the Export tab
yellowfive@57 65 function Amr:RenderTabExport(container)
yellowfive@57 66
yellowfive@57 67 local lbl = createLabel(container, L.ExportTitle)
yellowfive@57 68 lbl:SetFont(Amr.CreateFont("Bold", 24, Amr.Colors.TextHeaderActive))
yellowfive@57 69 lbl:SetPoint("TOPLEFT", container.content, "TOPLEFT", 0, -40)
yellowfive@57 70
yellowfive@57 71 local lbl2 = createLabel(container, L.ExportHelp1)
yellowfive@57 72 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -10)
yellowfive@57 73
yellowfive@57 74 lbl = createLabel(container, L.ExportHelp2)
yellowfive@57 75 lbl:SetPoint("TOPLEFT", lbl2.frame, "BOTTOMLEFT", 0, -10)
yellowfive@57 76
yellowfive@57 77 lbl2 = createLabel(container, L.ExportHelp3)
yellowfive@57 78 lbl2:SetPoint("TOPLEFT", lbl.frame, "BOTTOMLEFT", 0, -10)
yellowfive@57 79
yellowfive@57 80 _txt = AceGUI:Create("AmrUiTextarea")
yellowfive@57 81 _txt:SetWidth(800)
yellowfive@57 82 _txt:SetHeight(300)
yellowfive@57 83 _txt:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text))
yellowfive@69 84 _txt:SetCallback("OnTextChanged", onTextChanged)
yellowfive@57 85 container:AddChild(_txt)
yellowfive@124 86 _txt:SetPoint("TOP", lbl2.frame, "BOTTOM", 0, -20)
yellowfive@57 87
yellowfive@57 88 local data = self:ExportCharacter()
yellowfive@57 89 local txt = Amr.Serializer:SerializePlayerData(data, true)
yellowfive@57 90 _txt:SetText(txt)
yellowfive@57 91 _txt:SetFocus(true)
yellowfive@57 92
yellowfive@57 93 -- update shopping list data
yellowfive@57 94 Amr:UpdateShoppingData(data)
yellowfive@57 95
yellowfive@57 96 -- show help splash if first time a user is using this
yellowfive@57 97 if Amr.db.char.FirstUse then
yellowfive@57 98 Amr:ShowCover(renderSplash)
yellowfive@57 99 AceGUI:ClearFocus()
yellowfive@57 100 end
yellowfive@57 101 end
yellowfive@57 102
yellowfive@57 103 function Amr:ReleaseTabExport()
yellowfive@57 104 end
yellowfive@57 105
yellowfive@57 106 function Amr:GetExportText()
yellowfive@57 107 return _txt:GetText()
yellowfive@57 108 end
yellowfive@57 109
yellowfive@57 110
yellowfive@57 111 -- use some local variables to deal with the fact that a user can close the bank before a scan completes
yellowfive@57 112 local _lastBankBagId = nil
yellowfive@57 113 local _lastBankSlotId = nil
yellowfive@124 114 local _bankOpen = false
yellowfive@57 115
yellowfive@57 116 local function scanBag(bagId, isBank, bagTable, bagItemsWithCount)
yellowfive@57 117 local numSlots = GetContainerNumSlots(bagId)
yellowfive@191 118 --local loc = ItemLocation.CreateEmpty()
yellowfive@191 119 local item
yellowfive@57 120 for slotId = 1, numSlots do
yellowfive@57 121 local _, itemCount, _, _, _, _, itemLink = GetContainerItemInfo(bagId, slotId)
yellowfive@57 122 if itemLink ~= nil then
yellowfive@57 123 local itemData = Amr.Serializer.ParseItemLink(itemLink)
yellowfive@57 124 if itemData ~= nil then
yellowfive@191 125 item = Item:CreateFromBagAndSlot(bagId, slotId)
yellowfive@191 126
yellowfive@191 127 -- seems to be of the form Item-1147-0-4000000XXXXXXXXX, so we take just the last 9 digits
yellowfive@191 128 itemData.guid = item:GetItemGUID()
yellowfive@191 129 if itemData.guid and strlen(itemData.guid) > 9 then
yellowfive@191 130 itemData.guid = strsub(itemData.guid, -9)
yellowfive@191 131 end
yellowfive@124 132
yellowfive@124 133 -- see if this is an azerite item and read azerite power ids
yellowfive@185 134 --[[loc:SetBagAndSlot(bagId, slotId)
yellowfive@124 135 if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then
yellowfive@124 136 local powers = Amr.ReadAzeritePowers(loc)
yellowfive@124 137 if powers then
yellowfive@124 138 itemData.azerite = powers
yellowfive@124 139 end
yellowfive@185 140 end]]
yellowfive@124 141
yellowfive@124 142 if isBank then
yellowfive@124 143 _lastBankBagId = bagId
yellowfive@124 144 _lastBankSlotId = slotId
yellowfive@124 145 end
yellowfive@57 146
yellowfive@124 147 table.insert(bagTable, itemData)
yellowfive@57 148
yellowfive@57 149 -- all items and counts, used for e.g. shopping list and reagents, etc.
yellowfive@57 150 if bagItemsWithCount then
yellowfive@57 151 if bagItemsWithCount[itemData.id] then
yellowfive@57 152 bagItemsWithCount[itemData.id] = bagItemsWithCount[itemData.id] + itemCount
yellowfive@57 153 else
yellowfive@57 154 bagItemsWithCount[itemData.id] = itemCount
yellowfive@57 155 end
yellowfive@57 156 end
yellowfive@57 157 end
yellowfive@57 158 end
yellowfive@57 159 end
yellowfive@57 160 end
yellowfive@57 161
yellowfive@124 162 -- cache the currently equipped gear for this spec
yellowfive@124 163 local function cacheEquipped()
yellowfive@124 164 local data = Amr.Serializer:GetEquipped()
yellowfive@57 165
yellowfive@124 166 local spec = GetSpecialization()
yellowfive@57 167 Amr.db.char.Equipped[spec] = data.Equipped[spec]
yellowfive@57 168 end
yellowfive@57 169
yellowfive@57 170 local function scanBags()
yellowfive@57 171
yellowfive@57 172 local bagItems = {}
yellowfive@57 173 local itemsAndCounts = {}
yellowfive@57 174
yellowfive@57 175 scanBag(BACKPACK_CONTAINER, false, bagItems, itemsAndCounts) -- backpack
yellowfive@57 176 for bagId = 1, NUM_BAG_SLOTS do
yellowfive@57 177 scanBag(bagId, false, bagItems, itemsAndCounts)
yellowfive@57 178 end
yellowfive@57 179
yellowfive@57 180 Amr.db.char.BagItems = bagItems
yellowfive@57 181 Amr.db.char.BagItemsAndCounts = itemsAndCounts
yellowfive@57 182 end
yellowfive@57 183
yellowfive@57 184 -- scan the player's bank and save the contents, must be at the bank
yellowfive@57 185 local function scanBank()
yellowfive@57 186
yellowfive@57 187 local bankItems = {}
yellowfive@57 188 local itemsAndCounts = {}
yellowfive@127 189
yellowfive@127 190 local bagList = {}
yellowfive@127 191 table.insert(bagList, BANK_CONTAINER)
yellowfive@127 192 table.insert(bagList, REAGENTBANK_CONTAINER)
yellowfive@127 193 for bagId = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
yellowfive@127 194 table.insert(bagList, bagId)
yellowfive@127 195 end
yellowfive@57 196
yellowfive@127 197 for i,bagId in ipairs(bagList) do
yellowfive@124 198 local bagItems = {}
yellowfive@124 199 local bagItemsAndCounts = {}
yellowfive@124 200 scanBag(bagId, true, bagItems, bagItemsAndCounts)
yellowfive@124 201
yellowfive@124 202 bankItems[bagId] = bagItems
yellowfive@124 203 itemsAndCounts[bagId] = bagItemsAndCounts
yellowfive@57 204 end
yellowfive@57 205
yellowfive@57 206 -- see if the scan completed before the window closed, otherwise we don't overwrite with partial data
yellowfive@124 207 if _bankOpen and _lastBankBagId then
yellowfive@57 208 local itemLink = GetContainerItemLink(_lastBankBagId, _lastBankSlotId)
yellowfive@124 209 if itemLink then --still open
yellowfive@57 210 Amr.db.char.BankItems = bankItems
yellowfive@57 211 Amr.db.char.BankItemsAndCounts = itemsAndCounts
yellowfive@57 212 end
yellowfive@57 213 end
yellowfive@57 214 end
yellowfive@57 215
yellowfive@124 216 local function onBankOpened()
yellowfive@124 217 _bankOpen = true
yellowfive@124 218 scanBank()
yellowfive@124 219 end
yellowfive@124 220
yellowfive@124 221 local function onBankClosed()
yellowfive@124 222 _bankOpen = false
yellowfive@124 223 end
yellowfive@124 224
yellowfive@124 225 -- if a bank bag is updated while the bank is open, re-scan that bag
yellowfive@124 226 local function onBankUpdated(bagID)
yellowfive@124 227 if _bankOpen and (bagID == BANK_CONTAINER or bagID == REAGENTBANK_CONTAINER or (bagID >= NUM_BAG_SLOTS + 1 and bagID <= NUM_BAG_SLOTS + NUM_BANKBAGSLOTS)) then
yellowfive@124 228 local bagItems = {}
yellowfive@124 229 local bagItemsAndCounts = {}
yellowfive@124 230 scanBag(bagID, true, bagItems, bagItemsAndCounts)
yellowfive@124 231
yellowfive@124 232 -- see if the scan completed before the window closed, otherwise we don't overwrite with partial data
yellowfive@124 233 if _bankOpen and _lastBankBagId == bagID then
yellowfive@124 234 local itemLink = GetContainerItemLink(_lastBankBagId, _lastBankSlotId)
yellowfive@124 235 if itemLink then
yellowfive@124 236 Amr.db.char.BankItems[bagID] = bagItems
yellowfive@124 237 Amr.db.char.BankItemsAndCounts[bagID] = bagItemsAndCounts
yellowfive@124 238 end
yellowfive@124 239 end
yellowfive@124 240 end
yellowfive@124 241 end
yellowfive@124 242
yellowfive@124 243 --[[
yellowfive@57 244 -- scan the player's void storage and save the contents, must be at void storage
yellowfive@57 245 local function scanVoid()
yellowfive@57 246
yellowfive@57 247 if IsVoidStorageReady() then
yellowfive@57 248 local voidItems = {}
yellowfive@57 249 local VOID_STORAGE_MAX = 80
yellowfive@57 250 local VOID_STORAGE_PAGES = 2
yellowfive@57 251
yellowfive@57 252 for page = 1,VOID_STORAGE_PAGES do
yellowfive@57 253 for i = 1,VOID_STORAGE_MAX do
yellowfive@57 254 local itemId = GetVoidItemInfo(page, i)
yellowfive@57 255 if itemId then
yellowfive@57 256 local itemLink = GetVoidItemHyperlinkString(((page - 1) * VOID_STORAGE_MAX) + i);
yellowfive@57 257 if itemLink then
yellowfive@57 258 tinsert(voidItems, itemLink)
yellowfive@57 259 end
yellowfive@57 260 end
yellowfive@57 261 end
yellowfive@57 262 end
yellowfive@57 263
yellowfive@57 264 Amr.db.char.VoidItems = voidItems
yellowfive@57 265 end
yellowfive@57 266
yellowfive@57 267 end
yellowfive@124 268 ]]
yellowfive@57 269
Yellowfive@197 270 local function scanGreatVault()
Yellowfive@197 271
Yellowfive@197 272 Amr.db.char.GreatVaultItems = {}
Yellowfive@197 273
Yellowfive@197 274 if not C_WeeklyRewards then return end
Yellowfive@197 275
Yellowfive@197 276 local vaultItems = {}
Yellowfive@197 277 local activities = C_WeeklyRewards.GetActivities()
Yellowfive@197 278 for i, activityInfo in ipairs(activities) do
Yellowfive@197 279 if activityInfo and activityInfo.rewards then
Yellowfive@197 280 for i, rewardInfo in ipairs(activityInfo.rewards) do
Yellowfive@197 281 if rewardInfo.type == Enum.CachedRewardType.Item and not C_Item.IsItemKeystoneByID(rewardInfo.id) then
Yellowfive@197 282 local itemLink = C_WeeklyRewards.GetItemHyperlink(rewardInfo.itemDBID)
Yellowfive@197 283 if itemLink then
Yellowfive@197 284 local itemData = Amr.Serializer.ParseItemLink(itemLink)
Yellowfive@197 285 if itemData ~= nil then
Yellowfive@197 286 table.insert(vaultItems, itemData)
Yellowfive@197 287 end
Yellowfive@197 288 end
Yellowfive@197 289 end
Yellowfive@197 290 end
Yellowfive@197 291 end
Yellowfive@197 292 end
Yellowfive@197 293 Amr.db.char.GreatVaultItems = vaultItems
Yellowfive@197 294 end
Yellowfive@197 295
yellowfive@185 296 local function scanSoulbinds()
yellowfive@185 297 if not C_Soulbinds then return end
yellowfive@185 298
yellowfive@185 299 -- read which conduits this player has unlocked
yellowfive@185 300 Amr.db.char.UnlockedConduits = {}
yellowfive@185 301
yellowfive@185 302 for t = 0,2 do
yellowfive@185 303 local conduits = C_Soulbinds.GetConduitCollection(t)
yellowfive@185 304 for i, conduit in ipairs(conduits) do
yellowfive@185 305 table.insert(Amr.db.char.UnlockedConduits, { conduit.conduitID, conduit.conduitRank })
yellowfive@185 306 end
yellowfive@185 307 end
yellowfive@185 308
yellowfive@185 309 if not Amr.db.char.ActiveSoulbinds then
yellowfive@185 310 Amr.db.char.ActiveSoulbinds = {}
yellowfive@185 311 end
yellowfive@185 312
yellowfive@185 313 -- read the currently active soulbind for this spec
yellowfive@185 314 local specPos = GetSpecialization()
yellowfive@185 315 if specPos and specPos >= 1 and specPos <= 4 then
yellowfive@185 316 Amr.db.char.ActiveSoulbinds[specPos] = C_Soulbinds.GetActiveSoulbindID() or 0
yellowfive@185 317 end
yellowfive@185 318
yellowfive@185 319 -- update soulbind tree info for all soulbinds
yellowfive@185 320 Amr.db.char.Soulbinds = {}
yellowfive@185 321
yellowfive@185 322 local covenantData = C_Covenants.GetCovenantData(C_Covenants.GetActiveCovenantID())
yellowfive@185 323
yellowfive@185 324 if covenantData and covenantData.soulbindIDs then
yellowfive@185 325 for i, soulbindId in ipairs(covenantData.soulbindIDs) do
yellowfive@185 326 local soulbindData = soulbindId and C_Soulbinds.GetSoulbindData(soulbindId)
yellowfive@185 327 local nodes = {}
yellowfive@193 328 local unlockedTier = -1
yellowfive@185 329
yellowfive@185 330 if soulbindData and soulbindData.tree and soulbindData.tree.nodes then
yellowfive@185 331 for i, node in ipairs(soulbindData.tree.nodes) do
yellowfive@185 332 if node.state == 3 then
yellowfive@185 333 nodes[node.row] = { soulbindId, node.row, node.column, node.conduitID, node.conduitRank }
yellowfive@185 334 end
yellowfive@185 335 if node.state > 0 then
yellowfive@185 336 unlockedTier = math.max(node.row, unlockedTier)
yellowfive@185 337 end
yellowfive@185 338 end
yellowfive@185 339 end
yellowfive@185 340
yellowfive@185 341 Amr.db.char.Soulbinds[soulbindId] = {
yellowfive@185 342 UnlockedTier = unlockedTier,
yellowfive@185 343 Nodes = nodes
yellowfive@185 344 }
yellowfive@185 345
yellowfive@185 346 end
yellowfive@185 347 end
yellowfive@185 348
yellowfive@185 349 end
yellowfive@185 350
yellowfive@185 351 --[[
yellowfive@165 352 local function scanEssences()
yellowfive@165 353 if not C_AzeriteEssence then return end
yellowfive@165 354
yellowfive@165 355 -- read which essences this player has unlocked
yellowfive@165 356 Amr.db.char.UnlockedEssences = {}
yellowfive@165 357
yellowfive@165 358 local essences = C_AzeriteEssence.GetEssences()
yellowfive@165 359 if essences then
yellowfive@165 360 for i, essence in ipairs(essences) do
yellowfive@165 361 if essence.unlocked then
yellowfive@165 362 table.insert(Amr.db.char.UnlockedEssences, { essence.ID, essence.rank })
yellowfive@165 363 end
yellowfive@165 364 end
yellowfive@165 365 end
yellowfive@165 366
yellowfive@165 367 local specPos = GetSpecialization()
yellowfive@165 368 if not specPos or specPos < 1 or specPos > 4 then return end
yellowfive@165 369
yellowfive@165 370 if not Amr.db.char.Essences then
yellowfive@165 371 Amr.db.char.Essences = {}
yellowfive@165 372 end
yellowfive@165 373
yellowfive@165 374 Amr.db.char.Essences[specPos] = {}
yellowfive@165 375 local active = Amr.db.char.Essences[specPos]
yellowfive@165 376
yellowfive@165 377 local milestones = C_AzeriteEssence.GetMilestones()
yellowfive@165 378 if milestones then
yellowfive@165 379 for i, milestone in ipairs(milestones) do
yellowfive@165 380 -- if no slot, it corresponds to the stamina nodes, skip those
yellowfive@165 381 if milestone.slot ~= nil then
yellowfive@165 382 if milestone.unlocked then
yellowfive@165 383 local essenceId = C_AzeriteEssence.GetMilestoneEssence(milestone.ID)
yellowfive@165 384 if essenceId then
yellowfive@165 385 local essence = C_AzeriteEssence.GetEssenceInfo(essenceId)
yellowfive@165 386 table.insert(active, { milestone.slot, essence.ID, essence.rank })
yellowfive@165 387 end
yellowfive@165 388 end
yellowfive@165 389 end
yellowfive@165 390 end
yellowfive@165 391 end
yellowfive@165 392 end
yellowfive@185 393 ]]
yellowfive@165 394
yellowfive@81 395 local function scanTalents()
yellowfive@81 396 local specPos = GetSpecialization()
yellowfive@81 397 if not specPos or specPos < 1 or specPos > 4 then return end
yellowfive@81 398
yellowfive@81 399 local talentInfo = {}
yellowfive@81 400 local maxTiers = 7
yellowfive@81 401 for tier = 1, maxTiers do
yellowfive@81 402 for col = 1, 3 do
yellowfive@81 403 local id, name, _, _, _, spellId, _, t, c, selected = GetTalentInfoBySpecialization(specPos, tier, col)
yellowfive@81 404 if selected then
yellowfive@81 405 talentInfo[tier] = col
yellowfive@81 406 end
yellowfive@81 407 end
yellowfive@81 408 end
yellowfive@81 409
yellowfive@81 410 local str = ""
yellowfive@81 411 for i = 1, maxTiers do
yellowfive@81 412 if talentInfo[i] then
yellowfive@81 413 str = str .. talentInfo[i]
yellowfive@81 414 else
yellowfive@81 415 str = str .. '0'
yellowfive@81 416 end
yellowfive@81 417 end
yellowfive@81 418
yellowfive@81 419 Amr.db.char.Talents[specPos] = str
yellowfive@81 420 end
yellowfive@81 421
yellowfive@57 422 -- Returns a data object containing all information about the current player needed for an export:
yellowfive@57 423 -- gear, spec, reputations, bag, bank, and void storage items.
yellowfive@57 424 function Amr:ExportCharacter()
yellowfive@57 425
yellowfive@124 426 -- get all necessary player data
yellowfive@124 427 local data = Amr.Serializer:GetPlayerData()
yellowfive@124 428
yellowfive@124 429 -- cache latest-seen equipped gear for current spec
yellowfive@124 430 local spec = GetSpecialization()
yellowfive@124 431 Amr.db.char.Equipped[spec] = data.Equipped[spec]
yellowfive@124 432
yellowfive@124 433 -- scan current inventory just before export so that it is always fresh
yellowfive@57 434 scanBags()
yellowfive@57 435
yellowfive@81 436 -- scan current spec's talents just before exporting
yellowfive@81 437 scanTalents()
yellowfive@165 438
yellowfive@185 439 -- scan all soulbinds just before exporting
yellowfive@185 440 scanSoulbinds()
yellowfive@185 441
yellowfive@165 442 -- scan current spec's essences just before exporting
yellowfive@185 443 --scanEssences()
yellowfive@81 444
Yellowfive@197 445 -- scan the great vault for potential rewards this week
Yellowfive@197 446 scanGreatVault()
Yellowfive@197 447
yellowfive@124 448 data.Talents = Amr.db.char.Talents
yellowfive@185 449 data.UnlockedConduits = Amr.db.char.UnlockedConduits
yellowfive@185 450 data.ActiveSoulbinds = Amr.db.char.ActiveSoulbinds
yellowfive@185 451 data.Soulbinds = Amr.db.char.Soulbinds
yellowfive@185 452 --data.UnlockedEssences = Amr.db.char.UnlockedEssences
yellowfive@185 453 --data.Essences = Amr.db.char.Essences
yellowfive@124 454 data.Equipped = Amr.db.char.Equipped
yellowfive@57 455 data.BagItems = Amr.db.char.BagItems
Yellowfive@197 456 data.GreatVaultItems = Amr.db.char.GreatVaultItems
yellowfive@124 457
yellowfive@124 458 -- flatten bank data (which is stored by bag for more efficient updating)
yellowfive@124 459 data.BankItems = {}
yellowfive@124 460 for k,v in pairs(Amr.db.char.BankItems) do
yellowfive@124 461 for i,v2 in ipairs(v) do
yellowfive@124 462 table.insert(data.BankItems, v2)
yellowfive@124 463 end
yellowfive@124 464 end
yellowfive@124 465
yellowfive@124 466 --data.VoidItems = Amr.db.char.VoidItems
yellowfive@57 467
yellowfive@57 468 return data
yellowfive@57 469 end
yellowfive@57 470
yellowfive@57 471 function Amr:InitializeExport()
yellowfive@57 472 Amr:AddEventHandler("UNIT_INVENTORY_CHANGED", function(unitID)
yellowfive@57 473 if unitID and unitID ~= "player" then return end
yellowfive@124 474 cacheEquipped()
yellowfive@57 475 end)
yellowfive@57 476 end
yellowfive@57 477
yellowfive@124 478 Amr:AddEventHandler("BANKFRAME_OPENED", onBankOpened)
yellowfive@124 479 Amr:AddEventHandler("BANKFRAME_CLOSED", onBankClosed)
yellowfive@124 480 Amr:AddEventHandler("BAG_UPDATE", onBankUpdated)
yellowfive@57 481
yellowfive@124 482 --Amr:AddEventHandler("VOID_STORAGE_OPEN", scanVoid)
yellowfive@124 483 --Amr:AddEventHandler("VOID_STORAGE_CONTENTS_UPDATE", scanVoid)
yellowfive@124 484 --Amr:AddEventHandler("VOID_STORAGE_DEPOSIT_UPDATE", scanVoid)
yellowfive@124 485 --Amr:AddEventHandler("VOID_STORAGE_UPDATE", scanVoid)
yellowfive@81 486
yellowfive@81 487 Amr:AddEventHandler("PLAYER_TALENT_UPDATE", scanTalents)
yellowfive@165 488
yellowfive@185 489 --if C_AzeriteEssence then
yellowfive@185 490 -- Amr:AddEventHandler("AZERITE_ESSENCE_UPDATE", scanEssences)
yellowfive@185 491 --end
yellowfive@185 492
yellowfive@185 493 if C_Soulbinds then
yellowfive@185 494 Amr:AddEventHandler("SOULBIND_ACTIVATED", scanSoulbinds)
yellowfive@165 495 end