Mercurial > wow > askmrrobot
comparison Import.lua @ 124:e31b02b24488
Updated for 8.0 pre-patch and BfA.
| author | yellowfive |
|---|---|
| date | Tue, 17 Jul 2018 09:57:39 -0700 |
| parents | 6bbe64d587b4 |
| children | a0894ffebd15 |
comparison
equal
deleted
inserted
replaced
| 123:7a6364917f86 | 124:e31b02b24488 |
|---|---|
| 40 local function renderImportWindow(container, fromOverwolf) | 40 local function renderImportWindow(container, fromOverwolf) |
| 41 | 41 |
| 42 local panelImport = Amr:RenderCoverChrome(container, 700, 450) | 42 local panelImport = Amr:RenderCoverChrome(container, 700, 450) |
| 43 | 43 |
| 44 local lbl = AceGUI:Create("AmrUiLabel") | 44 local lbl = AceGUI:Create("AmrUiLabel") |
| 45 panelImport:AddChild(lbl) | |
| 45 lbl:SetWidth(600) | 46 lbl:SetWidth(600) |
| 46 lbl:SetText(L.ImportHeader) | 47 lbl:SetText(L.ImportHeader) |
| 47 lbl:SetPoint("TOP", panelImport.content, "TOP", 0, -10) | 48 lbl:SetPoint("TOP", panelImport.content, "TOP", 0, -10) |
| 48 panelImport:AddChild(lbl) | |
| 49 | 49 |
| 50 _txtImport = AceGUI:Create("AmrUiTextarea") | 50 _txtImport = AceGUI:Create("AmrUiTextarea") |
| 51 _txtImport:SetWidth(600) | 51 _txtImport:SetWidth(600) |
| 52 _txtImport:SetHeight(300) | 52 _txtImport:SetHeight(300) |
| 53 _txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10) | |
| 54 _txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) | 53 _txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text)) |
| 55 _txtImport:SetCallback("OnEnterPressed", onTextEnterPressed) | 54 _txtImport:SetCallback("OnEnterPressed", onTextEnterPressed) |
| 56 panelImport:AddChild(_txtImport) | 55 panelImport:AddChild(_txtImport) |
| 56 _txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10) | |
| 57 | 57 |
| 58 local btnImportOk = AceGUI:Create("AmrUiButton") | 58 local btnImportOk = AceGUI:Create("AmrUiButton") |
| 59 btnImportOk:SetText(L.ImportButtonOk) | 59 btnImportOk:SetText(L.ImportButtonOk) |
| 60 btnImportOk:SetBackgroundColor(Amr.Colors.Green) | 60 btnImportOk:SetBackgroundColor(Amr.Colors.Green) |
| 61 btnImportOk:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) | 61 btnImportOk:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) |
| 62 btnImportOk:SetWidth(120) | 62 btnImportOk:SetWidth(120) |
| 63 btnImportOk:SetHeight(28) | 63 btnImportOk:SetHeight(28) |
| 64 btnImportOk:SetPoint("TOPLEFT", _txtImport.frame, "BOTTOMLEFT", 0, -10) | |
| 65 btnImportOk:SetCallback("OnClick", onImportOkClick) | 64 btnImportOk:SetCallback("OnClick", onImportOkClick) |
| 66 panelImport:AddChild(btnImportOk) | 65 panelImport:AddChild(btnImportOk) |
| 66 btnImportOk:SetPoint("TOPLEFT", _txtImport.frame, "BOTTOMLEFT", 0, -10) | |
| 67 | 67 |
| 68 local btnImportCancel = AceGUI:Create("AmrUiButton") | 68 local btnImportCancel = AceGUI:Create("AmrUiButton") |
| 69 btnImportCancel:SetText(L.ImportButtonCancel) | 69 btnImportCancel:SetText(L.ImportButtonCancel) |
| 70 btnImportCancel:SetBackgroundColor(Amr.Colors.Green) | 70 btnImportCancel:SetBackgroundColor(Amr.Colors.Green) |
| 71 btnImportCancel:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) | 71 btnImportCancel:SetFont(Amr.CreateFont("Bold", 16, Amr.Colors.White)) |
| 72 btnImportCancel:SetWidth(120) | 72 btnImportCancel:SetWidth(120) |
| 73 btnImportCancel:SetHeight(28) | 73 btnImportCancel:SetHeight(28) |
| 74 btnImportCancel:SetPoint("LEFT", btnImportOk.frame, "RIGHT", 20, 0) | |
| 75 btnImportCancel:SetCallback("OnClick", onImportCancelClick) | 74 btnImportCancel:SetCallback("OnClick", onImportCancelClick) |
| 76 panelImport:AddChild(btnImportCancel) | 75 panelImport:AddChild(btnImportCancel) |
| 76 btnImportCancel:SetPoint("LEFT", btnImportOk.frame, "RIGHT", 20, 0) | |
| 77 | 77 |
| 78 _lblError = AceGUI:Create("AmrUiLabel") | 78 _lblError = AceGUI:Create("AmrUiLabel") |
| 79 panelImport:AddChild(_lblError) | |
| 79 _lblError:SetWidth(600) | 80 _lblError:SetWidth(600) |
| 80 _lblError:SetFont(Amr.CreateFont("Bold", 14, Amr.Colors.Red)) | 81 _lblError:SetFont(Amr.CreateFont("Bold", 14, Amr.Colors.Red)) |
| 81 _lblError:SetText("") | 82 _lblError:SetText("") |
| 82 _lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20) | 83 _lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20) |
| 83 panelImport:AddChild(_lblError) | |
| 84 | 84 |
| 85 if fromOverwolf then | 85 if fromOverwolf then |
| 86 -- show a cover preventing interaction until we receive data from overwolf | 86 -- show a cover preventing interaction until we receive data from overwolf |
| 87 _panelCover = AceGUI:Create("AmrUiPanel") | 87 _panelCover = AceGUI:Create("AmrUiPanel") |
| 88 _panelCover:SetLayout("None") | 88 _panelCover:SetLayout("None") |
| 89 _panelCover:EnableMouse(true) | 89 _panelCover:EnableMouse(true) |
| 90 _panelCover:SetBackgroundColor(Amr.Colors.Black, 0.75) | 90 _panelCover:SetBackgroundColor(Amr.Colors.Black, 0.75) |
| 91 panelImport:AddChild(_panelCover) | |
| 91 _panelCover:SetPoint("TOPLEFT", panelImport.frame, "TOPLEFT") | 92 _panelCover:SetPoint("TOPLEFT", panelImport.frame, "TOPLEFT") |
| 92 _panelCover:SetPoint("BOTTOMRIGHT", panelImport.frame, "BOTTOMRIGHT") | 93 _panelCover:SetPoint("BOTTOMRIGHT", panelImport.frame, "BOTTOMRIGHT") |
| 93 panelImport:AddChild(_panelCover) | |
| 94 | 94 |
| 95 local coverMsg = AceGUI:Create("AmrUiLabel") | 95 local coverMsg = AceGUI:Create("AmrUiLabel") |
| 96 _panelCover:AddChild(coverMsg) | |
| 96 coverMsg:SetWidth(500) | 97 coverMsg:SetWidth(500) |
| 97 coverMsg:SetFont(Amr.CreateFont("Regular", 16, Amr.Colors.TextTan)) | 98 coverMsg:SetFont(Amr.CreateFont("Regular", 16, Amr.Colors.TextTan)) |
| 98 coverMsg:SetJustifyH("MIDDLE") | 99 coverMsg:SetJustifyH("MIDDLE") |
| 99 coverMsg:SetJustifyV("MIDDLE") | 100 coverMsg:SetJustifyV("MIDDLE") |
| 100 coverMsg:SetText(L.ImportOverwolfWait) | 101 coverMsg:SetText(L.ImportOverwolfWait) |
| 101 coverMsg:SetPoint("CENTER", _panelCover.frame, "CENTER", 0, 20) | 102 coverMsg:SetPoint("CENTER", _panelCover.frame, "CENTER", 0, 20) |
| 102 _panelCover:AddChild(coverMsg) | |
| 103 | 103 |
| 104 -- after adding, set cover to sit on top of everything | 104 -- after adding, set cover to sit on top of everything |
| 105 _panelCover:SetStrata("FULLSCREEN_DIALOG") | 105 _panelCover:SetStrata("FULLSCREEN_DIALOG") |
| 106 _panelCover:SetLevel(Amr.FrameLevels.Highest) | 106 _panelCover:SetLevel(Amr.FrameLevels.Highest) |
| 107 end | 107 end |
| 187 return L.ImportErrorLevel | 187 return L.ImportErrorLevel |
| 188 end | 188 end |
| 189 end | 189 end |
| 190 | 190 |
| 191 -- if we make it this far, the data is valid, so read item information | 191 -- if we make it this far, the data is valid, so read item information |
| 192 local specSlot = tonumber(parts[10]) | 192 local specSlot = tonumber(parts[11]) |
| 193 | 193 |
| 194 local importData = {} | 194 local importData = {} |
| 195 | |
| 196 local itemInfo = {} | |
| 197 local gemInfo = {} | |
| 198 local enchantInfo = {} | 195 local enchantInfo = {} |
| 199 | 196 |
| 200 local prevItemId = 0 | 197 local prevItemId = 0 |
| 201 local prevGemId = 0 | 198 local prevGemId = 0 |
| 202 local prevEnchantId = 0 | 199 local prevEnchantId = 0 |
| 203 local prevUpgradeId = 0 | 200 local prevUpgradeId = 0 |
| 204 local prevBonusId = 0 | 201 local prevBonusId = 0 |
| 205 local prevLevel = 0 | 202 local prevLevel = 0 |
| 203 local prevAzeriteId = 0 | |
| 206 local digits = { | 204 local digits = { |
| 207 ["-"] = true, | 205 ["-"] = true, |
| 208 ["0"] = true, | 206 ["0"] = true, |
| 209 ["1"] = true, | 207 ["1"] = true, |
| 210 ["2"] = true, | 208 ["2"] = true, |
| 214 ["6"] = true, | 212 ["6"] = true, |
| 215 ["7"] = true, | 213 ["7"] = true, |
| 216 ["8"] = true, | 214 ["8"] = true, |
| 217 ["9"] = true, | 215 ["9"] = true, |
| 218 } | 216 } |
| 219 for i = 18, #parts do | 217 for i = 16, #parts do |
| 220 local itemString = parts[i] | 218 local itemString = parts[i] |
| 221 if itemString ~= "" and itemString ~= "_" then | 219 if itemString ~= "" and itemString ~= "_" then |
| 222 local tokens = {} | 220 local tokens = {} |
| 223 local bonusIds = {} | 221 local bonusIds = {} |
| 224 local relicBonusIds = {} | 222 local azerite = {} |
| 225 table.insert(relicBonusIds, {}) | |
| 226 table.insert(relicBonusIds, {}) | |
| 227 table.insert(relicBonusIds, {}) | |
| 228 local hasRelics = false | |
| 229 local hasBonuses = false | 223 local hasBonuses = false |
| 224 local hasAzerites = false | |
| 230 local token = "" | 225 local token = "" |
| 231 local prop = "i" | 226 local prop = "i" |
| 232 local tokenComplete = false | 227 local tokenComplete = false |
| 233 for j = 1, string.len(itemString) do | 228 for j = 1, string.len(itemString) do |
| 234 local c = string.sub(itemString, j, j) | 229 local c = string.sub(itemString, j, j) |
| 256 val = val + prevGemId | 251 val = val + prevGemId |
| 257 prevGemId = val | 252 prevGemId = val |
| 258 elseif prop == "e" then | 253 elseif prop == "e" then |
| 259 val = val + prevEnchantId | 254 val = val + prevEnchantId |
| 260 prevEnchantId = val | 255 prevEnchantId = val |
| 256 elseif prop == "a" then | |
| 257 val = val + prevAzeriteId | |
| 258 prevAzeriteId = val | |
| 261 end | 259 end |
| 262 | 260 |
| 263 if prop == "b" then | 261 if prop == "b" then |
| 264 table.insert(bonusIds, val) | 262 table.insert(bonusIds, val) |
| 265 hasBonuses = true | 263 hasBonuses = true |
| 266 elseif prop == "m" then | 264 elseif prop == "a" then |
| 267 table.insert(relicBonusIds[1], val) | 265 table.insert(azerite, val) |
| 268 hasRelics = true | 266 hasAzerites = true |
| 269 elseif prop == "n" then | |
| 270 table.insert(relicBonusIds[2], val) | |
| 271 hasRelics = true | |
| 272 elseif prop == "o" then | |
| 273 table.insert(relicBonusIds[3], val) | |
| 274 hasRelics = true | |
| 275 else | 267 else |
| 276 tokens[prop] = val | 268 tokens[prop] = val |
| 277 end | 269 end |
| 278 | 270 |
| 279 token = "" | 271 token = "" |
| 297 obj.gemIds = {} | 289 obj.gemIds = {} |
| 298 table.insert(obj.gemIds, tokens["x"] or 0) | 290 table.insert(obj.gemIds, tokens["x"] or 0) |
| 299 table.insert(obj.gemIds, tokens["y"] or 0) | 291 table.insert(obj.gemIds, tokens["y"] or 0) |
| 300 table.insert(obj.gemIds, tokens["z"] or 0) | 292 table.insert(obj.gemIds, tokens["z"] or 0) |
| 301 table.insert(obj.gemIds, 0) | 293 table.insert(obj.gemIds, 0) |
| 302 | |
| 303 if hasRelics then | |
| 304 obj.relicBonusIds = relicBonusIds | |
| 305 end | |
| 306 | 294 |
| 307 if hasBonuses then | 295 if hasBonuses then |
| 308 obj.bonusIds = bonusIds | 296 obj.bonusIds = bonusIds |
| 309 end | 297 end |
| 310 | 298 |
| 311 local itemObj = {} | 299 if hasAzerites then |
| 312 itemObj.id = obj.id | 300 obj.azerite = azerite |
| 313 itemInfo[obj.id] = itemObj | 301 end |
| 314 | |
| 315 -- look for any socket color information, add to our extra data | |
| 316 if tokens["c"] then | |
| 317 itemObj.socketColors = {} | |
| 318 for j = 1, string.len(tokens["c"]) do | |
| 319 table.insert(itemObj.socketColors, tonumber(string.sub(tokens["c"], j, j))) | |
| 320 end | |
| 321 end | |
| 322 | |
| 323 -- look for item ID duplicate info, deals with old SoO items | |
| 324 if tokens["d"] then | |
| 325 itemObj.duplicateId = tonumber(tokens["d"]) | |
| 326 itemInfo[itemObj.duplicateId] = itemObj | |
| 327 end | |
| 328 | |
| 329 end | 302 end |
| 330 end | 303 end |
| 331 | 304 |
| 332 -- now read any extra display information | 305 -- now read any extra display information |
| 333 parts = { strsplit("@", data1[3]) } | 306 parts = { strsplit("@", data1[3]) } |
| 334 for i = 1, #parts do | 307 for i = 1, #parts do |
| 335 local infoParts = { strsplit("\\", parts[i]) } | 308 local infoParts = { strsplit("\\", parts[i]) } |
| 336 | 309 |
| 337 if infoParts[1] == "g" then | 310 if infoParts[1] == "e" then |
| 338 | |
| 339 local gemObj = {} | |
| 340 gemObj.enchantId = tonumber(infoParts[2]) | |
| 341 gemObj.id = tonumber(infoParts[3]) | |
| 342 | |
| 343 local identicalGems = infoParts[4] | |
| 344 if string.len(identicalGems) > 0 then | |
| 345 gemObj.identicalGroup = {} | |
| 346 identicalGems = { strsplit(",", identicalGems) } | |
| 347 for j = 1, #identicalGems do | |
| 348 gemObj.identicalGroup[tonumber(identicalGems[j])] = true | |
| 349 end | |
| 350 end | |
| 351 | |
| 352 gemObj.text = string.gsub(infoParts[5], "_(%a+)_", function(s) return L.StatsShort[s] end) | |
| 353 if infoParts[6] == nil or string.len(infoParts[6]) == 0 then | |
| 354 gemObj.identicalItemGroup = {[gemObj.id]=true} | |
| 355 else | |
| 356 local identicalIds = { strsplit(',', infoParts[6]) } | |
| 357 gemObj.identicalItemGroup = {} | |
| 358 for j = 1, #identicalIds do | |
| 359 gemObj.identicalItemGroup[tonumber(identicalIds[j])] = true | |
| 360 end | |
| 361 end | |
| 362 | |
| 363 gemInfo[gemObj.id] = gemObj | |
| 364 | |
| 365 elseif infoParts[1] == "e" then | |
| 366 | 311 |
| 367 local enchObj = {} | 312 local enchObj = {} |
| 368 enchObj.id = tonumber(infoParts[2]) | 313 enchObj.id = tonumber(infoParts[2]) |
| 369 enchObj.itemId = tonumber(infoParts[3]) | 314 enchObj.itemId = tonumber(infoParts[3]) |
| 370 enchObj.spellId = tonumber(infoParts[4]) | 315 enchObj.spellId = tonumber(infoParts[4]) |
| 378 local kv = { strsplit("=", mats[j]) } | 323 local kv = { strsplit("=", mats[j]) } |
| 379 enchObj.materials[tonumber(kv[1])] = tonumber(kv[2]) | 324 enchObj.materials[tonumber(kv[1])] = tonumber(kv[2]) |
| 380 end | 325 end |
| 381 end | 326 end |
| 382 | 327 |
| 383 enchantInfo[enchObj.id] = enchObj | 328 enchantInfo[enchObj.id] = enchObj |
| 384 | |
| 385 end | 329 end |
| 386 end | 330 end |
| 387 | 331 |
| 388 if isTest then | 332 if isTest then |
| 389 print("spec " .. specSlot) | 333 print("spec " .. specSlot) |
| 395 print(link) | 339 print(link) |
| 396 if link == nil then | 340 if link == nil then |
| 397 print(blah) | 341 print(blah) |
| 398 print("bad item: " .. v.id) | 342 print("bad item: " .. v.id) |
| 399 end | 343 end |
| 400 end | 344 end |
| 401 | |
| 402 | |
| 403 else | 345 else |
| 404 -- we have succeeded, record the result | 346 -- we have succeeded, record the result |
| 405 Amr.db.char.GearSets[specSlot] = importData | 347 Amr.db.char.GearSets[specSlot] = importData |
| 406 Amr.db.char.ExtraItemData[specSlot] = itemInfo | 348 |
| 407 Amr.db.char.ExtraGemData[specSlot] = gemInfo | 349 for k,v in pairs(enchantInfo) do |
| 408 Amr.db.char.ExtraEnchantData[specSlot] = enchantInfo | 350 Amr.db.char.ExtraEnchantData[k] = v |
| 351 end | |
| 409 | 352 |
| 410 -- also update shopping list after import | 353 -- also update shopping list after import |
| 411 Amr:UpdateShoppingData(currentPlayerData) | 354 Amr:UpdateShoppingData(currentPlayerData) |
| 412 end | 355 end |
| 413 end | 356 end |
