2023-12-01 09:00:38 +01:00
|
|
|
extends DeckNode
|
|
|
|
|
|
|
|
var noobs: NoOBSWS
|
|
|
|
|
2023-12-10 19:49:27 +01:00
|
|
|
var lock := false # TODO: evaluate if this locking is actually needed
|
|
|
|
|
2023-12-01 09:00:38 +01:00
|
|
|
enum InputPorts{
|
|
|
|
SCENE_NAME,
|
|
|
|
SOURCE_ID,
|
|
|
|
XFORM,
|
|
|
|
SET,
|
|
|
|
}
|
|
|
|
|
2023-12-10 19:49:27 +01:00
|
|
|
|
2023-12-01 09:00:38 +01:00
|
|
|
func _init() -> void:
|
|
|
|
name = "Set Source Transform"
|
|
|
|
node_type = "obs_set_source_transform"
|
2023-12-14 19:15:42 +01:00
|
|
|
description = "Sets an OBS source's transform, which includes position and rotation, among other things."
|
2023-12-01 09:00:38 +01:00
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-12-04 15:16:39 +01:00
|
|
|
func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> void:
|
2023-12-01 09:00:38 +01:00
|
|
|
#{ "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
|
|
|
|
|
2023-12-10 19:49:27 +01:00
|
|
|
if lock:
|
|
|
|
return
|
|
|
|
|
2023-12-01 09:00:38 +01:00
|
|
|
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
|
|
|
|
|
2023-12-10 19:49:27 +01:00
|
|
|
lock = true
|
|
|
|
|
|
|
|
#noobs.make_generic_request("SetSceneItemTransform",
|
|
|
|
#{
|
|
|
|
#"scene_name": scene_name,
|
|
|
|
#"scene_item_id": source_id,
|
|
|
|
#"scene_item_transform": xform,
|
|
|
|
#})
|
|
|
|
#var sleep := noobs.make_generic_request("Sleep", {"sleep_frames": 1})
|
|
|
|
#sleep.response_received.connect(func(): lock = false)
|
|
|
|
var b := noobs.make_batch_request(false, NoOBSWS.Enums.RequestBatchExecutionType.SERIAL_FRAME)
|
|
|
|
b.add_request(
|
|
|
|
"SetSceneItemTransform",
|
|
|
|
"",
|
|
|
|
{
|
|
|
|
"scene_name": scene_name,
|
|
|
|
"scene_item_id": source_id,
|
|
|
|
"scene_item_transform": xform,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
b.add_request("Sleep", "", {"sleep_frames": 1})
|
|
|
|
b.response_received.connect(func(): lock = false)
|
|
|
|
b.send()
|