55--
66local ipairs = ipairs
77local t_insert = table.insert
8+ local t_remove = table.remove
89local b_rshift = bit .rshift
910local band = bit .band
1011local m_max = math.max
@@ -815,6 +816,97 @@ function ImportTabClass:ImportPassiveTreeAndJewels(charData)
815816 main :SetWindowTitleSubtext (string.format (" %s (%s, %s, %s)" , self .build .buildName , charData .name , charData .class , charData .league ))
816817end
817818
819+ local SOCKET_GROUP_REIMPORT_KEY_SEPARATOR = " \31 "
820+
821+ local function getSocketGroupReimportKey (socketGroup )
822+ -- Use a rarely-used separator to avoid accidental collisions when concatenating fields.
823+ local gemNameParts = { }
824+ for _ , gem in ipairs (socketGroup .gemList ) do
825+ t_insert (gemNameParts , (gem .nameSpec or " " ):lower ())
826+ end
827+ return table.concat ({
828+ tostring (# socketGroup .gemList ),
829+ table.concat (gemNameParts , SOCKET_GROUP_REIMPORT_KEY_SEPARATOR ),
830+ }, SOCKET_GROUP_REIMPORT_KEY_SEPARATOR )
831+ end
832+
833+ local function snapshotSocketGroupReimportState (socketGroup , isMainGroup )
834+ local gemStates = { }
835+ for gemIndex , gem in ipairs (socketGroup .gemList ) do
836+ gemStates [gemIndex ] = {
837+ enabled = gem .enabled ,
838+ count = gem .count ,
839+ statSet = gem .statSet and copyTable (gem .statSet ),
840+ statSetCalcs = gem .statSetCalcs and copyTable (gem .statSetCalcs ),
841+ skillPart = gem .skillPart ,
842+ skillPartCalcs = gem .skillPartCalcs ,
843+ skillStageCount = gem .skillStageCount ,
844+ skillStageCountCalcs = gem .skillStageCountCalcs ,
845+ skillMineCount = gem .skillMineCount ,
846+ skillMineCountCalcs = gem .skillMineCountCalcs ,
847+ skillMinion = gem .skillMinion ,
848+ skillMinionCalcs = gem .skillMinionCalcs ,
849+ skillMinionItemSet = gem .skillMinionItemSet ,
850+ skillMinionItemSetCalcs = gem .skillMinionItemSetCalcs ,
851+ skillMinionSkill = gem .skillMinionSkill ,
852+ skillMinionSkillCalcs = gem .skillMinionSkillCalcs ,
853+ skillMinionSkillStatSetIndexLookup = gem .skillMinionSkillStatSetIndexLookup and copyTable (gem .skillMinionSkillStatSetIndexLookup ),
854+ skillMinionSkillStatSetIndexLookupCalcs = gem .skillMinionSkillStatSetIndexLookupCalcs and copyTable (gem .skillMinionSkillStatSetIndexLookupCalcs ),
855+ enableGlobal1 = gem .enableGlobal1 ,
856+ enableGlobal2 = gem .enableGlobal2 ,
857+ }
858+ end
859+ return {
860+ enabled = socketGroup .enabled ,
861+ includeInFullDPS = socketGroup .includeInFullDPS ,
862+ groupCount = socketGroup .groupCount ,
863+ label = socketGroup .label ,
864+ mainActiveSkill = socketGroup .mainActiveSkill ,
865+ mainActiveSkillCalcs = socketGroup .mainActiveSkillCalcs ,
866+ gemStates = gemStates ,
867+ isMainGroup = isMainGroup ,
868+ }
869+ end
870+
871+ local function applyGemReimportState (gem , state )
872+ gem .enabled = state .enabled
873+ gem .count = state .count
874+ gem .statSet = state .statSet and copyTable (state .statSet )
875+ gem .statSetCalcs = state .statSetCalcs and copyTable (state .statSetCalcs )
876+ gem .skillPart = state .skillPart
877+ gem .skillPartCalcs = state .skillPartCalcs
878+ gem .skillStageCount = state .skillStageCount
879+ gem .skillStageCountCalcs = state .skillStageCountCalcs
880+ gem .skillMineCount = state .skillMineCount
881+ gem .skillMineCountCalcs = state .skillMineCountCalcs
882+ gem .skillMinion = state .skillMinion
883+ gem .skillMinionCalcs = state .skillMinionCalcs
884+ gem .skillMinionItemSet = state .skillMinionItemSet
885+ gem .skillMinionItemSetCalcs = state .skillMinionItemSetCalcs
886+ gem .skillMinionSkill = state .skillMinionSkill
887+ gem .skillMinionSkillCalcs = state .skillMinionSkillCalcs
888+ gem .skillMinionSkillStatSetIndexLookup = state .skillMinionSkillStatSetIndexLookup and copyTable (state .skillMinionSkillStatSetIndexLookup )
889+ gem .skillMinionSkillStatSetIndexLookupCalcs = state .skillMinionSkillStatSetIndexLookupCalcs and copyTable (state .skillMinionSkillStatSetIndexLookupCalcs )
890+ gem .enableGlobal1 = state .enableGlobal1
891+ gem .enableGlobal2 = state .enableGlobal2
892+ end
893+
894+ local function applySocketGroupReimportState (socketGroup , state )
895+ socketGroup .enabled = state .enabled
896+ socketGroup .includeInFullDPS = state .includeInFullDPS
897+ socketGroup .groupCount = state .groupCount
898+ socketGroup .label = state .label
899+ socketGroup .mainActiveSkill = state .mainActiveSkill
900+ socketGroup .mainActiveSkillCalcs = state .mainActiveSkillCalcs
901+ if state .gemStates then
902+ for gemIndex , gemState in ipairs (state .gemStates ) do
903+ if socketGroup .gemList [gemIndex ] then
904+ applyGemReimportState (socketGroup .gemList [gemIndex ], gemState )
905+ end
906+ end
907+ end
908+ end
909+
818910function ImportTabClass :ImportItemsAndSkills (charData )
819911 local charItemData = charData .equipment
820912 if self .controls .charImportItemsClearItems .state then
@@ -827,15 +919,22 @@ function ImportTabClass:ImportItemsAndSkills(charData)
827919
828920 local mainSkillEmpty = # self .build .skillsTab .socketGroupList == 0
829921 local skillOrder
922+ local preservedSocketGroupStateByKey
830923 if self .controls .charImportItemsClearSkills .state then
831924 skillOrder = { }
925+ preservedSocketGroupStateByKey = { }
832926 for _ , socketGroup in ipairs (self .build .skillsTab .socketGroupList ) do
833927 for _ , gem in ipairs (socketGroup .gemList ) do
834928 if gem .grantedEffect and not gem .grantedEffect .support then
835929 t_insert (skillOrder , gem .grantedEffect .name )
836930 end
837931 end
838932 end
933+ for index , socketGroup in ipairs (self .build .skillsTab .socketGroupList ) do
934+ local key = getSocketGroupReimportKey (socketGroup )
935+ preservedSocketGroupStateByKey [key ] = preservedSocketGroupStateByKey [key ] or { }
936+ t_insert (preservedSocketGroupStateByKey [key ], snapshotSocketGroupReimportState (socketGroup , index == self .build .mainSocketGroup ))
937+ end
839938 wipeTable (self .build .skillsTab .socketGroupList )
840939 end
841940 self .charImportStatus = colorCodes .POSITIVE .. " Items and skills successfully imported."
@@ -857,10 +956,10 @@ function ImportTabClass:ImportItemsAndSkills(charData)
857956
858957 -- This could be done better with the character melee skills data at some point.
859958 if typeLine :match (" Mace Strike" ) then
860- local weapon1Sel = self .build .itemsTab .activeItemSet [" Weapon 1" ].selItemId or 0
861- local weapon2Sel = self .build .itemsTab .activeItemSet [" Weapon 2" ].selItemId or 0
959+ local weapon1Sel = self .build .itemsTab .activeItemSet [" Weapon 1" ] and self . build . itemsTab . activeItemSet [ " Weapon 1 " ] .selItemId or 0
960+ local weapon2Sel = self .build .itemsTab .activeItemSet [" Weapon 2" ] and self . build . itemsTab . activeItemSet [ " Weapon 2 " ] .selItemId or 0
862961 if weapon2Sel == 0 then
863- if self .build .itemsTab .items [weapon1Sel ].base .type == " One Hand Mace" then
962+ if weapon1Sel == 0 or self .build .itemsTab .items [weapon1Sel ].base .type == " One Hand Mace" then -- Facebreaker uses single handed mace strike
864963 gemId = " Metadata/Items/Gems/SkillGemPlayerDefault1HMace"
865964 elseif self .build .itemsTab .items [weapon1Sel ].base .type == " Two Hand Mace" then
866965 gemId = " Metadata/Items/Gems/SkillGemPlayerDefault2HMace"
@@ -1010,6 +1109,22 @@ function ImportTabClass:ImportItemsAndSkills(charData)
10101109 end
10111110 end )
10121111 end
1112+ if preservedSocketGroupStateByKey then
1113+ local restoredMainSocketGroup
1114+ for index , socketGroup in ipairs (self .build .skillsTab .socketGroupList ) do
1115+ local stateList = preservedSocketGroupStateByKey [getSocketGroupReimportKey (socketGroup )]
1116+ if stateList and stateList [1 ] then
1117+ local state = t_remove (stateList , 1 )
1118+ applySocketGroupReimportState (socketGroup , state )
1119+ if state .isMainGroup then
1120+ restoredMainSocketGroup = index
1121+ end
1122+ end
1123+ end
1124+ if restoredMainSocketGroup then
1125+ self .build .mainSocketGroup = restoredMainSocketGroup
1126+ end
1127+ end
10131128 if mainSkillEmpty then
10141129 self .build .mainSocketGroup = self :GuessMainSocketGroup ()
10151130 end
@@ -1243,6 +1358,14 @@ function ImportTabClass:ImportItem(itemData, slotName)
12431358 end
12441359 end
12451360 end
1361+ if itemData .craftedMods then
1362+ for _ , line in ipairs (itemData .craftedMods ) do
1363+ for line in line :gmatch (" [^\n ]+" ) do
1364+ local modList , extra = modLib .parseMod (line )
1365+ t_insert (item .explicitModLines , { line = line , extra = extra , mods = modList or { }, crafted = true })
1366+ end
1367+ end
1368+ end
12461369
12471370 if itemData .grantedSkills then
12481371 for _ , grantedSkillInfo in ipairs (itemData .grantedSkills ) do
0 commit comments