yellowfive@57: local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot") yellowfive@57: local L = LibStub("AceLocale-3.0"):GetLocale("AskMrRobot", true) yellowfive@57: local AceGUI = LibStub("AceGUI-3.0") yellowfive@57: yellowfive@57: local _txtImport yellowfive@57: local _lblError yellowfive@69: local _panelCover yellowfive@57: yellowfive@57: local function onImportOkClick(widget) yellowfive@57: local txt = _txtImport:GetText() yellowfive@57: local msg = Amr:ImportCharacter(txt) yellowfive@57: if msg then yellowfive@57: _lblError:SetText(msg) yellowfive@57: _txtImport:SetFocus(true) yellowfive@57: else yellowfive@57: Amr:HideCover() yellowfive@139: Amr:RefreshGearDisplay() yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function onImportCancelClick(widget) yellowfive@57: Amr:HideCover() yellowfive@57: end yellowfive@57: yellowfive@69: local function onTextEnterPressed(widget) yellowfive@69: -- hide the overwolf cover when import data is received yellowfive@69: if _panelCover then yellowfive@69: _panelCover:SetVisible(false) yellowfive@69: end yellowfive@161: yellowfive@161: -- do an import if the data starts with a dollar sign yellowfive@161: local txt = _txtImport:GetText() yellowfive@69: local txtLen = string.len(txt) yellowfive@161: if txtLen > 6 and (string.sub(txt, 1, 1) == '$' or string.sub(txt, 1, 5) == "_bib_" or string.sub(txt, 1, 6) == "_junk_") then yellowfive@69: onImportOkClick() yellowfive@69: end yellowfive@69: yellowfive@69: end yellowfive@69: yellowfive@69: local function renderImportWindow(container, fromOverwolf) yellowfive@57: yellowfive@57: local panelImport = Amr:RenderCoverChrome(container, 700, 450) yellowfive@57: yellowfive@57: local lbl = AceGUI:Create("AmrUiLabel") yellowfive@124: panelImport:AddChild(lbl) yellowfive@57: lbl:SetWidth(600) yellowfive@57: lbl:SetText(L.ImportHeader) yellowfive@57: lbl:SetPoint("TOP", panelImport.content, "TOP", 0, -10) yellowfive@57: yellowfive@57: _txtImport = AceGUI:Create("AmrUiTextarea") yellowfive@57: _txtImport:SetWidth(600) yellowfive@57: _txtImport:SetHeight(300) yellowfive@57: _txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) yellowfive@69: _txtImport:SetCallback("OnEnterPressed", onTextEnterPressed) yellowfive@57: panelImport:AddChild(_txtImport) yellowfive@124: _txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10) yellowfive@57: yellowfive@57: local btnImportOk = AceGUI:Create("AmrUiButton") yellowfive@57: btnImportOk:SetText(L.ImportButtonOk) yellowfive@57: btnImportOk:SetBackgroundColor(Amr.Colors.Green) yellowfive@57: btnImportOk:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) yellowfive@57: btnImportOk:SetWidth(120) yellowfive@57: btnImportOk:SetHeight(28) yellowfive@57: btnImportOk:SetCallback("OnClick", onImportOkClick) yellowfive@57: panelImport:AddChild(btnImportOk) yellowfive@124: btnImportOk:SetPoint("TOPLEFT", _txtImport.frame, "BOTTOMLEFT", 0, -10) yellowfive@57: yellowfive@57: local btnImportCancel = AceGUI:Create("AmrUiButton") yellowfive@57: btnImportCancel:SetText(L.ImportButtonCancel) yellowfive@57: btnImportCancel:SetBackgroundColor(Amr.Colors.Green) yellowfive@57: btnImportCancel:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) yellowfive@57: btnImportCancel:SetWidth(120) yellowfive@57: btnImportCancel:SetHeight(28) yellowfive@57: btnImportCancel:SetCallback("OnClick", onImportCancelClick) yellowfive@57: panelImport:AddChild(btnImportCancel) yellowfive@124: btnImportCancel:SetPoint("LEFT", btnImportOk.frame, "RIGHT", 20, 0) yellowfive@57: yellowfive@57: _lblError = AceGUI:Create("AmrUiLabel") yellowfive@124: panelImport:AddChild(_lblError) yellowfive@57: _lblError:SetWidth(600) yellowfive@57: _lblError:SetFont(Amr.CreateFont("Bold", 14, Amr.Colors.Red)) yellowfive@57: _lblError:SetText("") yellowfive@57: _lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20) yellowfive@57: yellowfive@69: if fromOverwolf then yellowfive@69: -- show a cover preventing interaction until we receive data from overwolf yellowfive@69: _panelCover = AceGUI:Create("AmrUiPanel") yellowfive@69: _panelCover:SetLayout("None") yellowfive@69: _panelCover:EnableMouse(true) yellowfive@69: _panelCover:SetBackgroundColor(Amr.Colors.Black, 0.75) yellowfive@124: panelImport:AddChild(_panelCover) yellowfive@69: _panelCover:SetPoint("TOPLEFT", panelImport.frame, "TOPLEFT") yellowfive@69: _panelCover:SetPoint("BOTTOMRIGHT", panelImport.frame, "BOTTOMRIGHT") yellowfive@69: yellowfive@69: local coverMsg = AceGUI:Create("AmrUiLabel") yellowfive@124: _panelCover:AddChild(coverMsg) yellowfive@69: coverMsg:SetWidth(500) yellowfive@69: coverMsg:SetFont(Amr.CreateFont("Regular", 16, Amr.Colors.TextTan)) yellowfive@69: coverMsg:SetJustifyH("MIDDLE") yellowfive@69: coverMsg:SetJustifyV("MIDDLE") yellowfive@69: coverMsg:SetText(L.ImportOverwolfWait) yellowfive@69: coverMsg:SetPoint("CENTER", _panelCover.frame, "CENTER", 0, 20) yellowfive@69: yellowfive@69: -- after adding, set cover to sit on top of everything yellowfive@69: _panelCover:SetStrata("FULLSCREEN_DIALOG") yellowfive@69: _panelCover:SetLevel(Amr.FrameLevels.Highest) yellowfive@69: end yellowfive@57: end yellowfive@57: yellowfive@69: function Amr:ShowImportWindow(fromOverwolf) yellowfive@57: -- this is shown as a modal dialog yellowfive@69: Amr:ShowCover(function(container) yellowfive@69: renderImportWindow(container, fromOverwolf) yellowfive@69: end) yellowfive@57: yellowfive@57: _txtImport:SetText("") yellowfive@57: _txtImport:SetFocus(true) yellowfive@57: end yellowfive@57: yellowfive@57: ---------------------------------------------------------------------------- yellowfive@57: -- Import Parsing yellowfive@57: ---------------------------------------------------------------------------- yellowfive@57: yellowfive@57: -- yellowfive@161: -- Helper to parse a list of items in the standard item list format. yellowfive@161: -- yellowfive@161: local function parseItemList(parts, startPos, endToken, hasSlot) yellowfive@161: yellowfive@161: local importData = {} yellowfive@161: yellowfive@161: local prevItemId = 0 yellowfive@161: local prevGemId = 0 yellowfive@161: local prevEnchantId = 0 yellowfive@161: local prevUpgradeId = 0 yellowfive@161: local prevBonusId = 0 yellowfive@161: local prevLevel = 0 yellowfive@185: --local prevAzeriteId = 0 yellowfive@161: local digits = { yellowfive@161: ["-"] = true, yellowfive@161: ["0"] = true, yellowfive@161: ["1"] = true, yellowfive@161: ["2"] = true, yellowfive@161: ["3"] = true, yellowfive@161: ["4"] = true, yellowfive@161: ["5"] = true, yellowfive@161: ["6"] = true, yellowfive@161: ["7"] = true, yellowfive@161: ["8"] = true, yellowfive@161: ["9"] = true, yellowfive@161: } yellowfive@161: for i = startPos, #parts do yellowfive@161: local itemString = parts[i] yellowfive@161: if itemString == endToken then yellowfive@161: break yellowfive@161: elseif itemString ~= "" and itemString ~= "_" then yellowfive@161: local tokens = {} yellowfive@161: local bonusIds = {} yellowfive@185: --local azerite = {} yellowfive@161: local hasBonuses = false yellowfive@185: --local hasAzerites = false yellowfive@161: local token = "" yellowfive@161: local prop = "i" yellowfive@161: local tokenComplete = false yellowfive@191: local guid = nil yellowfive@191: yellowfive@191: for j = 1, string.len(itemString) do yellowfive@161: local c = string.sub(itemString, j, j) yellowfive@161: if digits[c] == nil then yellowfive@161: tokenComplete = true yellowfive@161: else yellowfive@161: token = token .. c yellowfive@161: end yellowfive@161: yellowfive@161: if tokenComplete or j == string.len(itemString) then yellowfive@161: local val = tonumber(token) yellowfive@161: if prop == "i" then yellowfive@161: val = val + prevItemId yellowfive@161: prevItemId = val yellowfive@161: elseif prop == "u" then yellowfive@161: val = val + prevUpgradeId yellowfive@161: prevUpgradeId = val yellowfive@161: elseif prop == "v" then yellowfive@161: val = val + prevLevel yellowfive@161: prevLevel = val yellowfive@161: elseif prop == "b" then yellowfive@161: val = val + prevBonusId yellowfive@161: prevBonusId = val yellowfive@161: elseif prop == "x" or prop == "y" or prop == "z" then yellowfive@161: val = val + prevGemId yellowfive@161: prevGemId = val yellowfive@161: elseif prop == "e" then yellowfive@161: val = val + prevEnchantId yellowfive@161: prevEnchantId = val yellowfive@185: --elseif prop == "a" then yellowfive@185: -- val = val + prevAzeriteId yellowfive@185: -- prevAzeriteId = val yellowfive@161: end yellowfive@161: yellowfive@161: if prop == "b" then yellowfive@161: table.insert(bonusIds, val) yellowfive@161: hasBonuses = true yellowfive@185: --elseif prop == "a" then yellowfive@185: -- table.insert(azerite, val) yellowfive@185: -- hasAzerites = true yellowfive@161: else yellowfive@161: tokens[prop] = val yellowfive@161: end yellowfive@161: yellowfive@161: token = "" yellowfive@161: tokenComplete = false yellowfive@161: yellowfive@161: -- we have moved on to the next token yellowfive@161: prop = c yellowfive@161: end yellowfive@191: yellowfive@191: if prop == "!" then yellowfive@191: -- guid is always at the end, if present yellowfive@191: guid = strsub(itemString, j + 1) yellowfive@191: break yellowfive@191: end yellowfive@161: end yellowfive@161: yellowfive@161: local obj = {} yellowfive@161: yellowfive@161: if hasSlot then yellowfive@161: importData[tonumber(tokens["s"])] = obj yellowfive@161: else yellowfive@161: table.insert(importData, obj) yellowfive@161: end yellowfive@161: yellowfive@161: obj.id = tokens["i"] yellowfive@161: obj.suffixId = tokens["f"] or 0 yellowfive@161: obj.upgradeId = tokens["u"] or 0 Yellowfive@195: obj.level = tokens["v"] or 0 Yellowfive@195: obj.stat1 = tokens["j"] or 0 Yellowfive@195: obj.stat2 = tokens["k"] or 0 yellowfive@161: obj.enchantId = tokens["e"] or 0 yellowfive@161: obj.inventoryId = tokens["t"] or 0 yellowfive@161: yellowfive@161: obj.gemIds = {} yellowfive@161: table.insert(obj.gemIds, tokens["x"] or 0) yellowfive@161: table.insert(obj.gemIds, tokens["y"] or 0) yellowfive@161: table.insert(obj.gemIds, tokens["z"] or 0) yellowfive@161: table.insert(obj.gemIds, 0) yellowfive@161: yellowfive@161: if hasBonuses then yellowfive@161: obj.bonusIds = bonusIds yellowfive@161: end yellowfive@161: yellowfive@191: if guid then yellowfive@191: obj.guid = guid yellowfive@191: end yellowfive@191: yellowfive@185: --if hasAzerites then yellowfive@185: -- obj.azerite = azerite yellowfive@185: --end yellowfive@161: end yellowfive@161: end yellowfive@161: yellowfive@161: return importData yellowfive@161: end yellowfive@161: yellowfive@185: --[[ yellowfive@165: local function parseEssenceList(essenceString) yellowfive@165: local ret = {} yellowfive@165: yellowfive@165: local parts = { strsplit("_", essenceString) } yellowfive@165: for i = 1, #parts do yellowfive@165: local essence = { strsplit(".", parts[i]) } yellowfive@181: table.insert(ret, { tonumber(essence[1]), tonumber(essence[2]), tonumber(essence[3]) }) yellowfive@165: end yellowfive@165: yellowfive@165: return ret yellowfive@165: end yellowfive@185: ]] yellowfive@185: yellowfive@185: local function parseSoulbinds(soulbindString) yellowfive@185: local ret = {} yellowfive@185: yellowfive@185: local parts = { strsplit(",", soulbindString) } yellowfive@185: for i = 1, #parts do yellowfive@185: local node = { strsplit(".", parts[i]) } yellowfive@185: table.insert(ret, { tonumber(node[1]), tonumber(node[2]), tonumber(node[3]) }) yellowfive@185: end yellowfive@185: yellowfive@185: return ret yellowfive@185: end yellowfive@165: yellowfive@161: -- yellowfive@57: -- Import a character, returning nil on success, otherwise an error message, import result stored in the db. yellowfive@57: -- yellowfive@139: function Amr:ImportCharacter(data, isTest, isChild) yellowfive@57: yellowfive@57: -- make sure all data is up to date before importing and get a local copy of player's current state yellowfive@57: local currentPlayerData = self:ExportCharacter() yellowfive@57: yellowfive@57: if data == nil or string.len(data) == 0 then yellowfive@57: return L.ImportErrorEmpty yellowfive@57: end yellowfive@161: yellowfive@139: -- if multiple setups are included in the data, parse each individually, then quit yellowfive@161: local specParts = { strsplit("\n", data) } yellowfive@161: yellowfive@161: if #specParts > 1 and specParts[1] == "_junk_" then yellowfive@161: -- if the string starts with "_junk_" then it is the junk list yellowfive@165: return Amr:ImportJunkList(specParts[2], currentPlayerData) yellowfive@161: yellowfive@161: elseif #specParts > 1 then yellowfive@139: -- clear out any previously-imported BiB setups when importing new ones (non-BiB will always be imported one at a time) yellowfive@139: for i = #Amr.db.char.GearSetups, 1, -1 do yellowfive@139: if Amr.db.char.GearSetups[i].IsBib then yellowfive@139: table.remove(Amr.db.char.GearSetups, i) yellowfive@139: end yellowfive@139: end yellowfive@139: yellowfive@141: for i = 1, #specParts do yellowfive@141: if specParts[i] ~= "_bib_" then yellowfive@141: local err = self:ImportCharacter(specParts[i], isTest, true) yellowfive@141: if err ~= nil then yellowfive@141: return err yellowfive@141: end yellowfive@141: end yellowfive@139: end yellowfive@139: yellowfive@139: -- ensure that all BiB setups are sorted to the top yellowfive@139: local nonBib = {} yellowfive@139: for i = #Amr.db.char.GearSetups, 1, -1 do yellowfive@139: if not Amr.db.char.GearSetups[i].IsBib then yellowfive@139: table.insert(nonBib, Amr.db.char.GearSetups[i]) yellowfive@139: table.remove(Amr.db.char.GearSetups, i) yellowfive@139: end yellowfive@139: end yellowfive@139: for i, setup in ipairs(nonBib) do yellowfive@139: table.insert(Amr.db.char.GearSetups, setup) yellowfive@139: end yellowfive@139: yellowfive@139: return yellowfive@57: end yellowfive@57: yellowfive@57: local data1 = { strsplit("$", data) } yellowfive@57: if #data1 ~= 3 then yellowfive@57: return L.ImportErrorFormat yellowfive@57: end yellowfive@57: yellowfive@57: local parts = { strsplit(";", data1[2]) } yellowfive@57: yellowfive@57: -- require a minimum version yellowfive@57: local ver = tonumber(parts[1]) yellowfive@57: if ver < Amr.MIN_IMPORT_VERSION then yellowfive@57: return L.ImportErrorVersion yellowfive@57: end yellowfive@57: yellowfive@57: -- require name match (don't match realm due to language issues for now) yellowfive@57: if not isTest then yellowfive@57: local region = parts[2] yellowfive@57: local realm = parts[3] yellowfive@57: local name = parts[4] yellowfive@57: if name ~= currentPlayerData.Name then yellowfive@57: local importPlayerName = name .. " (" .. realm .. ")" yellowfive@57: local you = currentPlayerData.Name .. " (" .. currentPlayerData.Realm .. ")" yellowfive@57: return L.ImportErrorChar(importPlayerName, you) yellowfive@57: end yellowfive@57: yellowfive@57: -- require race match yellowfive@57: local race = tonumber(parts[6]) yellowfive@57: if race ~= Amr.RaceIds[currentPlayerData.Race] then yellowfive@57: return L.ImportErrorRace yellowfive@57: end yellowfive@57: yellowfive@57: -- require faction match yellowfive@57: local faction = tonumber(parts[7]) yellowfive@57: if faction ~= Amr.FactionIds[currentPlayerData.Faction] then yellowfive@57: return L.ImportErrorFaction yellowfive@57: end yellowfive@57: yellowfive@57: -- require level match yellowfive@57: local level = tonumber(parts[8]) yellowfive@57: if level ~= currentPlayerData.Level then yellowfive@57: return L.ImportErrorLevel yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: -- if we make it this far, the data is valid, so read item information yellowfive@185: local specSlot = tonumber(parts[10]) yellowfive@165: yellowfive@185: local soulbindId = tonumber(parts[14]) yellowfive@185: local soulbindNodes = parseSoulbinds(parts[15]) yellowfive@185: --local essences = parseEssenceList(parts[15]) yellowfive@165: yellowfive@165: local importData = parseItemList(parts, 17, "n/a", true) yellowfive@57: yellowfive@139: -- extra information contains setup id, display label, then extra enchant info yellowfive@57: parts = { strsplit("@", data1[3]) } yellowfive@139: yellowfive@139: local setupId = parts[2] yellowfive@139: local setupName = parts[3] yellowfive@161: local enchantInfo = {} yellowfive@139: yellowfive@139: for i = 4, #parts do yellowfive@57: local infoParts = { strsplit("\\", parts[i]) } yellowfive@57: yellowfive@124: if infoParts[1] == "e" then yellowfive@57: yellowfive@57: local enchObj = {} yellowfive@57: enchObj.id = tonumber(infoParts[2]) yellowfive@57: enchObj.itemId = tonumber(infoParts[3]) yellowfive@57: enchObj.spellId = tonumber(infoParts[4]) yellowfive@57: enchObj.text = string.gsub(infoParts[5], "_(%a+)_", function(s) return L.StatsShort[s] end) yellowfive@57: yellowfive@57: local mats = infoParts[6] yellowfive@57: if string.len(mats) > 0 then yellowfive@57: enchObj.materials = {} yellowfive@57: mats = { strsplit(",", mats) } yellowfive@57: for j = 1, #mats do yellowfive@57: local kv = { strsplit("=", mats[j]) } yellowfive@57: enchObj.materials[tonumber(kv[1])] = tonumber(kv[2]) yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@124: enchantInfo[enchObj.id] = enchObj yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: if isTest then yellowfive@57: print("spec " .. specSlot) yellowfive@57: -- print result for debugging yellowfive@57: for k,v in pairs(importData) do yellowfive@57: local blah = Amr.CreateItemLink(v) yellowfive@57: --print(blah) yellowfive@57: local name, link = GetItemInfo(blah) yellowfive@57: print(link) yellowfive@57: if link == nil then yellowfive@57: print(blah) yellowfive@57: print("bad item: " .. v.id) yellowfive@57: end yellowfive@133: end yellowfive@57: else yellowfive@57: -- we have succeeded, record the result yellowfive@139: local result = { yellowfive@139: IsBib = string.sub(setupId, 1, 3) ~= "AMR", yellowfive@139: SpecSlot = tonumber(specSlot), yellowfive@139: Id = setupId, yellowfive@139: Label = setupName, yellowfive@165: Gear = importData, yellowfive@185: SoulbindId = soulbindId, yellowfive@185: SoulbindNodes = soulbindNodes yellowfive@185: --Essences = essences yellowfive@139: } yellowfive@139: yellowfive@139: if not result.IsBib then yellowfive@139: -- replace if this setup already exists yellowfive@139: local key = -1 yellowfive@139: for i,setup in ipairs(Amr.db.char.GearSetups) do yellowfive@139: if setup.Id == result.Id then yellowfive@139: key = i yellowfive@139: break yellowfive@139: end yellowfive@139: end yellowfive@139: yellowfive@139: if key ~= -1 then yellowfive@139: Amr.db.char.GearSetups[key] = result yellowfive@139: else yellowfive@139: table.insert(Amr.db.char.GearSetups, result) yellowfive@139: end yellowfive@139: yellowfive@139: if not isChild then yellowfive@139: -- if doing a single import of a setup, make it active yellowfive@139: Amr:SetActiveSetupId(setupId) yellowfive@139: end yellowfive@139: else yellowfive@139: table.insert(Amr.db.char.GearSetups, result) yellowfive@139: end yellowfive@124: yellowfive@124: for k,v in pairs(enchantInfo) do yellowfive@124: Amr.db.char.ExtraEnchantData[k] = v yellowfive@124: end yellowfive@57: yellowfive@57: -- also update shopping list after import yellowfive@57: Amr:UpdateShoppingData(currentPlayerData) yellowfive@57: end yellowfive@57: end yellowfive@161: yellowfive@161: -- yellowfive@161: -- Import a list of items that are junk. yellowfive@161: -- yellowfive@161: function Amr:ImportJunkList(data, currentPlayerData) yellowfive@161: yellowfive@161: local data1 = { strsplit("$", data) } yellowfive@161: if #data1 ~= 3 then yellowfive@161: return L.ImportErrorFormat yellowfive@161: end yellowfive@161: yellowfive@161: local parts = { strsplit(";", data1[2]) } yellowfive@161: yellowfive@161: -- require a minimum version yellowfive@161: local ver = tonumber(parts[1]) yellowfive@161: if ver < Amr.MIN_IMPORT_VERSION then yellowfive@161: return L.ImportErrorVersion yellowfive@161: end yellowfive@161: yellowfive@161: -- require name match yellowfive@161: local region = parts[2] yellowfive@161: local realm = parts[3] yellowfive@161: local name = parts[4] yellowfive@161: if name ~= currentPlayerData.Name then yellowfive@161: local importPlayerName = name .. " (" .. realm .. ")" yellowfive@161: local you = currentPlayerData.Name .. " (" .. currentPlayerData.Realm .. ")" yellowfive@161: return L.ImportErrorChar(importPlayerName, you) yellowfive@161: end yellowfive@161: yellowfive@161: local keepStartPos = 0 yellowfive@161: local junkStartPos = 0 yellowfive@161: for i = 5, #parts do yellowfive@161: local partString = parts[i] yellowfive@161: if partString == ".k" then yellowfive@161: keepStartPos = i + 1 yellowfive@161: elseif partString == ".d" then yellowfive@161: junkStartPos = i + 1 yellowfive@161: end yellowfive@161: end yellowfive@161: yellowfive@161: Amr.db.char.JunkData = {} yellowfive@161: yellowfive@161: -- Keep is a lookup by unique id yellowfive@161: local keep = parseItemList(parts, keepStartPos, ".d", false) yellowfive@161: Amr.db.char.JunkData.Keep = {} yellowfive@161: for i = 1, #keep do yellowfive@161: local uniqueId = Amr.GetItemUniqueId(keep[i]) yellowfive@161: Amr.db.char.JunkData.Keep[uniqueId] = keep[i] yellowfive@161: end yellowfive@161: yellowfive@161: -- Junk is a simple list of items to discard, in the desired display order yellowfive@161: Amr.db.char.JunkData.Junk = parseItemList(parts, junkStartPos, "n/a", false) yellowfive@163: yellowfive@161: -- extra information contains extra enchant info yellowfive@161: if #data1 >= 3 then yellowfive@161: parts = { strsplit("@", data1[3]) } yellowfive@161: yellowfive@161: local enchantInfo = {} yellowfive@161: yellowfive@161: for i = 2, #parts do yellowfive@161: local infoParts = { strsplit("\\", parts[i]) } yellowfive@161: yellowfive@161: if infoParts[1] == "e" then yellowfive@161: yellowfive@161: local enchObj = {} yellowfive@161: enchObj.id = tonumber(infoParts[2]) yellowfive@161: enchObj.itemId = tonumber(infoParts[3]) yellowfive@161: enchObj.spellId = tonumber(infoParts[4]) yellowfive@161: enchObj.text = string.gsub(infoParts[5], "_(%a+)_", function(s) return L.StatsShort[s] end) yellowfive@161: yellowfive@161: local mats = infoParts[6] yellowfive@161: if string.len(mats) > 0 then yellowfive@161: enchObj.materials = {} yellowfive@161: mats = { strsplit(",", mats) } yellowfive@161: for j = 1, #mats do yellowfive@161: local kv = { strsplit("=", mats[j]) } yellowfive@161: enchObj.materials[tonumber(kv[1])] = tonumber(kv[2]) yellowfive@161: end yellowfive@161: end yellowfive@161: yellowfive@161: enchantInfo[enchObj.id] = enchObj yellowfive@161: end yellowfive@161: end yellowfive@161: yellowfive@161: for k,v in pairs(enchantInfo) do yellowfive@161: Amr.db.char.ExtraEnchantData[k] = v yellowfive@161: end yellowfive@161: end yellowfive@161: yellowfive@161: -- show the junk window after a successful junk import yellowfive@161: Amr:ShowJunkWindow() yellowfive@161: end