mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-14 04:41:46 -05:00
Enable option to check previous scene during active transition
This commit is contained in:
parent
d6ef69a3d4
commit
e4526c4e81
|
|
@ -116,6 +116,7 @@ AdvSceneSwitcher.condition.scene.type.previous="Previous scene is"
|
|||
AdvSceneSwitcher.condition.scene.type.changed="Scene changed"
|
||||
AdvSceneSwitcher.condition.scene.type.notChanged="Scene has not changed"
|
||||
AdvSceneSwitcher.condition.scene.currentSceneTransitionBehaviour="During transition check for transition target scene"
|
||||
AdvSceneSwitcher.condition.scene.previousSceneTransitionBehaviour="During transition check for transition source scene"
|
||||
AdvSceneSwitcher.condition.scene.entry.line1="{{sceneType}} {{scenes}}"
|
||||
AdvSceneSwitcher.condition.scene.entry.line2="{{useTransitionTargetScene}}"
|
||||
AdvSceneSwitcher.condition.window="Window"
|
||||
|
|
|
|||
|
|
@ -460,6 +460,19 @@ bool SwitcherData::sceneChangedDuringWait()
|
|||
return (waitScene && currentSource != waitScene);
|
||||
}
|
||||
|
||||
// Relies on the fact that switcher->currentScene will only be updated on event
|
||||
// OBS_FRONTEND_EVENT_SCENE_CHANGED but obs_frontend_get_current_scene() will
|
||||
// already return the scene to be transitioned to.
|
||||
bool SwitcherData::anySceneTransitionStarted()
|
||||
{
|
||||
auto currentSceneSrouce = obs_frontend_get_current_scene();
|
||||
auto currentScene = obs_source_get_weak_source(currentSceneSrouce);
|
||||
bool ret = switcher->currentScene != currentScene;
|
||||
obs_weak_source_release(currentScene);
|
||||
obs_source_release(currentSceneSrouce);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* OBS module setup
|
||||
******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ struct SwitcherData {
|
|||
|
||||
void setWaitScene();
|
||||
bool sceneChangedDuringWait();
|
||||
bool anySceneTransitionStarted();
|
||||
|
||||
bool prioFuncsValid();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,19 +28,20 @@ bool MacroConditionScene::CheckCondition()
|
|||
|
||||
switch (_type) {
|
||||
case SceneType::CURRENT:
|
||||
if (!_useTransitionTargetScene) {
|
||||
return switcher->currentScene == _scene.GetScene(false);
|
||||
} else {
|
||||
|
||||
bool match = false;
|
||||
if (_useTransitionTargetScene) {
|
||||
auto current = obs_frontend_get_current_scene();
|
||||
auto weak = obs_source_get_weak_source(current);
|
||||
match = weak == _scene.GetScene(false);
|
||||
bool match = weak == _scene.GetScene(false);
|
||||
obs_weak_source_release(weak);
|
||||
obs_source_release(current);
|
||||
return match;
|
||||
}
|
||||
return switcher->currentScene == _scene.GetScene(false);
|
||||
case SceneType::PREVIOUS:
|
||||
if (switcher->anySceneTransitionStarted() &&
|
||||
_useTransitionTargetScene) {
|
||||
return switcher->currentScene == _scene.GetScene(false);
|
||||
}
|
||||
return switcher->previousScene == _scene.GetScene(false);
|
||||
case SceneType::CHANGED:
|
||||
return sceneChanged;
|
||||
|
|
@ -168,8 +169,18 @@ void MacroConditionSceneEdit::SetWidgetVisibility()
|
|||
{
|
||||
_scenes->setVisible(_entryData->_type == SceneType::CURRENT ||
|
||||
_entryData->_type == SceneType::PREVIOUS);
|
||||
_useTransitionTargetScene->setVisible(_entryData->_type ==
|
||||
SceneType::CURRENT);
|
||||
_useTransitionTargetScene->setVisible(
|
||||
_entryData->_type == SceneType::CURRENT ||
|
||||
_entryData->_type == SceneType::PREVIOUS);
|
||||
|
||||
if (_entryData->_type == SceneType::PREVIOUS) {
|
||||
_useTransitionTargetScene->setText(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.scene.previousSceneTransitionBehaviour"));
|
||||
}
|
||||
if (_entryData->_type == SceneType::CURRENT) {
|
||||
_useTransitionTargetScene->setText(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.scene.currentSceneTransitionBehaviour"));
|
||||
}
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,20 +36,6 @@ bool isCurrentTransition(OBSWeakSource &t)
|
|||
return match;
|
||||
}
|
||||
|
||||
// Relies on the fact that switcher->currentScene will only be updated on event
|
||||
// OBS_FRONTEND_EVENT_SCENE_CHANGED but obs_frontend_get_current_scene() will
|
||||
// already return the scene to be transitioned to.
|
||||
bool anySceneTransitionStarted()
|
||||
{
|
||||
bool ret;
|
||||
auto currentSceneSrouce = obs_frontend_get_current_scene();
|
||||
auto currentScene = obs_source_get_weak_source(currentSceneSrouce);
|
||||
ret = switcher->currentScene != currentScene;
|
||||
obs_weak_source_release(currentScene);
|
||||
obs_source_release(currentSceneSrouce);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isTargetScene(OBSWeakSource &target)
|
||||
{
|
||||
auto source = obs_frontend_get_current_scene();
|
||||
|
|
@ -64,7 +50,7 @@ bool MacroConditionTransition::CheckCondition()
|
|||
{
|
||||
bool anyTransitionEnded = _lastTransitionEndTime !=
|
||||
switcher->lastTransitionEndTime;
|
||||
bool anyTransitionStarted = anySceneTransitionStarted();
|
||||
bool anyTransitionStarted = switcher->anySceneTransitionStarted();
|
||||
bool transitionStarted = false;
|
||||
bool transitionEnded = false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user