SprayMesh Extended: Recreate panel if spray name is changed

If there is already a valid spray entry in the saved spray list, recreate it
This commit is contained in:
Chev 2023-11-06 00:26:21 -08:00
parent 45da650a08
commit 995e20125a
Signed by: chev2
GPG key ID: BE0CFBD5DCBB2511

View file

@ -361,9 +361,10 @@ local MAT_FAKE_TRANSPARENT = Material("spraymesh/fake_transparent.png", "noclamp
function PANEL:AddSpray(url, name)
-- If the spray already exists
if self.Sprays[url] then
self.IconLayout:Layout()
return
local existingSpray = self.Sprays[url]
if existingSpray and IsValid(existingSpray) and IsValid(existingSpray:GetParent()) then
existingSpray:GetParent():Remove()
self.Sprays[url] = nil
end
-- A transparency grid background, to indicate which sprays are transparent