From c94a791d191e88843bcd2c02c11f925fb779c900 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Mon, 21 Feb 2022 20:08:06 +0100 Subject: [PATCH] Allow switching to already active scene if in studio mode Preview and program scene can differ in regards to the active scene items. Thus it can make sense to switch to the already active scene. --- src/advanced-scene-switcher.cpp | 4 ++-- src/headers/advanced-scene-switcher.hpp | 2 +- src/macro-action-scene-switch.cpp | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp index 554fd392..89f21ccc 100644 --- a/src/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -343,7 +343,7 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene, return match; } -void switchScene(const sceneSwitchInfo &sceneSwitch) +void switchScene(const sceneSwitchInfo &sceneSwitch, bool force) { if (!sceneSwitch.scene && switcher->verbose) { blog(LOG_INFO, "nothing to switch to"); @@ -353,7 +353,7 @@ void switchScene(const sceneSwitchInfo &sceneSwitch) obs_source_t *source = obs_weak_source_get_source(sceneSwitch.scene); obs_source_t *currentSource = obs_frontend_get_current_scene(); - if (source && source != currentSource) { + if (source && (source != currentSource || force)) { transitionData currentTransitionData; setNextTransition(sceneSwitch, currentSource, currentTransitionData); diff --git a/src/headers/advanced-scene-switcher.hpp b/src/headers/advanced-scene-switcher.hpp index 08705087..736f3290 100644 --- a/src/headers/advanced-scene-switcher.hpp +++ b/src/headers/advanced-scene-switcher.hpp @@ -302,7 +302,7 @@ void setNextTransition(const sceneSwitchInfo &ssi, obs_source_t *currentSource, void overwriteTransitionOverride(const sceneSwitchInfo &ssi, transitionData &td); void restoreTransitionOverride(obs_source_t *scene, const transitionData &td); -void switchScene(const sceneSwitchInfo &ssi); +void switchScene(const sceneSwitchInfo &ssi, bool force = false); void switchPreviewScene(const OBSWeakSource &ws); /****************************************************************************** diff --git a/src/macro-action-scene-switch.cpp b/src/macro-action-scene-switch.cpp index 69afaa85..ca11c56f 100644 --- a/src/macro-action-scene-switch.cpp +++ b/src/macro-action-scene-switch.cpp @@ -39,7 +39,8 @@ bool MacroActionSwitchScene::PerformAction() { auto scene = _scene.GetScene(); switchScene({scene, _transition.GetTransition(), - (int)(_duration.seconds * 1000)}); + (int)(_duration.seconds * 1000)}, + obs_frontend_preview_program_mode_active()); if (_blockUntilTransitionDone && scene) { waitForTransitionChange(scene); return !switcher->abortMacroWait;