summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Rayhawk <jrayhawk@fairlystable.org>2022-11-09 21:36:50 -0800
committerJoe Rayhawk <jrayhawk@fairlystable.org>2022-11-09 21:36:50 -0800
commit3b5c8249289b6d82c5e19ad6e446e66972ae8371 (patch)
tree60860e25be9bb6f9228f0d26dc0cdafe4d4b30ec
parent7dfe13379ccb51c726b73d5a3379e816b809b50b (diff)
downloadcrystal-obs-websocket-3b5c8249289b6d82c5e19ad6e446e66972ae8371.tar.gz
crystal-obs-websocket-3b5c8249289b6d82c5e19ad6e446e66972ae8371.zip
metascene: recurse into meta-meta-scenes and provide array of SceneItem for multiple matches.
This is an API-breaking change.
-rw-r--r--src/obswebsocket.cr20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index 8a729d5..0753bb0 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -553,17 +553,23 @@ module OBSWebSocket
end
# Sources may be present a scene via other scenes.
# We can still look these up by source name.
- # FIXME: does not recurse
# Note: OBS refuses to create a referential loop
- # FIXME: only returns one SceneItem
- def metascene : Hash( String, OBSWebSocket::SceneItem )
+ def metascene : Hash( String, Array( OBSWebSocket::SceneItem ) )
@subscenes.empty? && populate
- metascene = Hash( String, OBSWebSocket::SceneItem ).new
- @subscenes.each do | subscene |
- metascene.merge!(subscene.to_h)
+ metascene = Hash( String, Array( OBSWebSocket::SceneItem ) ).new
+ newsubscenes = @subscenes
+ while ( subscene = newsubscenes.shift? )
+ subscene.to_h.each do | siname, sceneitem |
+ if sceneitem.type == "OBS_SOURCE_TYPE_SCENE"
+ newsubscenes.push( parent[siname] )
+ end
+ metascene[ siname ]? || ( metascene[ siname ] = Array( OBSWebSocket::SceneItem ).new )
+ metascene[ siname ].push( sceneitem )
+ end
end
@items_by_id.values.each do | sitem |
- metascene[ sitem.name ] = sitem
+ metascene[ sitem.name ]? || ( metascene[ sitem.name ] = Array( OBSWebSocket::SceneItem ).new )
+ metascene[ sitem.name ].push( sitem )
end
return metascene
end