mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-17 07:07:15 -05:00
Adjust function signature
Don't pass bool by reference if not necessary.
This commit is contained in:
parent
acf1ae63aa
commit
139df8a641
|
|
@ -568,7 +568,7 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene,
|
|||
bool match = false;
|
||||
|
||||
if (uninterruptibleSceneSequenceActive) {
|
||||
checkSceneSequence(match, scene, transition, linger);
|
||||
match = checkSceneSequence(scene, transition, linger);
|
||||
if (match) {
|
||||
return match;
|
||||
}
|
||||
|
|
@ -577,35 +577,35 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene,
|
|||
for (int switchFuncName : functionNamesByPriority) {
|
||||
switch (switchFuncName) {
|
||||
case read_file_func:
|
||||
checkSwitchInfoFromFile(match, scene, transition);
|
||||
checkFileContent(match, scene, transition);
|
||||
match = checkSwitchInfoFromFile(scene, transition);
|
||||
match = checkFileContent(scene, transition);
|
||||
break;
|
||||
case idle_func:
|
||||
checkIdleSwitch(match, scene, transition);
|
||||
match = checkIdleSwitch(scene, transition);
|
||||
break;
|
||||
case exe_func:
|
||||
checkExeSwitch(match, scene, transition);
|
||||
match = checkExeSwitch(scene, transition);
|
||||
break;
|
||||
case screen_region_func:
|
||||
checkScreenRegionSwitch(match, scene, transition);
|
||||
match = checkScreenRegionSwitch(scene, transition);
|
||||
break;
|
||||
case window_title_func:
|
||||
checkWindowTitleSwitch(match, scene, transition);
|
||||
match = checkWindowTitleSwitch(scene, transition);
|
||||
break;
|
||||
case round_trip_func:
|
||||
checkSceneSequence(match, scene, transition, linger);
|
||||
match = checkSceneSequence(scene, transition, linger);
|
||||
break;
|
||||
case media_func:
|
||||
checkMediaSwitch(match, scene, transition);
|
||||
match = checkMediaSwitch(scene, transition);
|
||||
break;
|
||||
case time_func:
|
||||
checkTimeSwitch(match, scene, transition);
|
||||
match = checkTimeSwitch(scene, transition);
|
||||
break;
|
||||
case audio_func:
|
||||
checkAudioSwitch(match, scene, transition);
|
||||
match = checkAudioSwitch(scene, transition);
|
||||
break;
|
||||
case video_func:
|
||||
checkVideoSwitch(match, scene, transition);
|
||||
match = checkVideoSwitch(scene, transition);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -709,7 +709,7 @@ void SwitcherData::checkNoMatchSwitch(bool &match, OBSWeakSource &scene,
|
|||
transition = nullptr;
|
||||
}
|
||||
if (switchIfNotMatching == RANDOM_SWITCH) {
|
||||
checkRandom(match, scene, transition, sleep);
|
||||
match = checkRandom(scene, transition, sleep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,32 +189,25 @@ struct SwitcherData {
|
|||
|
||||
bool checkForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &linger);
|
||||
void checkSceneSequence(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &linger);
|
||||
void checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool checkSceneSequence(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &linger);
|
||||
bool checkIdleSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
bool checkWindowTitleSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkExeSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool checkExeSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
bool checkScreenRegionSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkSwitchInfoFromFile(bool &match, OBSWeakSource &scene,
|
||||
bool checkSwitchInfoFromFile(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkFileContent(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkRandom(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &delay);
|
||||
void checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkTimeSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkAudioSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
bool checkFileContent(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
bool checkRandom(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &delay);
|
||||
bool checkMediaSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
bool checkTimeSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
bool checkAudioSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
void checkAudioSwitchFallback(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkVideoSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
bool checkVideoSwitch(OBSWeakSource &scene, OBSWeakSource &transition);
|
||||
void checkNoMatchSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &sleep);
|
||||
void checkSwitchCooldown(bool &match);
|
||||
|
|
|
|||
|
|
@ -111,13 +111,14 @@ void SwitcherData::checkAudioSwitchFallback(OBSWeakSource &scene,
|
|||
audioFallback.matchCount++;
|
||||
}
|
||||
|
||||
void SwitcherData::checkAudioSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkAudioSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (AudioSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
bool fallbackChecked = false; // false if only one or no match
|
||||
|
||||
for (AudioSwitch &s : audioSwitches) {
|
||||
|
|
@ -185,6 +186,8 @@ void SwitcherData::checkAudioSwitch(bool &match, OBSWeakSource &scene,
|
|||
if (!fallbackChecked) {
|
||||
audioFallback.matchCount = 0;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveAudioSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -77,16 +77,17 @@ void AdvSceneSwitcher::on_executableDown_clicked()
|
|||
switcher->executableSwitches[index + 1]);
|
||||
}
|
||||
|
||||
void SwitcherData::checkExeSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkExeSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (executableSwitches.size() == 0 || ExecutableSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string title;
|
||||
QStringList runningProcesses;
|
||||
bool ignored = false;
|
||||
bool match = false;
|
||||
|
||||
// Check if current window is ignored
|
||||
GetCurrentWindowTitle(title);
|
||||
|
|
@ -135,6 +136,8 @@ void SwitcherData::checkExeSwitch(bool &match, OBSWeakSource &scene,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveExecutableSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -115,19 +115,20 @@ void SwitcherData::writeToStatusFile(QString msg)
|
|||
file.close();
|
||||
}
|
||||
|
||||
void SwitcherData::checkSwitchInfoFromFile(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkSwitchInfoFromFile(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (!fileIO.readEnabled || fileIO.readPath.empty() ||
|
||||
FileSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(QString::fromStdString(fileIO.readPath));
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
QTextStream in(&file);
|
||||
|
||||
QString sceneStr = in.readLine();
|
||||
|
|
@ -149,6 +150,8 @@ void SwitcherData::checkSwitchInfoFromFile(bool &match, OBSWeakSource &scene,
|
|||
fileIO.readPath.c_str());
|
||||
}
|
||||
file.close();
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
static size_t WriteCallback(void *contents, size_t size, size_t nmemb,
|
||||
|
|
@ -247,13 +250,14 @@ bool checkLocalFileContent(FileSwitch &s)
|
|||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::checkFileContent(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkFileContent(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (FileSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
for (FileSwitch &s : fileSwitches) {
|
||||
if (!s.initialized()) {
|
||||
continue;
|
||||
|
|
@ -277,6 +281,7 @@ void SwitcherData::checkFileContent(bool &match, OBSWeakSource &scene,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_fileAdd_clicked()
|
||||
|
|
|
|||
|
|
@ -6,16 +6,17 @@
|
|||
bool IdleData::pause = false;
|
||||
IdleWidget *idleWidget = nullptr;
|
||||
|
||||
void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkIdleSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (!idleData.idleEnable || IdleData::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string title;
|
||||
bool ignoreIdle = false;
|
||||
GetCurrentWindowTitle(title);
|
||||
bool match = false;
|
||||
|
||||
for (std::string &window : ignoreIdleWindows) {
|
||||
if (window == title) {
|
||||
|
|
@ -40,7 +41,7 @@ void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
|||
|
||||
if (!ignoreIdle && secondsSinceLastInput() > idleData.time) {
|
||||
if (idleData.alreadySwitched) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
scene = idleData.getScene();
|
||||
transition = idleData.transition;
|
||||
|
|
@ -50,8 +51,11 @@ void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
|||
if (verbose) {
|
||||
idleData.logMatch();
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
idleData.alreadySwitched = false;
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_idleCheckBox_stateChanged(int state)
|
||||
|
|
|
|||
|
|
@ -80,13 +80,14 @@ void AdvSceneSwitcher::on_mediaDown_clicked()
|
|||
switcher->mediaSwitches[index + 1]);
|
||||
}
|
||||
|
||||
void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkMediaSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (MediaSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
for (MediaSwitch &mediaSwitch : mediaSwitches) {
|
||||
if (!mediaSwitch.initialized()) {
|
||||
continue;
|
||||
|
|
@ -196,6 +197,7 @@ void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveMediaSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -36,17 +36,18 @@ void AdvSceneSwitcher::on_randomRemove_clicked()
|
|||
delete item;
|
||||
}
|
||||
|
||||
void SwitcherData::checkRandom(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &delay)
|
||||
bool SwitcherData::checkRandom(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &delay)
|
||||
{
|
||||
if (randomSwitches.size() == 0 || RandomSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::deque<RandomSwitch> rs(randomSwitches);
|
||||
std::random_device rng;
|
||||
std::mt19937 urng(rng());
|
||||
std::shuffle(rs.begin(), rs.end(), urng);
|
||||
bool match = false;
|
||||
for (RandomSwitch &r : rs) {
|
||||
if (!r.initialized()) {
|
||||
continue;
|
||||
|
|
@ -75,6 +76,7 @@ void SwitcherData::checkRandom(bool &match, OBSWeakSource &scene,
|
|||
}
|
||||
break;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveRandomSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -151,15 +151,16 @@ bool shouldIgnoreSceneSwitch(ScreenRegionSwitch &matchingRegion)
|
|||
return matchingRegion.excludeScene == ws;
|
||||
}
|
||||
|
||||
void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkScreenRegionSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (ScreenRegionSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<int, int> cursorPos = getCursorPos();
|
||||
int minRegionSize = 99999;
|
||||
bool match = false;
|
||||
|
||||
for (auto &s : screenRegionSwitches) {
|
||||
if (!s.initialized()) {
|
||||
|
|
@ -173,7 +174,7 @@ void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
|||
if (shouldIgnoreSceneSwitch(s)) {
|
||||
// We technically have a match.
|
||||
// But just ignore it.
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
match = true;
|
||||
scene = s.getScene();
|
||||
|
|
@ -187,6 +188,7 @@ void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
|||
}
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::updateScreenRegionCursorPos()
|
||||
|
|
|
|||
|
|
@ -179,16 +179,17 @@ void AdvSceneSwitcher::on_sceneSequenceSwitches_itemDoubleClicked(
|
|||
OpenSequenceExtendEdit(currentWidget);
|
||||
}
|
||||
|
||||
void SwitcherData::checkSceneSequence(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkSceneSequence(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition, int &linger)
|
||||
{
|
||||
if (SceneSequenceSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
obs_source_t *currentSceneSource = obs_frontend_get_current_scene();
|
||||
obs_weak_source_t *currentScene =
|
||||
obs_source_get_weak_source(currentSceneSource);
|
||||
bool match = false;
|
||||
|
||||
for (SceneSequenceSwitch &s : sceneSequenceSwitches) {
|
||||
// Continue the active uninterruptible sequence and skip others
|
||||
|
|
@ -233,6 +234,8 @@ void SwitcherData::checkSceneSequence(bool &match, OBSWeakSource &scene,
|
|||
|
||||
obs_source_release(currentSceneSource);
|
||||
obs_weak_source_release(currentScene);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveSceneSequenceSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -113,13 +113,14 @@ bool checkRegularTime(TimeSwitch &s, int &interval)
|
|||
return timesAreInInterval(s.time, now, interval);
|
||||
}
|
||||
|
||||
void SwitcherData::checkTimeSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkTimeSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (TimeSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
for (TimeSwitch &s : timeSwitches) {
|
||||
if (!s.initialized()) {
|
||||
continue;
|
||||
|
|
@ -142,6 +143,7 @@ void SwitcherData::checkTimeSwitch(bool &match, OBSWeakSource &scene,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveTimeSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -257,13 +257,14 @@ void AdvSceneSwitcher::on_getScreenshot_clicked()
|
|||
sw->SetFilePath(file.fileName());
|
||||
}
|
||||
|
||||
void SwitcherData::checkVideoSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkVideoSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (VideoSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
for (auto &s : videoSwitches) {
|
||||
bool matched = s.checkMatch();
|
||||
if (!match && matched) {
|
||||
|
|
@ -275,6 +276,7 @@ void SwitcherData::checkVideoSwitch(bool &match, OBSWeakSource &scene,
|
|||
}
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveVideoSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
|
|
@ -214,15 +214,16 @@ void checkWindowTitleSwitchRegex(WindowSwitch &s,
|
|||
}
|
||||
}
|
||||
|
||||
void SwitcherData::checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,
|
||||
bool SwitcherData::checkWindowTitleSwitch(OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
if (WindowSwitch::pause) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string currentWindowTitle;
|
||||
GetCurrentWindowTitle(currentWindowTitle);
|
||||
bool match = false;
|
||||
|
||||
// Check if current window is ignored
|
||||
for (auto &window : ignoreWindowsSwitches) {
|
||||
|
|
@ -268,6 +269,7 @@ void SwitcherData::checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
void SwitcherData::saveWindowTitleSwitches(obs_data_t *obj)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user