mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Utils: [BREAKING CHANGE] Remove groups from GetSceneList + re-add order
- Removes the `isGroup` boolean field from the scene object, and does not include any groups in the returned array. - Reintroduces ordered results. Previous versions used a method which did not return the scene list in the same order as the UI. This change also means that this request is more susceptible to crashing OBS if called during a scene collection change. - Adds the `sceneIndex` number to the scene object. 0 being the bottom of the scene list, just like in other requests like `GetSceneItemList`.
This commit is contained in:
parent
889062e44b
commit
20426924cd
@ -277,19 +277,27 @@ std::vector<std::string> Utils::Obs::ListHelper::GetHotkeyNameList()
|
|||||||
|
|
||||||
std::vector<json> Utils::Obs::ListHelper::GetSceneList()
|
std::vector<json> Utils::Obs::ListHelper::GetSceneList()
|
||||||
{
|
{
|
||||||
|
obs_frontend_source_list sceneList = {};
|
||||||
|
obs_frontend_get_scenes(&sceneList);
|
||||||
|
|
||||||
std::vector<json> ret;
|
std::vector<json> ret;
|
||||||
auto sceneEnumProc = [](void *param, obs_source_t *scene) {
|
for (size_t i = 0; i < sceneList.sources.num; i++) {
|
||||||
auto ret = reinterpret_cast<std::vector<json>*>(param);
|
obs_source_t *scene = sceneList.sources.array[i];
|
||||||
|
|
||||||
|
if (obs_source_is_group(scene))
|
||||||
|
continue;
|
||||||
|
|
||||||
json sceneJson;
|
json sceneJson;
|
||||||
sceneJson["sceneName"] = obs_source_get_name(scene);
|
sceneJson["sceneName"] = obs_source_get_name(scene);
|
||||||
sceneJson["isGroup"] = obs_source_is_group(scene);
|
sceneJson["sceneIndex"] = sceneList.sources.num - i - 1;
|
||||||
|
|
||||||
ret->push_back(sceneJson);
|
ret.push_back(sceneJson);
|
||||||
return true;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
obs_enum_scenes(sceneEnumProc, &ret);
|
obs_frontend_source_list_free(&sceneList);
|
||||||
|
|
||||||
|
// Reverse the vector order to match other array returns
|
||||||
|
std::reverse(ret.begin(), ret.end());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user