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

Method PerformAction

plugins/base/macro-action-scene-switch.cpp:130–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130bool MacroActionSwitchScene::PerformAction()
131{
132 OBSWeakSource sceneToSwitchTo;
133 OBSWeakCanvas canvasToSwitchFor;
134
135 OBSCanvasAutoRelease mainCanvas = obs_get_main_canvas();
136 OBSWeakCanvas mainCanvasWeak = OBSGetWeakRef(mainCanvas);
137
138 const auto getActiveSceneHelper = [this](const OBSWeakCanvas &canvas) {
139 OBSWeakSource activeScene;
140 if (IsMainCanvas(canvas) && _sceneType == SceneType::PREVIEW) {
141 OBSSourceAutoRelease previewSource =
142 obs_frontend_get_current_preview_scene();
143 return OBSGetWeakRef(previewSource);
144 } else {
145 return GetActiveCanvasScene(canvas);
146 }
147 };
148
149 switch (_action) {
150 case Action::SCENE_NAME:
151 sceneToSwitchTo = _scene.GetScene();
152 canvasToSwitchFor = _scene.GetCanvas();
153 break;
154 case Action::SCENE_LIST_NEXT: {
155 canvasToSwitchFor = _canvas ? _canvas : mainCanvasWeak;
156 const auto activeScene =
157 getActiveSceneHelper(canvasToSwitchFor);
158 const int currentIndex =
159 GetIndexOfScene(canvasToSwitchFor, activeScene);
160 sceneToSwitchTo =
161 GetSceneAtIndex(canvasToSwitchFor, currentIndex + 1);
162 break;
163 }
164 case Action::SCENE_LIST_PREVIOUS: {
165 canvasToSwitchFor = _canvas ? _canvas : mainCanvasWeak;
166 const auto activeScene =
167 getActiveSceneHelper(canvasToSwitchFor);
168 const int currentIndex =
169 GetIndexOfScene(canvasToSwitchFor, activeScene);
170 sceneToSwitchTo =
171 GetSceneAtIndex(canvasToSwitchFor, currentIndex - 1);
172 break;
173 }
174 case Action::SCENE_LIST_INDEX: {
175 canvasToSwitchFor = _canvas ? _canvas : mainCanvasWeak;
176 sceneToSwitchTo = GetSceneAtIndex(canvasToSwitchFor,
177 _index.GetValue() - 1);
178 break;
179 }
180 default:
181 break;
182 }
183
184 if (_sceneType == SceneType::PREVIEW) {
185 OBSSourceAutoRelease previewSceneSource =
186 obs_weak_source_get_source(sceneToSwitchTo);
187 obs_frontend_set_current_preview_scene(previewSceneSource);

Callers

nothing calls this directly

Calls 12

obs_get_main_canvasFunction · 0.85
IsMainCanvasFunction · 0.85
GetActiveCanvasSceneFunction · 0.85
GetIndexOfSceneFunction · 0.85
GetSceneAtIndexFunction · 0.85
SwitchSceneFunction · 0.85
GetCurrentSceneFunction · 0.85
GetSceneMethod · 0.80
GetValueMethod · 0.80
GetTransitionMethod · 0.80
MillisecondsMethod · 0.80
GetCanvasMethod · 0.45

Tested by

no test coverage detected