Add option "has changed" to video tab (#168)

This commit is contained in:
WarmUpTill 2021-04-22 11:51:35 -07:00 committed by GitHub
parent e4bf5fa749
commit 45fa4dac8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View File

@ -215,6 +215,7 @@ AdvSceneSwitcher.videoTab.condition.match="genau übereinstimmt mit"
AdvSceneSwitcher.videoTab.condition.match.tooltip="Eine genaue Übereinstimmung setzt voraus, dass sowohl Zielquelle als auch das Bild die gleiche Auflösung besitzen.\nZusätzlich muss jeder einzelne Pixel zwischen beiden Bildquellen übereinstimmen weshalb Bildformate, welche das Bild komprimieren (z. B. .JPG) nicht zu empfehlen sind."
AdvSceneSwitcher.videoTab.condition.differ="nicht übereinstimmt mit"
AdvSceneSwitcher.videoTab.condition.hasNotChanged="sich nicht verändert"
AdvSceneSwitcher.videoTab.condition.hasNotChanged="sich verändert"
AdvSceneSwitcher.videoTab.ignoreInactiveSource="außer Video Quelle ist inaktiv"
AdvSceneSwitcher.videoTab.entry="Wenn {{videoSources}} {{condition}} {{filePath}} {{browseButton}} für {{duration}} wechsle zu {{scenes}} mit {{transitions}} {{ignoreInactiveSource}}"
AdvSceneSwitcher.videoTab.help="<html><head/><body><p>Dieser Tab ermöglicht es basierend auf der Videoausgabe von Quellen scenen zu wechseln.<br/>Für eine noch bessere Implementierung dieser Funktionalität siehe <a href=\"https://obsproject.com/forum/resources/pixel-match-switcher.1202/\"><span style=\" text-decoration: underline; color:#268bd2;\">Pixel Match Switcher</span></a>.<br/><br/>Klicke auf das markierte Plus Symbol, um einen neuen Eintrag hinzuzufügen..</p></body></html>"

View File

@ -215,6 +215,7 @@ AdvSceneSwitcher.videoTab.condition.match="exactly matches"
AdvSceneSwitcher.videoTab.condition.match.tooltip="An exact match requires the target and the source image to be of the same resolution.\nAdditionally every single pixel needs to match, which is why use of image formats which use compression (e.g. .JPG) is not recommended!"
AdvSceneSwitcher.videoTab.condition.differ="does not match"
AdvSceneSwitcher.videoTab.condition.hasNotChanged="has not changed"
AdvSceneSwitcher.videoTab.condition.hasChanged="has changed"
AdvSceneSwitcher.videoTab.ignoreInactiveSource="unless source is inactive"
AdvSceneSwitcher.videoTab.entry="When {{videoSources}} {{condition}} {{filePath}} {{browseButton}} for {{duration}} switch to {{scenes}} using {{transitions}} {{ignoreInactiveSource}}"
AdvSceneSwitcher.videoTab.help="<html><head/><body><p>This tab will allow you to switch scenes based on the current video output of selected sources.<br/>Make sure to check out <a href=\"https://obsproject.com/forum/resources/pixel-match-switcher.1202/\"><span style=\" text-decoration: underline; color:#268bd2;\">Pixel Match Switcher</span></a> for an even better implementation of this functionality.<br/><br/> Click on the highlighted plus symbol to continue.</p></body></html>"

View File

@ -10,6 +10,7 @@ enum class videoSwitchType {
MATCH,
DIFFER,
HAS_NOT_CHANGED,
HAS_CHANGED,
};
class AdvSSScreenshotObj {

View File

@ -355,6 +355,11 @@ void VideoSwitch::save(obs_data_t *obj)
obs_data_set_bool(obj, "ignoreInactiveSource", ignoreInactiveSource);
}
bool requiresFileInput(videoSwitchType t)
{
return t == videoSwitchType::MATCH || t == videoSwitchType::DIFFER;
}
void VideoSwitch::load(obs_data_t *obj)
{
SceneSwitcherEntry::load(obj);
@ -367,7 +372,7 @@ void VideoSwitch::load(obs_data_t *obj)
file = obs_data_get_string(obj, "filePath");
ignoreInactiveSource = obs_data_get_bool(obj, "ignoreInactiveSource");
if (condition != videoSwitchType::HAS_NOT_CHANGED) {
if (requiresFileInput(condition)) {
(void)loadImageFromFile();
}
}
@ -423,6 +428,10 @@ bool VideoSwitch::checkMatch()
conditionMatch = screenshotData->image ==
matchImage;
break;
case videoSwitchType::HAS_CHANGED:
conditionMatch = screenshotData->image !=
matchImage;
break;
default:
break;
}
@ -444,7 +453,7 @@ bool VideoSwitch::checkMatch()
match = true;
}
if (condition == videoSwitchType::HAS_NOT_CHANGED) {
if (!requiresFileInput(condition)) {
matchImage = std::move(screenshotData->image);
}
previousTime = std::move(screenshotData->time);
@ -480,6 +489,8 @@ static inline void populateConditionSelection(QComboBox *list)
obs_module_text("AdvSceneSwitcher.videoTab.condition.differ"));
list->addItem(obs_module_text(
"AdvSceneSwitcher.videoTab.condition.hasNotChanged"));
list->addItem(obs_module_text(
"AdvSceneSwitcher.videoTab.condition.hasChanged"));
}
VideoSwitchWidget::VideoSwitchWidget(QWidget *parent, VideoSwitch *s)
@ -530,7 +541,7 @@ VideoSwitchWidget::VideoSwitchWidget(QWidget *parent, VideoSwitch *s)
filePath->setText(QString::fromStdString(s->file));
ignoreInactiveSource->setChecked(s->ignoreInactiveSource);
if (s->condition == videoSwitchType::HAS_NOT_CHANGED) {
if (!requiresFileInput(s->condition)) {
filePath->hide();
browseButton->hide();
}
@ -582,8 +593,7 @@ void VideoSwitchWidget::swapSwitchData(VideoSwitchWidget *s1,
void VideoSwitchWidget::UpdatePreviewTooltip()
{
if (!switchData ||
switchData->condition == videoSwitchType::HAS_NOT_CHANGED) {
if (!switchData || !requiresFileInput(switchData->condition)) {
return;
}
@ -627,12 +637,12 @@ void VideoSwitchWidget::ConditionChanged(int cond)
std::lock_guard<std::mutex> lock(switcher->m);
switchData->condition = static_cast<videoSwitchType>(cond);
if (switchData->condition == videoSwitchType::HAS_NOT_CHANGED) {
filePath->hide();
browseButton->hide();
} else {
if (requiresFileInput(switchData->condition)) {
filePath->show();
browseButton->show();
} else {
filePath->hide();
browseButton->hide();
}
// Reload image data to avoid incorrect matches.