Skip to content

Commit 8b7585a

Browse files
committed
Add loadout warning message and support for loadout import prefix
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent f29ceed commit 8b7585a

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
@@ -958,7 +958,7 @@ holding Shift will put it in the second.]])
958958
self.lastSlot = self.slots[baseSlots[#baseSlots]]
959959
end)
960960

961-
function ItemsTabClass:Load(xml, dbFileName, appendItems)
961+
function ItemsTabClass:Load(xml, dbFileName, appendItems, prefix)
962962
if not appendItems then
963963
self.activeItemSetId = 0
964964
self.itemSets = { }
@@ -1037,7 +1037,11 @@ function ItemsTabClass:Load(xml, dbFileName, appendItems)
10371037
end
10381038
elseif node.elem == "ItemSet" then
10391039
local itemSet = self:NewItemSet(not appendItems and tonumber(node.attrib.id) or nil)
1040-
itemSet.title = node.attrib.title
1040+
local title = node.attrib.title
1041+
if appendItems and prefix then
1042+
title = prefix .. (title or "")
1043+
end
1044+
itemSet.title = title
10411045
itemSet.useSecondWeaponSet = node.attrib.useSecondWeaponSet == "true"
10421046
for _, child in ipairs(node) do
10431047
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
@@ -374,7 +374,7 @@ function SkillsTabClass:LoadSkill(node, skillSetId)
374374
t_insert(self.skillSets[skillSetId].socketGroupList, socketGroup)
375375
end
376376

377-
function SkillsTabClass:Load(xml, fileName, appendSkills)
377+
function SkillsTabClass:Load(xml, fileName, appendSkills, prefix)
378378
if not appendSkills then
379379
self.activeSkillSetId = 0
380380
self.skillSets = { }
@@ -416,7 +416,11 @@ function SkillsTabClass:Load(xml, fileName, appendSkills)
416416

417417
if node.elem == "SkillSet" then
418418
local skillSet = self:NewSkillSet(not appendSkills and tonumber(node.attrib.id) or nil)
419-
skillSet.title = node.attrib.title
419+
local title = node.attrib.title
420+
if appendSkills and prefix then
421+
title = prefix .. (title or "")
422+
end
423+
skillSet.title = title
420424
t_insert(self.skillSetOrderList, skillSet.id)
421425
for _, subNode in ipairs(node) do
422426
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
@@ -1881,7 +1881,7 @@ function buildMode:LoadDBFile()
18811881
return self:LoadDB(xmlText, self.dbFileName)
18821882
end
18831883

1884-
function buildMode:ImportLoadouts(xmlText)
1884+
function buildMode:ImportLoadouts(xmlText, prefix)
18851885
-- Parse the XML
18861886
local dbXML = self:ParseXML(xmlText, self.dbFileName)
18871887
if not dbXML then
@@ -1930,19 +1930,20 @@ function buildMode:ImportLoadouts(xmlText)
19301930

19311931
local itemIdMap = { }
19321932
if itemsSection then
1933-
itemIdMap = self.itemsTab:Load(itemsSection, self.dbFileName, true) or { }
1933+
itemIdMap = self.itemsTab:Load(itemsSection, self.dbFileName, true, prefix) or { }
19341934
end
19351935
if skillsSection then
1936-
self.skillsTab:Load(skillsSection, self.dbFileName, true)
1936+
self.skillsTab:Load(skillsSection, self.dbFileName, true, prefix)
19371937
end
19381938
if treeSection then
1939-
self.treeTab:Load(treeSection, self.dbFileName, true, itemIdMap)
1939+
self.treeTab:Load(treeSection, self.dbFileName, true, prefix, itemIdMap)
19401940
self.treeTab:PostLoad()
19411941
end
19421942

19431943
-- Mark build as modified
19441944
self.modFlag = true
19451945
self.buildFlag = true
1946+
self:SyncLoadouts()
19461947

19471948
-- Show success message
19481949
local message = "Successfully imported:\n"

0 commit comments

Comments
 (0)