Skip to content

Commit

Permalink
Added: Centralized base node panel expand routine
Browse files Browse the repository at this point in the history
Fixed: All nodes are expanded/contracted correctly no matter where are clicked
Fixed: Database browser consistency between expander/node
Fixed: Sub-categories are expanded/contacted and state is preserved
  • Loading branch information
dvdvideo1234 committed Jul 29, 2024
1 parent 54b4253 commit 186db54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.758")
asmlib.SetOpVar("TOOL_VERSION","8.759")

------------ CONFIGURE GLOBAL INIT OPVARS ------------

Expand Down
23 changes: 18 additions & 5 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,22 @@ function GetDirectory(pCurr, vName)
return pItem, pItem[keyOb]
end

function SetExpandNode(pnBase)
if(inputIsKeyDown(KEY_LSHIFT)) then
if(pnBase:GetExpanded()) then
pnBase:ExpandRecurse(false)
else
pnBase:ExpandRecurse(true)
end
else
if(pnBase:GetExpanded()) then
pnBase:SetExpanded(false)
else
pnBase:SetExpanded(true)
end
end
end

function SetDirectory(pnBase, pCurr, vName)
if(not IsValid(pnBase)) then
LogInstance("Base panel invalid"); return nil end
Expand All @@ -1724,11 +1740,8 @@ function SetDirectory(pnBase, pCurr, vName)
pCurr[sName] = {}; pCurr[sName][keyOb] = pNode
pNode:SetTooltip(languageGetPhrase("tool."..sTool..".subfolder"))
pNode.Icon:SetImage(ToIcon("subfolder_item"))
pNode.DoClick = function(pnSelf)
if(inputIsKeyDown(KEY_LSHIFT)) then
pNode:ExpandRecurse(true)
else pnSelf:SetExpanded(true) end
end
pNode.DoClick = function() SetExpandNode(pNode) end
pNode.Expander.DoClick = function() SetExpandNode(pNode) end
pNode.DoRightClick = function()
SetClipboardText(pNode:GetText())
end
Expand Down
7 changes: 2 additions & 5 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2329,11 +2329,8 @@ function TOOL.BuildCPanel(CPanel)
local pRoot = pTree:AddNode(sTyp) -- No type folder made already
pRoot:SetTooltip(languageGetPhrase("tool."..gsToolNameL..".type"))
pRoot.Icon:SetImage(asmlib.ToIcon(defTable.Name))
pRoot.DoClick = function(pnSelf)
if(inputIsKeyDown(KEY_LSHIFT)) then
pnSelf:ExpandRecurse(true)
else pnSelf:SetExpanded(true) end
end
pRoot.DoClick = function() asmlib.SetExpandNode(pRoot) end
pRoot.Expander.DoClick = function() asmlib.SetExpandNode(pRoot) end
pRoot.DoRightClick = function()
local sID = asmlib.WorkshopID(sTyp)
if(sID and sID:len() > 0 and inputIsKeyDown(KEY_LSHIFT)) then
Expand Down

0 comments on commit 186db54

Please sign in to comment.