comparison AskMrRobot.lua @ 31:44c285acfff0 v8

fixed item display bug on summary tab
author yellowfive
date Sat, 18 Oct 2014 10:33:33 -0700
parents aabec73640a0
children 4ba69d2ee252
comparison
equal deleted inserted replaced
30:55906ac875ae 31:44c285acfff0
33 AskMrRobot.eventListener:RegisterEvent("VOID_STORAGE_UPDATE") 33 AskMrRobot.eventListener:RegisterEvent("VOID_STORAGE_UPDATE")
34 34
35 AskMrRobot.AddonName = ... 35 AskMrRobot.AddonName = ...
36 AskMrRobot.ChatPrefix = "_AMR" 36 AskMrRobot.ChatPrefix = "_AMR"
37 37
38 -- flag to turn on debugging behavior
39 AskMrRobot.debug = false
40
38 -- the main user interface window 41 -- the main user interface window
39 AskMrRobot.mainWindow = nil 42 AskMrRobot.mainWindow = nil
40 43
41 local _amrLDB 44 local _amrLDB
42 local _minimapIcon 45 local _minimapIcon
448 451
449 function AskMrRobot.GetCurrencies() 452 function AskMrRobot.GetCurrencies()
450 local currencies = {}; 453 local currencies = {};
451 currencies[-1] = GetMoney() 454 currencies[-1] = GetMoney()
452 455
453 local currencyList = {61, 81, 241, 361, 384, 394, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 416, 515, 614, 615, 676, 679} 456 local currencyList = {61, 81, 241, 361, 384, 394, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 416, 515, 614, 615, 676, 679, 823}
454 for i, currency in pairs(currencyList) do 457 for i, currency in pairs(currencyList) do
455 local amount = getCurrencyAmount(currency) 458 local amount = getCurrencyAmount(currency)
456 if amount ~= 0 then 459 if amount ~= 0 then
457 currencies[currency] = amount 460 currencies[currency] = amount
458 end 461 end
801 local MIN_IMPORT_VERSION = 2 804 local MIN_IMPORT_VERSION = 2
802 805
803 -- 806 --
804 -- Import a character, returning nil on success, otherwise an error message, import result stored in AskMrRobot.ImportData 807 -- Import a character, returning nil on success, otherwise an error message, import result stored in AskMrRobot.ImportData
805 -- 808 --
806 function AskMrRobot.ImportCharacter(data) 809 function AskMrRobot.ImportCharacter(data, isTest)
807 810
808 -- make sure all data is up to date before importing 811 -- make sure all data is up to date before importing
809 AskMrRobot.SaveAll() 812 AskMrRobot.SaveAll()
810 813
811 if data == nil or string.len(data) == 0 then 814 if data == nil or string.len(data) == 0 then
824 if ver < MIN_IMPORT_VERSION then 827 if ver < MIN_IMPORT_VERSION then
825 return L.AMR_IMPORT_ERROR_VERSION 828 return L.AMR_IMPORT_ERROR_VERSION
826 end 829 end
827 830
828 -- require realm/name match 831 -- require realm/name match
829 local realm = parts[2] 832 if not isTest then
830 local name = parts[3] 833 local realm = parts[2]
831 if name ~= AmrDb.CharacterName then 834 local name = parts[3]
832 local badPers = name .. " (" .. realm .. ")" 835 if name ~= AmrDb.CharacterName then
833 local goodPers = AmrDb.CharacterName .. " (" .. AmrDb.RealmName .. ")" 836 local badPers = name .. " (" .. realm .. ")"
834 return L.AMR_IMPORT_ERROR_CHAR:format(badPers, goodPers) 837 local goodPers = AmrDb.CharacterName .. " (" .. AmrDb.RealmName .. ")"
835 end 838 return L.AMR_IMPORT_ERROR_CHAR:format(badPers, goodPers)
836 839 end
837 -- require race match 840
838 local race = tonumber(parts[5]) 841 -- require race match
839 if race ~= AskMrRobot.raceIds[AmrDb.Race] then 842 local race = tonumber(parts[5])
840 return L.AMR_IMPORT_ERROR_RACE 843 if race ~= AskMrRobot.raceIds[AmrDb.Race] then
841 end 844 return L.AMR_IMPORT_ERROR_RACE
842 845 end
843 -- require faction match 846
844 local faction = tonumber(parts[6]) 847 -- require faction match
845 if faction ~= AskMrRobot.factionIds[AmrDb.Faction] then 848 local faction = tonumber(parts[6])
846 return L.AMR_IMPORT_ERROR_FACTION 849 if faction ~= AskMrRobot.factionIds[AmrDb.Faction] then
847 end 850 return L.AMR_IMPORT_ERROR_FACTION
848 851 end
849 -- require level match 852
850 local level = tonumber(parts[7]) 853 -- require level match
851 if level ~= AmrDb.Level then 854 local level = tonumber(parts[7])
852 return L.AMR_IMPORT_ERROR_LEVEL 855 if level ~= AmrDb.Level then
853 end 856 return L.AMR_IMPORT_ERROR_LEVEL
854 857 end
855 -- require spec match 858
856 local spec = tonumber(parts[11]) 859 -- require spec match
857 if spec ~= AmrDb.Specs[AmrDb.ActiveSpec] then 860 local spec = tonumber(parts[11])
858 print(AmrDb.ActiveSpec) 861 if spec ~= AmrDb.Specs[AmrDb.ActiveSpec] then
859 print(spec) 862 print(AmrDb.ActiveSpec)
860 print(AmrDb.Specs[AmrDb.ActiveSpec]) 863 print(spec)
861 local _, specName = GetSpecializationInfoByID(AskMrRobot.gameSpecIds[spec]) 864 print(AmrDb.Specs[AmrDb.ActiveSpec])
862 return L.AMR_IMPORT_ERROR_SPEC:format(specName) 865 local _, specName = GetSpecializationInfoByID(AskMrRobot.gameSpecIds[spec])
863 end 866 return L.AMR_IMPORT_ERROR_SPEC:format(specName)
864 867 end
865 -- require talent match 868
866 local talents = parts[12] 869 -- require talent match
867 if talents ~= AmrDb.Talents[AmrDb.ActiveSpec] then 870 local talents = parts[12]
868 return L.AMR_IMPORT_ERROR_TALENT 871 if talents ~= AmrDb.Talents[AmrDb.ActiveSpec] then
869 end 872 return L.AMR_IMPORT_ERROR_TALENT
870 873 end
871 -- require glyph match 874
872 -- TODO: re-enable this check when glyphs are more consistent 875 -- require glyph match
873 --local glyphs = parts[13] 876 -- TODO: re-enable this check when glyphs are more consistent
874 --if glyphs ~= AskMrRobot.toCompressedNumberList(AmrDb.Glyphs[AmrDb.ActiveSpec]) then 877 --local glyphs = parts[13]
875 -- return L.AMR_IMPORT_ERROR_GLYPH 878 --if glyphs ~= AskMrRobot.toCompressedNumberList(AmrDb.Glyphs[AmrDb.ActiveSpec]) then
876 --end 879 -- return L.AMR_IMPORT_ERROR_GLYPH
880 --end
881 end
882
877 883
878 -- if we make it this far, the data is valid, so read item information 884 -- if we make it this far, the data is valid, so read item information
879 local importData = {} 885 local importData = {}
880 886
881 local itemInfo = {} 887 local itemInfo = {}
1043 enchantInfo[enchObj.id] = enchObj 1049 enchantInfo[enchObj.id] = enchObj
1044 1050
1045 end 1051 end
1046 end 1052 end
1047 1053
1048 -- we have succeeded, record the result 1054 if isTest then
1049 AskMrRobot.ImportData = importData 1055 -- print result for debugging
1050 AskMrRobot.ExtraItemData = itemInfo 1056 local blah = importData[1]
1051 AskMrRobot.ExtraGemData = gemInfo 1057 local name, link = GetItemInfo(AskMrRobot.createItemLink(blah))
1052 AskMrRobot.ExtraEnchantData = enchantInfo 1058 print(link)
1053 1059
1054 AmrDb.LastCharacterImport = data 1060 else
1055 AmrDb.LastCharacterImportDate = date() 1061 -- we have succeeded, record the result
1056 end 1062 AskMrRobot.ImportData = importData
1063 AskMrRobot.ExtraItemData = itemInfo
1064 AskMrRobot.ExtraGemData = gemInfo
1065 AskMrRobot.ExtraEnchantData = enchantInfo
1066
1067 AmrDb.LastCharacterImport = data
1068 AmrDb.LastCharacterImportDate = date()
1069 end
1070 end