mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-14 21:01:39 -05:00
Move getSceneItemsWithName() to utility
This commit is contained in:
parent
1bf2a154e2
commit
beec7d5939
|
|
@ -25,6 +25,8 @@ std::string getSourceSettings(OBSWeakSource ws);
|
|||
void setSourceSettings(obs_source_t *s, const std::string &settings);
|
||||
bool compareSourceSettings(const OBSWeakSource &source,
|
||||
const std::string &settings, bool regex);
|
||||
std::vector<obs_scene_item *> getSceneItemsWithName(OBSScene scene,
|
||||
std::string &name);
|
||||
std::string getDataFilePath(const std::string &file);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,37 +22,14 @@ const static std::map<SceneOrderAction, std::string> actionTypes = {
|
|||
"AdvSceneSwitcher.action.sceneOrder.type.movePosition"},
|
||||
};
|
||||
|
||||
struct MoveInfo {
|
||||
std::string name;
|
||||
std::vector<obs_sceneitem_t *> items = {};
|
||||
};
|
||||
|
||||
static bool getSceneItems(obs_scene_t *, obs_sceneitem_t *item, void *ptr)
|
||||
{
|
||||
MoveInfo *moveInfo = reinterpret_cast<MoveInfo *>(ptr);
|
||||
auto sourceName = obs_source_get_name(obs_sceneitem_get_source(item));
|
||||
if (moveInfo->name == sourceName) {
|
||||
obs_sceneitem_addref(item);
|
||||
moveInfo->items.push_back(item);
|
||||
}
|
||||
|
||||
if (obs_sceneitem_is_group(item)) {
|
||||
obs_scene_t *scene = obs_sceneitem_group_get_scene(item);
|
||||
obs_scene_enum_items(scene, getSceneItems, ptr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroActionSceneOrder::PerformAction()
|
||||
{
|
||||
auto s = obs_weak_source_get_source(_scene);
|
||||
auto scene = obs_scene_from_source(s);
|
||||
auto sourceName = GetWeakSourceName(_source);
|
||||
MoveInfo moveInfo = {sourceName};
|
||||
obs_scene_enum_items(scene, getSceneItems, &moveInfo);
|
||||
auto name = GetWeakSourceName(_source);
|
||||
auto items = getSceneItemsWithName(scene, name);
|
||||
|
||||
for (auto &i : moveInfo.items) {
|
||||
for (auto &i : items) {
|
||||
switch (_action) {
|
||||
case SceneOrderAction::MOVE_UP:
|
||||
obs_sceneitem_set_order(i, OBS_ORDER_MOVE_UP);
|
||||
|
|
|
|||
|
|
@ -235,6 +235,36 @@ void setSourceSettings(obs_source_t *s, const std::string &settings)
|
|||
obs_data_release(data);
|
||||
}
|
||||
|
||||
struct ItemInfo {
|
||||
std::string name;
|
||||
std::vector<obs_sceneitem_t *> items = {};
|
||||
};
|
||||
|
||||
static bool getSceneItems(obs_scene_t *, obs_sceneitem_t *item, void *ptr)
|
||||
{
|
||||
ItemInfo *moveInfo = reinterpret_cast<ItemInfo *>(ptr);
|
||||
auto sourceName = obs_source_get_name(obs_sceneitem_get_source(item));
|
||||
if (moveInfo->name == sourceName) {
|
||||
obs_sceneitem_addref(item);
|
||||
moveInfo->items.push_back(item);
|
||||
}
|
||||
|
||||
if (obs_sceneitem_is_group(item)) {
|
||||
obs_scene_t *scene = obs_sceneitem_group_get_scene(item);
|
||||
obs_scene_enum_items(scene, getSceneItems, ptr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<obs_scene_item *> getSceneItemsWithName(OBSScene scene,
|
||||
std::string &name)
|
||||
{
|
||||
ItemInfo itemInfo = {name};
|
||||
obs_scene_enum_items(scene, getSceneItems, &itemInfo);
|
||||
return itemInfo.items;
|
||||
}
|
||||
|
||||
bool compareSourceSettings(const OBSWeakSource &source,
|
||||
const std::string &settings, bool useRegex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user