diff --git a/advanced-scene-switcher.cpp b/advanced-scene-switcher.cpp index fbf71072..14289360 100644 --- a/advanced-scene-switcher.cpp +++ b/advanced-scene-switcher.cpp @@ -177,12 +177,13 @@ SceneSwitcher::SceneSwitcher(QWidget* parent) string sceneName2 = GetWeakSourceName(s.scene2); string transitionName = GetWeakSourceName(s.transition); QString text = MakeSceneRoundTripSwitchName( - sceneName1.c_str(), sceneName2.c_str(), transitionName.c_str(), s.delay); + sceneName1.c_str(), sceneName2.c_str(), transitionName.c_str(), (double)s.delay / 1000); QListWidgetItem* item = new QListWidgetItem(text, ui->sceneRoundTrips); item->setData(Qt::UserRole, text); - if (s.delay * 1000 < smallestDelay) - smallestDelay = s.delay * 1000; + + if (s.delay < smallestDelay) + smallestDelay = s.delay; } (smallestDelay < switcher->interval) ? ui->intervalWarning->setVisible(true) : ui->intervalWarning->setVisible(false); @@ -386,7 +387,8 @@ static void SaveSceneSwitcher(obs_data_t* save_data, bool saving, void*) obs_data_set_string(array_obj, "sceneRoundTripScene1", sceneName1); obs_data_set_string(array_obj, "sceneRoundTripScene2", sceneName2); obs_data_set_string(array_obj, "transition", transitionName); - obs_data_set_int(array_obj, "sceneRoundTripDelay", s.delay); + obs_data_set_int(array_obj, "sceneRoundTripDelay", s.delay / 1000); + obs_data_set_int(array_obj, "sceneRoundTripDelayMs", s.delay % 1000); //extra value for ms to not destroy settings of old versions obs_data_set_string(array_obj, "sceneRoundTripStr", s.sceneRoundTripStr.c_str()); obs_data_array_push_back(sceneRoundTripArray, array_obj); obs_source_release(source1); @@ -655,6 +657,7 @@ static void SaveSceneSwitcher(obs_data_t* save_data, bool saving, void*) const char* scene2 = obs_data_get_string(array_obj, "sceneRoundTripScene2"); const char* transition = obs_data_get_string(array_obj, "transition"); int delay = obs_data_get_int(array_obj, "sceneRoundTripDelay"); + delay = delay * 1000 + obs_data_get_int(array_obj, "sceneRoundTripDelayMs"); //extra value for ms to not destroy settings of old versions const char* sceneRoundTripStr = obs_data_get_string(array_obj, "sceneRoundTripStr"); switcher->sceneRoundTripSwitches.emplace_back(GetWeakSourceByName(scene1), diff --git a/scene-round-trip.cpp b/scene-round-trip.cpp index 2794f606..1030ce4e 100644 --- a/scene-round-trip.cpp +++ b/scene-round-trip.cpp @@ -15,7 +15,7 @@ void SceneSwitcher::on_sceneRoundTripAdd_clicked() if (scene1Name.isEmpty() || scene2Name.isEmpty()) return; - int delay = ui->sceneRoundTripSpinBox->value(); + double delay = ui->sceneRoundTripSpinBox->value(); if (scene1Name == scene2Name) return; @@ -36,7 +36,7 @@ void SceneSwitcher::on_sceneRoundTripAdd_clicked() lock_guard lock(switcher->m); switcher->sceneRoundTripSwitches.emplace_back( - source1, source2, transition, delay, text.toUtf8().constData()); + source1, source2, transition, int(delay * 1000), text.toUtf8().constData()); } else { @@ -49,7 +49,7 @@ void SceneSwitcher::on_sceneRoundTripAdd_clicked() { if (s.scene1 == source1 && s.scene2 == source2) { - s.delay = delay; + s.delay = int(delay * 1000); s.transition = transition; s.sceneRoundTripStr = text.toUtf8().constData(); break; @@ -214,7 +214,7 @@ void SwitcherData::checkSceneRoundTrip(bool& match, OBSWeakSource& scene, OBSWea if (s.scene1 == ws) { sceneRoundTripActive = true; - int dur = s.delay * 1000 - interval; + int dur = s.delay - interval; if (dur > 0) { string s = obs_source_get_name(currentSource); @@ -261,7 +261,7 @@ void SceneSwitcher::on_sceneRoundTrips_currentRowChanged(int idx) ui->sceneRoundTripScenes1->setCurrentText(scene1.c_str()); ui->sceneRoundTripScenes2->setCurrentText(scene2.c_str()); ui->sceneRoundTripTransitions->setCurrentText(transitionName.c_str()); - ui->sceneRoundTripSpinBox->setValue(delay); + ui->sceneRoundTripSpinBox->setValue((double)delay/1000); break; } } diff --git a/utility.hpp b/utility.hpp index 5627a78a..2fec2530 100644 --- a/utility.hpp +++ b/utility.hpp @@ -43,7 +43,7 @@ static inline QString MakeScreenRegionSwitchName( } static inline QString MakeSceneRoundTripSwitchName( - const QString& scene1, const QString& scene2, const QString& transition, int delay) + const QString& scene1, const QString& scene2, const QString& transition, double delay) { return scene1 + QStringLiteral(" -> wait for ") + QString::number(delay) + QStringLiteral(" seconds -> ") + scene2 + QStringLiteral(" (using ") + transition