mirror of
https://github.com/chev2/gmod-addons.git
synced 2025-10-30 06:31:35 +00:00
SprayMesh Extended: Fix search being broken
This commit is contained in:
parent
d19db098a0
commit
f02d8e4ce7
1 changed files with 16 additions and 6 deletions
|
|
@ -497,24 +497,34 @@ function PANEL:AddSpray(url, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PANEL:FilterSearch(text)
|
function PANEL:FilterSearch(text)
|
||||||
|
local numVisible = 0
|
||||||
|
|
||||||
|
local queryIsEmpty = string.Trim(text, " ") == ""
|
||||||
|
|
||||||
for url, sprayPanel in pairs(self.Sprays) do
|
for url, sprayPanel in pairs(self.Sprays) do
|
||||||
if not IsValid(sprayPanel) then continue end
|
if not IsValid(sprayPanel) then continue end
|
||||||
|
|
||||||
-- Since spray panels are wrapped inside a parent, we want to target visibility for the parent instead
|
|
||||||
local panelParent = sprayPanel:GetParent()
|
|
||||||
|
|
||||||
local queryIsEmpty = string.Trim(text, " ") == ""
|
|
||||||
local textInURL = string.find(url:lower(), text:lower(), 0, true) ~= nil
|
local textInURL = string.find(url:lower(), text:lower(), 0, true) ~= nil
|
||||||
local textInName = string.find(sprayPanel.Name:lower(), text:lower(), 0, true) ~= nil
|
local textInName = string.find(sprayPanel.Name:lower(), text:lower(), 0, true) ~= nil
|
||||||
|
|
||||||
if queryIsEmpty or textInURL or textInName then
|
if queryIsEmpty or textInURL or textInName then
|
||||||
panelParent:SetVisible(true)
|
sprayPanel:SetVisible(true)
|
||||||
|
numVisible = numVisible + 1
|
||||||
else
|
else
|
||||||
panelParent:SetVisible(false)
|
sprayPanel:SetVisible(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.IconLayout:Layout()
|
self.IconLayout:Layout()
|
||||||
|
self.Scroll.VBar:SetScroll(0)
|
||||||
|
|
||||||
|
-- Give self.IconLayout some time (the next frame) to relayout
|
||||||
|
-- Then, we can re-layout the scroll bar
|
||||||
|
timer.Simple(0, function()
|
||||||
|
if IsValid(self.Scroll) then
|
||||||
|
self.Scroll:Rebuild()
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register control
|
-- Register control
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue