From 9c109742fb875541c2c89424a8c693dda52bb537 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Mon, 3 Nov 2025 20:39:50 +0100 Subject: [PATCH] Add option to change action state based on label and action type --- data/locale/en-US.ini | 10 +- data/locale/pt-BR.ini | 6 +- data/locale/zh-CN.ini | 6 +- lib/macro/macro-action-macro.cpp | 297 ++++++++++++++++++++++++------- lib/macro/macro-action-macro.hpp | 27 ++- 5 files changed, 272 insertions(+), 74 deletions(-) diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index af72f1e2..4db993af 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -984,12 +984,16 @@ AdvSceneSwitcher.action.macro.type.disableAction="Disable action" AdvSceneSwitcher.action.macro.type.enableAction="Enable action" AdvSceneSwitcher.action.macro.type.toggleAction="Toggle action" AdvSceneSwitcher.action.macro.type.nestedMacro="Nested macro" +AdvSceneSwitcher.action.macro.actionSelectionType.index="at index" +AdvSceneSwitcher.action.macro.actionSelectionType.label="with label" +AdvSceneSwitcher.action.macro.actionSelectionType.id="of action type" AdvSceneSwitcher.action.macro.type.nestedMacro.conditionHelp="This section allows you to define macro conditions.\n\nClick the plus button below to add a new condition." AdvSceneSwitcher.action.macro.type.nestedMacro.actionHelp="This section allows you to define macro actions.\nThe actions in this section will be performed when the conditions are met.\n\nClick the plus button below to add a new action." AdvSceneSwitcher.action.macro.type.nestedMacro.elseActionHelp="This section allows you to define macro actions.\nThe actions in this section will be performed when the conditions are *not* met.\n\nClick the plus button below to add a new action." -AdvSceneSwitcher.action.macro.entry.run="{{actions}}{{actionTypes}}of{{macros}}" -AdvSceneSwitcher.action.macro.entry.run.condition="{{conditionBehaviors}}of{{conditionMacros}}" -AdvSceneSwitcher.action.macro.entry.other="{{actions}}{{actionIndex}}{{macros}}" +AdvSceneSwitcher.action.macro.layout.run="{{actions}}{{actionSections}}of{{macros}}" +AdvSceneSwitcher.action.macro.layout.run.condition="{{conditionBehaviors}}of{{conditionMacros}}" +AdvSceneSwitcher.action.macro.layout.actionState="{{actions}}{{actionSelectionType}}{{actionIndex}}{{label}}{{regex}}{{actionTypes}}in{{actionSections}}section of{{macros}}" +AdvSceneSwitcher.action.macro.layout.other="{{actions}}{{macros}}" AdvSceneSwitcher.action.pluginState="Plugin state" AdvSceneSwitcher.action.pluginState.type.stop="Stop the Advanced Scene Switcher plugin" AdvSceneSwitcher.action.pluginState.type.noMatch="Change the no-match behaviour:" diff --git a/data/locale/pt-BR.ini b/data/locale/pt-BR.ini index 615bca6a..1e8e8f00 100644 --- a/data/locale/pt-BR.ini +++ b/data/locale/pt-BR.ini @@ -861,9 +861,9 @@ AdvSceneSwitcher.action.macro.type.stop="Parar ações" AdvSceneSwitcher.action.macro.type.disableAction="Desabilitar ação" AdvSceneSwitcher.action.macro.type.enableAction="Habilitar ação" AdvSceneSwitcher.action.macro.type.toggleAction="Alternar ação" -AdvSceneSwitcher.action.macro.entry.run="{{actions}}{{actionTypes}}de{{macros}}" -AdvSceneSwitcher.action.macro.entry.run.condition="{{conditionBehaviors}}de{{conditionMacros}}" -AdvSceneSwitcher.action.macro.entry.other="{{actions}}{{actionIndex}}{{macros}}" +AdvSceneSwitcher.action.macro.layout.run="{{actions}}{{actionSections}}de{{macros}}" +AdvSceneSwitcher.action.macro.layout.run.condition="{{conditionBehaviors}}de{{conditionMacros}}" +AdvSceneSwitcher.action.macro.layout.other="{{actions}}{{macros}}" AdvSceneSwitcher.action.pluginState="Estado do plugin" AdvSceneSwitcher.action.pluginState.type.stop="Parar o plugin Advanced Scene Switcher" AdvSceneSwitcher.action.pluginState.type.noMatch="Alterar o comportamento em caso de não correspondência:" diff --git a/data/locale/zh-CN.ini b/data/locale/zh-CN.ini index 431eba29..485e010f 100644 --- a/data/locale/zh-CN.ini +++ b/data/locale/zh-CN.ini @@ -920,9 +920,9 @@ AdvSceneSwitcher.action.macro.type.stop="停止操作" AdvSceneSwitcher.action.macro.type.disableAction="停用操作" AdvSceneSwitcher.action.macro.type.enableAction="启用操作" AdvSceneSwitcher.action.macro.type.toggleAction="切换操作开关" -AdvSceneSwitcher.action.macro.entry.run="{{actions}}{{actionTypes}}{{macros}}" -AdvSceneSwitcher.action.macro.entry.run.condition="{{conditionBehaviors}}{{conditionMacros}}" -AdvSceneSwitcher.action.macro.entry.other="{{actions}}{{actionIndex}}{{macros}}" +AdvSceneSwitcher.action.macro.layout.run="{{actions}}{{actionSections}}{{macros}}" +AdvSceneSwitcher.action.macro.layout.run.condition="{{conditionBehaviors}}{{conditionMacros}}" +AdvSceneSwitcher.action.macro.layout.other="{{actions}}{{macros}}" AdvSceneSwitcher.action.pluginState="插件状态" AdvSceneSwitcher.action.pluginState.type.stop="停止高级场景切换插件" AdvSceneSwitcher.action.pluginState.type.noMatch="没有匹配项时:" diff --git a/lib/macro/macro-action-macro.cpp b/lib/macro/macro-action-macro.cpp index dfa26336..7310fbe6 100644 --- a/lib/macro/macro-action-macro.cpp +++ b/lib/macro/macro-action-macro.cpp @@ -2,6 +2,7 @@ #include "help-icon.hpp" #include "layout-helpers.hpp" #include "macro.hpp" +#include "macro-action-factory.hpp" namespace advss { @@ -12,6 +13,74 @@ bool MacroActionMacro::_registered = MacroActionFactory::Register( {MacroActionMacro::Create, MacroActionMacroEdit::Create, "AdvSceneSwitcher.action.macro"}); +void MacroActionMacro::AdjustActionState(Macro *macro) const +{ + const auto ¯oActions = _useElseSection ? macro->ElseActions() + : macro->Actions(); + + std::vector> actionsToModify; + switch (_actionSelectionType) { + case SelectionType::INDEX: { + const bool isValidAction = + (_useElseSection && + IsValidElseActionIndex(macro, _actionIndex - 1)) || + (!_useElseSection && + IsValidActionIndex(macro, _actionIndex - 1)); + + if (isValidAction) { + actionsToModify.emplace_back( + macroActions.at(_actionIndex - 1)); + } + break; + } + case SelectionType::LABEL: + for (const auto &action : macroActions) { + if (!action->GetUseCustomLabel()) { + continue; + } + + const auto label = action->GetCustomLabel(); + + if (_regex.Enabled()) { + if (_regex.Matches(label, _label)) { + actionsToModify.emplace_back(action); + } + continue; + } + + if (label == std::string(_label)) { + actionsToModify.emplace_back(action); + } + } + break; + case SelectionType::ID: + for (const auto &action : macroActions) { + if (action->GetId() == _actionId) { + actionsToModify.emplace_back(action); + } + } + break; + default: + break; + } + + for (const auto &action : actionsToModify) { + switch (_action) { + case Action::DISABLE_ACTION: + action->SetEnabled(false); + break; + case Action::ENABLE_ACTION: + action->SetEnabled(true); + break; + case Action::TOGGLE_ACTION: + action->SetEnabled(!action->Enabled()); + break; + default: + break; + } + } +} + bool MacroActionMacro::PerformAction() { if (_action == Action::NESTED_MACRO) { @@ -44,23 +113,9 @@ bool MacroActionMacro::PerformAction() macro->Stop(); break; case Action::DISABLE_ACTION: - if (IsValidMacroSegmentIndex(macro.get(), _actionIndex - 1, - false)) { - macro->Actions().at(_actionIndex - 1)->SetEnabled(false); - } - break; case Action::ENABLE_ACTION: - if (IsValidMacroSegmentIndex(macro.get(), _actionIndex - 1, - false)) { - macro->Actions().at(_actionIndex - 1)->SetEnabled(true); - } - break; case Action::TOGGLE_ACTION: - if (IsValidMacroSegmentIndex(macro.get(), _actionIndex - 1, - false)) { - auto action = macro->Actions().at(_actionIndex - 1); - action->SetEnabled(!action->Enabled()); - } + AdjustActionState(macro.get()); break; default: break; @@ -115,9 +170,14 @@ void MacroActionMacro::LogAction() const bool MacroActionMacro::Save(obs_data_t *obj) const { MacroAction::Save(obj); - _macro.Save(obj); - _actionIndex.Save(obj, "actionIndex"); obs_data_set_int(obj, "action", static_cast(_action)); + _macro.Save(obj); + obs_data_set_int(obj, "actionSelectionType", + static_cast(_actionSelectionType)); + _actionIndex.Save(obj, "actionIndex"); + _label.Save(obj, "label"); + obs_data_set_string(obj, "actionId", _actionId.c_str()); + _regex.Save(obj); _runOptions.Save(obj); OBSDataAutoRelease nestedMacroData = obs_data_create(); _nestedMacro->Save(nestedMacroData); @@ -129,10 +189,15 @@ bool MacroActionMacro::Save(obs_data_t *obj) const bool MacroActionMacro::Load(obs_data_t *obj) { MacroAction::Load(obj); - _macro.Load(obj); - _actionIndex.Load(obj, "actionIndex"); _action = static_cast( obs_data_get_int(obj, "action")); + _macro.Load(obj); + _actionSelectionType = static_cast( + obs_data_get_int(obj, "actionSelectionType")); + _actionIndex.Load(obj, "actionIndex"); + _label.Load(obj, "label"); + _actionId = obs_data_get_string(obj, "actionId"); + _regex.Load(obj); _runOptions.Load(obj); if (obs_data_has_user_value(obj, "nestedMacro")) { @@ -183,6 +248,7 @@ std::shared_ptr MacroActionMacro::Copy() const void MacroActionMacro::ResolveVariablesToFixedValues() { _actionIndex.ResolveVariables(); + _label.ResolveVariables(); } static void runActionsHelper(Macro *macro, bool runElseActions, bool setInputs, @@ -266,7 +332,7 @@ static void populateConditionBehaviorSelection(QComboBox *list) "AdvSceneSwitcher.action.macro.type.run.conditions.false")); } -static void populateActionTypeSelection(QComboBox *list) +static void populateActionSectionSelection(QComboBox *list) { list->addItem(obs_module_text( "AdvSceneSwitcher.action.macro.type.run.actionType.regular")); @@ -274,19 +340,47 @@ static void populateActionTypeSelection(QComboBox *list) "AdvSceneSwitcher.action.macro.type.run.actionType.else")); } +static void populateActionTypes(QComboBox *list) +{ + for (const auto &[id, info] : MacroActionFactory::GetActionTypes()) { + list->addItem(obs_module_text(info._name.c_str()), + QString::fromStdString(id)); + } +} + +static void populateActionSelectionTypes(QComboBox *list) +{ + list->addItem( + obs_module_text( + "AdvSceneSwitcher.action.macro.actionSelectionType.index"), + static_cast(MacroActionMacro::SelectionType::INDEX)); + list->addItem( + obs_module_text( + "AdvSceneSwitcher.action.macro.actionSelectionType.label"), + static_cast(MacroActionMacro::SelectionType::LABEL)); + list->addItem( + obs_module_text( + "AdvSceneSwitcher.action.macro.actionSelectionType.id"), + static_cast(MacroActionMacro::SelectionType::ID)); +} + MacroActionMacroEdit::MacroActionMacroEdit( QWidget *parent, std::shared_ptr entryData) : ResizableWidget(parent), + _actions(new QComboBox()), _macros(new MacroSelection(parent)), + _actionSelectionType(new QComboBox(this)), _actionIndex(new MacroSegmentSelection( this, MacroSegmentSelection::Type::ACTION)), - _actions(new QComboBox()), + _label(new VariableLineEdit(this)), + _actionTypes(new FilterComboBox(this)), + _regex(new RegexConfigWidget(this)), _conditionMacros(new MacroSelection(parent)), _conditionBehaviors(new QComboBox()), _reevaluateConditionState(new QCheckBox( obs_module_text("AdvSceneSwitcher.action.macro.type.run." "updateConditionMatchState"))), - _actionTypes(new QComboBox()), + _actionSections(new QComboBox(this)), _skipWhenPaused(new QCheckBox(obs_module_text( "AdvSceneSwitcher.action.macro.type.run.skipWhenPaused"))), _setInputs(new QCheckBox(obs_module_text( @@ -305,7 +399,9 @@ MacroActionMacroEdit::MacroActionMacroEdit( { populateActionSelection(_actions); populateConditionBehaviorSelection(_conditionBehaviors); - populateActionTypeSelection(_actionTypes); + populateActionSectionSelection(_actionSections); + populateActionSelectionTypes(_actionSelectionType); + populateActionTypes(_actionTypes); _conditionMacros->HideSelectedMacro(); @@ -313,16 +409,25 @@ MacroActionMacroEdit::MacroActionMacroEdit( this, SLOT(MacroChanged(const QString &))); QWidget::connect(_actions, SIGNAL(currentIndexChanged(int)), this, SLOT(ActionChanged(int))); + QWidget::connect(_actionSelectionType, SIGNAL(currentIndexChanged(int)), + this, SLOT(ActionSelectionTypeChanged(int))); QWidget::connect(_actionIndex, SIGNAL(SelectionChanged(const IntVariable &)), this, SLOT(ActionIndexChanged(const IntVariable &))); + QWidget::connect(_label, SIGNAL(editingFinished()), this, + SLOT(LabelChanged())); + QWidget::connect(_actionTypes, SIGNAL(currentIndexChanged(int)), this, + SLOT(ActionTypeChanged(int))); + QWidget::connect(_regex, + SIGNAL(RegexConfigChanged(const RegexConfig &)), this, + SLOT(RegexChanged(const RegexConfig &))); QWidget::connect(_conditionMacros, SIGNAL(currentTextChanged(const QString &)), this, SLOT(ConditionMacroChanged(const QString &))); QWidget::connect(_conditionBehaviors, SIGNAL(currentIndexChanged(int)), this, SLOT(ConditionBehaviorChanged(int))); - QWidget::connect(_actionTypes, SIGNAL(currentIndexChanged(int)), this, - SLOT(ActionTypeChanged(int))); + QWidget::connect(_actionSections, SIGNAL(currentIndexChanged(int)), + this, SLOT(ActionSectionChanged(int))); QWidget::connect(_skipWhenPaused, SIGNAL(stateChanged(int)), this, SLOT(SkipWhenPausedChanged(int))); QWidget::connect(_setInputs, SIGNAL(stateChanged(int)), this, @@ -375,17 +480,24 @@ void MacroActionMacroEdit::UpdateEntryData() if (!_entryData) { return; } + _actions->setCurrentIndex( _actions->findData(static_cast(_entryData->_action))); + _actionSelectionType->setCurrentIndex(_actionSelectionType->findData( + static_cast(_entryData->_actionSelectionType))); _actionIndex->SetValue(_entryData->_actionIndex); _actionIndex->SetMacro(_entryData->_macro.GetMacro()); + _label->setText(_entryData->_label); + _actionTypes->setCurrentIndex(_actionTypes->findData( + QString::fromStdString(_entryData->_actionId))); + _regex->SetRegexConfig(_entryData->_regex); _macros->SetCurrentMacro(_entryData->_macro); _conditionMacros->SetCurrentMacro(_entryData->_runOptions.macro); _conditionBehaviors->setCurrentIndex( static_cast(_entryData->_runOptions.logic)); _reevaluateConditionState->setChecked( _entryData->_runOptions.reevaluateConditionState); - _actionTypes->setCurrentIndex( + _actionSections->setCurrentIndex( _entryData->_runOptions.runElseActions ? 1 : 0); _skipWhenPaused->setChecked(_entryData->_runOptions.skipWhenPaused); _setInputs->setChecked(_entryData->_runOptions.setInputs); @@ -424,12 +536,40 @@ void MacroActionMacroEdit::ActionChanged(int idx) SetWidgetVisibility(); } +void MacroActionMacroEdit::ActionSelectionTypeChanged(int idx) +{ + GUARD_LOADING_AND_LOCK(); + _entryData->_actionSelectionType = + static_cast( + _actionSelectionType->itemData(idx).toInt()); + SetWidgetVisibility(); +} + void MacroActionMacroEdit::ActionIndexChanged(const IntVariable &value) { GUARD_LOADING_AND_LOCK(); _entryData->_actionIndex = value; } +void MacroActionMacroEdit::LabelChanged() +{ + GUARD_LOADING_AND_LOCK(); + _entryData->_label = _label->text().toStdString(); +} + +void MacroActionMacroEdit::ActionTypeChanged(int idx) +{ + GUARD_LOADING_AND_LOCK(); + _entryData->_actionId = + _actionTypes->itemData(idx).toString().toStdString(); +} + +void MacroActionMacroEdit::RegexChanged(const RegexConfig ®ex) +{ + GUARD_LOADING_AND_LOCK(); + _entryData->_regex = regex; +} + void MacroActionMacroEdit::ConditionMacroChanged(const QString &text) { GUARD_LOADING_AND_LOCK(); @@ -451,10 +591,13 @@ void MacroActionMacroEdit::ReevaluateConditionStateChanged(int value) SetWidgetVisibility(); } -void MacroActionMacroEdit::ActionTypeChanged(int value) +void MacroActionMacroEdit::ActionSectionChanged(int useElse) { GUARD_LOADING_AND_LOCK(); - _entryData->_runOptions.runElseActions = value; + _entryData->_runOptions.runElseActions = useElse; + _entryData->_useElseSection = useElse; + _actionIndex->SetType(useElse ? MacroSegmentSelection::Type::ELSE_ACTION + : MacroSegmentSelection::Type::ACTION); } void MacroActionMacroEdit::SkipWhenPausedChanged(int value) @@ -483,7 +626,11 @@ void MacroActionMacroEdit::SetWidgetVisibility() _entryLayout->removeWidget(_actions); _entryLayout->removeWidget(_actionIndex); _entryLayout->removeWidget(_macros); + _entryLayout->removeWidget(_actionSections); + _entryLayout->removeWidget(_label); + _entryLayout->removeWidget(_regex); _entryLayout->removeWidget(_actionTypes); + _entryLayout->removeWidget(_actionSelectionType); _conditionLayout->removeWidget(_conditionBehaviors); _conditionLayout->removeWidget(_conditionMacros); @@ -494,19 +641,40 @@ void MacroActionMacroEdit::SetWidgetVisibility() {"{{actions}}", _actions}, {"{{actionIndex}}", _actionIndex}, {"{{macros}}", _macros}, - {"{{actionTypes}}", _actionTypes}, + {"{{actionSections}}", _actionSections}, {"{{conditionBehaviors}}", _conditionBehaviors}, {"{{conditionMacros}}", _conditionMacros}, + {"{{actionSelectionType}}", _actionSelectionType}, + {"{{label}}", _label}, + {"{{regex}}", _regex}, + {"{{actionTypes}}", _actionTypes}, }; - PlaceWidgets( - obs_module_text( - _entryData->_action == - MacroActionMacro::Action::RUN_ACTIONS - ? "AdvSceneSwitcher.action.macro.entry.run" - : "AdvSceneSwitcher.action.macro.entry.other"), - _entryLayout, placeholders); + const auto action = _entryData->_action; + const char *layoutText = ""; + switch (action) { + case MacroActionMacro::Action::PAUSE: + case MacroActionMacro::Action::UNPAUSE: + case MacroActionMacro::Action::TOGGLE_PAUSE: + case MacroActionMacro::Action::RESET_COUNTER: + case MacroActionMacro::Action::STOP: + case MacroActionMacro::Action::NESTED_MACRO: + layoutText = "AdvSceneSwitcher.action.macro.layout.other"; + break; + case MacroActionMacro::Action::RUN_ACTIONS: + layoutText = "AdvSceneSwitcher.action.macro.layout.run"; + break; + case MacroActionMacro::Action::DISABLE_ACTION: + case MacroActionMacro::Action::ENABLE_ACTION: + case MacroActionMacro::Action::TOGGLE_ACTION: + layoutText = "AdvSceneSwitcher.action.macro.layout.actionState"; + break; + default: + break; + } + + PlaceWidgets(obs_module_text(layoutText), _entryLayout, placeholders); if (_entryData->_runOptions.logic == MacroActionMacro::RunOptions::Logic::IGNORE_CONDITIONS) { @@ -515,56 +683,63 @@ void MacroActionMacroEdit::SetWidgetVisibility() } else { PlaceWidgets( obs_module_text( - "AdvSceneSwitcher.action.macro.entry.run.condition"), + "AdvSceneSwitcher.action.macro.layout.run.condition"), _conditionLayout, placeholders); } - if (_entryData->_action == MacroActionMacro::Action::RUN_ACTIONS || - _entryData->_action == MacroActionMacro::Action::STOP) { + if (action == MacroActionMacro::Action::RUN_ACTIONS || + action == MacroActionMacro::Action::STOP) { _macros->HideSelectedMacro(); } else { _macros->ShowAllMacros(); } + const auto actionSelectionType = _entryData->_actionSelectionType; const bool isModifyingActionState = - _entryData->_action == - MacroActionMacro::Action::DISABLE_ACTION || - _entryData->_action == - MacroActionMacro::Action::ENABLE_ACTION || - _entryData->_action == MacroActionMacro::Action::TOGGLE_ACTION; - _actionIndex->setVisible(isModifyingActionState); + action == MacroActionMacro::Action::DISABLE_ACTION || + action == MacroActionMacro::Action::ENABLE_ACTION || + action == MacroActionMacro::Action::TOGGLE_ACTION; + _actionSelectionType->setVisible(isModifyingActionState); + _actionIndex->setVisible( + isModifyingActionState && + actionSelectionType == MacroActionMacro::SelectionType::INDEX); + _label->setVisible(isModifyingActionState && + actionSelectionType == + MacroActionMacro::SelectionType::LABEL); + _regex->setVisible(isModifyingActionState && + actionSelectionType == + MacroActionMacro::SelectionType::LABEL); + _actionTypes->setVisible(isModifyingActionState && + actionSelectionType == + MacroActionMacro::SelectionType::ID); SetLayoutVisible(_conditionLayout, - _entryData->_action == - MacroActionMacro::Action::RUN_ACTIONS); + action == MacroActionMacro::Action::RUN_ACTIONS); const bool needsAdditionalConditionWidgets = - _entryData->_action == MacroActionMacro::Action::RUN_ACTIONS && + action == MacroActionMacro::Action::RUN_ACTIONS && _entryData->_runOptions.logic != MacroActionMacro::RunOptions::Logic::IGNORE_CONDITIONS; _conditionMacros->setVisible(needsAdditionalConditionWidgets); SetLayoutVisible(_reevaluateConditionStateLayout, needsAdditionalConditionWidgets); SetLayoutVisible(_setInputsLayout, - _entryData->_action == - MacroActionMacro::Action::RUN_ACTIONS); - _inputs->setVisible(_entryData->_action == - MacroActionMacro::Action::RUN_ACTIONS && + action == MacroActionMacro::Action::RUN_ACTIONS); + _inputs->setVisible(action == MacroActionMacro::Action::RUN_ACTIONS && _entryData->_runOptions.setInputs); HighlightMacroSettingsButton( - _entryData->_action == MacroActionMacro::Action::RUN_ACTIONS && + action == MacroActionMacro::Action::RUN_ACTIONS && _entryData->_runOptions.setInputs && !_inputs->HasInputsToSet()); - _actionTypes->setVisible(_entryData->_action == - MacroActionMacro::Action::RUN_ACTIONS); - _skipWhenPaused->setVisible(_entryData->_action == + _actionSections->setVisible( + action == MacroActionMacro::Action::RUN_ACTIONS || + isModifyingActionState); + _skipWhenPaused->setVisible(action == MacroActionMacro::Action::RUN_ACTIONS); - _nestedMacro->setVisible(_entryData->_action == + _nestedMacro->setVisible(action == MacroActionMacro::Action::NESTED_MACRO); - _macros->setVisible(_entryData->_action != - MacroActionMacro::Action::NESTED_MACRO); - SetResizingEnabled(_entryData->_action == - MacroActionMacro::Action::NESTED_MACRO); + _macros->setVisible(action != MacroActionMacro::Action::NESTED_MACRO); + SetResizingEnabled(action == MacroActionMacro::Action::NESTED_MACRO); if (_nestedMacro->IsEmpty()) { _nestedMacro->ShowAllMacroSections(); diff --git a/lib/macro/macro-action-macro.hpp b/lib/macro/macro-action-macro.hpp index b0e47942..f2453bb5 100644 --- a/lib/macro/macro-action-macro.hpp +++ b/lib/macro/macro-action-macro.hpp @@ -5,7 +5,9 @@ #include "macro-input.hpp" #include "macro-selection.hpp" #include "macro-segment-selection.hpp" +#include "regex-config.hpp" #include "resizable-widget.hpp" +#include "variable-line-edit.hpp" #include #include @@ -55,14 +57,23 @@ public: TOGGLE_PAUSE, NESTED_MACRO, }; + + enum class SelectionType { INDEX, LABEL, ID }; + Action _action = Action::NESTED_MACRO; + SelectionType _actionSelectionType = SelectionType::INDEX; + bool _useElseSection = false; IntVariable _actionIndex = 1; + StringVariable _label = "Custom label"; + std::string _actionId; + RegexConfig _regex; RunOptions _runOptions = {}; std::shared_ptr _nestedMacro = std::make_shared(); int _customWidgetHeight = 0; private: void RunActions(Macro *actionMacro) const; + void AdjustActionState(Macro *) const; static bool _registered; static const std::string id; @@ -82,11 +93,15 @@ public: private slots: void MacroChanged(const QString &text); void ActionChanged(int value); + void ActionSelectionTypeChanged(int value); void ActionIndexChanged(const IntVariable &value); + void LabelChanged(); + void ActionTypeChanged(int value); + void RegexChanged(const RegexConfig &); void ConditionMacroChanged(const QString &text); void ConditionBehaviorChanged(int value); void ReevaluateConditionStateChanged(int value); - void ActionTypeChanged(int value); + void ActionSectionChanged(int value); void SkipWhenPausedChanged(int value); void SetInputsChanged(int value); void InputsChanged(const StringList &); @@ -98,13 +113,17 @@ private: void SetWidgetVisibility(); void SetupMacroInput(Macro *) const; - MacroSelection *_macros; - MacroSegmentSelection *_actionIndex; QComboBox *_actions; + MacroSelection *_macros; + QComboBox *_actionSelectionType; + MacroSegmentSelection *_actionIndex; + VariableLineEdit *_label; + FilterComboBox *_actionTypes; + RegexConfigWidget *_regex; MacroSelection *_conditionMacros; QComboBox *_conditionBehaviors; QCheckBox *_reevaluateConditionState; - QComboBox *_actionTypes; + QComboBox *_actionSections; QCheckBox *_skipWhenPaused; QCheckBox *_setInputs; MacroInputEdit *_inputs;