Utils: Fix up transition related utils

This commit is contained in:
tt2468 2021-12-22 16:27:50 -08:00
parent 1c6ec1dda2
commit 2302fdd25f
2 changed files with 35 additions and 21 deletions

View File

@ -120,9 +120,10 @@ namespace Utils {
std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetTransitionList();
std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList();
}
namespace ObjectHelper {

View File

@ -143,26 +143,6 @@ std::vector<json> Utils::Obs::ArrayHelper::GetSceneItemList(obs_scene_t *scene,
return enumData.first;
}
std::vector<json> Utils::Obs::ArrayHelper::GetTransitionList()
{
obs_frontend_source_list transitionList = {};
obs_frontend_get_transitions(&transitionList);
std::vector<json> ret;
for (size_t i = 0; i < transitionList.sources.num; i++) {
obs_source_t *transition = transitionList.sources.array[i];
json transitionJson;
transitionJson["transitionName"] = obs_source_get_name(transition);
transitionJson["transitionKind"] = obs_source_get_id(transition);
transitionJson["transitionFixed"] = obs_transition_fixed(transition);
ret.push_back(transitionJson);
}
obs_frontend_source_list_free(&transitionList);
return ret;
}
struct EnumInputInfo {
std::string inputKind; // For searching by input kind
std::vector<json> inputs;
@ -220,3 +200,36 @@ std::vector<std::string> Utils::Obs::ArrayHelper::GetInputKindList(bool unversio
return ret;
}
std::vector<std::string> Utils::Obs::ArrayHelper::GetTransitionKindList()
{
std::vector<std::string> ret;
size_t idx = 0;
const char *kind;
while (obs_enum_transition_types(idx++, &kind))
ret.emplace_back(kind);
return ret;
}
std::vector<json> Utils::Obs::ArrayHelper::GetSceneTransitionList()
{
obs_frontend_source_list transitionList = {};
obs_frontend_get_transitions(&transitionList);
std::vector<json> ret;
for (size_t i = 0; i < transitionList.sources.num; i++) {
obs_source_t *transition = transitionList.sources.array[i];
json transitionJson;
transitionJson["transitionName"] = obs_source_get_name(transition);
transitionJson["transitionKind"] = obs_source_get_id(transition);
transitionJson["transitionFixed"] = obs_transition_fixed(transition);
transitionJson["transitionConfigurable"] = obs_source_configurable(transition);
ret.push_back(transitionJson);
}
obs_frontend_source_list_free(&transitionList);
return ret;
}