diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/obswebsocket.cr | 20 |
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 |