Skip to content

Commit 02f4343

Browse files
committed
Add loadout warning message and support for loadout import prefix
Signed-off-by: Tomas Slusny <[email protected]>
1 parent 8e69c40 commit 02f4343

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

src/Classes/ImportTab.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,20 @@ You can get this from your web browser's cookies while logged into the Path of E
315315
self.build.viewMode = "TREE"
316316
end)
317317
elseif self.controls.importCodeMode.selIndex == 3 then
318-
self.build:ImportLoadouts(self.importCodeXML)
318+
local controls = { }
319+
t_insert(controls, new("LabelControl", nil, {0, 20, 0, 16}, colorCodes.WARNING.."Warning:^7 Importing many loadouts into the same build"))
320+
t_insert(controls, new("LabelControl", nil, {0, 36, 0, 16}, "may cause performance issues. Use with caution."))
321+
t_insert(controls, new("LabelControl", nil, {0, 64, 0, 16}, "^7Prefix for imported loadouts (optional):"))
322+
controls.prefix = new("EditControl", nil, {0, 84, 350, 20}, "", nil, nil, 50)
323+
controls.import = new("ButtonControl", nil, {-45, 114, 80, 20}, "Import", function()
324+
local prefix = controls.prefix.buf
325+
main:ClosePopup()
326+
self.build:ImportLoadouts(self.importCodeXML, prefix ~= "" and prefix or nil)
327+
end)
328+
t_insert(controls, new("ButtonControl", nil, {45, 114, 80, 20}, "Cancel", function()
329+
main:ClosePopup()
330+
end))
331+
main:OpenPopup(380, 144, "Import Loadouts", controls, "import")
319332
else
320333
self.build:Shutdown()
321334
self.build:Init(false, "Imported build", self.importCodeXML, false, self.importCodeSite and self.controls.importCodeIn.buf or nil)

src/Classes/ItemsTab.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ holding Shift will put it in the second.]])
943943
self.lastSlot = self.slots[baseSlots[#baseSlots]]
944944
end)
945945

946-
function ItemsTabClass:Load(xml, dbFileName, appendItems)
946+
function ItemsTabClass:Load(xml, dbFileName, appendItems, prefix)
947947
if not appendItems then
948948
self.activeItemSetId = 0
949949
self.itemSets = { }
@@ -1022,7 +1022,11 @@ function ItemsTabClass:Load(xml, dbFileName, appendItems)
10221022
end
10231023
elseif node.elem == "ItemSet" then
10241024
local itemSet = self:NewItemSet(not appendItems and tonumber(node.attrib.id) or nil)
1025-
itemSet.title = node.attrib.title
1025+
local title = node.attrib.title
1026+
if appendItems and prefix then
1027+
title = prefix .. (title or "")
1028+
end
1029+
itemSet.title = title
10261030
itemSet.useSecondWeaponSet = node.attrib.useSecondWeaponSet == "true"
10271031
for _, child in ipairs(node) do
10281032
if child.elem == "Slot" then

src/Classes/PassiveSpec.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ function PassiveSpecClass:Init(treeVersion, convert)
8383
self.hashOverrides = { }
8484
end
8585

86-
function PassiveSpecClass:Load(xml, dbFileName)
87-
self.title = xml.attrib.title
86+
function PassiveSpecClass:Load(xml, dbFileName, prefix)
87+
local title = xml.attrib.title
88+
if prefix then
89+
title = prefix .. (title or "")
90+
end
91+
self.title = title
8892
local url
8993
for _, node in pairs(xml) do
9094
if type(node) == "table" then

src/Classes/SkillsTab.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function SkillsTabClass:LoadSkill(node, skillSetId)
373373
t_insert(self.skillSets[skillSetId].socketGroupList, socketGroup)
374374
end
375375

376-
function SkillsTabClass:Load(xml, fileName, appendSkills)
376+
function SkillsTabClass:Load(xml, fileName, appendSkills, prefix)
377377
if not appendSkills then
378378
self.activeSkillSetId = 0
379379
self.skillSets = { }
@@ -415,7 +415,11 @@ function SkillsTabClass:Load(xml, fileName, appendSkills)
415415

416416
if node.elem == "SkillSet" then
417417
local skillSet = self:NewSkillSet(not appendSkills and tonumber(node.attrib.id) or nil)
418-
skillSet.title = node.attrib.title
418+
local title = node.attrib.title
419+
if appendSkills and prefix then
420+
title = prefix .. (title or "")
421+
end
422+
skillSet.title = title
419423
t_insert(self.skillSetOrderList, skillSet.id)
420424
for _, subNode in ipairs(node) do
421425
self:LoadSkill(subNode, skillSet.id)

src/Classes/TreeTab.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ function TreeTabClass:GetSpecList()
444444
return newSpecList
445445
end
446446

447-
function TreeTabClass:Load(xml, dbFileName, appendSpecs, itemIdMap)
447+
function TreeTabClass:Load(xml, dbFileName, appendSpecs, prefix, itemIdMap)
448448
if not appendSpecs then
449449
self.specList = { }
450450
end
@@ -482,7 +482,7 @@ function TreeTabClass:Load(xml, dbFileName, appendSpecs, itemIdMap)
482482
end
483483

484484
local newSpec = new("PassiveSpec", self.build, node.attrib.treeVersion or defaultTreeVersion)
485-
newSpec:Load(node, dbFileName)
485+
newSpec:Load(node, dbFileName, prefix)
486486
t_insert(self.specList, newSpec)
487487
end
488488
end

src/Modules/Build.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,7 @@ function buildMode:LoadDBFile()
18391839
return self:LoadDB(xmlText, self.dbFileName)
18401840
end
18411841

1842-
function buildMode:ImportLoadouts(xmlText)
1842+
function buildMode:ImportLoadouts(xmlText, prefix)
18431843
-- Parse the XML
18441844
local dbXML = self:ParseXML(xmlText, self.dbFileName)
18451845
if not dbXML then
@@ -1888,19 +1888,20 @@ function buildMode:ImportLoadouts(xmlText)
18881888

18891889
local itemIdMap = { }
18901890
if itemsSection then
1891-
itemIdMap = self.itemsTab:Load(itemsSection, self.dbFileName, true) or { }
1891+
itemIdMap = self.itemsTab:Load(itemsSection, self.dbFileName, true, prefix) or { }
18921892
end
18931893
if skillsSection then
1894-
self.skillsTab:Load(skillsSection, self.dbFileName, true)
1894+
self.skillsTab:Load(skillsSection, self.dbFileName, true, prefix)
18951895
end
18961896
if treeSection then
1897-
self.treeTab:Load(treeSection, self.dbFileName, true, itemIdMap)
1897+
self.treeTab:Load(treeSection, self.dbFileName, true, prefix, itemIdMap)
18981898
self.treeTab:PostLoad()
18991899
end
19001900

19011901
-- Mark build as modified
19021902
self.modFlag = true
19031903
self.buildFlag = true
1904+
self:SyncLoadouts()
19041905

19051906
-- Show success message
19061907
local message = "Successfully imported:\n"

0 commit comments

Comments
 (0)