| 65 | } |
| 66 | |
| 67 | bool MacroConditionSource::CheckCondition() |
| 68 | { |
| 69 | if (!_source.GetSource()) { |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | bool ret = false; |
| 74 | OBSSourceAutoRelease s = |
| 75 | obs_weak_source_get_source(_source.GetSource()); |
| 76 | |
| 77 | switch (_condition) { |
| 78 | case Condition::ACTIVE: |
| 79 | ret = obs_source_active(s); |
| 80 | break; |
| 81 | case Condition::SHOWING: |
| 82 | ret = obs_source_showing(s); |
| 83 | break; |
| 84 | case Condition::ALL_SETTINGS_MATCH: { |
| 85 | const auto settings = GetSourceSettings(_source.GetSource(), |
| 86 | _includeDefaults); |
| 87 | if (!settings) { |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | ret = CompareSourceSettings(*settings, _settings, _regex); |
| 92 | SetVariableValue(*settings); |
| 93 | SetTempVarValue("settings", *settings); |
| 94 | break; |
| 95 | } |
| 96 | case Condition::SETTINGS_CHANGED: { |
| 97 | const auto settings = GetSourceSettings(_source.GetSource(), |
| 98 | _includeDefaults); |
| 99 | ret = _currentSettings.has_value() && |
| 100 | settings != _currentSettings; |
| 101 | _currentSettings = settings; |
| 102 | if (!settings) { |
| 103 | break; |
| 104 | } |
| 105 | SetVariableValue(*settings); |
| 106 | SetTempVarValue("settings", *settings); |
| 107 | break; |
| 108 | } |
| 109 | case Condition::INDIVIDUAL_SETTING_MATCH: { |
| 110 | const auto value = |
| 111 | GetSourceSettingValue(_source.GetSource(), _setting); |
| 112 | if (!value) { |
| 113 | return false; |
| 114 | } |
| 115 | ret = _regex.Enabled() ? _regex.Matches(*value, _settings) |
| 116 | : value == std::string(_settings); |
| 117 | SetVariableValue(*value); |
| 118 | SetTempVarValue("setting", *value); |
| 119 | break; |
| 120 | } |
| 121 | case Condition::INDIVIDUAL_SETTING_LIST_ENTRY_MATCH: { |
| 122 | const auto entryName = GetSourceSettingListEntryName( |
| 123 | _source.GetSource(), _setting); |
| 124 | if (!entryName) { |
nothing calls this directly
no test coverage detected