Merge pull request #619 from Palakis/feature/events-add-target-new-state

Events: provide new state of entity (in events that don't do it already)
This commit is contained in:
Stéphane Lepin
2020-11-27 17:23:51 +01:00
committed by GitHub

View File

@ -467,25 +467,35 @@ void WSEvents::OnSceneChange() {
* *
* Note: This event is not fired when the scenes are reordered. * Note: This event is not fired when the scenes are reordered.
* *
* @return {Array<Scene>} `scenes` Scenes list.
*
* @api events * @api events
* @name ScenesChanged * @name ScenesChanged
* @category scenes * @category scenes
* @since 0.3 * @since 0.3
*/ */
void WSEvents::OnSceneListChange() { void WSEvents::OnSceneListChange() {
broadcastUpdate("ScenesChanged"); OBSDataArrayAutoRelease scenes = Utils::GetScenes();
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "scenes", scenes);
broadcastUpdate("ScenesChanged", fields);
} }
/** /**
* Triggered when switching to another scene collection or when renaming the current scene collection. * Triggered when switching to another scene collection or when renaming the current scene collection.
* *
* @return {String} `sceneCollection` Name of the new current scene collection.
*
* @api events * @api events
* @name SceneCollectionChanged * @name SceneCollectionChanged
* @category scenes * @category scenes
* @since 4.0.0 * @since 4.0.0
*/ */
void WSEvents::OnSceneCollectionChange() { void WSEvents::OnSceneCollectionChange() {
broadcastUpdate("SceneCollectionChanged"); OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sceneCollection", obs_frontend_get_current_scene_collection());
broadcastUpdate("SceneCollectionChanged", fields);
OnTransitionListChange(); OnTransitionListChange();
OnTransitionChange(); OnTransitionChange();
@ -497,13 +507,23 @@ void WSEvents::OnSceneCollectionChange() {
/** /**
* Triggered when a scene collection is created, added, renamed, or removed. * Triggered when a scene collection is created, added, renamed, or removed.
* *
* @return {Array<Object>} `sceneCollections` Scene collections list.
* @return {String} `sceneCollections.*.name` Scene collection name.
*
* @api events * @api events
* @name SceneCollectionListChanged * @name SceneCollectionListChanged
* @category scenes * @category scenes
* @since 4.0.0 * @since 4.0.0
*/ */
void WSEvents::OnSceneCollectionListChange() { void WSEvents::OnSceneCollectionListChange() {
broadcastUpdate("SceneCollectionListChanged"); char** sceneCollections = obs_frontend_get_scene_collections();
OBSDataArrayAutoRelease sceneCollectionsList =
Utils::StringListToArray(sceneCollections, "name");
bfree(sceneCollections);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "sceneCollections", sceneCollectionsList);
broadcastUpdate("SceneCollectionListChanged", fields);
} }
/** /**
@ -530,37 +550,68 @@ void WSEvents::OnTransitionChange() {
* The list of available transitions has been modified. * The list of available transitions has been modified.
* Transitions have been added, removed, or renamed. * Transitions have been added, removed, or renamed.
* *
* @return {Array<Object>} `transitions` Transitions list.
* @return {String} `transitions.*.name` Transition name.
*
* @api events * @api events
* @name TransitionListChanged * @name TransitionListChanged
* @category transitions * @category transitions
* @since 4.0.0 * @since 4.0.0
*/ */
void WSEvents::OnTransitionListChange() { void WSEvents::OnTransitionListChange() {
broadcastUpdate("TransitionListChanged"); obs_frontend_source_list transitionList = {};
obs_frontend_get_transitions(&transitionList);
OBSDataArrayAutoRelease transitions = obs_data_array_create();
for (size_t i = 0; i < transitionList.sources.num; i++) {
OBSSource transition = transitionList.sources.array[i];
OBSDataAutoRelease obj = obs_data_create();
obs_data_set_string(obj, "name", obs_source_get_name(transition));
obs_data_array_push_back(transitions, obj);
}
obs_frontend_source_list_free(&transitionList);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "transitions", transitions);
broadcastUpdate("TransitionListChanged", fields);
} }
/** /**
* Triggered when switching to another profile or when renaming the current profile. * Triggered when switching to another profile or when renaming the current profile.
* *
* @return {String} `profile` Name of the new current profile.
*
* @api events * @api events
* @name ProfileChanged * @name ProfileChanged
* @category profiles * @category profiles
* @since 4.0.0 * @since 4.0.0
*/ */
void WSEvents::OnProfileChange() { void WSEvents::OnProfileChange() {
broadcastUpdate("ProfileChanged"); OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "profile", obs_frontend_get_current_profile());
broadcastUpdate("ProfileChanged", fields);
} }
/** /**
* Triggered when a profile is created, added, renamed, or removed. * Triggered when a profile is created, added, renamed, or removed.
* *
* @return {Array<Object>} `profiles` Profiles list.
* @return {String} `profiles.*.name` Profile name.
*
* @api events * @api events
* @name ProfileListChanged * @name ProfileListChanged
* @category profiles * @category profiles
* @since 4.0.0 * @since 4.0.0
*/ */
void WSEvents::OnProfileListChange() { void WSEvents::OnProfileListChange() {
broadcastUpdate("ProfileListChanged"); char** profiles = obs_frontend_get_profiles();
OBSDataArrayAutoRelease profilesList = Utils::StringListToArray(profiles, "name");
bfree(profiles);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "profiles", profilesList);
broadcastUpdate("ProfileListChanged", fields);
} }
/** /**