Add temp var support for size and running state

This commit is contained in:
WarmUpTill 2024-10-13 11:40:16 +02:00 committed by WarmUpTill
parent f641c20564
commit 392e775c7b
4 changed files with 29 additions and 10 deletions

View File

@ -1960,6 +1960,10 @@ AdvSceneSwitcher.tempVar.streamDeck.column="Key column"
AdvSceneSwitcher.tempVar.streamDeck.data="Data"
AdvSceneSwitcher.tempVar.streamDeck.data.description="The value of the \"Data\" field configured in the action on the Stream Deck side."
AdvSceneSwitcher.tempVar.queue.size="Size"
AdvSceneSwitcher.tempVar.queue.running="Is running"
AdvSceneSwitcher.tempVar.queue.running.description="Returns \"true\" if the queue is started and \"false\" if it is stopped."
AdvSceneSwitcher.selectScene="--select scene--"
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
AdvSceneSwitcher.selectCurrentScene="Current Scene"

View File

@ -27,6 +27,9 @@ bool MacroConditionQueue::CheckCondition()
return false;
}
SetTempVarValue("size", std::to_string(queue->Size()));
SetTempVarValue("running", queue->IsRunning());
switch (_condition) {
case Condition::STARTED:
return queue->IsRunning();
@ -63,6 +66,18 @@ std::string MacroConditionQueue::GetShortDesc() const
return GetActionQueueName(_queue);
}
void MacroConditionQueue::SetupTempVars()
{
MacroCondition::SetupTempVars();
AddTempvar("size",
obs_module_text("AdvSceneSwitcher.tempVar.queue.size"));
AddTempvar(
"running",
obs_module_text("AdvSceneSwitcher.tempVar.queue.running"),
obs_module_text(
"AdvSceneSwitcher.tempVar.queue.running.description"));
}
static inline void populateQueueTypeSelection(QComboBox *list)
{
for (const auto &[_, name] : conditionTypes) {

View File

@ -32,6 +32,8 @@ public:
IntVariable _size = 1;
private:
void SetupTempVars();
static bool _registered;
static const std::string id;
};

View File

@ -304,11 +304,10 @@ bool MacroConditionTwitch::CheckChannelGenericEvents()
continue;
}
SetVariableValue(event->ToString());
setTempVarsHelper(
event->data,
std::bind(&MacroConditionTwitch::SetTempVarValue, this,
std::placeholders::_1,
std::placeholders::_2));
setTempVarsHelper(event->data,
[this](const char *id, const char *value) {
SetTempVarValue(id, value);
});
if (_clearBufferOnMatch) {
_eventBuffer->Clear();
@ -346,11 +345,10 @@ bool MacroConditionTwitch::CheckChannelLiveEvents()
}
SetVariableValue(event->ToString());
setTempVarsHelper(
event->data,
std::bind(&MacroConditionTwitch::SetTempVarValue, this,
std::placeholders::_1,
std::placeholders::_2));
setTempVarsHelper(event->data,
[this](const char *id, const char *value) {
SetTempVarValue(id, value);
});
if (_clearBufferOnMatch) {
_eventBuffer->Clear();