mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 04:11:06 -05:00
Add option to use transition overrides for transition changes (#164)
* Adjust switchScene() signature to support adjustActiveTransitionType and verbose parameters and only change the transition type if adjustActiveTransitionType, otherwise rely on transition overrides * Add new adjustActiveTransitionType checkbox * save and load adjustActiveTransitionType * Add check to either enable transition type change or use of transition overrides * Add locale * Adjust layout and locale
This commit is contained in:
@@ -552,7 +552,8 @@ void SwitcherData::Thread()
|
||||
server.sendMessage(scene, transition);
|
||||
}
|
||||
switchScene(scene, transition,
|
||||
tansitionOverrideOverride);
|
||||
tansitionOverrideOverride,
|
||||
adjustActiveTransitionType, verbose);
|
||||
}
|
||||
|
||||
writeSceneInfoToFile();
|
||||
@@ -619,9 +620,10 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene,
|
||||
}
|
||||
|
||||
void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride)
|
||||
bool transitionOverrideOverride,
|
||||
bool adjustActiveTransitionType, bool verbose)
|
||||
{
|
||||
if (!scene && switcher->verbose) {
|
||||
if (!scene && verbose) {
|
||||
blog(LOG_INFO, "nothing to switch to");
|
||||
return;
|
||||
}
|
||||
@@ -632,13 +634,14 @@ void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
if (source && source != currentSource) {
|
||||
transitionData td;
|
||||
setNextTransition(scene, currentSource, transition,
|
||||
transitionOverrideOverride, td);
|
||||
transitionOverrideOverride,
|
||||
adjustActiveTransitionType, td);
|
||||
obs_frontend_set_current_scene(source);
|
||||
if (transitionOverrideOverride) {
|
||||
restoreTransitionOverride(source, td);
|
||||
}
|
||||
|
||||
if (switcher->verbose) {
|
||||
if (verbose) {
|
||||
blog(LOG_INFO, "switched scene");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ public slots:
|
||||
void on_defaultTransitionsUp_clicked();
|
||||
void on_defaultTransitionsDown_clicked();
|
||||
void on_transitionOverridecheckBox_stateChanged(int state);
|
||||
void on_adjustActiveTransitionType_stateChanged(int state);
|
||||
void defTransitionDelayValueChanged(int value);
|
||||
|
||||
void on_browseButton_clicked();
|
||||
@@ -287,12 +288,14 @@ bool isInFocus(const QString &executable);
|
||||
|
||||
void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
|
||||
OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride, transitionData &td);
|
||||
bool transitionOverrideOverride,
|
||||
bool adjustActiveTransitionType, 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);
|
||||
bool transitionOverrideOverride,
|
||||
bool adjustActiveTransitionType, bool verbose);
|
||||
|
||||
/******************************************************************************
|
||||
* Main SwitcherData
|
||||
|
||||
@@ -62,6 +62,7 @@ struct SwitcherData {
|
||||
bool disableHints = false;
|
||||
bool showFrame = false;
|
||||
bool tansitionOverrideOverride = false;
|
||||
bool adjustActiveTransitionType = true;
|
||||
|
||||
int interval = default_interval;
|
||||
|
||||
|
||||
@@ -268,7 +268,8 @@ std::string processMessage(std::string payload)
|
||||
"'";
|
||||
}
|
||||
|
||||
switchScene(scene, transition, switcher->tansitionOverrideOverride);
|
||||
switchScene(scene, transition, switcher->tansitionOverrideOverride,
|
||||
switcher->adjustActiveTransitionType, switcher->verbose);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,12 +182,31 @@ void AdvSceneSwitcher::on_transitionOverridecheckBox_stateChanged(int state)
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
switcher->tansitionOverrideOverride = false;
|
||||
} else {
|
||||
switcher->tansitionOverrideOverride = true;
|
||||
if (!state && !switcher->adjustActiveTransitionType) {
|
||||
DisplayMessage(obs_module_text(
|
||||
"AdvSceneSwitcher.transitionTab.transitionBehaviorSelectionError"));
|
||||
ui->adjustActiveTransitionType->setChecked(true);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->tansitionOverrideOverride = state;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_adjustActiveTransitionType_stateChanged(int state)
|
||||
{
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This option only makes sense if we are allowed to use transition overrides
|
||||
if (!state && !switcher->tansitionOverrideOverride) {
|
||||
DisplayMessage(obs_module_text(
|
||||
"AdvSceneSwitcher.transitionTab.transitionBehaviorSelectionError"));
|
||||
ui->transitionOverridecheckBox->setChecked(true);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->adjustActiveTransitionType = state;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::defTransitionDelayValueChanged(int value)
|
||||
@@ -251,7 +270,8 @@ void restoreTransitionOverride(obs_source_t *scene, transitionData td)
|
||||
|
||||
void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
|
||||
OBSWeakSource &transition,
|
||||
bool &transitionOverrideOverride, transitionData &td)
|
||||
bool transitionOverrideOverride,
|
||||
bool adjustActiveTransitionType, transitionData &td)
|
||||
{
|
||||
obs_weak_source_t *currentScene =
|
||||
obs_source_get_weak_source(currentSource);
|
||||
@@ -266,7 +286,7 @@ void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
|
||||
nextTransition = obs_weak_source_get_source(transition);
|
||||
}
|
||||
|
||||
if (nextTransition) {
|
||||
if (nextTransition && adjustActiveTransitionType) {
|
||||
obs_frontend_set_current_transition(nextTransition);
|
||||
}
|
||||
|
||||
@@ -334,6 +354,8 @@ void SwitcherData::saveSceneTransitions(obs_data_t *obj)
|
||||
|
||||
obs_data_set_bool(obj, "tansitionOverrideOverride",
|
||||
switcher->tansitionOverrideOverride);
|
||||
obs_data_set_bool(obj, "adjustActiveTransitionType",
|
||||
switcher->adjustActiveTransitionType);
|
||||
obs_data_set_default_int(obj, "defTransitionDelay",
|
||||
default_def_transition_dealy);
|
||||
obs_data_set_int(obj, "defTransitionDelay",
|
||||
@@ -390,6 +412,8 @@ void SwitcherData::loadSceneTransitions(obs_data_t *obj)
|
||||
|
||||
switcher->tansitionOverrideOverride =
|
||||
obs_data_get_bool(obj, "tansitionOverrideOverride");
|
||||
switcher->adjustActiveTransitionType =
|
||||
obs_data_get_bool(obj, "adjustActiveTransitionType");
|
||||
DefaultSceneTransition::delay =
|
||||
obs_data_get_int(obj, "defTransitionDelay");
|
||||
}
|
||||
@@ -430,6 +454,8 @@ void AdvSceneSwitcher::setupTransitionsTab()
|
||||
|
||||
ui->transitionOverridecheckBox->setChecked(
|
||||
switcher->tansitionOverrideOverride);
|
||||
ui->adjustActiveTransitionType->setChecked(
|
||||
switcher->adjustActiveTransitionType);
|
||||
|
||||
QSpinBox *defTransitionDelay = new QSpinBox();
|
||||
defTransitionDelay->setSuffix("ms");
|
||||
|
||||
Reference in New Issue
Block a user