mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
add obs set source transform and search source id node
This commit is contained in:
parent
c5512cfee7
commit
542758c660
4 changed files with 157 additions and 0 deletions
|
@ -110,6 +110,7 @@ func remove_node(uuid: String, remove_connections: bool = false) -> void:
|
||||||
if remove_connections:
|
if remove_connections:
|
||||||
var outgoing_connections := node.outgoing_connections.duplicate(true)
|
var outgoing_connections := node.outgoing_connections.duplicate(true)
|
||||||
|
|
||||||
|
# FIXME: rework this to account for new outgoing connections format
|
||||||
for output_port: int in outgoing_connections:
|
for output_port: int in outgoing_connections:
|
||||||
for connection: Dictionary in outgoing_connections[output_port]:
|
for connection: Dictionary in outgoing_connections[output_port]:
|
||||||
disconnect_nodes(uuid, connection.keys()[0], output_port, connection.values()[0])
|
disconnect_nodes(uuid, connection.keys()[0], output_port, connection.values()[0])
|
||||||
|
|
|
@ -143,6 +143,16 @@ func request_value(on_port: int) -> Variant:
|
||||||
return node._value_request(connection.values()[0])
|
return node._value_request(connection.values()[0])
|
||||||
|
|
||||||
|
|
||||||
|
## Asynchronous version of [method request_value].
|
||||||
|
func request_value_async(on_port: int) -> Variant:
|
||||||
|
if !incoming_connections.has(on_port):
|
||||||
|
return null
|
||||||
|
|
||||||
|
var connection: Dictionary = incoming_connections[on_port]
|
||||||
|
var node := get_node(connection.keys()[0])
|
||||||
|
return await node._value_request(connection.values()[0])
|
||||||
|
|
||||||
|
|
||||||
## Virtual function that's called when this node has been requested a value from the output port
|
## Virtual function that's called when this node has been requested a value from the output port
|
||||||
## at [param from_port].
|
## at [param from_port].
|
||||||
func _value_request(from_port: int) -> Variant:
|
func _value_request(from_port: int) -> Variant:
|
||||||
|
|
64
classes/deck/nodes/obs_search_source.gd
Normal file
64
classes/deck/nodes/obs_search_source.gd
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
extends DeckNode
|
||||||
|
|
||||||
|
var noobs: NoOBSWS
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
name = "Get Source ID"
|
||||||
|
node_type = "obs_search_source"
|
||||||
|
description = ""
|
||||||
|
category = "obs"
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.STRING,
|
||||||
|
"Scene name",
|
||||||
|
"field"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.STRING,
|
||||||
|
"Source name",
|
||||||
|
"field"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_output_port(
|
||||||
|
DeckType.Types.NUMERIC,
|
||||||
|
"Source ID"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _value_request(on_output_port: int) -> Variant:
|
||||||
|
if noobs == null:
|
||||||
|
noobs = Connections.obs_websocket
|
||||||
|
|
||||||
|
var scene_name: String
|
||||||
|
if request_value(0) != null:
|
||||||
|
scene_name = request_value(0)
|
||||||
|
elif get_input_ports()[0].value_callback.get_object() && get_input_ports()[0].value_callback.call() != "":
|
||||||
|
scene_name = get_input_ports()[0].value_callback.call()
|
||||||
|
if scene_name.is_empty():
|
||||||
|
return null
|
||||||
|
|
||||||
|
var source_name: String
|
||||||
|
if request_value(1) != null:
|
||||||
|
source_name = request_value(1)
|
||||||
|
elif get_input_ports()[1].value_callback.get_object() && get_input_ports()[1].value_callback.call() != "":
|
||||||
|
source_name = get_input_ports()[1].value_callback.call()
|
||||||
|
if source_name.is_empty():
|
||||||
|
return null
|
||||||
|
|
||||||
|
var req := noobs.make_generic_request(
|
||||||
|
"GetSceneItemId",
|
||||||
|
{
|
||||||
|
"scene_name": scene_name,
|
||||||
|
"source_name": source_name
|
||||||
|
}
|
||||||
|
)
|
||||||
|
await req.response_received
|
||||||
|
|
||||||
|
var data := req.message.get_data()
|
||||||
|
#if int(data.request_status.code) != NoOBSWS.Enums.RequestStatus.NO_ERROR:
|
||||||
|
#return null
|
||||||
|
|
||||||
|
return data.response_data.scene_item_id
|
||||||
|
|
82
classes/deck/nodes/obs_set_source_transform.gd
Normal file
82
classes/deck/nodes/obs_set_source_transform.gd
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
extends DeckNode
|
||||||
|
|
||||||
|
var noobs: NoOBSWS
|
||||||
|
|
||||||
|
enum InputPorts{
|
||||||
|
SCENE_NAME,
|
||||||
|
SOURCE_ID,
|
||||||
|
XFORM,
|
||||||
|
SET,
|
||||||
|
}
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
name = "Set Source Transform"
|
||||||
|
node_type = "obs_set_source_transform"
|
||||||
|
description = ""
|
||||||
|
category = "obs"
|
||||||
|
|
||||||
|
props_to_serialize = []
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.STRING,
|
||||||
|
"Scene name",
|
||||||
|
"field"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.NUMERIC,
|
||||||
|
"Source ID",
|
||||||
|
"field"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.DICTIONARY,
|
||||||
|
"Transform"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_input_port(
|
||||||
|
DeckType.Types.BOOL,
|
||||||
|
"Set",
|
||||||
|
"button"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
|
||||||
|
#{ "scene_item_transform": { "alignment": 5, "bounds_alignment": 0, "bounds_height": 0, "bounds_type": "OBS_BOUNDS_NONE", "bounds_width": 0, "crop_bottom": 0, "crop_left": 0, "crop_right": 0, "crop_top": 0, "height": 257, "position_x": 1800, "position_y": 414, "rotation": 0, "scale_x": 1, "scale_y": 1, "source_height": 257, "source_width": 146, "width": 146 }}
|
||||||
|
if to_input_port != 3:
|
||||||
|
return
|
||||||
|
|
||||||
|
if noobs == null:
|
||||||
|
noobs = Connections.obs_websocket
|
||||||
|
|
||||||
|
var scene_name: String
|
||||||
|
if request_value(InputPorts.SCENE_NAME) != null:
|
||||||
|
scene_name = request_value(InputPorts.SCENE_NAME)
|
||||||
|
elif get_input_ports()[InputPorts.SCENE_NAME].value_callback.get_object() && get_input_ports()[InputPorts.SCENE_NAME].value_callback.call() != "":
|
||||||
|
scene_name = get_input_ports()[InputPorts.SCENE_NAME].value_callback.call()
|
||||||
|
|
||||||
|
if scene_name.is_empty():
|
||||||
|
return
|
||||||
|
|
||||||
|
var source_id: float
|
||||||
|
var res_as = await request_value_async(InputPorts.SOURCE_ID)
|
||||||
|
if res_as != null:
|
||||||
|
source_id = res_as
|
||||||
|
elif get_input_ports()[InputPorts.SOURCE_ID].value_callback.get_object() && get_input_ports()[InputPorts.SOURCE_ID].value_callback.call() != null:
|
||||||
|
source_id = get_input_ports()[InputPorts.SOURCE_ID].value_callback.call()
|
||||||
|
|
||||||
|
var xform: Dictionary
|
||||||
|
if request_value(InputPorts.XFORM) != null:
|
||||||
|
xform = request_value(InputPorts.XFORM)
|
||||||
|
elif get_input_ports()[InputPorts.XFORM].value_callback.get_object() && get_input_ports()[InputPorts.XFORM].value_callback.call() != null:
|
||||||
|
xform = get_input_ports()[InputPorts.XFORM].value_callback.call()
|
||||||
|
|
||||||
|
if xform.is_empty():
|
||||||
|
return
|
||||||
|
|
||||||
|
var req := noobs.make_generic_request("SetSceneItemTransform",
|
||||||
|
{
|
||||||
|
"scene_name": scene_name,
|
||||||
|
"scene_item_id": source_id,
|
||||||
|
"scene_item_transform": xform,
|
||||||
|
})
|
Loading…
Reference in a new issue