From daeebbee7dc82048ae369f8c8e4f0abfc4c60b4b Mon Sep 17 00:00:00 2001 From: Silverlan Date: Sun, 15 Dec 2024 16:41:06 +0100 Subject: [PATCH] feat(shader_graph): sockets are now highlighted when linked --- .../shader_graph/lua/gui/shader_graph/node_socket.lua | 4 ++++ .../shader_graph/lua/gui/shader_graph/shader_graph.lua | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/assets/addons/shader_graph/lua/gui/shader_graph/node_socket.lua b/assets/addons/shader_graph/lua/gui/shader_graph/node_socket.lua index 998635861..892a3daa8 100644 --- a/assets/addons/shader_graph/lua/gui/shader_graph/node_socket.lua +++ b/assets/addons/shader_graph/lua/gui/shader_graph/node_socket.lua @@ -23,8 +23,12 @@ function Element:OnInitialize() inner:SetMaterial("gui/pfm/circle_filled") inner:CenterToParent() inner:SetColor(Color.Lime) + inner:SetVisible(false) self.m_innerCircle = inner end +function Element:SetLinked(linked) + self.m_innerCircle:SetVisible(linked) +end function Element:SetSocket(node, socket, socketType) self.m_node = node self.m_socket = socket diff --git a/assets/addons/shader_graph/lua/gui/shader_graph/shader_graph.lua b/assets/addons/shader_graph/lua/gui/shader_graph/shader_graph.lua index e16b84087..63d8a1c87 100644 --- a/assets/addons/shader_graph/lua/gui/shader_graph/shader_graph.lua +++ b/assets/addons/shader_graph/lua/gui/shader_graph/shader_graph.lua @@ -173,7 +173,14 @@ function Element:AddLink(elOutputSocket, elInputSocket) l:SetAnchor(0, 0, 1, 1) l:SetZPos(-1) l:Setup(elOutputSocket, elInputSocket) + l:AddCallback("OnRemove", function() + if(elInputSocket:IsValid()) then elInputSocket:SetLinked(false) end + if(elOutputSocket:IsValid()) then elOutputSocket:SetLinked(false) end + end) table.insert(self.m_linkElements, l) + + elInputSocket:SetLinked(true) + elOutputSocket:SetLinked(true) end function Element:RemoveNode(name) local t = self.m_nameToElementData[name]