Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,12 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.controls.scrollBar = new("ScrollBarControl", {"TOPRIGHT",self,"TOPRIGHT"}, {0, 0, 18, 0}, 50, "VERTICAL", true)
end)

function ConfigTabClass:Load(xml, fileName)
self.activeConfigSetId = 1
self.configSets = { }
self.configSetOrderList = { 1 }
function ConfigTabClass:Load(xml, fileName, appendConfigs)
if not appendConfigs then
self.activeConfigSetId = 0
self.configSets = { }
self.configSetOrderList = { }
end

local function setInputAndPlaceholder(node, configSetId)
if node.elem == "Input" then
Expand Down Expand Up @@ -660,24 +662,25 @@ function ConfigTabClass:Load(xml, fileName)
if xml.empty then
self:NewConfigSet(1, "Default")
end
for index, node in ipairs(xml) do
for _, node in ipairs(xml) do
if node.elem ~= "ConfigSet" then
if not self.configSets[1] then
self:NewConfigSet(1, "Default")
end
setInputAndPlaceholder(node, 1)
else
local configSetId = tonumber(node.attrib.id)
self:NewConfigSet(configSetId, node.attrib.title or "Default")
self.configSetOrderList[index] = configSetId
local configSet = self:NewConfigSet(not appendConfigs and tonumber(node.attrib.id) or nil, node.attrib.title or "Default")
t_insert(self.configSetOrderList, configSet.id)
for _, child in ipairs(node) do
setInputAndPlaceholder(child, configSetId)
setInputAndPlaceholder(child, configSet.id)
end
end
end

self:SetActiveConfigSet(tonumber(xml.attrib.activeConfigSet) or 1)
self:ResetUndo()
if not appendConfigs then
self:SetActiveConfigSet(tonumber(xml.attrib.activeConfigSet) or 1)
self:ResetUndo()
end
end

function ConfigTabClass:GetDefaultState(var, varType)
Expand Down
22 changes: 20 additions & 2 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@ You can get this from your web browser's cookies while logged into the Path of E
self.build:Init(self.build.dbFileName, self.build.buildName, self.importCodeXML, false, self.importCodeSite and self.controls.importCodeIn.buf or nil)
self.build.viewMode = "TREE"
end)
elseif self.controls.importCodeMode.selIndex == 3 then
local controls = { }
t_insert(controls, new("LabelControl", nil, {0, 20, 0, 16}, colorCodes.WARNING.."Warning:^7 Importing many loadouts into the same build"))
t_insert(controls, new("LabelControl", nil, {0, 36, 0, 16}, "may cause performance issues. Use with caution."))
t_insert(controls, new("LabelControl", nil, {0, 64, 0, 16}, "^7Prefix for imported loadouts:"))
controls.prefix = new("EditControl", nil, {0, 84, 350, 20}, "Imported - ", nil, nil, 50)
controls.import = new("ButtonControl", nil, {-45, 114, 80, 20}, "Import", function()
local prefix = controls.prefix.buf
if prefix == "" then
prefix = "Imported - "
end
main:ClosePopup()
self.build:ImportLoadouts(self.importCodeXML, prefix)
end)
t_insert(controls, new("ButtonControl", nil, {45, 114, 80, 20}, "Cancel", function()
main:ClosePopup()
end))
main:OpenPopup(380, 144, "Import Loadouts", controls, "import")
else
self.build:Shutdown()
self.build:Init(false, "Imported build", self.importCodeXML, false, self.importCodeSite and self.controls.importCodeIn.buf or nil)
Expand All @@ -331,7 +349,7 @@ You can get this from your web browser's cookies while logged into the Path of E
self.controls.importCodeState.label = function()
return self.importCodeDetail or ""
end
self.controls.importCodeMode = new("DropDownControl", {"TOPLEFT",self.controls.importCodeIn,"BOTTOMLEFT"}, {0, 4, 160, 20}, { "Import to this build", "Import to a new build" })
self.controls.importCodeMode = new("DropDownControl", {"TOPLEFT",self.controls.importCodeIn,"BOTTOMLEFT"}, {0, 4, 160, 20}, { "Import to this build", "Import to a new build", "Import loadouts only" })
self.controls.importCodeMode.enabled = function()
return self.build.dbFileName and self.importCodeValid
end
Expand Down Expand Up @@ -1214,4 +1232,4 @@ function ImportTabClass:SetPredefinedBuildName()
local charData = charSelect.list[charSelect.selIndex].char
local charName = charData.name
main.predefinedBuildName = accountName.." - "..charName
end
end
59 changes: 40 additions & 19 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -958,15 +958,23 @@ holding Shift will put it in the second.]])
self.lastSlot = self.slots[baseSlots[#baseSlots]]
end)

function ItemsTabClass:Load(xml, dbFileName)
self.activeItemSetId = 0
self.itemSets = { }
self.itemSetOrderList = { }
self.tradeQuery.statSortSelectionList = { }
function ItemsTabClass:Load(xml, dbFileName, appendItems)
if not appendItems then
self.activeItemSetId = 0
self.itemSets = { }
self.itemSetOrderList = { }
self.tradeQuery.statSortSelectionList = { }
end

local itemIdMap = { }
for _, node in ipairs(xml) do
if node.elem == "Item" then
local item = new("Item", "")
item.id = tonumber(node.attrib.id)
local itemId = tonumber(node.attrib.id)
if not appendItems then
item.id = itemId
end

item.variant = tonumber(node.attrib.variant)
if node.attrib.variantAlt then
item.hasAltVariant = true
Expand Down Expand Up @@ -1009,8 +1017,13 @@ function ItemsTabClass:Load(xml, dbFileName)
end
if item.base then
item:BuildModList()
self.items[item.id] = item
t_insert(self.itemOrderList, item.id)
if appendItems then
self:AddItem(item, true)
itemIdMap[itemId] = item.id
else
self.items[item.id] = item
t_insert(self.itemOrderList, item.id)
end
end
-- Below is OBE and left for legacy compatibility (all Slots are part of ItemSets now)
elseif node.elem == "Slot" then
Expand All @@ -1023,14 +1036,18 @@ function ItemsTabClass:Load(xml, dbFileName)
end
end
elseif node.elem == "ItemSet" then
local itemSet = self:NewItemSet(tonumber(node.attrib.id))
local itemSet = self:NewItemSet(not appendItems and tonumber(node.attrib.id) or nil)
itemSet.title = node.attrib.title
itemSet.useSecondWeaponSet = node.attrib.useSecondWeaponSet == "true"
for _, child in ipairs(node) do
if child.elem == "Slot" then
local slotName = child.attrib.name or ""
if itemSet[slotName] then
itemSet[slotName].selItemId = tonumber(child.attrib.itemId)
local itemId = tonumber(child.attrib.itemId)
if appendItems and itemIdMap[itemId] then
itemId = itemIdMap[itemId]
end
itemSet[slotName].selItemId = itemId
itemSet[slotName].active = child.attrib.active == "true"
itemSet[slotName].pbURL = child.attrib.itemPbURL or ""
end
Expand All @@ -1051,16 +1068,20 @@ function ItemsTabClass:Load(xml, dbFileName)
end
end
end
if not self.itemSetOrderList[1] then
self.activeItemSet = self:NewItemSet(1)
self.activeItemSet.useSecondWeaponSet = xml.attrib.useSecondWeaponSet == "true"
self.itemSetOrderList[1] = 1
end
self:SetActiveItemSet(tonumber(xml.attrib.activeItemSet) or 1)
if xml.attrib.showStatDifferences then
self.showStatDifferences = xml.attrib.showStatDifferences == "true"
if not appendItems then
if not self.itemSetOrderList[1] then
self.activeItemSet = self:NewItemSet(1)
self.activeItemSet.useSecondWeaponSet = xml.attrib.useSecondWeaponSet == "true"
self.itemSetOrderList[1] = 1
end
self:SetActiveItemSet(tonumber(xml.attrib.activeItemSet) or 1)
if xml.attrib.showStatDifferences then
self.showStatDifferences = xml.attrib.showStatDifferences == "true"
end
self:ResetUndo()
else
return itemIdMap
end
self:ResetUndo()
end

function ItemsTabClass:Save(xml)
Expand Down
65 changes: 35 additions & 30 deletions src/Classes/SkillsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,33 +374,36 @@ function SkillsTabClass:LoadSkill(node, skillSetId)
t_insert(self.skillSets[skillSetId].socketGroupList, socketGroup)
end

function SkillsTabClass:Load(xml, fileName)
self.activeSkillSetId = 0
self.skillSets = { }
self.skillSetOrderList = { }
-- Handle legacy configuration settings when loading `defaultGemLevel`
if xml.attrib.matchGemLevelToCharacterLevel == "true" then
self.controls.defaultLevel:SelByValue("characterLevel", "gemLevel")
elseif type(xml.attrib.defaultGemLevel) == "string" and tonumber(xml.attrib.defaultGemLevel) == nil then
self.controls.defaultLevel:SelByValue(xml.attrib.defaultGemLevel, "gemLevel")
else
self.controls.defaultLevel:SelByValue("normalMaximum", "gemLevel")
end
self.defaultGemLevel = self.controls.defaultLevel:GetSelValueByKey("gemLevel")
self.defaultGemQuality = m_max(m_min(tonumber(xml.attrib.defaultGemQuality) or 0, 23), 0)
self.controls.defaultQuality:SetText(self.defaultGemQuality or "")
if xml.attrib.sortGemsByDPS then
self.sortGemsByDPS = xml.attrib.sortGemsByDPS == "true"
end
self.controls.sortGemsByDPS.state = self.sortGemsByDPS
if xml.attrib.showAltQualityGems then
self.showAltQualityGems = xml.attrib.showAltQualityGems == "true"
end
self.controls.showAltQualityGems.state = self.showAltQualityGems
self.controls.showSupportGemTypes:SelByValue(xml.attrib.showSupportGemTypes or "ALL", "show")
self.controls.sortGemsByDPSFieldControl:SelByValue(xml.attrib.sortGemsByDPSField or "CombinedDPS", "type")
self.showSupportGemTypes = self.controls.showSupportGemTypes:GetSelValueByKey("show")
self.sortGemsByDPSField = self.controls.sortGemsByDPSFieldControl:GetSelValueByKey("type")
function SkillsTabClass:Load(xml, fileName, appendSkills)
if not appendSkills then
self.activeSkillSetId = 0
self.skillSets = { }
self.skillSetOrderList = { }
-- Handle legacy configuration settings when loading `defaultGemLevel`
if xml.attrib.matchGemLevelToCharacterLevel == "true" then
self.controls.defaultLevel:SelByValue("characterLevel", "gemLevel")
elseif type(xml.attrib.defaultGemLevel) == "string" and tonumber(xml.attrib.defaultGemLevel) == nil then
self.controls.defaultLevel:SelByValue(xml.attrib.defaultGemLevel, "gemLevel")
else
self.controls.defaultLevel:SelByValue("normalMaximum", "gemLevel")
end
self.defaultGemLevel = self.controls.defaultLevel:GetSelValueByKey("gemLevel")
self.defaultGemQuality = m_max(m_min(tonumber(xml.attrib.defaultGemQuality) or 0, 23), 0)
self.controls.defaultQuality:SetText(self.defaultGemQuality or "")
if xml.attrib.sortGemsByDPS then
self.sortGemsByDPS = xml.attrib.sortGemsByDPS == "true"
end
self.controls.sortGemsByDPS.state = self.sortGemsByDPS
if xml.attrib.showAltQualityGems then
self.showAltQualityGems = xml.attrib.showAltQualityGems == "true"
end
self.controls.showAltQualityGems.state = self.showAltQualityGems
self.controls.showSupportGemTypes:SelByValue(xml.attrib.showSupportGemTypes or "ALL", "show")
self.controls.sortGemsByDPSFieldControl:SelByValue(xml.attrib.sortGemsByDPSField or "CombinedDPS", "type")
self.showSupportGemTypes = self.controls.showSupportGemTypes:GetSelValueByKey("show")
self.sortGemsByDPSField = self.controls.sortGemsByDPSFieldControl:GetSelValueByKey("type")
end

for _, node in ipairs(xml) do
if node.elem == "Skill" then
-- Old format, initialize skill sets if needed
Expand All @@ -412,16 +415,18 @@ function SkillsTabClass:Load(xml, fileName)
end

if node.elem == "SkillSet" then
local skillSet = self:NewSkillSet(tonumber(node.attrib.id))
local skillSet = self:NewSkillSet(not appendSkills and tonumber(node.attrib.id) or nil)
skillSet.title = node.attrib.title
t_insert(self.skillSetOrderList, skillSet.id)
for _, subNode in ipairs(node) do
self:LoadSkill(subNode, skillSet.id)
end
end
end
self:SetActiveSkillSet(tonumber(xml.attrib.activeSkillSet) or 1)
self:ResetUndo()
if not appendSkills then
self:SetActiveSkillSet(tonumber(xml.attrib.activeSkillSet) or 1)
self:ResetUndo()
end
end

function SkillsTabClass:Save(xml)
Expand Down
32 changes: 27 additions & 5 deletions src/Classes/TreeTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ function TreeTabClass:GetSpecList()
return newSpecList
end

function TreeTabClass:Load(xml, dbFileName)
self.specList = { }
function TreeTabClass:Load(xml, dbFileName, appendSpecs, itemIdMap)
if not appendSpecs then
self.specList = { }
end

if xml.elem == "Spec" then
-- Import single spec from old build
self.specList[1] = new("PassiveSpec", self.build, defaultTreeVersion)
Expand All @@ -461,16 +464,35 @@ function TreeTabClass:Load(xml, dbFileName)
main:OpenMessagePopup("Unknown Passive Tree Version", "The build you are trying to load uses an unrecognised version of the passive skill tree.\nYou may need to update the program before loading this build.")
return true
end

-- Remap jewel socket item IDs if appending
if appendSpecs and itemIdMap then
for _, child in ipairs(node) do
if child.elem == "Sockets" then
for _, socket in ipairs(child) do
if socket.elem == "Socket" then
local oldItemId = tonumber(socket.attrib.itemId)
if oldItemId and itemIdMap[oldItemId] then
socket.attrib.itemId = tostring(itemIdMap[oldItemId])
end
end
end
end
end
end

local newSpec = new("PassiveSpec", self.build, node.attrib.treeVersion or defaultTreeVersion)
newSpec:Load(node, dbFileName)
t_insert(self.specList, newSpec)
end
end
end
if not self.specList[1] then
self.specList[1] = new("PassiveSpec", self.build, latestTreeVersion)
if not appendSpecs then
if not self.specList[1] then
self.specList[1] = new("PassiveSpec", self.build, latestTreeVersion)
end
self:SetActiveSpec(tonumber(xml.attrib.activeSpec) or 1)
end
self:SetActiveSpec(tonumber(xml.attrib.activeSpec) or 1)
end

function TreeTabClass:PostLoad()
Expand Down
Loading