Skip to content

Commit 0e38589

Browse files
committed
init ListControls as needed instead of always
1 parent 175a53e commit 0e38589

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

src/Modules/Build.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
320320
local oneConfig = self.configTab and #self.configTab.configSetOrderList == 1
321321

322322
-- *** big block of variables shared across Copy, Delete, and Rename Loadouts
323-
-- generic SetListControls so we can reuse copy/delete/rename functions
324-
local passiveSpecListControl = new ("PassiveSpecListControl", nil, nil, self.treeTab)
325-
local itemSetListControl = new("ItemSetListControl", nil, nil, self.itemsTab)
326-
local skillSetListControl = new("SkillSetListControl", nil, nil, self.skillsTab)
327-
local configSetListControl = new("ConfigSetListControl", nil, nil, self.configTab)
323+
-- generic SetListControls so we can reuse copy and delete functions
324+
local passiveSpecListControl = { }
325+
local itemSetListControl = { }
326+
local skillSetListControl = { }
327+
local configSetListControl = { }
328328
-- list for dropdown
329329
local existingLoadoutsList = self.controls.buildLoadouts.existingLoadoutsList or {}
330330
local selectedLoadoutTitle = existingLoadoutsList[1] or "Default"
@@ -338,7 +338,7 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
338338

339339
local function setSelectedLoadout(title)
340340
selectedLoadoutTreeId, loadoutTitleOrIdentifier = findNamedSetId(self.treeTab:GetSpecList(), title, self.treeListSpecialLinks)
341-
-- because we are creating the SetListControl in real time, the SetOrderLists can get out of sync with the ItemSets, SkillSets, ConfigSets
341+
-- because we are creating the ListControls in real time, the SetOrderLists can get out of sync with the ItemSets, SkillSets, ConfigSets
342342
-- so we will loop until we find the title or identifier match from the selected loadout
343343
for index, id in pairs(self.itemsTab.itemSetOrderList) do
344344
if (string.match(self.itemsTab.itemSets[id].title or "Default", "%b{}") == loadoutTitleOrIdentifier) or ((self.itemsTab.itemSets[id].title or "Default") == loadoutTitleOrIdentifier) then
@@ -364,7 +364,16 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
364364
end
365365
setSelectedLoadout(selectedLoadoutTitle)
366366

367+
local function initListControls()
368+
passiveSpecListControl = new ("PassiveSpecListControl", nil, nil, self.treeTab)
369+
itemSetListControl = new("ItemSetListControl", nil, nil, self.itemsTab)
370+
skillSetListControl = new("SkillSetListControl", nil, nil, self.skillsTab)
371+
configSetListControl = new("ConfigSetListControl", nil, nil, self.configTab)
372+
end
373+
367374
local function copyLoadout(loadoutTitle)
375+
initListControls()
376+
368377
local oldSpec = self.treeTab.specList[selectedLoadoutTreeId]
369378
local newSpec = passiveSpecListControl.controls.copy.onClick(oldSpec)
370379
t_insert(self.treeTab.specList, newSpec)
@@ -475,7 +484,6 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
475484
return
476485
elseif value == "^7^7Copy Loadout" then
477486
local controls = { }
478-
local numberofLoadouts = nil
479487

480488
controls.loadoutNameLabel = new("LabelControl", nil, {0, 20, 0, 16}, "^7Enter name for this loadout:")
481489
controls.loadoutName = new("EditControl", nil, { 0, 40, 350, 20}, "New Loadout", nil, nil, 100, function(buf)
@@ -512,6 +520,8 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
512520

513521
controls.delete = new("ButtonControl", nil, {-45, 85, 80, 20}, "Delete", function()
514522
main:OpenConfirmPopup("Delete All", "Are you sure you want to delete this loadout?", "Delete", function()
523+
initListControls()
524+
515525
passiveSpecListControl:DeleteByIndex(selectedLoadoutTreeId)
516526
itemSetListControl:DeleteById(selectedLoadoutItemIndex, selectedLoadoutItemId)
517527
skillSetListControl:DeleteById(selectedLoadoutSkillIndex, selectedLoadoutSkillId)

0 commit comments

Comments
 (0)