mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-02 22:08:08 -05:00
add option to override transitionOverrides
This commit is contained in:
parent
eeefd8279f
commit
340cb559ee
|
|
@ -539,6 +539,20 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="transitionOverridecheckBox">
|
||||
<property name="text">
|
||||
<string>Scene transitions defined in the scene switcher take priority over Transition Overrides defined per scene</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_17">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
|
|
|
|||
|
|
@ -270,6 +270,9 @@ void SceneSwitcher::loadUI()
|
|||
item->setData(Qt::UserRole, text);
|
||||
}
|
||||
|
||||
ui->transitionOverridecheckBox->setChecked(
|
||||
switcher->tansitionOverrideOverride);
|
||||
|
||||
for (auto &window : switcher->ignoreIdleWindows) {
|
||||
QString text = QString::fromStdString(window);
|
||||
|
||||
|
|
@ -593,7 +596,8 @@ void SwitcherData::Thread()
|
|||
checkRandom(match, scene, transition, sleep);
|
||||
}
|
||||
if (match) {
|
||||
switchScene(scene, transition, lock);
|
||||
switchScene(scene, transition,
|
||||
tansitionOverrideOverride, lock);
|
||||
}
|
||||
}
|
||||
endLoop:
|
||||
|
|
@ -601,45 +605,29 @@ endLoop:
|
|||
}
|
||||
|
||||
void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride,
|
||||
std::unique_lock<std::mutex> &lock)
|
||||
{
|
||||
obs_source_t *source = obs_weak_source_get_source(scene);
|
||||
obs_source_t *currentSource = obs_frontend_get_current_scene();
|
||||
|
||||
if (source && source != currentSource) {
|
||||
obs_weak_source_t *currentScene =
|
||||
obs_source_get_weak_source(currentSource);
|
||||
obs_weak_source_t *nextTransitionWs =
|
||||
getNextTransition(currentScene, scene);
|
||||
obs_weak_source_release(currentScene);
|
||||
|
||||
if (nextTransitionWs) {
|
||||
obs_source_t *nextTransition =
|
||||
obs_weak_source_get_source(nextTransitionWs);
|
||||
lock.unlock();
|
||||
obs_frontend_set_current_transition(nextTransition);
|
||||
lock.lock();
|
||||
obs_source_release(nextTransition);
|
||||
} else if (transition) {
|
||||
obs_source_t *nextTransition =
|
||||
obs_weak_source_get_source(transition);
|
||||
lock.unlock();
|
||||
obs_frontend_set_current_transition(nextTransition);
|
||||
lock.lock();
|
||||
obs_source_release(nextTransition);
|
||||
}
|
||||
|
||||
// this call might block when OBS_FRONTEND_EVENT_SCENE_CHANGED is active and mutex is held
|
||||
// thus unlock mutex to avoid deadlock
|
||||
lock.unlock();
|
||||
|
||||
transitionData td;
|
||||
setNextTransition(scene, currentSource, transition,
|
||||
transitionOverrideOverride, td);
|
||||
obs_frontend_set_current_scene(source);
|
||||
if (transitionOverrideOverride)
|
||||
restoreTransitionOverride(source, td);
|
||||
lock.lock();
|
||||
|
||||
if (switcher->verbose)
|
||||
blog(LOG_INFO,
|
||||
"Advanced Scene Switcher switched scene");
|
||||
|
||||
obs_weak_source_release(nextTransitionWs);
|
||||
}
|
||||
obs_source_release(currentSource);
|
||||
obs_source_release(source);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ public slots:
|
|||
void on_defaultTransitions_currentRowChanged(int idx);
|
||||
void on_defaultTransitionsAdd_clicked();
|
||||
void on_defaultTransitionsRemove_clicked();
|
||||
void on_transitionOverridecheckBox_stateChanged(int state);
|
||||
|
||||
void on_browseButton_clicked();
|
||||
void on_readFileCheckBox_stateChanged(int state);
|
||||
|
|
@ -187,9 +188,20 @@ bool isInFocus(const QString &executable);
|
|||
struct obs_weak_source;
|
||||
typedef struct obs_weak_source obs_weak_source_t;
|
||||
|
||||
obs_weak_source_t *getNextTransition(obs_weak_source_t *scene1,
|
||||
obs_weak_source_t *scene2);
|
||||
typedef struct transitionData {
|
||||
std::string name = "";
|
||||
int duration = 0;
|
||||
} transitionData;
|
||||
|
||||
void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
|
||||
OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride, transitionData &td);
|
||||
void overwriteTransitionOverride(obs_weak_source_t *sceneWs,
|
||||
obs_source_t *transition, transitionData &td);
|
||||
void restoreTransitionOverride(obs_source_t *scene, transitionData td);
|
||||
|
||||
void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride,
|
||||
std::unique_lock<std::mutex> &lock);
|
||||
|
||||
/********************************************************************************
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ struct SwitcherData {
|
|||
bool startAtLaunch = false;
|
||||
bool stop = false;
|
||||
bool verbose = false;
|
||||
bool tansitionOverrideOverride = false;
|
||||
|
||||
int interval = DEFAULT_INTERVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -269,6 +269,19 @@ void SceneSwitcher::on_defaultTransitions_currentRowChanged(int idx)
|
|||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_transitionOverridecheckBox_stateChanged(int state)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
switcher->tansitionOverrideOverride = false;
|
||||
} else {
|
||||
switcher->tansitionOverrideOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
obs_weak_source_t *getNextTransition(obs_weak_source_t *scene1,
|
||||
obs_weak_source_t *scene2)
|
||||
{
|
||||
|
|
@ -283,6 +296,63 @@ obs_weak_source_t *getNextTransition(obs_weak_source_t *scene1,
|
|||
return ws;
|
||||
}
|
||||
|
||||
void overwriteTransitionOverride(obs_weak_source_t *sceneWs,
|
||||
obs_source_t *transition, transitionData &td)
|
||||
{
|
||||
obs_source_t *scene = obs_weak_source_get_source(sceneWs);
|
||||
obs_data_t *data = obs_source_get_private_settings(scene);
|
||||
|
||||
td.name = obs_data_get_string(data, "transition");
|
||||
td.duration = obs_data_get_int(data, "duration");
|
||||
|
||||
const char *name = obs_source_get_name(transition);
|
||||
int duration = obs_frontend_get_transition_duration();
|
||||
|
||||
obs_data_set_string(data, "transition", name);
|
||||
obs_data_set_int(data, "transition_duration", duration);
|
||||
|
||||
obs_data_release(data);
|
||||
obs_source_release(scene);
|
||||
}
|
||||
|
||||
void restoreTransitionOverride(obs_source_t *scene, transitionData td)
|
||||
{
|
||||
obs_data_t *data = obs_source_get_private_settings(scene);
|
||||
|
||||
obs_data_set_string(data, "transition", td.name.c_str());
|
||||
obs_data_set_int(data, "transition_duration", td.duration);
|
||||
|
||||
obs_data_release(data);
|
||||
}
|
||||
|
||||
void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
|
||||
OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride, transitionData &td)
|
||||
{
|
||||
obs_weak_source_t *currentScene =
|
||||
obs_source_get_weak_source(currentSource);
|
||||
obs_weak_source_t *nextTransitionWs =
|
||||
getNextTransition(currentScene, targetScene);
|
||||
obs_weak_source_release(currentScene);
|
||||
|
||||
obs_source_t *nextTransition = nullptr;
|
||||
if (nextTransitionWs) {
|
||||
nextTransition = obs_weak_source_get_source(nextTransitionWs);
|
||||
} else if (transition) {
|
||||
nextTransition = obs_weak_source_get_source(transition);
|
||||
}
|
||||
|
||||
if (nextTransition) {
|
||||
obs_frontend_set_current_transition(nextTransition);
|
||||
}
|
||||
|
||||
if (transitionOverrideOverride)
|
||||
overwriteTransitionOverride(targetScene, nextTransition, td);
|
||||
|
||||
obs_weak_source_release(nextTransitionWs);
|
||||
obs_source_release(nextTransition);
|
||||
}
|
||||
|
||||
void SwitcherData::saveSceneTransitions(obs_data_t *obj)
|
||||
{
|
||||
obs_data_array_t *sceneTransitionsArray = obs_data_array_create();
|
||||
|
|
@ -342,6 +412,9 @@ void SwitcherData::saveSceneTransitions(obs_data_t *obj)
|
|||
}
|
||||
obs_data_set_array(obj, "defaultTransitions", defaultTransitionsArray);
|
||||
obs_data_array_release(defaultTransitionsArray);
|
||||
|
||||
obs_data_set_bool(obj, "tansitionOverrideOverride",
|
||||
switcher->tansitionOverrideOverride);
|
||||
}
|
||||
|
||||
void SwitcherData::loadSceneTransitions(obs_data_t *obj)
|
||||
|
|
@ -397,4 +470,7 @@ void SwitcherData::loadSceneTransitions(obs_data_t *obj)
|
|||
obs_data_release(array_obj);
|
||||
}
|
||||
obs_data_array_release(defaultTransitionsArray);
|
||||
|
||||
switcher->tansitionOverrideOverride =
|
||||
obs_data_get_bool(obj, "tansitionOverrideOverride");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user