Skip to content

Commit

Permalink
Sort loadouts by set name if it's there
Browse files Browse the repository at this point in the history
  • Loading branch information
Wires77 committed Jul 21, 2024
1 parent 1fbcf2e commit 600d1cd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Modules/Build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ function buildMode:SyncLoadouts(reset)

if self.treeTab ~= nil and self.itemsTab ~= nil and self.skillsTab ~= nil and self.configTab ~= nil then
local transferTable = {}
local sortedTreeListSpecialLinks = {}
for id, spec in ipairs(self.treeTab.specList) do
local specTitle = spec.title or "Default"
-- only alphanumeric and comma are allowed in the braces { }
Expand All @@ -910,13 +911,16 @@ function buildMode:SyncLoadouts(reset)
for linkId in string.gmatch(linkIdentifier, "[^%,]+") do
transferTable["setId"] = id
transferTable["setName"] = string.match(specTitle, "(.+)% {")
transferTable["linkId"] = linkId
self.treeListSpecialLinks[linkId] = transferTable
t_insert(sortedTreeListSpecialLinks, transferTable)
transferTable = {}
end
else
t_insert(treeList, (spec.treeVersion ~= latestTreeVersion and ("["..treeVersions[spec.treeVersion].display.."] ") or "")..(specTitle))
end
end
table.sort(sortedTreeListSpecialLinks, function (t1, t2) return t1.linkId < t2.linkId end)

-- item, skill, and config sets have identical structure
local function identifyLinks(setOrderList, tabSets, setList, specialLinks)
Expand Down Expand Up @@ -954,15 +958,10 @@ function buildMode:SyncLoadouts(reset)
end
end
-- loop over the identifiers found within braces and set the loadout name to the TreeSet
for treeLinkId, tree in pairs(self.treeListSpecialLinks) do
for itemLinkId, item in pairs(self.itemListSpecialLinks) do
for skillLinkId, skill in pairs(self.skillListSpecialLinks) do
for configLinkId, config in pairs(self.configListSpecialLinks) do
if (treeLinkId == skillLinkId and treeLinkId == itemLinkId and treeLinkId == configLinkId) then
t_insert(filteredList, tree["setName"].." {"..treeLinkId.."}")
end
end
end
for _, tree in ipairs(sortedTreeListSpecialLinks) do
local treeLinkId = tree.linkId
if (self.itemListSpecialLinks[treeLinkId] and self.skillListSpecialLinks[treeLinkId] and self.configListSpecialLinks[treeLinkId]) then
t_insert(filteredList, tree.setName .." {"..treeLinkId.."}")
end
end
end
Expand Down

0 comments on commit 600d1cd

Please sign in to comment.