Add temp variable support to websocket condition

This commit is contained in:
WarmUpTill
2024-01-26 20:50:49 +01:00
committed by WarmUpTill
parent 458a1ec4c1
commit d237e3fe4e
3 changed files with 17 additions and 0 deletions

View File

@@ -1546,6 +1546,9 @@ AdvSceneSwitcher.tempVar.video.text.description="The text detected in a given vi
AdvSceneSwitcher.tempVar.video.color="Average color"
AdvSceneSwitcher.tempVar.video.color.description="The average RGB color in a given video input frame in HexArgb format."
AdvSceneSwitcher.tempVar.websocket.message="Received websocket message"
AdvSceneSwitcher.tempVar.websocket.message.description="The received websocket message, which matched the given pattern"
AdvSceneSwitcher.selectScene="--select scene--"
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
AdvSceneSwitcher.selectCurrentScene="Current Scene"

View File

@@ -42,12 +42,14 @@ bool MacroConditionWebsocket::CheckCondition()
for (auto &m : *messages) {
if (_regex.Enabled()) {
if (_regex.Matches(m.message, _message)) {
SetTempVarValue("message", m.message);
SetVariableValue(m.message);
m.processed = true;
return true;
}
} else {
if (m.message == std::string(_message)) {
SetTempVarValue("message", m.message);
SetVariableValue(m.message);
m.processed = true;
return true;
@@ -93,6 +95,16 @@ std::string MacroConditionWebsocket::GetShortDesc() const
return GetWeakConnectionName(_connection);
}
void MacroConditionWebsocket::SetupTempVars()
{
MacroCondition::SetupTempVars();
AddTempvar(
"message",
obs_module_text("AdvSceneSwitcher.tempVar.websocket.message"),
obs_module_text(
"AdvSceneSwitcher.tempVar.websocket.message.description"));
}
static inline void populateConditionSelection(QComboBox *list)
{
for (auto entry : conditionTypes) {

View File

@@ -32,6 +32,8 @@ public:
std::weak_ptr<Connection> _connection;
private:
void SetupTempVars();
static bool _registered;
static const std::string id;
};