• How to remove unwanted nodes from /DFileBrowser/ ?
    2 replies, posted
Simply as is says guys. I made a file browser that scans the data folder of Gmod and on file select gets the file location. The thing is that I only want certain folders to be displayed there nat all the folders from the data folder. Like the E2 folder and my custom folder. concommand.Add(gsToolPrefix.."configurator",     function(oPly,oCom,oArgs)       -- http://wiki.garrysmod.com/page/Enums/KEY       -- To draw sensor beams after list view add: https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/vgui/dmodelpanel.lua       local scrW = surface.ScreenWidth()       local scrH = surface.ScreenHeight()       local nRat = hoverlib.GetOpVar("GOLDEN_RATIO")       local xyPos, xyDsz = {x=(scrW / 4), y=(scrH / 4)}, {x=5, y=5}       local xySiz = {x=math.floor((scrW/(1 + nRat))*nRat), y=0}       xySiz.y = math.floor(xySiz.x / (1 + nRat))       local pnFrame, lvLen = vgui.Create("DFrame"), 100 -- List view width       if(not IsValid(pnFrame)) then pnFrame:Close()         return logStatus("CONFIGURATOR: Main panel invalid", nil) end       pnFrame:SetPos(xyPos.x, xyPos.y)       pnFrame:SetSize(xySiz.x, xySiz.y)       pnFrame:SetTitle(language.GetPhrase("tool."..gsToolName..".menu_name").." {"..gsScriptVer.."}")       pnFrame:SetVisible(true)       pnFrame:SetDraggable(true)       pnFrame:SetDeleteOnClose(true)       pnFrame:Center()       pnFrame:MakePopup()       local pnFile = vgui.Create("DFileBrowser", pnFrame)       if(not IsValid(pnFile)) then pnFrame:Close()         return logStatus("CONFIGURATOR: File browser invalid", nil) end       pnFile:Dock(FILL) -- http://wiki.garrysmod.com/page/Category:DFileBrowser       pnFile:SetName(language.GetPhrase("tool."..gsToolName..".menu_name"))       pnFile:SetPath("GAME")       pnFile:SetBaseFolder("data")       pnFile:SetCurrentFolder(gsDirpathBase..gsDirpathSave)       pnFile:SetFileTypes("*.txt") -- File type filter       pnFile:SetOpen(true) -- Remove the leading "data/"       pnFile.Divider:SetLeftWidth(xySiz.x * (1 - (nRat - 1)))       pnFile.OnSelect = function(pnSelf, sPath, oPnl)         local sSrc = gsInitFile..sPath:sub(6,-1)         RunConsoleCommand(gsToolPrefix.."source", sSrc)         logStatus("CONFIGURATOR: File <"..sSrc..">")       end       local pnNode, ID = pnFile:GetFolderNode(), 0       if(not IsValid(pnNode)) then pnFrame:Close()         return logStatus("CONFIGURATOR: File node invalid <"..tostring(pnNode)..">", nil) end       local pnChil = pnNode:GetChildNode(ID)       if(not IsValid(pnChil)) then pnFrame:Close()         return logStatus("CONFIGURATOR: No children", nil) end       while(pnChil) do         logStatus("CONFIGURATOR: Child <"..pnChil:GetName().."> "..tostring(pnChil))         ID = ID + 1; pnChil = pnNode:GetChildNode(ID)         if(not IsValid(pnChil)) then break end       end   end) I am using ( DFileBrowser ) and I want to cycle trough all the folder nodes that I do not need and remove them, so I can only leave there my custom folder and the E2 folder. I see that the panel is created here ans later on I can retrieve the root using this and all its folders by ID using this. In the logs I receiving: CLIENT > [21-01-18 14:05:33:160.063863] CONFIGURATOR: File node invalid <nil> How do I do that ?
Instead of using data/ use data/myspecialfolder/ as the root for the DTree problem solved?
Yep, that works as a charm, but I am generating some stuff using the wiremod and I want to inclue E2files/Expression2 folder as well.
Sorry, you need to Log In to post a reply to this thread.