diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 2d4bd2bf..30d47fb2 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -983,6 +983,7 @@ AdvSceneSwitcher.action.variable.type.sceneItemCount="Set to scene item count of AdvSceneSwitcher.action.variable.type.stringLength="Set to length of string" AdvSceneSwitcher.action.variable.type.extractJson="Extract json field with name" AdvSceneSwitcher.action.variable.type.setToTempvar="Set to macro property" +AdvSceneSwitcher.action.variable.type.setToTempvar.help="This action type will allow you to extract values out of segments of the current macro and assign those values to the selected variable.\nFor example, you can get the current scene name from a scene condition and assign this name to a variable." AdvSceneSwitcher.action.variable.type.sceneItemName="Set to scene item name at index" AdvSceneSwitcher.action.variable.type.padValue="Pad current value" AdvSceneSwitcher.action.variable.type.truncateValue="Truncate current value" @@ -999,7 +1000,7 @@ AdvSceneSwitcher.action.variable.invalidSelection="Invalid selection!" AdvSceneSwitcher.action.variable.actionNoVariableSupport="Getting variable values from %1 actions is not supported!" AdvSceneSwitcher.action.variable.conditionNoVariableSupport="Getting variable values from %1 conditions is not supported!" AdvSceneSwitcher.action.variable.currentSegmentValue="Current value:" -AdvSceneSwitcher.action.variable.entry.other="{{actions}}{{variables}}{{variables2}}{{strValue}}{{numValue}}{{segmentIndex}}{{mathExpression}}{{envVariableName}}{{scenes}}{{tempVars}}{{sceneItemIndex}}{{direction}}{{stringLength}}{{paddingCharSelection}}" +AdvSceneSwitcher.action.variable.entry.other="{{actions}}{{variables}}{{variables2}}{{strValue}}{{numValue}}{{segmentIndex}}{{mathExpression}}{{envVariableName}}{{scenes}}{{tempVars}}{{tempVarsHelp}}{{sceneItemIndex}}{{direction}}{{stringLength}}{{paddingCharSelection}}" AdvSceneSwitcher.action.variable.entry.pad="{{actions}}of{{variables}}to length{{stringLength}}by adding{{paddingCharSelection}}to the{{direction}}" AdvSceneSwitcher.action.variable.entry.truncate="{{actions}}of{{variables}}to length{{stringLength}}by removing characters from the{{direction}}" AdvSceneSwitcher.action.variable.entry.substringIndex="Substring start:{{subStringStart}}Substring size:{{subStringSize}}" diff --git a/lib/macro/macro-action-variable.cpp b/lib/macro/macro-action-variable.cpp index 1fb0055b..bf503935 100644 --- a/lib/macro/macro-action-variable.cpp +++ b/lib/macro/macro-action-variable.cpp @@ -6,6 +6,7 @@ #include "macro.hpp" #include "non-modal-dialog.hpp" #include "source-helpers.hpp" +#include "ui-helpers.hpp" #include "utility.hpp" namespace advss { @@ -630,6 +631,7 @@ MacroActionVariableEdit::MacroActionVariableEdit( _scenes(new SceneSelectionWidget(this, true, false, true, true, true)), _tempVars(new TempVariableSelection(this)), + _tempVarsHelp(new QLabel()), _sceneItemIndex(new VariableSpinBox()), _direction(new QComboBox()), _stringLength(new VariableSpinBox()), @@ -657,6 +659,15 @@ MacroActionVariableEdit::MacroActionVariableEdit( populateTypeSelection(_actions); populateDirectionSelection(_direction); + QString path = GetThemeTypeName() == "Light" + ? ":/res/images/help.svg" + : ":/res/images/help_light.svg"; + QIcon icon(path); + QPixmap pixmap = icon.pixmap(QSize(16, 16)); + _tempVarsHelp->setPixmap(pixmap); + _tempVarsHelp->setToolTip(obs_module_text( + "AdvSceneSwitcher.action.variable.type.setToTempvar.help")); + QWidget::connect(_variables, SIGNAL(SelectionChanged(const QString &)), this, SLOT(VariableChanged(const QString &))); QWidget::connect(_variables2, SIGNAL(SelectionChanged(const QString &)), @@ -742,6 +753,7 @@ MacroActionVariableEdit::MacroActionVariableEdit( {"{{envVariableName}}", _envVariable}, {"{{scenes}}", _scenes}, {"{{tempVars}}", _tempVars}, + {"{{tempVarsHelp}}", _tempVarsHelp}, {"{{sceneItemIndex}}", _sceneItemIndex}, {"{{direction}}", _direction}, {"{{stringLength}}", _stringLength}, @@ -1202,6 +1214,7 @@ void MacroActionVariableEdit::SelectionChanged(const TempVariableRef &var) auto lock = LockContext(); _entryData->_tempVar = var; + SetWidgetVisibility(); } void MacroActionVariableEdit::SceneItemIndexChanged( @@ -1268,6 +1281,7 @@ void MacroActionVariableEdit::SetWidgetVisibility() {"{{envVariableName}}", _envVariable}, {"{{scenes}}", _scenes}, {"{{tempVars}}", _tempVars}, + {"{{tempVarsHelp}}", _tempVarsHelp}, {"{{sceneItemIndex}}", _sceneItemIndex}, {"{{direction}}", _direction}, {"{{stringLength}}", _stringLength}, @@ -1381,6 +1395,10 @@ void MacroActionVariableEdit::SetWidgetVisibility() MacroActionVariable::Type::SCENE_ITEM_NAME); _tempVars->setVisible(_entryData->_type == MacroActionVariable::Type::SET_TO_TEMPVAR); + _tempVarsHelp->setVisible( + _entryData->_type == + MacroActionVariable::Type::SET_TO_TEMPVAR && + !_entryData->_tempVar.HasValidID()); _sceneItemIndex->setVisible(_entryData->_type == MacroActionVariable::Type::SCENE_ITEM_NAME); _direction->setVisible( diff --git a/lib/macro/macro-action-variable.hpp b/lib/macro/macro-action-variable.hpp index 6afb0864..3a8d504c 100644 --- a/lib/macro/macro-action-variable.hpp +++ b/lib/macro/macro-action-variable.hpp @@ -185,6 +185,7 @@ private: VariableLineEdit *_envVariable; SceneSelectionWidget *_scenes; TempVariableSelection *_tempVars; + QLabel *_tempVarsHelp; VariableSpinBox *_sceneItemIndex; QComboBox *_direction; VariableSpinBox *_stringLength; diff --git a/lib/utils/temp-variable.hpp b/lib/utils/temp-variable.hpp index b2758e15..d91f8cf0 100644 --- a/lib/utils/temp-variable.hpp +++ b/lib/utils/temp-variable.hpp @@ -65,6 +65,7 @@ public: EXPORT void Load(obs_data_t *, Macro *, const char *name = "tempVar"); EXPORT std::optional GetTempVariable(Macro *) const; EXPORT bool operator==(const TempVariableRef &other) const; + bool HasValidID() const { return !_id.empty(); } private: enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };