Skip to content

Commit

Permalink
Merge pull request #134 from Silverlan/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan authored Dec 9, 2024
2 parents db1ade7 + d6b7fc7 commit b41ee1e
Show file tree
Hide file tree
Showing 143 changed files with 3,488 additions and 1,140 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ Build Requirements

Build Instructions
------
To build Pragma, all you have to do is run the following command from a command-line interface:
Quick-Start: Simply run the "build.bat" for Windows or "build.sh" for Linux systems to build Pragma with the default settings.

Alternatively you can run the following command from a command-line interface:
```console
git clone https://github.com/Silverlan/pragma.git && cd pragma && python build_scripts/build.py --with-pfm --with-all-pfm-modules --with-vr
```
(Use `python3` instead of `python` if you're on Linux.)

This will clone Pragma and run the build-script, which will automatically download all dependencies, configure CMake, and build and install the project (this will take several hours).
If you don't need the filmmaker, you can omit the `--with-pfm --with-all-pfm-modules` arguments, which will reduce the build time and the required amount of disk space.
Expand Down
120 changes: 120 additions & 0 deletions assets/addons/shader_graph/lua/gui/shader_graph/node.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
--[[
Copyright (C) 2024 Silverlan
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]

local Element = util.register_class("gui.GraphNode", gui.Base)
function Element:OnInitialize()
gui.Base.OnInitialize(self)

self:SetSize(128, 128)

local bg = gui.create("WIRect", self, 0, 0, self:GetWidth(), self:GetHeight(), 0, 0, 1, 1)
self.m_bg = bg

local box = gui.create("WIVBox", self, 0, 0, self:GetWidth(), self:GetHeight())
box:SetName("global_container")
box:SetFixedWidth(true)
box:AddCallback("SetSize", function()
self:SetHeight(box:GetBottom())
end)

local outputControls = gui.create("WIPFMControlsMenu", box, 0, 0, box:GetWidth(), box:GetHeight())
outputControls:SetAutoFillContentsToHeight(false)
outputControls:SetFixedHeight(false)
self.m_outputControls = outputControls

local offsetControls = 0
local inputControls = gui.create(
"WIPFMControlsMenu",
box,
offsetControls,
outputControls:GetBottom(),
box:GetWidth() - offsetControls,
box:GetHeight()
)
inputControls:SetAutoFillContentsToHeight(false)
inputControls:SetFixedHeight(false)
self.m_inputControls = inputControls

self.m_inputs = {}
self.m_outputs = {}

outputControls:SetHeight(0)
inputControls:SetHeight(0)
outputControls:ResetControls()
inputControls:ResetControls()
end
function Element:SetNode(name)
self.m_node = name
end
function Element:GetNode()
return self.m_node
end
function Element:AddControl(socketType, title, id, type)
local ctrlMenu = (socketType == gui.GraphNodeSocket.SOCKET_TYPE_INPUT) and self.m_inputControls
or self.m_outputControls
local elCtrl
if socketType == gui.GraphNodeSocket.SOCKET_TYPE_INPUT and type ~= nil then
local udmType = shader.Socket.to_udm_type(type)
local propInfo = {}
if type == shader.Socket.TYPE_COLOR then
propInfo.specializationType = "color"
end
local wrapper = ctrlMenu:AddPropertyControl(udmType, id, title, propInfo)
wrapper:SetOnChangeValueHandler(function(val, isFinal, initialValue)
if isFinal then
self:CallCallbacks("OnSocketValueChanged", id, val)
end
end)
elCtrl = wrapper:GetWrapperElement()
else
local el, wrapper = ctrlMenu:AddText(title, id, "")
elCtrl = wrapper
end
local el = gui.create("WIGraphNodeSocket", elCtrl)
el:SetSocket(self, id, socketType)
el:SetMouseInputEnabled(true)
el:AddCallback("OnMouseEvent", function(el, button, state, mods)
if button == input.MOUSE_BUTTON_LEFT and state == input.STATE_PRESS then
self:CallCallbacks("OnSocketClicked", el, socketType, id)
return util.EVENT_REPLY_HANDLED
end
end)
local t = (socketType == gui.GraphNodeSocket.SOCKET_TYPE_INPUT) and self.m_inputs or self.m_outputs
t[id] = {
socketElement = el,
controlElement = elCtrl,
}
return el, elCtrl
end
function Element:GetSocket(socketType, name)
local t = (socketType == gui.GraphNodeSocket.SOCKET_TYPE_INPUT) and self.m_inputs or self.m_outputs
if t[name] == nil then
return
end
return t[name].socketElement
end
function Element:GetInputSocket(name)
return self:GetSocket(gui.GraphNodeSocket.SOCKET_TYPE_INPUT, name)
end
function Element:GetOutputSocket(name)
return self:GetSocket(gui.GraphNodeSocket.SOCKET_TYPE_OUTPUT, name)
end
function Element:AddInput(name, type)
local elSocket, elCtrl = self:AddControl(gui.GraphNodeSocket.SOCKET_TYPE_INPUT, name, name, type)
elSocket:SetX(elSocket:GetWidth() * -0.5)
elSocket:SetY(elCtrl:GetHeight() * 0.5 - elSocket:GetHeight() * 0.5)
return elSocket
end
function Element:AddOutput(name)
local elSocket, elCtrl = self:AddControl(gui.GraphNodeSocket.SOCKET_TYPE_OUTPUT, name, name)
elSocket:SetX(elCtrl:GetWidth() - elSocket:GetWidth() * 0.5)
elSocket:SetY(elCtrl:GetHeight() * 0.5 - elSocket:GetHeight() * 0.5)
elSocket:SetAnchor(1, 0, 1, 0)
return elSocket
end
gui.register("WIGraphNode", Element)
35 changes: 35 additions & 0 deletions assets/addons/shader_graph/lua/gui/shader_graph/node_socket.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--[[
Copyright (C) 2024 Silverlan
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]

local Element = util.register_class("gui.GraphNodeSocket", gui.Base)
Element.SOCKET_TYPE_INPUT = 0
Element.SOCKET_TYPE_OUTPUT = 1
function Element:OnInitialize()
gui.Base.OnInitialize(self)

self:SetSize(16, 16)

local bg = gui.create("WITexturedRect", self, 0, 0, self:GetWidth(), self:GetHeight(), 0, 0, 1, 1)
bg:SetMaterial("circle")
self.m_bg = bg
end
function Element:SetSocket(node, socket, socketType)
self.m_node = node
self.m_socket = socket
self.m_socketType = socketType
end
function Element:GetNode()
return self.m_node
end
function Element:GetSocket()
return self.m_socket
end
function Element:GetSocketType()
return self.m_socketType
end
gui.register("WIGraphNodeSocket", Element)
Loading

0 comments on commit b41ee1e

Please sign in to comment.