From 2405b6dbbf6696d0e72bb35d4ecba070dd508190 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:26:04 +0100 Subject: [PATCH] Add "Next Macro" temp var to Sequence actions when setting index --- data/locale/en-US.ini | 2 ++ plugins/base/macro-action-sequence.cpp | 30 ++++++++++++++++++-------- plugins/base/macro-action-sequence.hpp | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 66eb814b..2724ba74 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -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." diff --git a/plugins/base/macro-action-sequence.cpp b/plugins/base/macro-action-sequence.cpp index 550391d9..549162e1 100644 --- a/plugins/base/macro-action-sequence.cpp +++ b/plugins/base/macro-action-sequence.cpp @@ -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() diff --git a/plugins/base/macro-action-sequence.hpp b/plugins/base/macro-action-sequence.hpp index 9c933b57..f67c2214 100644 --- a/plugins/base/macro-action-sequence.hpp +++ b/plugins/base/macro-action-sequence.hpp @@ -46,7 +46,7 @@ public: private: bool RunSequence(); - bool SetSequenceIndex() const; + bool SetSequenceIndex(); void SetupTempVars();