mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-05-09 04:32:13 -05:00
Add option to keep source of video condition active
This commit is contained in:
parent
145e5d3fff
commit
5feff07134
|
|
@ -118,12 +118,28 @@ MacroConditionVideo::MacroConditionVideo(Macro *m)
|
|||
{
|
||||
}
|
||||
|
||||
void MacroConditionVideo::UpdateActiveKeeper()
|
||||
{
|
||||
_activeKeeper.SetActive(_keepActive);
|
||||
if (_video.type == VideoInput::Type::OBS_MAIN_OUTPUT) {
|
||||
return;
|
||||
}
|
||||
auto videoSource = _video.GetVideo();
|
||||
if (videoSource == _lastActiveKeeperSource) {
|
||||
return;
|
||||
}
|
||||
_lastActiveKeeperSource = videoSource;
|
||||
_activeKeeper.SetSource(OBSGetStrongRef(videoSource));
|
||||
}
|
||||
|
||||
bool MacroConditionVideo::CheckCondition()
|
||||
{
|
||||
if (!_video.ValidSelection()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateActiveKeeper();
|
||||
|
||||
bool match = false;
|
||||
if (CheckShouldBeSkipped()) {
|
||||
return _lastMatchResult;
|
||||
|
|
@ -159,6 +175,7 @@ bool MacroConditionVideo::Save(obs_data_t *obj) const
|
|||
{
|
||||
MacroCondition::Save(obj);
|
||||
_video.Save(obj);
|
||||
obs_data_set_bool(obj, "keepActive", _keepActive);
|
||||
obs_data_set_int(obj, "condition", static_cast<int>(_condition));
|
||||
obs_data_set_string(obj, "filePath", _file.c_str());
|
||||
obs_data_set_bool(obj, "blockUntilScreenshotDone",
|
||||
|
|
@ -178,6 +195,7 @@ bool MacroConditionVideo::Load(obs_data_t *obj)
|
|||
{
|
||||
MacroCondition::Load(obj);
|
||||
_video.Load(obj);
|
||||
_keepActive = obs_data_get_bool(obj, "keepActive");
|
||||
SetCondition(static_cast<VideoCondition>(
|
||||
obs_data_get_int(obj, "condition")));
|
||||
_file = obs_data_get_string(obj, "filePath");
|
||||
|
|
@ -1233,7 +1251,12 @@ MacroConditionVideoEdit::MacroConditionVideoEdit(
|
|||
_area(new AreaEdit(this, &_previewDialog, entryData)),
|
||||
_throttleControlLayout(new QHBoxLayout),
|
||||
_throttleEnable(new QCheckBox()),
|
||||
_throttleCount(new QSpinBox())
|
||||
_throttleCount(new QSpinBox()),
|
||||
_keepActive(new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.keepSourceActive"))),
|
||||
_keepActiveHelp(new HelpIcon(
|
||||
obs_module_text("AdvSceneSwitcher.keepSourceActive.help"),
|
||||
this))
|
||||
{
|
||||
_reduceLatency->setToolTip(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.video.reduceLatency.tooltip"));
|
||||
|
|
@ -1290,6 +1313,8 @@ MacroConditionVideoEdit::MacroConditionVideoEdit(
|
|||
SLOT(ThrottleEnableChanged(int)));
|
||||
QWidget::connect(_throttleCount, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(ThrottleCountChanged(int)));
|
||||
QWidget::connect(_keepActive, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(KeepActiveChanged(int)));
|
||||
QWidget::connect(_showMatch, SIGNAL(clicked()), this,
|
||||
SLOT(ShowMatchClicked()));
|
||||
QWidget::connect(this,
|
||||
|
|
@ -1334,6 +1359,11 @@ MacroConditionVideoEdit::MacroConditionVideoEdit(
|
|||
"AdvSceneSwitcher.condition.video.layout.throttle"),
|
||||
_throttleControlLayout, widgetPlaceholders);
|
||||
|
||||
QHBoxLayout *keepActiveLayout = new QHBoxLayout;
|
||||
keepActiveLayout->addWidget(_keepActive);
|
||||
keepActiveLayout->addWidget(_keepActiveHelp);
|
||||
keepActiveLayout->addStretch();
|
||||
|
||||
QHBoxLayout *showMatchLayout = new QHBoxLayout;
|
||||
showMatchLayout->addWidget(_showMatch);
|
||||
showMatchLayout->addStretch();
|
||||
|
|
@ -1349,6 +1379,7 @@ MacroConditionVideoEdit::MacroConditionVideoEdit(
|
|||
mainLayout->addWidget(_color);
|
||||
mainLayout->addLayout(_throttleControlLayout);
|
||||
mainLayout->addWidget(_area);
|
||||
mainLayout->addLayout(keepActiveLayout);
|
||||
mainLayout->addWidget(_reduceLatency);
|
||||
mainLayout->addLayout(showMatchLayout);
|
||||
setLayout(mainLayout);
|
||||
|
|
@ -1569,6 +1600,12 @@ void MacroConditionVideoEdit::ThrottleCountChanged(int value)
|
|||
_entryData->_throttleCount = value / GetIntervalValue();
|
||||
}
|
||||
|
||||
void MacroConditionVideoEdit::KeepActiveChanged(int value)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_keepActive = value;
|
||||
}
|
||||
|
||||
void MacroConditionVideoEdit::ShowMatchClicked()
|
||||
{
|
||||
_previewDialog.show();
|
||||
|
|
@ -1634,6 +1671,11 @@ void MacroConditionVideoEdit::SetWidgetVisibility()
|
|||
needsThrottleControls(_entryData->GetCondition()));
|
||||
_area->setVisible(needsAreaControls(_entryData->GetCondition()));
|
||||
|
||||
const bool sourceOrScene = _entryData->_video.type !=
|
||||
VideoInput::Type::OBS_MAIN_OUTPUT;
|
||||
_keepActive->setVisible(sourceOrScene);
|
||||
_keepActiveHelp->setVisible(sourceOrScene);
|
||||
|
||||
if (_entryData->GetCondition() == VideoCondition::HAS_CHANGED ||
|
||||
_entryData->GetCondition() == VideoCondition::HAS_NOT_CHANGED) {
|
||||
_patternThreshold->setVisible(
|
||||
|
|
@ -1700,6 +1742,7 @@ void MacroConditionVideoEdit::UpdateEntryData()
|
|||
_throttleEnable->setChecked(_entryData->_throttleEnabled);
|
||||
_throttleCount->setValue(_entryData->_throttleCount *
|
||||
GetIntervalValue());
|
||||
_keepActive->setChecked(_entryData->_keepActive);
|
||||
UpdatePreviewTooltip();
|
||||
SetupPreviewDialogParams();
|
||||
SetWidgetVisibility();
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@
|
|||
#include "parameter-wrappers.hpp"
|
||||
#include "preview-dialog.hpp"
|
||||
|
||||
#include <help-icon.hpp>
|
||||
#include <macro-condition-edit.hpp>
|
||||
#include <file-selection.hpp>
|
||||
#include <screenshot-helper.hpp>
|
||||
#include <slider-spinbox.hpp>
|
||||
#include <source-helpers.hpp>
|
||||
#include <variable-line-edit.hpp>
|
||||
#include <variable-text-edit.hpp>
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ public:
|
|||
void SetupTempVars();
|
||||
|
||||
VideoInput _video;
|
||||
bool _keepActive = false;
|
||||
std::string _file = obs_module_text("AdvSceneSwitcher.enterPath");
|
||||
// Enabling this will reduce matching latency, but slow down the
|
||||
// the condition checks of all macros overall.
|
||||
|
|
@ -80,6 +83,7 @@ signals:
|
|||
|
||||
private:
|
||||
bool FileInputIsUpToDate() const;
|
||||
void UpdateActiveKeeper();
|
||||
|
||||
bool OutputChanged();
|
||||
bool ScreenshotContainsPattern();
|
||||
|
|
@ -92,6 +96,8 @@ private:
|
|||
|
||||
VideoCondition _condition = VideoCondition::MATCH;
|
||||
|
||||
SourceActiveKeeper _activeKeeper;
|
||||
OBSWeakSource _lastActiveKeeperSource;
|
||||
bool _getNextScreenshot = true;
|
||||
Screenshot _screenshotData;
|
||||
QImage _matchImage;
|
||||
|
|
@ -285,6 +291,7 @@ private slots:
|
|||
void ThrottleEnableChanged(int value);
|
||||
void ThrottleCountChanged(int value);
|
||||
void ShowMatchClicked();
|
||||
void KeepActiveChanged(int value);
|
||||
|
||||
void SetWidgetVisibility();
|
||||
void Resize();
|
||||
|
|
@ -326,6 +333,9 @@ private:
|
|||
QCheckBox *_throttleEnable;
|
||||
QSpinBox *_throttleCount;
|
||||
|
||||
QCheckBox *_keepActive;
|
||||
HelpIcon *_keepActiveHelp;
|
||||
|
||||
std::shared_ptr<MacroConditionVideo> _entryData;
|
||||
bool _loading = true;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user