mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 09:54:54 -05:00
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
* always -> same as old behavior, if "on change" was disabled * results changes -> same as old behavior, if "on change" was enabled * any condition changes * any condition changes and evaluates to true
116 lines
2.4 KiB
C++
116 lines
2.4 KiB
C++
#include "macro-condition.hpp"
|
|
|
|
namespace advss {
|
|
|
|
MacroCondition::MacroCondition(Macro *m, bool supportsVariableValue)
|
|
: MacroSegment(m, supportsVariableValue)
|
|
{
|
|
}
|
|
|
|
bool MacroCondition::EvaluateCondition()
|
|
{
|
|
bool newValue = CheckCondition();
|
|
_changed = _previousValue.has_value() && (*_previousValue != newValue);
|
|
const bool negate = _logic.IsNegationType(GetLogicType());
|
|
_risingEdge = _changed &&
|
|
((!negate && newValue) || (negate && !newValue));
|
|
_previousValue = newValue;
|
|
return newValue;
|
|
}
|
|
|
|
bool MacroCondition::Save(obs_data_t *obj) const
|
|
{
|
|
MacroSegment::Save(obj);
|
|
obs_data_set_string(obj, "id", GetId().c_str());
|
|
_logic.Save(obj, "logic");
|
|
_durationModifier.Save(obj);
|
|
return true;
|
|
}
|
|
|
|
bool MacroCondition::Load(obs_data_t *obj)
|
|
{
|
|
MacroSegment::Load(obj);
|
|
_logic.Load(obj, "logic");
|
|
_durationModifier.Load(obj);
|
|
return true;
|
|
}
|
|
|
|
void MacroCondition::ValidateLogicSelection(bool isRootCondition,
|
|
const char *context)
|
|
{
|
|
if (_logic.IsValidSelection(isRootCondition)) {
|
|
return;
|
|
}
|
|
|
|
if (_logic.IsRootType()) {
|
|
_logic.SetType(Logic::Type::ROOT_NONE);
|
|
blog(LOG_WARNING,
|
|
"setting invalid logic selection to 'if' for macro %s",
|
|
context);
|
|
return;
|
|
}
|
|
|
|
_logic.SetType(Logic::Type::NONE);
|
|
blog(LOG_WARNING,
|
|
"setting invalid logic selection to 'ignore' for macro %s",
|
|
context);
|
|
}
|
|
|
|
void MacroCondition::ResetDuration()
|
|
{
|
|
_durationModifier.ResetDuration();
|
|
}
|
|
|
|
bool MacroCondition::CheckDurationModifier(bool conditionValue)
|
|
{
|
|
return _durationModifier.CheckConditionWithDurationModifier(
|
|
conditionValue);
|
|
}
|
|
|
|
DurationModifier MacroCondition::GetDurationModifier() const
|
|
{
|
|
return _durationModifier;
|
|
}
|
|
|
|
void MacroCondition::SetDurationModifier(DurationModifier::Type m)
|
|
{
|
|
_durationModifier.SetModifier(m);
|
|
}
|
|
|
|
void MacroCondition::SetDuration(const Duration &duration)
|
|
{
|
|
_durationModifier.SetDuration(duration);
|
|
}
|
|
|
|
std::string_view MacroCondition::GetDefaultID()
|
|
{
|
|
return "scene";
|
|
}
|
|
|
|
MacroRefCondition::MacroRefCondition(Macro *m, bool supportsVariableValue)
|
|
: MacroCondition(m, supportsVariableValue)
|
|
{
|
|
}
|
|
|
|
bool MacroRefCondition::PostLoad()
|
|
{
|
|
_macro.PostLoad();
|
|
return true;
|
|
}
|
|
|
|
MultiMacroRefCondition::MultiMacroRefCondition(Macro *m,
|
|
bool supportsVariableValue)
|
|
: MacroCondition(m, supportsVariableValue)
|
|
{
|
|
}
|
|
|
|
bool MultiMacroRefCondition::PostLoad()
|
|
{
|
|
for (auto ¯o : _macros) {
|
|
macro.PostLoad();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace advss
|