Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
fix(builds): sort builds
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerR909 committed Jul 1, 2021
1 parent 2956529 commit d44b2b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
16 changes: 8 additions & 8 deletions TalentedTalentFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ function Talented:InitPvEDropdown()
{ text=TALENTS, isTitle=true, notCheckable=true}
}

for _,build in pairs(self.db.class[specid].PvE) do
for name,build in self.tools.traverseBuilds(self.db.class[specid].PvE) do
local btn = {
text = build.name,
value = build.build,
checked = compare(build.build, activeBuild),
text = name,
value = build,
checked = compare(build, activeBuild),
func = function(btn) self.tools.LearnTalentString(btn.value) end
}
tinsert(menu, btn)
Expand Down Expand Up @@ -102,11 +102,11 @@ function Talented:InitPvPDropdown()
{ text = PVP..' '..TALENTS, isTitle=true, notCheckable=true}
}

for _,build in pairs(self.db.class[specid].PvP) do
for name,build in self.tools.traverseBuilds(self.db.class[specid].PvP) do
local btn = {
text = build.name,
value = build.build,
checked = compare(build.build, activeBuild),
text = name,
value = build,
checked = compare(build, activeBuild),
func = function(btn) self.tools.LearnPvPTalentGroup(btn.value) end
}
tinsert(menu, btn)
Expand Down
18 changes: 18 additions & 0 deletions TalentedTools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ function tools.CompareTalentStrings(a,b)
return true
end

function tools.traverseBuilds(builds)
local a = {}
for k in pairs(builds) do tinsert(a, k) end
table.sort(a, function(left,right)
return string.lower(left) < string.lower(right)
end)

local i = 0
local iter = function()
i = i+1
if a[i] == nil then return nil end
local build = builds[a[i]]
return build.name, build.build
end

return iter
end

function tools.ComparePvPTalentBuilds(a,b)
if #a ~= #b then return false end
local tala, talb;
Expand Down

0 comments on commit d44b2b8

Please sign in to comment.