MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / CheckCondition

Method CheckCondition

plugins/base/macro-condition-scene.cpp:73–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73bool MacroConditionScene::CheckCondition()
74{
75 bool sceneChanged = _lastSceneChangeTime != GetLastSceneChangeTime();
76 if (sceneChanged) {
77 _lastSceneChangeTime = GetLastSceneChangeTime();
78 }
79
80 const auto canvas = _scene.GetCanvas();
81
82 switch (_type) {
83 case Type::CURRENT: {
84 auto scene = getCurrentSceneHelper(_useTransitionTargetScene,
85 canvas);
86 SetVariableValue(GetWeakSourceName(scene));
87 SetTempVarValue("current", GetWeakSourceName(scene));
88 SetTempVarValue("position",
89 std::to_string(GetIndexOfScene(canvas, scene)));
90 return scene && scene == _scene.GetScene(false);
91 }
92 case Type::PREVIOUS: {
93 if (!IsMainCanvas(canvas)) {
94 return false;
95 }
96
97 auto scene = getPreviousSceneHelper(_useTransitionTargetScene);
98 if (!scene) {
99 // Scene was never switched
100 return false;
101 }
102
103 SetVariableValue(GetWeakSourceName(scene));
104 SetTempVarValue("position",
105 std::to_string(GetIndexOfScene(canvas, scene)));
106 SetTempVarValue("previous", GetWeakSourceName(scene));
107 return scene == _scene.GetScene(false);
108 }
109 case Type::PREVIEW: {
110 if (!IsMainCanvas(canvas)) {
111 return false;
112 }
113
114 OBSSourceAutoRelease source =
115 obs_frontend_get_current_preview_scene();
116 OBSWeakSourceAutoRelease scene =
117 obs_source_get_weak_source(source);
118 SetVariableValue(GetWeakSourceName(scene));
119 SetTempVarValue("preview", GetWeakSourceName(scene));
120 SetTempVarValue("position", std::to_string(GetIndexOfScene(
121 canvas, scene.Get())));
122 return scene && scene == _scene.GetScene(false);
123 }
124 case Type::CHANGED:
125 if (!IsMainCanvas(canvas)) {
126 return false;
127 }
128
129 SetVariableValue(GetWeakSourceName(GetCurrentScene()));
130 SetTempVarValue("current",

Callers

nothing calls this directly

Calls 14

GetLastSceneChangeTimeFunction · 0.85
getCurrentSceneHelperFunction · 0.85
GetWeakSourceNameFunction · 0.85
SetTempVarValueFunction · 0.85
to_stringFunction · 0.85
GetIndexOfSceneFunction · 0.85
IsMainCanvasFunction · 0.85
getPreviousSceneHelperFunction · 0.85
GetCurrentSceneFunction · 0.85
GetPreviousSceneFunction · 0.85
sceneNameMatchesRegexFunction · 0.85
GetSceneMethod · 0.80

Tested by

no test coverage detected