Add "Next Macro" temp var to Sequence actions when setting index
Some checks are pending
debian-build / build (push) Waiting to run
Check locale / ubuntu64 (push) Waiting to run
Push to master / Check Formatting 🔍 (push) Waiting to run
Push to master / Build Project 🧱 (push) Waiting to run
Push to master / Create Release 🛫 (push) Blocked by required conditions

This commit is contained in:
WarmUpTill 2026-03-18 12:26:04 +01:00 committed by WarmUpTill
parent e64f2d195e
commit 2405b6dbbf
3 changed files with 24 additions and 10 deletions

View File

@ -2358,6 +2358,8 @@ AdvSceneSwitcher.tempVar.replay.lastSavePath.description="The file path of the l
AdvSceneSwitcher.tempVar.sequence.macro="Macro"
AdvSceneSwitcher.tempVar.sequence.macro.description="The name of the macro executed by the \"Sequence\" action.\nIf no macro was executed the returned value is the empty string."
AdvSceneSwitcher.tempVar.sequence.nextMacro="Next Macro"
AdvSceneSwitcher.tempVar.sequence.nextMacro.description="The name of the macro which will be executed next after the index was set.\nIf no macro will be executed the returned value is the empty string."
AdvSceneSwitcher.tempVar.random.macro="Macro"
AdvSceneSwitcher.tempVar.random.macro.description="The name of the macro executed by the \"Random\" action.\nIf no macro was executed the returned value is the empty string."

View File

@ -105,18 +105,21 @@ bool MacroActionSequence::RunSequence()
return RunMacroActions(macro.get());
}
bool MacroActionSequence::SetSequenceIndex() const
bool MacroActionSequence::SetSequenceIndex()
{
auto macro = _macro.GetMacro();
if (!macro) {
SetTempVarValue("nextMacro", "");
return true;
}
auto actions = GetMacroActions(macro.get());
if (!actions) {
SetTempVarValue("nextMacro", "");
return true;
}
std::string nextMacroName;
for (const auto &action : *actions) {
if (action->GetId() != id) {
continue;
@ -130,7 +133,10 @@ bool MacroActionSequence::SetSequenceIndex() const
// -2 is needed since the _lastIndex starts at -1 and the reset
// index starts at 1
sequenceAction->_lastIdx = _resetIndex - 2;
nextMacroName = GetMacroName(
sequenceAction->GetNextMacro(false).GetMacro().get());
}
SetTempVarValue("nextMacro", nextMacroName);
return true;
}
@ -138,15 +144,21 @@ void MacroActionSequence::SetupTempVars()
{
MacroAction::SetupTempVars();
if (_action != Action::RUN_SEQUENCE) {
return;
if (_action == Action::RUN_SEQUENCE) {
AddTempvar(
"macro",
obs_module_text(
"AdvSceneSwitcher.tempVar.sequence.macro"),
obs_module_text(
"AdvSceneSwitcher.tempVar.sequence.macro.description"));
} else if (_action == Action::SET_INDEX) {
AddTempvar(
"nextMacro",
obs_module_text(
"AdvSceneSwitcher.tempVar.sequence.nextMacro"),
obs_module_text(
"AdvSceneSwitcher.tempVar.sequence.nextMacro.description"));
}
AddTempvar(
"macro",
obs_module_text("AdvSceneSwitcher.tempVar.sequence.macro"),
obs_module_text(
"AdvSceneSwitcher.tempVar.sequence.macro.description"));
}
bool MacroActionSequence::PerformAction()

View File

@ -46,7 +46,7 @@ public:
private:
bool RunSequence();
bool SetSequenceIndex() const;
bool SetSequenceIndex();
void SetupTempVars();