Skip to content

Commit

Permalink
Fix searching and filtering on the Lua Packlist
Browse files Browse the repository at this point in the history
  • Loading branch information
caiohsr14 committed Nov 29, 2018
1 parent 3ea88b2 commit 9f51065
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local filters = {"", "0", "0", "0", "0", "0", "0"}

local curInput = ""
local inputting = 0 --1=name 2=lowerdiff 3=upperdiff 4=lowersize 5=uppersize 0=none
local packlist

local function getFilter(index)
return filters[index]
Expand Down Expand Up @@ -165,7 +164,6 @@ local o =
InitCommand = function(self)
self:xy(0, 0):halign(0.5):valign(0)
self:GetChild("PacklistDisplay"):xy(SCREEN_WIDTH / 2.5 - offx, offy * 2 + 14)
packlist = DLMAN:GetPacklist()
self:SetUpdateFunction(highlight)
end,
BeginCommand = function(self)
Expand Down
3 changes: 1 addition & 2 deletions Themes/Til Death/BGAnimations/packlistDisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function highlightIfOver(self)
end
end

local packlist
packlist = {}
local packtable
local o =
Def.ActorFrame {
Expand All @@ -42,7 +42,6 @@ local o =
BeginCommand = function(self)
self:SetUpdateFunction(highlight)
packlist = PackList:new()
packlist:SetFromAll()
self:queuecommand("PackTableRefresh")
end,
PackTableRefreshCommand = function(self)
Expand Down
33 changes: 26 additions & 7 deletions Themes/_fallback/Scripts/09 PackList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,39 @@ function PackList:SortBySize()
return self:SortByProp(getSizePropName)
end
function PackList:FilterAndSearch(name, avgMin, avgMax, sizeMin, sizeMax)
self.packs =
self.packs =
filter(
function(x)
local d = x[getAvgDiffPropName]:x()
local n = x[getNamePropName]:x()
local s = x[getSizePropName]:x()
return n == name and ((d > avgMin and d < avgMax) or d <= 0) and ((s > sizeMin and d < sizeMax) or s <= 0)
local d = x[getAvgDiffPropName](x)
local n = x[getNamePropName](x)
local s = x[getSizePropName](x)
local valid = string.lower(n):sub(1, #name) == string.lower(name)
if d > 0 then
if avgMin > 0 then
valid = valid and d > avgMin
end
if avgMax > 0 then
valid = valid and d < avgMax
end
end
if s > 0 then
if sizeMin > 0 then
valid = valid and s > sizeMin
end
if sizeMax > 0 then
valid = valid and s < sizeMax
end
end
return valid
end,
self.packs
self.allPacks
)
return self
end
function PackList:SetFromAll()
self.packs = DLMAN:GetAllPacks()
local allPacks = DLMAN:GetAllPacks()
self.allPacks = allPacks
self.packs = DeepCopy(allPacks)
return self
end
function PackList:new()
Expand Down

0 comments on commit 9f51065

Please sign in to comment.