mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
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:
parent
ea948766a5
commit
4e0b8c5f11
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user