mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
make obs set source transform node batch requests and cache some things
This commit is contained in:
parent
c323a64d60
commit
9a40aa3717
4 changed files with 42 additions and 9 deletions
|
@ -2,6 +2,10 @@ extends DeckNode
|
||||||
|
|
||||||
var noobs: NoOBSWS
|
var noobs: NoOBSWS
|
||||||
|
|
||||||
|
var cached_scene_name: String
|
||||||
|
var cached_source_name: String
|
||||||
|
var cached_id # TODO: evaluate if this caching is actually needed
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
name = "Get Source ID"
|
name = "Get Source ID"
|
||||||
|
@ -47,6 +51,12 @@ func _value_request(_on_output_port: int) -> Variant:
|
||||||
if source_name.is_empty():
|
if source_name.is_empty():
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
if cached_scene_name == scene_name && cached_source_name == scene_name:
|
||||||
|
return cached_id
|
||||||
|
|
||||||
|
cached_scene_name = scene_name
|
||||||
|
cached_source_name = source_name
|
||||||
|
|
||||||
var req := noobs.make_generic_request(
|
var req := noobs.make_generic_request(
|
||||||
"GetSceneItemId",
|
"GetSceneItemId",
|
||||||
{
|
{
|
||||||
|
@ -59,6 +69,7 @@ func _value_request(_on_output_port: int) -> Variant:
|
||||||
var data := req.message.get_data()
|
var data := req.message.get_data()
|
||||||
#if int(data.request_status.code) != NoOBSWS.Enums.RequestStatus.NO_ERROR:
|
#if int(data.request_status.code) != NoOBSWS.Enums.RequestStatus.NO_ERROR:
|
||||||
#return null
|
#return null
|
||||||
|
cached_id = data.response_data.scene_item_id
|
||||||
|
|
||||||
return data.response_data.scene_item_id
|
return data.response_data.scene_item_id
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ extends DeckNode
|
||||||
|
|
||||||
var noobs: NoOBSWS
|
var noobs: NoOBSWS
|
||||||
|
|
||||||
|
var lock := false # TODO: evaluate if this locking is actually needed
|
||||||
|
|
||||||
enum InputPorts{
|
enum InputPorts{
|
||||||
SCENE_NAME,
|
SCENE_NAME,
|
||||||
SOURCE_ID,
|
SOURCE_ID,
|
||||||
|
@ -9,6 +11,7 @@ enum InputPorts{
|
||||||
SET,
|
SET,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
name = "Set Source Transform"
|
name = "Set Source Transform"
|
||||||
node_type = "obs_set_source_transform"
|
node_type = "obs_set_source_transform"
|
||||||
|
@ -49,6 +52,9 @@ func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> vo
|
||||||
if noobs == null:
|
if noobs == null:
|
||||||
noobs = Connections.obs_websocket
|
noobs = Connections.obs_websocket
|
||||||
|
|
||||||
|
if lock:
|
||||||
|
return
|
||||||
|
|
||||||
var scene_name: String
|
var scene_name: String
|
||||||
if request_value(InputPorts.SCENE_NAME) != null:
|
if request_value(InputPorts.SCENE_NAME) != null:
|
||||||
scene_name = request_value(InputPorts.SCENE_NAME)
|
scene_name = request_value(InputPorts.SCENE_NAME)
|
||||||
|
@ -74,9 +80,26 @@ func _receive(to_input_port: int, _data: Variant, _extra_data: Array = []) -> vo
|
||||||
if xform.is_empty():
|
if xform.is_empty():
|
||||||
return
|
return
|
||||||
|
|
||||||
var req := noobs.make_generic_request("SetSceneItemTransform",
|
lock = true
|
||||||
{
|
|
||||||
"scene_name": scene_name,
|
#noobs.make_generic_request("SetSceneItemTransform",
|
||||||
"scene_item_id": source_id,
|
#{
|
||||||
"scene_item_transform": xform,
|
#"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()
|
||||||
|
|
|
@ -14,9 +14,9 @@ script = ExtResource("1_xx7my")
|
||||||
anchors_preset = 5
|
anchors_preset = 5
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
offset_left = -179.5
|
offset_left = 8.0
|
||||||
offset_top = 8.0
|
offset_top = 8.0
|
||||||
offset_right = 179.5
|
offset_right = 367.0
|
||||||
offset_bottom = 109.0
|
offset_bottom = 109.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
|
|
|
@ -16,7 +16,6 @@ run/main_scene="res://graph_node_renderer/deck_holder_renderer.tscn"
|
||||||
config/use_custom_user_dir=true
|
config/use_custom_user_dir=true
|
||||||
config/custom_user_dir_name="dotdeck"
|
config/custom_user_dir_name="dotdeck"
|
||||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||||
run/low_processor_mode=true
|
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
Loading…
Reference in a new issue