Utils/Obs: Add GetSceneItemByName

Simple, didn't really need to be a util tbh. But I added it anyway
and there's nothing you can do to stop me
This commit is contained in:
tt2468 2021-09-25 17:13:29 -07:00
parent ea948766a5
commit 4e0b8c5f11
2 changed files with 17 additions and 0 deletions

View File

@ -421,6 +421,9 @@ json Utils::Obs::DataHelper::GetSceneItemTransform(obs_sceneitem_t *item)
obs_hotkey_t *Utils::Obs::SearchHelper::GetHotkeyByName(std::string name)
{
if (name.empty())
return nullptr;
auto hotkeys = ListHelper::GetHotkeyList();
for (auto hotkey : hotkeys) {
@ -431,6 +434,19 @@ obs_hotkey_t *Utils::Obs::SearchHelper::GetHotkeyByName(std::string name)
return nullptr;
}
// Increments item ref. Use OBSSceneItemAutoRelease
obs_sceneitem_t *Utils::Obs::SearchHelper::GetSceneItemByName(obs_scene_t *scene, std::string name)
{
if (name.empty())
return nullptr;
// Finds first matching scene item in scene, search starts at index 0
obs_sceneitem_t *ret = obs_scene_find_source(scene, name.c_str());
obs_sceneitem_addref(ret);
return ret;
}
struct CreateSceneItemData {
obs_source_t *source;
bool sceneItemEnabled;

View File

@ -63,6 +63,7 @@ namespace Utils {
namespace SearchHelper {
obs_hotkey_t *GetHotkeyByName(std::string name);
obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name); // Increments ref. Use OBSSceneItemAutoRelease
}
namespace ActionHelper {