mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-27 19:56:07 -05:00
add no match delay option (#78)
This commit is contained in:
@@ -289,13 +289,23 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>If no switch condition is met</string>
|
||||
<string>If no switch condition is met for</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="noMatchDelay">
|
||||
<property name="suffix">
|
||||
<string>s</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.989999999990687</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -415,15 +415,7 @@ void SwitcherData::Thread()
|
||||
}
|
||||
}
|
||||
|
||||
if (!match && switchIfNotMatching == SWITCH &&
|
||||
nonMatchingScene) {
|
||||
match = true;
|
||||
scene = nonMatchingScene;
|
||||
transition = nullptr;
|
||||
}
|
||||
if (!match && switchIfNotMatching == RANDOM_SWITCH) {
|
||||
checkRandom(match, scene, transition, sleep);
|
||||
}
|
||||
checkNoMatchSwitch(match, scene, transition, sleep);
|
||||
|
||||
// After this point we will call frontend functions
|
||||
// obs_frontend_set_current_scene() and
|
||||
|
||||
@@ -56,6 +56,14 @@ void AdvSceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
ui->randomDisabledWarning->setVisible(false);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_noMatchDelay_valueChanged(double i)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->noMatchDelay = i;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_startupBehavior_currentIndexChanged(int index)
|
||||
{
|
||||
if (loading)
|
||||
@@ -450,6 +458,7 @@ void SwitcherData::saveGeneralSettings(obs_data_t *obj)
|
||||
nonMatchingSceneName.c_str());
|
||||
obs_data_set_int(obj, "switch_if_not_matching",
|
||||
switcher->switchIfNotMatching);
|
||||
obs_data_set_double(obj, "noMatchDelay", switcher->noMatchDelay);
|
||||
|
||||
obs_data_set_bool(obj, "active", !switcher->stop);
|
||||
obs_data_set_int(obj, "startup_behavior", switcher->startupBehavior);
|
||||
@@ -526,6 +535,7 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj)
|
||||
obs_data_get_string(obj, "non_matching_scene");
|
||||
switcher->nonMatchingScene =
|
||||
GetWeakSourceByName(nonMatchingScene.c_str());
|
||||
switcher->noMatchDelay = obs_data_get_double(obj, "noMatchDelay");
|
||||
|
||||
switcher->stop = !obs_data_get_bool(obj, "active");
|
||||
switcher->startupBehavior =
|
||||
@@ -636,6 +646,29 @@ void SwitcherData::loadGeneralSettings(obs_data_t *obj)
|
||||
(int)(obs_data_get_int(obj, "audioTabPos")));
|
||||
}
|
||||
|
||||
void SwitcherData::checkNoMatchSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &sleep)
|
||||
{
|
||||
if (match) {
|
||||
noMatchCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((noMatchCount * interval) / 1000.0 < noMatchDelay) {
|
||||
noMatchCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (switchIfNotMatching == SWITCH && nonMatchingScene) {
|
||||
match = true;
|
||||
scene = nonMatchingScene;
|
||||
transition = nullptr;
|
||||
}
|
||||
if (switchIfNotMatching == RANDOM_SWITCH) {
|
||||
checkRandom(match, scene, transition, sleep);
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::setupGeneralTab()
|
||||
{
|
||||
populateSceneSelection(ui->noMatchSwitchScene, false);
|
||||
@@ -654,6 +687,9 @@ void AdvSceneSwitcher::setupGeneralTab()
|
||||
}
|
||||
ui->noMatchSwitchScene->setCurrentText(
|
||||
GetWeakSourceName(switcher->nonMatchingScene).c_str());
|
||||
ui->noMatchDelay->setValue(switcher->noMatchDelay);
|
||||
ui->noMatchDelay->setToolTip(
|
||||
"Will only ever be as accurate as the configured check interval.");
|
||||
ui->checkInterval->setValue(switcher->interval);
|
||||
|
||||
ui->autoStopSceneCheckBox->setChecked(switcher->autoStopEnable);
|
||||
|
||||
@@ -86,6 +86,7 @@ public slots:
|
||||
void on_noMatchDontSwitch_clicked();
|
||||
void on_noMatchSwitch_clicked();
|
||||
void on_noMatchRandomSwitch_clicked();
|
||||
void on_noMatchDelay_valueChanged(double i);
|
||||
void on_startupBehavior_currentIndexChanged(int index);
|
||||
void on_noMatchSwitchScene_currentTextChanged(const QString &text);
|
||||
void on_checkInterval_valueChanged(int value);
|
||||
|
||||
@@ -63,6 +63,8 @@ struct SwitcherData {
|
||||
OBSWeakSource lastRandomScene;
|
||||
OBSWeakSource nonMatchingScene;
|
||||
NoMatch switchIfNotMatching = NO_SWITCH;
|
||||
double noMatchDelay;
|
||||
double noMatchCount = 0;
|
||||
StartupBehavior startupBehavior = PERSIST;
|
||||
|
||||
std::deque<WindowSwitch> windowSwitches;
|
||||
@@ -183,6 +185,8 @@ struct SwitcherData {
|
||||
OBSWeakSource &transition);
|
||||
void checkAudioSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkNoMatchSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &sleep);
|
||||
|
||||
void saveWindowTitleSwitches(obs_data_t *obj);
|
||||
void saveScreenRegionSwitches(obs_data_t *obj);
|
||||
|
||||
Reference in New Issue
Block a user